diff --git a/.gitignore b/.gitignore index 3d5baab..10a48fb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ __pycache__/ *.py[cod] *$py.class - +*.bak # C extensions *.so diff --git a/pyproject.toml b/pyproject.toml index 5e1aa56..c0e3917 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 ", "Sergey Malyshev "] license = "MIT" diff --git a/src/gigachat/client.py b/src/gigachat/client.py index 2c2dc9c..a513a3b 100644 --- a/src/gigachat/client.py +++ b/src/gigachat/client.py @@ -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 @@ -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: @@ -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) diff --git a/src/gigachat/models/chat.py b/src/gigachat/models/chat.py index 39d967f..fd154ba 100644 --- a/src/gigachat/models/chat.py +++ b/src/gigachat/models/chat.py @@ -33,3 +33,5 @@ class Chat(BaseModel): """Правила вызова функций""" functions: Optional[List[Function]] = None """Набор функций, которые могут быть вызваны моделью""" + flags: Optional[List[str]] = None + """Флаги, включающие особенные фичи""" diff --git a/src/gigachat/settings.py b/src/gigachat/settings.py index 84c6052..490bafe 100644 --- a/src/gigachat/settings.py +++ b/src/gigachat/settings.py @@ -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 diff --git a/tests/data/chat_function.json b/tests/data/chat_function.json index a3913e6..c25e766 100644 --- a/tests/data/chat_function.json +++ b/tests/data/chat_function.json @@ -60,5 +60,6 @@ } } ], - "model": "GigaChat-funcs" + "model": "GigaChat-funcs", + "flags": ["some_flag"] }