Skip to content

Commit

Permalink
Mypi fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Krestnikov authored and Konstantin Krestnikov committed Mar 5, 2024
1 parent f9cd0d5 commit bb0d87b
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
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.17"
version = "0.1.18"
description = "GigaChat. Python-library for GigaChain and LangChain"
authors = ["Konstantin Krestnikov <[email protected]>", "Sergey Malyshev <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/gigachat/api/post_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _get_kwargs(
return {
"method": "POST",
"url": "/chat/completions",
"json": chat.dict(exclude_none=True, exclude={"stream"}),
"json": chat.dict(exclude_none=True, by_alias=True, exclude={"stream"}),
"headers": headers,
}

Expand Down
2 changes: 1 addition & 1 deletion src/gigachat/api/stream_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _get_kwargs(
return {
"method": "POST",
"url": "/chat/completions",
"json": {**chat.dict(exclude_none=True), **{"stream": True}},
"json": {**chat.dict(exclude_none=True, by_alias=True), **{"stream": True}},
"headers": headers,
}

Expand Down
4 changes: 2 additions & 2 deletions src/gigachat/models/chat_completion_chunk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Optional

from gigachat.models.choices_chunk import ChoicesChunk
from gigachat.pydantic_v1 import BaseModel, Field
Expand All @@ -13,5 +13,5 @@ class ChatCompletionChunk(BaseModel):
"""Дата и время создания ответа в формате Unix time"""
model: str
"""Название модели, которая вернула ответ"""
object_: str = Field(alias="object")
object_: object = Optional[Field(default=None, alias="object")]
"""Название вызываемого метода"""
2 changes: 1 addition & 1 deletion src/gigachat/models/function_paramaers_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class FunctionParametersProperty(BaseModel):
"""Функция, которая может быть вызвана моделью"""

_type: str = Field(default="obect", alias="type")
type_: str = Field(default="object", alias="type")
"""Тип аргумента функции"""
description: str = ""
"""Описание аргумента"""
Expand Down
2 changes: 1 addition & 1 deletion src/gigachat/models/function_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class FunctionParameters(BaseModel):
"""Функция, которая может быть вызвана моделью"""

_type: str = Field(default="obect", alias="type")
type_: str = Field(default="object", alias="type")
"""Тип параметров функции"""
properties: Optional[Dict[Any, FunctionParametersProperty]] = None
"""Описание функции"""
Expand Down
2 changes: 1 addition & 1 deletion src/gigachat/models/messages_chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MessagesChunk(BaseModel):

role: Optional[MessagesRole] = None
"""Роль автора сообщения"""
content: str
content: Optional[str] = None
"""Текст сообщения"""
function_call: Optional[FunctionCall] = None
"""Вызов функции"""
2 changes: 1 addition & 1 deletion tests/unit_tests/gigachat/api/test_stream_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_sync_value_error(httpx_mock: HTTPXMock) -> None:
httpx_mock.add_response(url=MOCK_URL, content=b"data: {}", headers=HEADERS_STREAM)

with httpx.Client(base_url=BASE_URL) as client:
with pytest.raises(ValueError, match="4 validation errors for ChatCompletionChunk*"):
with pytest.raises(ValueError, match="3 validation errors for ChatCompletionChunk*"):
list(stream_chat.sync(client, chat=CHAT))


Expand Down

0 comments on commit bb0d87b

Please sign in to comment.