test_base.py — langchain Source File
Architecture documentation for test_base.py, a python file in the langchain codebase. 16 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 88d47f46_ad13_014d_f204_d90438937ccd["test_base.py"] 66c6348c_7716_027c_42d7_71449bc64eeb["base64"] 88d47f46_ad13_014d_f204_d90438937ccd --> 66c6348c_7716_027c_42d7_71449bc64eeb 7025b240_fdc3_cf68_b72f_f41dac94566b["json"] 88d47f46_ad13_014d_f204_d90438937ccd --> 7025b240_fdc3_cf68_b72f_f41dac94566b 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c["os"] 88d47f46_ad13_014d_f204_d90438937ccd --> 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] 88d47f46_ad13_014d_f204_d90438937ccd --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8["pathlib"] 88d47f46_ad13_014d_f204_d90438937ccd --> b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8 243100a0_4629_4394_a66b_1f67b00ce784["textwrap"] 88d47f46_ad13_014d_f204_d90438937ccd --> 243100a0_4629_4394_a66b_1f67b00ce784 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 88d47f46_ad13_014d_f204_d90438937ccd --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 1803c8c1_a347_1256_1454_9f04c3553d93["httpx"] 88d47f46_ad13_014d_f204_d90438937ccd --> 1803c8c1_a347_1256_1454_9f04c3553d93 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] 88d47f46_ad13_014d_f204_d90438937ccd --> 120e2591_3e15_b895_72b6_cb26195e40a6 f3bc7443_c889_119d_0744_aacc3620d8d2["langchain_core.callbacks"] 88d47f46_ad13_014d_f204_d90438937ccd --> f3bc7443_c889_119d_0744_aacc3620d8d2 d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] 88d47f46_ad13_014d_f204_d90438937ccd --> d758344f_537f_649e_f467_b9d7442e86df ac2a9b92_4484_491e_1b48_ec85e71e1d58["langchain_core.outputs"] 88d47f46_ad13_014d_f204_d90438937ccd --> ac2a9b92_4484_491e_1b48_ec85e71e1d58 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] 88d47f46_ad13_014d_f204_d90438937ccd --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] 88d47f46_ad13_014d_f204_d90438937ccd --> 91721f45_4909_e489_8c1f_084f8bd87145 style 88d47f46_ad13_014d_f204_d90438937ccd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Test ChatOpenAI chat model."""
import base64
import json
import os
from collections.abc import AsyncIterator
from pathlib import Path
from textwrap import dedent
from typing import Any, Literal, cast
import httpx
import pytest
from langchain_core.callbacks import CallbackManager
from langchain_core.messages import (
AIMessage,
AIMessageChunk,
BaseMessage,
BaseMessageChunk,
HumanMessage,
SystemMessage,
ToolCall,
ToolMessage,
)
from langchain_core.outputs import ChatGeneration, ChatResult, LLMResult
from pydantic import BaseModel, field_validator
from typing_extensions import TypedDict
from langchain_openai import ChatOpenAI
from tests.unit_tests.fake.callbacks import FakeCallbackHandler
MAX_TOKEN_COUNT = 100
@pytest.mark.scheduled
def test_chat_openai() -> None:
"""Test ChatOpenAI wrapper."""
chat = ChatOpenAI(
temperature=0.7,
base_url=None,
organization=None,
openai_proxy=None,
timeout=10.0,
max_retries=3,
http_client=None,
n=1,
max_tokens=MAX_TOKEN_COUNT, # type: ignore[call-arg]
default_headers=None,
default_query=None,
)
message = HumanMessage(content="Hello")
response = chat.invoke([message])
assert isinstance(response, BaseMessage)
assert isinstance(response.content, str)
def test_chat_openai_model() -> None:
"""Test ChatOpenAI wrapper handles model_name."""
chat = ChatOpenAI(model="foo")
assert chat.model_name == "foo"
chat = ChatOpenAI(model_name="bar") # type: ignore[call-arg]
// ... (1216 more lines)
Domain
Subdomains
Functions
- test_abatch_tags()
- test_astream()
- test_astream_o_series()
- test_astream_response_format()
- test_async_response_metadata()
- test_async_response_metadata_streaming()
- test_audio_input_modality()
- test_audio_output_modality()
- test_bind_tools_tool_choice()
- test_callable_api_key()
- test_callable_api_key_async()
- test_chat_openai()
- test_chat_openai_generate()
- test_chat_openai_invalid_streaming_params()
- test_chat_openai_llm_output_contains_model_name()
- test_chat_openai_model()
- test_chat_openai_multiple_completions()
- test_chat_openai_streaming()
- test_chat_openai_streaming_generation_info()
- test_chat_openai_streaming_llm_output_contains_model_name()
- test_chat_openai_system_message()
- test_disable_parallel_tool_calling()
- test_flex_usage_responses()
- test_image_token_counting_jpeg()
- test_image_token_counting_png()
- test_json_schema_openai_format()
- test_manual_tool_call_msg()
- test_multi_party_conversation()
- test_nested_structured_output_strict()
- test_o1()
- test_o1_stream_default_works()
- test_openai_abatch_tags()
- test_openai_invoke()
- test_openai_proxy()
- test_openai_response_headers()
- test_openai_response_headers_async()
- test_openai_structured_output()
- test_prediction_tokens()
- test_prompt_cache_key_invoke()
- test_prompt_cache_key_usage_methods_integration()
- test_response_metadata()
- test_response_metadata_streaming()
- test_schema_parsing_failures()
- test_schema_parsing_failures_async()
- test_schema_parsing_failures_responses_api()
- test_schema_parsing_failures_responses_api_async()
- test_stream()
- test_stream_o_series()
- test_stream_response_format()
- test_structured_output_and_tools()
- test_structured_output_strict()
- test_tool_use()
- test_tools_and_structured_output()
Classes
Dependencies
- base64
- collections.abc
- httpx
- json
- langchain_core.callbacks
- langchain_core.messages
- langchain_core.outputs
- langchain_openai
- os
- pathlib
- pydantic
- pytest
- tests.unit_tests.fake.callbacks
- textwrap
- typing
- typing_extensions
Source
Frequently Asked Questions
What does test_base.py do?
test_base.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_base.py?
test_base.py defines 53 function(s): test_abatch_tags, test_astream, test_astream_o_series, test_astream_response_format, test_async_response_metadata, test_async_response_metadata_streaming, test_audio_input_modality, test_audio_output_modality, test_bind_tools_tool_choice, test_callable_api_key, and 43 more.
What does test_base.py depend on?
test_base.py imports 16 module(s): base64, collections.abc, httpx, json, langchain_core.callbacks, langchain_core.messages, langchain_core.outputs, langchain_openai, and 8 more.
Where is test_base.py in the architecture?
test_base.py is located at libs/partners/openai/tests/integration_tests/chat_models/test_base.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/openai/tests/integration_tests/chat_models).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free