mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 06:39:52 +00:00
community:yuan2[patch]: standardize init args (#21462)
updated stop and request_timeout so they aliased to stop_sequences, and timeout respectively. Added test that both continue to set the same underlying attributes. Related to [20085](https://github.com/langchain-ai/langchain/issues/20085) Co-authored-by: ccurme <chester.curme@gmail.com>
This commit is contained in:
parent
bc557a5663
commit
f355a98bb6
@ -93,7 +93,9 @@ class ChatYuan2(BaseChatModel):
|
||||
)
|
||||
"""Base URL path for API requests, an OpenAI compatible API server."""
|
||||
|
||||
request_timeout: Optional[Union[float, Tuple[float, float]]] = None
|
||||
request_timeout: Optional[Union[float, Tuple[float, float]]] = Field(
|
||||
default=None, alias="timeout"
|
||||
)
|
||||
"""Timeout for requests to yuan2 completion API. Default is 600 seconds."""
|
||||
|
||||
max_retries: int = 6
|
||||
@ -111,7 +113,7 @@ class ChatYuan2(BaseChatModel):
|
||||
top_p: Optional[float] = 0.9
|
||||
"""The top-p value to use for sampling."""
|
||||
|
||||
stop: Optional[List[str]] = ["<eod>"]
|
||||
stop: Optional[List[str]] = Field(default=["<eod>"], alias="stop_sequences")
|
||||
"""A list of strings to stop generation when encountered."""
|
||||
|
||||
repeat_last_n: Optional[int] = 64
|
||||
|
@ -22,6 +22,22 @@ def test_yuan2_model_param() -> None:
|
||||
assert chat.model_name == "foo"
|
||||
|
||||
|
||||
@pytest.mark.requires("openai")
|
||||
def test_yuan2_timeout_param() -> None:
|
||||
chat = ChatYuan2(request_timeout=5) # type: ignore[call-arg]
|
||||
assert chat.request_timeout == 5
|
||||
chat = ChatYuan2(timeout=10) # type: ignore[call-arg]
|
||||
assert chat.request_timeout == 10
|
||||
|
||||
|
||||
@pytest.mark.requires("openai")
|
||||
def test_yuan2_stop_sequences_param() -> None:
|
||||
chat = ChatYuan2(stop=["<eod>"]) # type: ignore[call-arg]
|
||||
assert chat.stop == ["<eod>"]
|
||||
chat = ChatYuan2(stop_sequences=["<eod>"]) # type: ignore[call-arg]
|
||||
assert chat.stop == ["<eod>"]
|
||||
|
||||
|
||||
def test__convert_message_to_dict_human() -> None:
|
||||
message = HumanMessage(content="foo")
|
||||
result = _convert_message_to_dict(message)
|
||||
|
Loading…
Reference in New Issue
Block a user