Skip to content

Commit

Permalink
Merge pull request #35 from ai-forever/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Rai220 authored Aug 15, 2024
2 parents 9f75a76 + ef3f38b commit e64ab9d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 3 deletions.
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"]
}

0 comments on commit e64ab9d

Please sign in to comment.