community[patch]: standardize init args (#20166)

Related to https://github.com/langchain-ai/langchain/issues/20085

@baskaryan
pull/20539/head
Guangdong Liu 3 months ago committed by GitHub
parent 3729bec1a2
commit b78ede2f96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -103,7 +103,7 @@ class QianfanChatEndpoint(BaseChatModel):
streaming: Optional[bool] = False
"""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"""
top_p: Optional[float] = 0.8
@ -125,6 +125,11 @@ class QianfanChatEndpoint(BaseChatModel):
endpoint: Optional[str] = None
"""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()
def validate_environment(cls, values: Dict) -> Dict:
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:
"""Test default model(`ERNIE-Bot`) call."""
chat = QianfanChatEndpoint()

Loading…
Cancel
Save