test_responses.py — langchain Source File
Architecture documentation for test_responses.py, a python file in the langchain codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 1355db93_4c37_8f03_4889_aeb1b68410ec["test_responses.py"] 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] 1355db93_4c37_8f03_4889_aeb1b68410ec --> 120e2591_3e15_b895_72b6_cb26195e40a6 d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] 1355db93_4c37_8f03_4889_aeb1b68410ec --> d758344f_537f_649e_f467_b9d7442e86df 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] 1355db93_4c37_8f03_4889_aeb1b68410ec --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 c57803e6_8295_a18f_018d_3926ecdf1855["langchain.agents.structured_output"] 1355db93_4c37_8f03_4889_aeb1b68410ec --> c57803e6_8295_a18f_018d_3926ecdf1855 style 1355db93_4c37_8f03_4889_aeb1b68410ec fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Unit tests for langchain.agents.structured_output module."""
import pytest
from langchain_core.messages import AIMessage
from pydantic import BaseModel
from langchain.agents.structured_output import (
OutputToolBinding,
ProviderStrategy,
ProviderStrategyBinding,
ToolStrategy,
_SchemaSpec,
)
class _TestModel(BaseModel):
"""A test model for structured output."""
name: str
age: int
email: str = "default@example.com"
class CustomModel(BaseModel):
"""Custom model with a custom docstring."""
value: float
description: str
class EmptyDocModel(BaseModel):
# No custom docstring, should have no description in tool
data: str
class TestToolStrategy:
"""Test ToolStrategy dataclass."""
def test_basic_creation(self) -> None:
"""Test basic ToolStrategy creation."""
strategy = ToolStrategy(schema=_TestModel)
assert strategy.schema == _TestModel
assert strategy.tool_message_content is None
assert len(strategy.schema_specs) == 1
assert strategy.schema_specs[0].schema == _TestModel
def test_multiple_schemas(self) -> None:
"""Test ToolStrategy with multiple schemas."""
strategy = ToolStrategy(schema=_TestModel | CustomModel)
assert len(strategy.schema_specs) == 2
assert strategy.schema_specs[0].schema == _TestModel
assert strategy.schema_specs[1].schema == CustomModel
def test_schema_with_tool_message_content(self) -> None:
"""Test ToolStrategy with tool message content."""
strategy = ToolStrategy(schema=_TestModel, tool_message_content="custom message")
assert strategy.schema == _TestModel
assert strategy.tool_message_content == "custom message"
assert len(strategy.schema_specs) == 1
assert strategy.schema_specs[0].schema == _TestModel
// ... (223 more lines)
Domain
Subdomains
Classes
Dependencies
- langchain.agents.structured_output
- langchain_core.messages
- pydantic
- pytest
Source
Frequently Asked Questions
What does test_responses.py do?
test_responses.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What does test_responses.py depend on?
test_responses.py imports 4 module(s): langchain.agents.structured_output, langchain_core.messages, pydantic, pytest.
Where is test_responses.py in the architecture?
test_responses.py is located at libs/langchain_v1/tests/unit_tests/agents/test_responses.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/langchain_v1/tests/unit_tests/agents).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free