Skip to content

Commit

Permalink
community[patch]: standardize baichuan init args (#20209)
Browse files Browse the repository at this point in the history
Related to #20085

@baskaryan
  • Loading branch information
liugddx authored Apr 9, 2024
1 parent cd7abc4 commit 97d91ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/community/langchain_community/chat_models/baichuan.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def lc_serializable(self) -> bool:
"""[DEPRECATED, keeping it for for backward compatibility] Baichuan Secret Key"""
streaming: bool = False
"""Whether to stream the results or not."""
request_timeout: int = 60
request_timeout: int = Field(default=60, alias="timeout")
"""request timeout for chat http requests"""
model = "Baichuan2-Turbo-192K"
"""model name of Baichuan, default is `Baichuan2-Turbo-192K`,
Expand Down
17 changes: 17 additions & 0 deletions libs/community/tests/unit_tests/chat_models/test_baichuan.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@
)


def test_initialization() -> None:
"""Test chat model initialization."""

for model in [
ChatBaichuan(
model="Baichuan2-Turbo-192K", baichuan_api_key="test-api-key", timeout=40
),
ChatBaichuan(
model="Baichuan2-Turbo-192K",
baichuan_api_key="test-api-key",
request_timeout=40,
),
]:
assert model.model == "Baichuan2-Turbo-192K"
assert model.request_timeout == 40


def test__convert_message_to_dict_human() -> None:
message = HumanMessage(content="foo")
result = _convert_message_to_dict(message)
Expand Down

0 comments on commit 97d91ec

Please sign in to comment.