Home / Function/ test_max_tokens_error() — langchain Function Reference

test_max_tokens_error() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/tests/unit_tests/output_parsers/test_openai_tools.py lines 877–895

def test_max_tokens_error(caplog: Any) -> None:
    parser = PydanticToolsParser(tools=[NameCollector], first_tool_only=True)
    message = AIMessage(
        content="",
        tool_calls=[
            {
                "id": "call_OwL7f5PE",
                "name": "NameCollector",
                "args": {"names": ["suz", "jerm"]},
            }
        ],
        response_metadata={"stop_reason": "max_tokens"},
    )
    with pytest.raises(ValidationError):
        _ = parser.invoke(message)
    assert any(
        "`max_tokens` stop reason" in msg and record.levelname == "ERROR"
        for record, msg in zip(caplog.records, caplog.messages, strict=False)
    )

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free