mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-17 02:03:44 +00:00
community[patch]: standardize init args (#20166)
Related to https://github.com/langchain-ai/langchain/issues/20085 @baskaryan
This commit is contained in:
parent
3729bec1a2
commit
b78ede2f96
@ -103,7 +103,7 @@ class QianfanChatEndpoint(BaseChatModel):
|
|||||||
streaming: Optional[bool] = False
|
streaming: Optional[bool] = False
|
||||||
"""Whether to stream the results or not."""
|
"""Whether to stream the results or not."""
|
||||||
|
|
||||||
request_timeout: Optional[int] = 60
|
request_timeout: Optional[int] = Field(60, alias="timeout")
|
||||||
"""request timeout for chat http requests"""
|
"""request timeout for chat http requests"""
|
||||||
|
|
||||||
top_p: Optional[float] = 0.8
|
top_p: Optional[float] = 0.8
|
||||||
@ -125,6 +125,11 @@ class QianfanChatEndpoint(BaseChatModel):
|
|||||||
endpoint: Optional[str] = None
|
endpoint: Optional[str] = None
|
||||||
"""Endpoint of the Qianfan LLM, required if custom model used."""
|
"""Endpoint of the Qianfan LLM, required if custom model used."""
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
"""Configuration for this pydantic object."""
|
||||||
|
|
||||||
|
allow_population_by_field_name = True
|
||||||
|
|
||||||
@root_validator()
|
@root_validator()
|
||||||
def validate_environment(cls, values: Dict) -> Dict:
|
def validate_environment(cls, values: Dict) -> Dict:
|
||||||
values["qianfan_ak"] = convert_to_secret_str(
|
values["qianfan_ak"] = convert_to_secret_str(
|
||||||
|
@ -86,6 +86,17 @@ _FUNCTIONS: Any = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_initialization() -> None:
|
||||||
|
"""Test chat model initialization."""
|
||||||
|
|
||||||
|
for model in [
|
||||||
|
QianfanChatEndpoint(model="BLOOMZ-7B", timeout=40),
|
||||||
|
QianfanChatEndpoint(model="BLOOMZ-7B", request_timeout=40),
|
||||||
|
]:
|
||||||
|
assert model.model == "BLOOMZ-7B"
|
||||||
|
assert model.request_timeout == 40
|
||||||
|
|
||||||
|
|
||||||
def test_default_call() -> None:
|
def test_default_call() -> None:
|
||||||
"""Test default model(`ERNIE-Bot`) call."""
|
"""Test default model(`ERNIE-Bot`) call."""
|
||||||
chat = QianfanChatEndpoint()
|
chat = QianfanChatEndpoint()
|
||||||
|
Loading…
Reference in New Issue
Block a user