Home / File/ test_chat_generation.py — langchain Source File

test_chat_generation.py — langchain Source File

Architecture documentation for test_chat_generation.py, a python file in the langchain codebase. 4 imports, 0 dependents.

File python CoreAbstractions MessageSchema 4 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  f9b60b63_1916_8d73_75dc_44cd4229a6d8["test_chat_generation.py"]
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  f9b60b63_1916_8d73_75dc_44cd4229a6d8 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  f9b60b63_1916_8d73_75dc_44cd4229a6d8 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"]
  f9b60b63_1916_8d73_75dc_44cd4229a6d8 --> d758344f_537f_649e_f467_b9d7442e86df
  ac2a9b92_4484_491e_1b48_ec85e71e1d58["langchain_core.outputs"]
  f9b60b63_1916_8d73_75dc_44cd4229a6d8 --> ac2a9b92_4484_491e_1b48_ec85e71e1d58
  style f9b60b63_1916_8d73_75dc_44cd4229a6d8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Any

import pytest

from langchain_core.messages import AIMessage
from langchain_core.outputs import ChatGeneration


@pytest.mark.parametrize(
    "content",
    [
        "foo",
        ["foo"],
        [{"text": "foo", "type": "text"}],
        [
            {"tool_use": {}, "type": "tool_use"},
            {"text": "foo", "type": "text"},
            "bar",
        ],
    ],
)
def test_msg_with_text(content: str | list[str | dict[str, Any]]) -> None:
    expected = "foo"
    actual = ChatGeneration(message=AIMessage(content=content)).text
    assert actual == expected


@pytest.mark.parametrize("content", [[], [{"tool_use": {}, "type": "tool_use"}]])
def test_msg_no_text(content: str | list[str | dict[str, Any]]) -> None:
    expected = ""
    actual = ChatGeneration(message=AIMessage(content=content)).text
    assert actual == expected

Subdomains

Dependencies

  • langchain_core.messages
  • langchain_core.outputs
  • pytest
  • typing

Frequently Asked Questions

What does test_chat_generation.py do?
test_chat_generation.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_chat_generation.py?
test_chat_generation.py defines 2 function(s): test_msg_no_text, test_msg_with_text.
What does test_chat_generation.py depend on?
test_chat_generation.py imports 4 module(s): langchain_core.messages, langchain_core.outputs, pytest, typing.
Where is test_chat_generation.py in the architecture?
test_chat_generation.py is located at libs/core/tests/unit_tests/outputs/test_chat_generation.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/core/tests/unit_tests/outputs).

Analyze Your Own Codebase

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

Try Supermodel Free