test_chat_models.py — langchain Source File
Architecture documentation for test_chat_models.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 87f22f50_c247_4dc3_5b99_c5643ccb1083["test_chat_models.py"] 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 87f22f50_c247_4dc3_5b99_c5643ccb1083 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 525a7d6f_f455_56e3_854a_c8a7da4a1417["unittest.mock"] 87f22f50_c247_4dc3_5b99_c5643ccb1083 --> 525a7d6f_f455_56e3_854a_c8a7da4a1417 d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] 87f22f50_c247_4dc3_5b99_c5643ccb1083 --> d758344f_537f_649e_f467_b9d7442e86df 2e073793_7bdb_2272_3b6f_82c878fdc38c["pytest_mock"] 87f22f50_c247_4dc3_5b99_c5643ccb1083 --> 2e073793_7bdb_2272_3b6f_82c878fdc38c 0a64b352_1be7_5fff_8155_512d479e612f["langchain_perplexity"] 87f22f50_c247_4dc3_5b99_c5643ccb1083 --> 0a64b352_1be7_5fff_8155_512d479e612f 7cb9c5ca_28fd_9911_b782_ae3bceaabce7["langchain_perplexity.chat_models"] 87f22f50_c247_4dc3_5b99_c5643ccb1083 --> 7cb9c5ca_28fd_9911_b782_ae3bceaabce7 style 87f22f50_c247_4dc3_5b99_c5643ccb1083 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from typing import Any, cast
from unittest.mock import MagicMock
from langchain_core.messages import AIMessageChunk, BaseMessage
from pytest_mock import MockerFixture
from langchain_perplexity import ChatPerplexity, MediaResponse, WebSearchOptions
from langchain_perplexity.chat_models import _create_usage_metadata
def test_perplexity_model_name_param() -> None:
llm = ChatPerplexity(model="foo")
assert llm.model == "foo"
def test_perplexity_model_kwargs() -> None:
llm = ChatPerplexity(model="test", model_kwargs={"foo": "bar"})
assert llm.model_kwargs == {"foo": "bar"}
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 is not None
and model.pplx_api_key.get_secret_value() == "test"
)
def test_perplexity_new_params() -> None:
"""Test new Perplexity-specific parameters."""
web_search_options = WebSearchOptions(search_type="pro", search_context_size="high")
media_response = MediaResponse(overrides={"return_videos": True})
llm = ChatPerplexity(
model="sonar-pro",
search_mode="academic",
web_search_options=web_search_options,
media_response=media_response,
return_images=True,
)
params = llm._default_params
assert params["search_mode"] == "academic"
assert params["web_search_options"] == {
"search_type": "pro",
// ... (154 more lines)
Domain
Subdomains
Functions
- test_create_usage_metadata_basic()
- test_perplexity_initialization()
- test_perplexity_invoke_includes_num_search_queries()
- test_perplexity_model_kwargs()
- test_perplexity_model_name_param()
- test_perplexity_new_params()
- test_perplexity_stream_includes_citations()
- test_perplexity_stream_includes_videos_and_reasoning()
- test_profile()
Dependencies
- langchain_core.messages
- langchain_perplexity
- langchain_perplexity.chat_models
- pytest_mock
- typing
- unittest.mock
Source
Frequently Asked Questions
What does test_chat_models.py do?
test_chat_models.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_chat_models.py?
test_chat_models.py defines 9 function(s): test_create_usage_metadata_basic, test_perplexity_initialization, test_perplexity_invoke_includes_num_search_queries, test_perplexity_model_kwargs, test_perplexity_model_name_param, test_perplexity_new_params, test_perplexity_stream_includes_citations, test_perplexity_stream_includes_videos_and_reasoning, test_profile.
What does test_chat_models.py depend on?
test_chat_models.py imports 6 module(s): langchain_core.messages, langchain_perplexity, langchain_perplexity.chat_models, pytest_mock, typing, unittest.mock.
Where is test_chat_models.py in the architecture?
test_chat_models.py is located at libs/partners/perplexity/tests/unit_tests/test_chat_models.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/perplexity/tests/unit_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free