community[patch]: standardize chat init args (#20844)

Thank you for contributing to LangChain!

community:perplexity[patch]: standardize init args

updated pplx_api_key and request_timeout so that aliased to api_key, 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: Bagatur <22008038+baskaryan@users.noreply.github.com>
This commit is contained in:
JeffKatzy
2024-04-24 12:26:05 -07:00
committed by GitHub
parent 70ae59bcfe
commit 5ab3f9a995
2 changed files with 20 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
"""Wrapper around Perplexity APIs."""
from __future__ import annotations
import logging
@@ -63,10 +64,12 @@ class ChatPerplexity(BaseChatModel):
"""What sampling temperature to use."""
model_kwargs: Dict[str, Any] = Field(default_factory=dict)
"""Holds any model parameters valid for `create` call not explicitly specified."""
pplx_api_key: Optional[str] = None
pplx_api_key: Optional[str] = Field(None, alias="api_key")
"""Base URL path for API requests,
leave blank if not using a proxy or service emulator."""
request_timeout: Optional[Union[float, Tuple[float, float]]] = None
request_timeout: Optional[Union[float, Tuple[float, float]]] = Field(
None, alias="timeout"
)
"""Timeout for requests to PerplexityChat completion API. Default is 600 seconds."""
max_retries: int = 6
"""Maximum number of retries to make when generating."""