test_base.py — langchain Source File
Architecture documentation for test_base.py, a python file in the langchain codebase. 34 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf["test_base.py"] 7025b240_fdc3_cf68_b72f_f41dac94566b["json"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 7025b240_fdc3_cf68_b72f_f41dac94566b 0c635125_6987_b8b3_7ff7_d60249aecde7["warnings"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 0c635125_6987_b8b3_7ff7_d60249aecde7 c990f2d7_9509_7cea_ca95_51ad57dbe5c6["functools"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> c990f2d7_9509_7cea_ca95_51ad57dbe5c6 05bcd40b_a309_8a05_c2c6_59e32e113cf5["types"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 05bcd40b_a309_8a05_c2c6_59e32e113cf5 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 525a7d6f_f455_56e3_854a_c8a7da4a1417["unittest.mock"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 525a7d6f_f455_56e3_854a_c8a7da4a1417 1803c8c1_a347_1256_1454_9f04c3553d93["httpx"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 1803c8c1_a347_1256_1454_9f04c3553d93 45fc8fd3_e815_b442_a6d1_0dedc9327b62["openai"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 45fc8fd3_e815_b442_a6d1_0dedc9327b62 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 120e2591_3e15_b895_72b6_cb26195e40a6 75137834_4ba7_dc43_7ec5_182c05eceedf["langchain_core.exceptions"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 75137834_4ba7_dc43_7ec5_182c05eceedf 36cce5da_d805_04c3_7e86_e1b4dd49b497["langchain_core.load"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 36cce5da_d805_04c3_7e86_e1b4dd49b497 d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> d758344f_537f_649e_f467_b9d7442e86df 4eb42b7a_5c64_04cb_fcec_1401d5c10628["langchain_core.messages.ai"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 4eb42b7a_5c64_04cb_fcec_1401d5c10628 5bb05482_5f6d_f5c2_1460_a2ec977e38f7["langchain_core.messages.block_translators.openai"] 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf --> 5bb05482_5f6d_f5c2_1460_a2ec977e38f7 style 8d5a57f5_d3ae_39c7_5d28_b197f71cc4cf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Test OpenAI Chat API wrapper."""
from __future__ import annotations
import json
import warnings
from functools import partial
from types import TracebackType
from typing import Any, Literal, cast
from unittest.mock import AsyncMock, MagicMock, patch
import httpx
import openai
import pytest
from langchain_core.exceptions import ContextOverflowError
from langchain_core.load import dumps, loads
from langchain_core.messages import (
AIMessage,
AIMessageChunk,
BaseMessage,
FunctionMessage,
HumanMessage,
InvalidToolCall,
SystemMessage,
ToolCall,
ToolMessage,
)
from langchain_core.messages import content as types
from langchain_core.messages.ai import UsageMetadata
from langchain_core.messages.block_translators.openai import (
_convert_from_v03_ai_message,
)
from langchain_core.outputs import ChatGeneration, ChatResult
from langchain_core.runnables import RunnableLambda
from langchain_core.runnables.base import RunnableBinding, RunnableSequence
from langchain_core.tracers.base import BaseTracer
from langchain_core.tracers.schemas import Run
from openai.types.responses import ResponseOutputMessage, ResponseReasoningItem
from openai.types.responses.response import IncompleteDetails, Response
from openai.types.responses.response_error import ResponseError
from openai.types.responses.response_file_search_tool_call import (
ResponseFileSearchToolCall,
Result,
)
from openai.types.responses.response_function_tool_call import ResponseFunctionToolCall
from openai.types.responses.response_function_web_search import (
ActionSearch,
ResponseFunctionWebSearch,
)
from openai.types.responses.response_output_refusal import ResponseOutputRefusal
from openai.types.responses.response_output_text import ResponseOutputText
from openai.types.responses.response_reasoning_item import Summary
from openai.types.responses.response_usage import (
InputTokensDetails,
OutputTokensDetails,
ResponseUsage,
)
from pydantic import BaseModel, Field, SecretStr
from typing_extensions import Self, TypedDict
// ... (3335 more lines)
Domain
Subdomains
Functions
- mock_async_client()
- mock_client()
- mock_completion()
- mock_deepseek_completion()
- mock_glm4_completion()
- mock_openai_completion()
- test__construct_lc_result_from_responses_api_basic_text_response()
- test__construct_lc_result_from_responses_api_complex_response()
- test__construct_lc_result_from_responses_api_error_handling()
- test__construct_lc_result_from_responses_api_file_search_response()
- test__construct_lc_result_from_responses_api_function_call_invalid_json()
- test__construct_lc_result_from_responses_api_function_call_valid_json()
- test__construct_lc_result_from_responses_api_mixed_search_responses()
- test__construct_lc_result_from_responses_api_multiple_messages()
- test__construct_lc_result_from_responses_api_multiple_text_blocks()
- test__construct_lc_result_from_responses_api_no_usage_metadata()
- test__construct_lc_result_from_responses_api_refusal_response()
- test__construct_lc_result_from_responses_api_web_search_response()
- test__construct_responses_api_input_ai_message_with_tool_calls()
- test__construct_responses_api_input_ai_message_with_tool_calls_and_content()
- test__construct_responses_api_input_human_message_with_image_url_conversion()
- test__construct_responses_api_input_human_message_with_text_blocks_conversion()
- test__construct_responses_api_input_multiple_message_components()
- test__construct_responses_api_input_multiple_message_types()
- test__construct_responses_api_input_skips_blocks_without_text()
- test__construct_responses_api_input_tool_message_conversion()
- test__convert_dict_to_message_ai()
- test__convert_dict_to_message_ai_with_name()
- test__convert_dict_to_message_developer()
- test__convert_dict_to_message_human()
- test__convert_dict_to_message_human_with_name()
- test__convert_dict_to_message_system()
- test__convert_dict_to_message_system_with_name()
- test__convert_dict_to_message_tool()
- test__convert_dict_to_message_tool_call()
- test__convert_to_openai_response_format()
- test__create_usage_metadata()
- test__create_usage_metadata_responses()
- test__get_encoding_model()
- test__get_request_payload()
- test__resize_caps_dimensions_preserving_ratio()
- test_bind_tools_tool_choice()
- test_compat_responses_v03()
- test_context_overflow_error_backwards_compatibility()
- test_context_overflow_error_invoke_async()
- test_context_overflow_error_invoke_async_responses_api()
- test_context_overflow_error_invoke_sync()
- test_context_overflow_error_invoke_sync_responses_api()
- test_context_overflow_error_stream_async()
- test_context_overflow_error_stream_async_responses_api()
- test_context_overflow_error_stream_sync()
- test_context_overflow_error_stream_sync_responses_api()
- test_convert_from_v1_to_chat_completions()
- test_convert_from_v1_to_responses()
- test_custom_token_counting()
- test_deepseek_astream()
- test_deepseek_stream()
- test_extra_body_parameter()
- test_extra_body_with_model_kwargs()
- test_format_message_content()
- test_function_calls_with_tool_calls()
- test_function_message_dict_to_function_message()
- test_get_last_messages()
- test_get_last_messages_with_mixed_response_metadata()
- test_get_num_tokens_from_messages()
- test_get_request_payload_use_previous_response_id()
- test_glm4_astream()
- test_glm4_stream()
- test_gpt_5_1_temperature_with_reasoning_effort_none()
- test_gpt_5_temperature()
- test_gpt_5_temperature_case_insensitive()
- test_init_minimal_reasoning_effort()
- test_init_o1()
- test_lc_tool_call_to_openai_tool_call_unicode()
- test_make_computer_call_output_from_message()
- test_mcp_tracing()
- test_minimal_reasoning_effort_payload()
- test_model_prefers_responses_api()
- test_nested_structured_output_strict()
- test_openai_ainvoke()
- test_openai_astream()
- test_openai_client_caching()
- test_openai_invoke()
- test_openai_invoke_name()
- test_openai_model_param()
- test_openai_o1_temperature()
- test_openai_stream()
- test_openai_structured_output_refusal_handling_responses_api()
- test_output_version_compat()
- test_profile()
- test_schema_from_with_structured_output()
- test_service_tier()
- test_streaming_attribute_should_stream()
- test_structured_output_old_model()
- test_structured_output_strict()
- test_structured_output_verbosity()
- test_structured_outputs_parser()
- test_verbosity_parameter_payload()
- test_with_structured_output()
Classes
Dependencies
- functools
- httpx
- json
- langchain_core.exceptions
- langchain_core.load
- langchain_core.messages
- langchain_core.messages.ai
- langchain_core.messages.block_translators.openai
- langchain_core.outputs
- langchain_core.runnables
- langchain_core.runnables.base
- langchain_core.tracers.base
- langchain_core.tracers.schemas
- langchain_openai
- langchain_openai.chat_models._compat
- langchain_openai.chat_models.base
- openai
- openai.types.responses
- openai.types.responses.response
- openai.types.responses.response_error
- openai.types.responses.response_file_search_tool_call
- openai.types.responses.response_function_tool_call
- openai.types.responses.response_function_web_search
- openai.types.responses.response_output_refusal
- openai.types.responses.response_output_text
- openai.types.responses.response_reasoning_item
- openai.types.responses.response_usage
- pydantic
- pytest
- types
- typing
- typing_extensions
- unittest.mock
- warnings
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 99 function(s): mock_async_client, mock_client, mock_completion, mock_deepseek_completion, mock_glm4_completion, mock_openai_completion, test__construct_lc_result_from_responses_api_basic_text_response, test__construct_lc_result_from_responses_api_complex_response, test__construct_lc_result_from_responses_api_error_handling, test__construct_lc_result_from_responses_api_file_search_response, and 89 more.
What does test_base.py depend on?
test_base.py imports 34 module(s): functools, httpx, json, langchain_core.exceptions, langchain_core.load, langchain_core.messages, langchain_core.messages.ai, langchain_core.messages.block_translators.openai, and 26 more.
Where is test_base.py in the architecture?
test_base.py is located at libs/partners/openai/tests/unit_tests/chat_models/test_base.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/openai/tests/unit_tests/chat_models).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free