mirror of
https://github.com/hwchase17/langchain
synced 2024-11-11 19:11:02 +00:00
5ab3f9a995
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>
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
"""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.
|
|
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"
|