Home / File/ test_response_format.py — langchain Source File

test_response_format.py — langchain Source File

Architecture documentation for test_response_format.py, a python file in the langchain codebase. 19 imports, 0 dependents.

File python CoreAbstractions MessageSchema 19 imports 3 functions 11 classes

Entity Profile

Dependency Diagram

graph LR
  78b88257_eb76_9d35_8abe_db981de29160["test_response_format.py"]
  7025b240_fdc3_cf68_b72f_f41dac94566b["json"]
  78b88257_eb76_9d35_8abe_db981de29160 --> 7025b240_fdc3_cf68_b72f_f41dac94566b
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  78b88257_eb76_9d35_8abe_db981de29160 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  aac5f8ad_7f2a_3a8e_3b4b_b07d681cbdcf["dataclasses"]
  78b88257_eb76_9d35_8abe_db981de29160 --> aac5f8ad_7f2a_3a8e_3b4b_b07d681cbdcf
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  78b88257_eb76_9d35_8abe_db981de29160 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  525a7d6f_f455_56e3_854a_c8a7da4a1417["unittest.mock"]
  78b88257_eb76_9d35_8abe_db981de29160 --> 525a7d6f_f455_56e3_854a_c8a7da4a1417
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  78b88257_eb76_9d35_8abe_db981de29160 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  ba43b74d_3099_7e1c_aac3_cf594720469e["langchain_core.language_models"]
  78b88257_eb76_9d35_8abe_db981de29160 --> ba43b74d_3099_7e1c_aac3_cf594720469e
  2312f229_c199_ac88_c29f_62e2a2958404["langchain_core.language_models.chat_models"]
  78b88257_eb76_9d35_8abe_db981de29160 --> 2312f229_c199_ac88_c29f_62e2a2958404
  833aeadc_c3e9_bfcf_db07_ecb37ad3ba24["langchain_core.language_models.fake_chat_models"]
  78b88257_eb76_9d35_8abe_db981de29160 --> 833aeadc_c3e9_bfcf_db07_ecb37ad3ba24
  d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"]
  78b88257_eb76_9d35_8abe_db981de29160 --> d758344f_537f_649e_f467_b9d7442e86df
  2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c["langchain_core.runnables"]
  78b88257_eb76_9d35_8abe_db981de29160 --> 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c
  6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"]
  78b88257_eb76_9d35_8abe_db981de29160 --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7
  91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"]
  78b88257_eb76_9d35_8abe_db981de29160 --> 91721f45_4909_e489_8c1f_084f8bd87145
  839143dd_e377_b604_96de_3624dbdffeb5["langchain.agents"]
  78b88257_eb76_9d35_8abe_db981de29160 --> 839143dd_e377_b604_96de_3624dbdffeb5
  style 78b88257_eb76_9d35_8abe_db981de29160 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Test suite for create_agent with structured output response_format permutations."""

import json
from collections.abc import Callable, Sequence
from dataclasses import dataclass
from typing import Any
from unittest.mock import patch

import pytest
from langchain_core.language_models import LanguageModelInput
from langchain_core.language_models.chat_models import BaseChatModel
from langchain_core.language_models.fake_chat_models import GenericFakeChatModel
from langchain_core.messages import HumanMessage
from langchain_core.runnables import Runnable
from pydantic import BaseModel, Field
from typing_extensions import TypedDict

from langchain.agents import create_agent
from langchain.agents.middleware.types import (
    AgentMiddleware,
    ModelCallResult,
    ModelRequest,
    ModelResponse,
)
from langchain.agents.structured_output import (
    MultipleStructuredOutputsError,
    ProviderStrategy,
    StructuredOutputValidationError,
    ToolStrategy,
)
from langchain.messages import AIMessage
from langchain.tools import BaseTool, tool
from tests.unit_tests.agents.model import FakeToolCallingModel


# Test data models
class WeatherBaseModel(BaseModel):
    """Weather response."""

    temperature: float = Field(description="The temperature in fahrenheit")
    condition: str = Field(description="Weather condition")


@dataclass
class WeatherDataclass:
    """Weather response."""

    temperature: float
    condition: str


class WeatherTypedDict(TypedDict):
    """Weather response."""

    temperature: float
    condition: str


weather_json_schema = {
    "type": "object",
// ... (840 more lines)

Subdomains

Dependencies

  • collections.abc
  • dataclasses
  • json
  • langchain.agents
  • langchain.agents.middleware.types
  • langchain.agents.structured_output
  • langchain.messages
  • langchain.tools
  • langchain_core.language_models
  • langchain_core.language_models.chat_models
  • langchain_core.language_models.fake_chat_models
  • langchain_core.messages
  • langchain_core.runnables
  • pydantic
  • pytest
  • tests.unit_tests.agents.model
  • typing
  • typing_extensions
  • unittest.mock

Frequently Asked Questions

What does test_response_format.py do?
test_response_format.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_response_format.py?
test_response_format.py defines 3 function(s): get_location, get_weather, test_union_of_types.
What does test_response_format.py depend on?
test_response_format.py imports 19 module(s): collections.abc, dataclasses, json, langchain.agents, langchain.agents.middleware.types, langchain.agents.structured_output, langchain.messages, langchain.tools, and 11 more.
Where is test_response_format.py in the architecture?
test_response_format.py is located at libs/langchain_v1/tests/unit_tests/agents/test_response_format.py (domain: CoreAbstractions, subdomain: MessageSchema, 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