Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perplexity[patch]: standardize chat init args #20844

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions libs/community/langchain_community/chat_models/perplexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ 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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run make format to prettify the content

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @eyurtsev just ran ruff on the file, and updated the pull request.

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."""
Expand Down
11 changes: 8 additions & 3 deletions libs/community/tests/unit_tests/chat_models/test_perplexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def test_perplexity_initialization() -> None:
"""Test perplexity initialization."""
# Verify that chat perplexity can be initialized using a secret key provided
# as a parameter rather than an environment variable.
ChatPerplexity(
model="test", perplexity_api_key="test", temperature=0.7, verbose=True
)
for model in [
ChatPerplexity(model="test", timeout=1, api_key="test",
temperature=0.7, verbose=True),
ChatPerplexity(model="test", request_timeout=1,
pplx_api_key="test", temperature=0.7, verbose=True)
]:
assert model.request_timeout == 1
assert model.pplx_api_key == "test"
Loading