Home / Function/ test_json_mode_structured_output() — langchain Function Reference

test_json_mode_structured_output() — langchain Function Reference

Architecture documentation for the test_json_mode_structured_output() function in test_chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  d6dced31_ed37_9f5c_e105_2b0f6cac7d8c["test_json_mode_structured_output()"]
  af57ae60_607e_c138_9ab0_fb8bb1c5916a["test_chat_models.py"]
  d6dced31_ed37_9f5c_e105_2b0f6cac7d8c -->|defined in| af57ae60_607e_c138_9ab0_fb8bb1c5916a
  style d6dced31_ed37_9f5c_e105_2b0f6cac7d8c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/groq/tests/integration_tests/test_chat_models.py lines 535–552

def test_json_mode_structured_output() -> None:
    """Test with_structured_output with json."""

    class Joke(BaseModel):
        """Joke to tell user."""

        setup: str = Field(description="question to set up a joke")
        punchline: str = Field(description="answer to resolve the joke")

    chat = ChatGroq(model=DEFAULT_MODEL_NAME).with_structured_output(
        Joke, method="json_mode"
    )
    result = chat.invoke(
        "Tell me a joke about cats, respond in JSON with `setup` and `punchline` keys"
    )
    assert type(result) is Joke
    assert len(result.setup) != 0
    assert len(result.punchline) != 0

Domain

Subdomains

Frequently Asked Questions

What does test_json_mode_structured_output() do?
test_json_mode_structured_output() is a function in the langchain codebase, defined in libs/partners/groq/tests/integration_tests/test_chat_models.py.
Where is test_json_mode_structured_output() defined?
test_json_mode_structured_output() is defined in libs/partners/groq/tests/integration_tests/test_chat_models.py at line 535.

Analyze Your Own Codebase

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

Try Supermodel Free