Home / Function/ test_json_schema() — langchain Function Reference

test_json_schema() — langchain Function Reference

Architecture documentation for the test_json_schema() function in test_response_format.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  748bd42d_dddb_4ca0_c940_7ad204379de2["test_json_schema()"]
  d1d579f8_d411_ce75_6fa3_d97e725405cb["TestResponseFormatAsToolStrategy"]
  748bd42d_dddb_4ca0_c940_7ad204379de2 -->|defined in| d1d579f8_d411_ce75_6fa3_d97e725405cb
  3a19584d_56f8_f36c_495e_d0a23bd1d48b["test_json_schema()"]
  3a19584d_56f8_f36c_495e_d0a23bd1d48b -->|calls| 748bd42d_dddb_4ca0_c940_7ad204379de2
  3a19584d_56f8_f36c_495e_d0a23bd1d48b["test_json_schema()"]
  748bd42d_dddb_4ca0_c940_7ad204379de2 -->|calls| 3a19584d_56f8_f36c_495e_d0a23bd1d48b
  style 748bd42d_dddb_4ca0_c940_7ad204379de2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/test_response_format.py lines 296–317

    def test_json_schema(self) -> None:
        """Test response_format as ToolStrategy with JSON schema."""
        tool_calls = [
            [{"args": {}, "id": "1", "name": "get_weather"}],
            [
                {
                    "name": "weather_schema",
                    "id": "2",
                    "args": WEATHER_DATA,
                }
            ],
        ]

        model = FakeToolCallingModel(tool_calls=tool_calls)

        agent = create_agent(
            model, [get_weather], response_format=ToolStrategy(weather_json_schema)
        )
        response = agent.invoke({"messages": [HumanMessage("What's the weather?")]})

        assert response["structured_response"] == EXPECTED_WEATHER_DICT
        assert len(response["messages"]) == 5

Domain

Subdomains

Called By

Frequently Asked Questions

What does test_json_schema() do?
test_json_schema() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/test_response_format.py.
Where is test_json_schema() defined?
test_json_schema() is defined in libs/langchain_v1/tests/unit_tests/agents/test_response_format.py at line 296.
What does test_json_schema() call?
test_json_schema() calls 1 function(s): test_json_schema.
What calls test_json_schema()?
test_json_schema() is called by 1 function(s): test_json_schema.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free