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

Dev #35

Merged
merged 4 commits into from
Aug 15, 2024
Merged

Dev #35

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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__pycache__/
*.py[cod]
*$py.class

*.bak
# C extensions
*.so

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gigachat"
version = "0.1.33"
version = "0.1.34"
description = "GigaChat. Python-library for GigaChain and LangChain"
authors = ["Konstantin Krestnikov <[email protected]>", "Sergey Malyshev <[email protected]>"]
license = "MIT"
Expand Down
4 changes: 4 additions & 0 deletions src/gigachat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def _parse_chat(payload: Union[Chat, Dict[str, Any], str], settings: Settings) -
chat.model = settings.model or GIGACHAT_MODEL
if chat.profanity_check is None:
chat.profanity_check = settings.profanity_check
if chat.flags is None:
chat.flags = settings.flags
return chat


Expand Down Expand Up @@ -124,6 +126,7 @@ def __init__(
cert_file: Optional[str] = None,
key_file: Optional[str] = None,
key_file_password: Optional[str] = None,
flags: Optional[list[str]] = None,
**_unknown_kwargs: Any,
) -> None:
if _unknown_kwargs:
Expand All @@ -146,6 +149,7 @@ def __init__(
"cert_file": cert_file,
"key_file": key_file,
"key_file_password": key_file_password,
"flags": flags,
}
config = {k: v for k, v in kwargs.items() if v is not None}
self._settings = Settings(**config)
Expand Down
2 changes: 2 additions & 0 deletions src/gigachat/models/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ class Chat(BaseModel):
"""Правила вызова функций"""
functions: Optional[List[Function]] = None
"""Набор функций, которые могут быть вызваны моделью"""
flags: Optional[List[str]] = None
"""Флаги, включающие особенные фичи"""
1 change: 1 addition & 0 deletions src/gigachat/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Settings(BaseSettings):
cert_file: Optional[str] = None
key_file: Optional[str] = None
key_file_password: Optional[str] = None
flags: Optional[list[str]] = None

class Config:
env_prefix = ENV_PREFIX
3 changes: 2 additions & 1 deletion tests/data/chat_function.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
}
}
],
"model": "GigaChat-funcs"
"model": "GigaChat-funcs",
"flags": ["some_flag"]
}
Loading