Home / Function/ test_parse_with_different_pydantic_2_v1() — langchain Function Reference

test_parse_with_different_pydantic_2_v1() — langchain Function Reference

Architecture documentation for the test_parse_with_different_pydantic_2_v1() function in test_openai_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  957abd68_64e9_5a7a_101e_2a5d27cf11f9["test_parse_with_different_pydantic_2_v1()"]
  0f94a062_f577_31c7_fb9c_0f526b273e64["test_openai_tools.py"]
  957abd68_64e9_5a7a_101e_2a5d27cf11f9 -->|defined in| 0f94a062_f577_31c7_fb9c_0f526b273e64
  style 957abd68_64e9_5a7a_101e_2a5d27cf11f9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/output_parsers/test_openai_tools.py lines 811–841

def test_parse_with_different_pydantic_2_v1() -> None:
    """Test with pydantic.v1.BaseModel from pydantic 2."""

    class Forecast(pydantic.v1.BaseModel):
        temperature: int
        forecast: str

    # Can't get pydantic to work here due to the odd typing of tryig to support
    # both v1 and v2 in the same codebase.
    parser = PydanticToolsParser(tools=[Forecast])
    message = AIMessage(
        content="",
        tool_calls=[
            {
                "id": "call_OwL7f5PE",
                "name": "Forecast",
                "args": {"temperature": 20, "forecast": "Sunny"},
            }
        ],
    )

    generation = ChatGeneration(
        message=message,
    )

    assert parser.parse_result([generation]) == [
        Forecast(
            temperature=20,
            forecast="Sunny",
        )
    ]

Domain

Subdomains

Frequently Asked Questions

What does test_parse_with_different_pydantic_2_v1() do?
test_parse_with_different_pydantic_2_v1() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/output_parsers/test_openai_tools.py.
Where is test_parse_with_different_pydantic_2_v1() defined?
test_parse_with_different_pydantic_2_v1() is defined in libs/core/tests/unit_tests/output_parsers/test_openai_tools.py at line 811.

Analyze Your Own Codebase

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

Try Supermodel Free