test_responses_api.py — langchain Source File
Architecture documentation for test_responses_api.py, a python file in the langchain codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 59768664_aad5_9d85_2eb2_cef37bb0ef06["test_responses_api.py"] 7025b240_fdc3_cf68_b72f_f41dac94566b["json"] 59768664_aad5_9d85_2eb2_cef37bb0ef06 --> 7025b240_fdc3_cf68_b72f_f41dac94566b 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c["os"] 59768664_aad5_9d85_2eb2_cef37bb0ef06 --> 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 59768664_aad5_9d85_2eb2_cef37bb0ef06 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 45fc8fd3_e815_b442_a6d1_0dedc9327b62["openai"] 59768664_aad5_9d85_2eb2_cef37bb0ef06 --> 45fc8fd3_e815_b442_a6d1_0dedc9327b62 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] 59768664_aad5_9d85_2eb2_cef37bb0ef06 --> 120e2591_3e15_b895_72b6_cb26195e40a6 d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] 59768664_aad5_9d85_2eb2_cef37bb0ef06 --> d758344f_537f_649e_f467_b9d7442e86df 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] 59768664_aad5_9d85_2eb2_cef37bb0ef06 --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] 59768664_aad5_9d85_2eb2_cef37bb0ef06 --> 91721f45_4909_e489_8c1f_084f8bd87145 0b28cff6_d823_1571_d2bb_ec61508cc89c["langchain_openai"] 59768664_aad5_9d85_2eb2_cef37bb0ef06 --> 0b28cff6_d823_1571_d2bb_ec61508cc89c ef0b6fc5_6cf5_c982_78be_65b7adea64a3["langchain_openai.chat_models.base"] 59768664_aad5_9d85_2eb2_cef37bb0ef06 --> ef0b6fc5_6cf5_c982_78be_65b7adea64a3 style 59768664_aad5_9d85_2eb2_cef37bb0ef06 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Test Responses API usage."""
import json
import os
from typing import Annotated, Any, Literal, cast
import openai
import pytest
from langchain_core.messages import (
AIMessage,
AIMessageChunk,
BaseMessage,
BaseMessageChunk,
HumanMessage,
MessageLikeRepresentation,
)
from pydantic import BaseModel
from typing_extensions import TypedDict
from langchain_openai import ChatOpenAI, custom_tool
from langchain_openai.chat_models.base import _convert_to_openai_response_format
MODEL_NAME = "gpt-4o-mini"
def _check_response(response: BaseMessage | None) -> None:
assert isinstance(response, AIMessage)
assert isinstance(response.content, list)
for block in response.content:
assert isinstance(block, dict)
if block["type"] == "text":
assert isinstance(block.get("text"), str)
annotations = block.get("annotations", [])
for annotation in annotations:
if annotation["type"] == "file_citation":
assert all(
key in annotation
for key in ["file_id", "filename", "file_index", "type"]
)
elif annotation["type"] == "web_search":
assert all(
key in annotation
for key in ["end_index", "start_index", "title", "type", "url"]
)
elif annotation["type"] == "citation":
assert all(key in annotation for key in ["title", "type"])
if "url" in annotation:
assert "start_index" in annotation
assert "end_index" in annotation
text_content = response.text # type: ignore[operator,misc]
assert isinstance(text_content, str)
assert text_content
assert response.usage_metadata
assert response.usage_metadata["input_tokens"] > 0
assert response.usage_metadata["output_tokens"] > 0
assert response.usage_metadata["total_tokens"] > 0
assert response.response_metadata["model_name"]
assert response.response_metadata["service_tier"] # type: ignore[typeddict-item]
// ... (1050 more lines)
Domain
Subdomains
Functions
- _check_response()
- test_code_interpreter()
- test_computer_calls()
- test_custom_tool()
- test_file_search()
- test_function_calling()
- test_function_calling_and_structured_output()
- test_image_generation_multi_turn()
- test_image_generation_multi_turn_v1()
- test_image_generation_streaming()
- test_image_generation_streaming_v1()
- test_incomplete_response()
- test_mcp_builtin()
- test_mcp_builtin_zdr()
- test_mcp_builtin_zdr_v1()
- test_parsed_dict_schema()
- test_parsed_dict_schema_async()
- test_parsed_pydantic_schema()
- test_parsed_pydantic_schema_async()
- test_parsed_strict()
- test_reasoning()
- test_route_from_model_kwargs()
- test_stateful_api()
- test_stream_reasoning_summary()
- test_verbosity_parameter()
- test_web_search()
- test_web_search_async()
Dependencies
- json
- langchain_core.messages
- langchain_openai
- langchain_openai.chat_models.base
- openai
- os
- pydantic
- pytest
- typing
- typing_extensions
Source
Frequently Asked Questions
What does test_responses_api.py do?
test_responses_api.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_responses_api.py?
test_responses_api.py defines 27 function(s): _check_response, test_code_interpreter, test_computer_calls, test_custom_tool, test_file_search, test_function_calling, test_function_calling_and_structured_output, test_image_generation_multi_turn, test_image_generation_multi_turn_v1, test_image_generation_streaming, and 17 more.
What does test_responses_api.py depend on?
test_responses_api.py imports 10 module(s): json, langchain_core.messages, langchain_openai, langchain_openai.chat_models.base, openai, os, pydantic, pytest, and 2 more.
Where is test_responses_api.py in the architecture?
test_responses_api.py is located at libs/partners/openai/tests/integration_tests/chat_models/test_responses_api.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