mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-15 22:44:36 +00:00
community[minor]: Add support for Perplexity chat model(#17024)
- **Description:** This PR adds support for [Perplexity AI APIs](https://blog.perplexity.ai/blog/introducing-pplx-api). - **Issues:** None - **Dependencies:** None - **Twitter handle:** [@atherfawaz](https://twitter.com/AtherFawaz) --------- Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
@@ -41,6 +41,7 @@ EXPECTED_ALL = [
|
||||
"GPTRouter",
|
||||
"ChatYuan2",
|
||||
"ChatZhipuAI",
|
||||
"ChatPerplexity",
|
||||
"ChatKinetica",
|
||||
]
|
||||
|
||||
|
@@ -0,0 +1,30 @@
|
||||
"""Test Perplexity Chat API wrapper."""
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from langchain_community.chat_models import ChatPerplexity
|
||||
|
||||
os.environ["PPLX_API_KEY"] = "foo"
|
||||
|
||||
|
||||
@pytest.mark.requires("openai")
|
||||
def test_perplexity_model_name_param() -> None:
|
||||
llm = ChatPerplexity(model="foo")
|
||||
assert llm.model == "foo"
|
||||
|
||||
|
||||
@pytest.mark.requires("openai")
|
||||
def test_perplexity_model_kwargs() -> None:
|
||||
llm = ChatPerplexity(model="test", model_kwargs={"foo": "bar"})
|
||||
assert llm.model_kwargs == {"foo": "bar"}
|
||||
|
||||
|
||||
@pytest.mark.requires("openai")
|
||||
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
|
||||
)
|
Reference in New Issue
Block a user