Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Adds ssl context support for gigachat #21

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions libs/gigachat/langchain_gigachat/chat_models/base_gigachat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
import ssl
from functools import cached_property
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional

Expand Down Expand Up @@ -41,6 +42,11 @@ class _BaseGigaChat(Serializable):
verify_ssl_certs: Optional[bool] = None
""" Check certificates for all requests """

ssl_context: Optional[ssl.SSLContext] = None

class Config:
arbitrary_types_allowed = True

ca_bundle_file: Optional[str] = None
cert_file: Optional[str] = None
key_file: Optional[str] = None
Expand Down Expand Up @@ -103,6 +109,7 @@ def _client(self) -> gigachat.GigaChat:
user=self.user,
password=self.password,
timeout=self.timeout,
ssl_context=self.ssl_context,
verify_ssl_certs=self.verify_ssl_certs,
ca_bundle_file=self.ca_bundle_file,
cert_file=self.cert_file,
Expand Down
7 changes: 7 additions & 0 deletions libs/gigachat/langchain_gigachat/embeddings/gigachat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
import ssl
from functools import cached_property
from typing import Any, Dict, List, Optional

Expand Down Expand Up @@ -55,6 +56,11 @@ class GigaChatEmbeddings(BaseModel, Embeddings):
verify_ssl_certs: Optional[bool] = None
""" Check certificates for all requests """

ssl_context: Optional[ssl.SSLContext] = None

class Config:
arbitrary_types_allowed = True

ca_bundle_file: Optional[str] = None
cert_file: Optional[str] = None
key_file: Optional[str] = None
Expand Down Expand Up @@ -82,6 +88,7 @@ def _client(self) -> Any:
user=self.user,
password=self.password,
timeout=self.timeout,
ssl_context=self.ssl_context,
verify_ssl_certs=self.verify_ssl_certs,
ca_bundle_file=self.ca_bundle_file,
cert_file=self.cert_file,
Expand Down
2 changes: 1 addition & 1 deletion libs/gigachat/langchain_gigachat/tools/giga_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def from_function(
args_schema: Optional[type[BaseModel]] = None,
infer_schema: bool = True,
return_schema: Optional[Type[BaseModel]] = None,
few_shot_examples: Optional[List[Dict[str, Any]]] = None,
few_shot_examples: FewShotExamples = None,
*,
response_format: Literal["content", "content_and_artifact"] = "content",
parse_docstring: bool = False,
Expand Down
14 changes: 7 additions & 7 deletions libs/gigachat/langchain_gigachat/utils/function_calling.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,13 @@ def format_tool_to_gigachat_function(tool: BaseTool) -> GigaFunctionDescription:
else:
return_schema = None

return {
"name": tool.name,
"description": tool.description,
"parameters": {"properties": {}, "type": "object"},
"few_shot_examples": few_shot_examples,
"return_parameters": return_schema,
}
return GigaFunctionDescription(
name=tool.name,
description=tool.description,
parameters={"properties": {}, "type": "object"},
few_shot_examples=few_shot_examples,
return_parameters=return_schema,
)


def convert_pydantic_to_gigachat_function(
Expand Down
12 changes: 6 additions & 6 deletions libs/gigachat/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions libs/gigachat/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langchain-gigachat"
version = "0.3.2"
version = "0.3.3"
description = "An integration package connecting GigaChat and LangChain"
authors = []
readme = "README.md"
Expand All @@ -13,7 +13,7 @@ license = "MIT"
[tool.poetry.dependencies]
python = ">=3.9,<4.0"
langchain-core = "^0.3"
gigachat = "^0.1.36"
gigachat = "^0.1.37"
types-requests = "^2.32"

[tool.poetry.group.dev]
Expand Down
Loading