Home / Function/ test_json_output_function_parser() — langchain Function Reference

test_json_output_function_parser() — langchain Function Reference

Architecture documentation for the test_json_output_function_parser() function in test_openai_functions.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  c632c588_d465_4413_f7c0_70edca166c1e["test_json_output_function_parser()"]
  051794f3_743e_b482_fc72_029694e0fa16["test_openai_functions.py"]
  c632c588_d465_4413_f7c0_70edca166c1e -->|defined in| 051794f3_743e_b482_fc72_029694e0fa16
  style c632c588_d465_4413_f7c0_70edca166c1e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/output_parsers/test_openai_functions.py lines 16–46

def test_json_output_function_parser() -> None:
    """Test the JSON output function parser is configured with robust defaults."""
    message = AIMessage(
        content="This is a test message",
        additional_kwargs={
            "function_call": {
                "name": "function_name",
                "arguments": '{"arg1": "code\ncode"}',
            }
        },
    )
    chat_generation = ChatGeneration(message=message)

    # Full output
    # Test that the parsers defaults are configured to parse in non-strict mode
    parser = JsonOutputFunctionsParser(args_only=False)
    result = parser.parse_result([chat_generation])
    assert result == {"arguments": {"arg1": "code\ncode"}, "name": "function_name"}

    # Args only
    parser = JsonOutputFunctionsParser(args_only=True)
    result = parser.parse_result([chat_generation])
    assert result == {"arg1": "code\ncode"}

    # Verify that the original message is not modified
    assert message.additional_kwargs == {
        "function_call": {
            "name": "function_name",
            "arguments": '{"arg1": "code\ncode"}',
        }
    }

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free