Skip to content

Commit

Permalink
Flags field support in API
Browse files Browse the repository at this point in the history
  • Loading branch information
kzayko committed Aug 14, 2024
1 parent 9f75a76 commit 586dfdf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
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
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] = 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
1 change: 1 addition & 0 deletions src/gigachat/models/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ class Chat(BaseModel):
"""Правила вызова функций"""
functions: Optional[List[Function]] = None
"""Набор функций, которые могут быть вызваны моделью"""
flags: Optional[list] = 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] = None

class Config:
env_prefix = ENV_PREFIX

0 comments on commit 586dfdf

Please sign in to comment.