Home / File/ test_chat.py — langchain Source File

test_chat.py — langchain Source File

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

File python CoreAbstractions MessageSchema 17 imports 63 functions

Entity Profile

Dependency Diagram

graph LR
  bf3138ca_0068_68ea_f479_35376e264d13["test_chat.py"]
  67ec3255_645e_8b6e_1eff_1eb3c648ed95["re"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> 67ec3255_645e_8b6e_1eff_1eb3c648ed95
  0c635125_6987_b8b3_7ff7_d60249aecde7["warnings"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> 0c635125_6987_b8b3_7ff7_d60249aecde7
  b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8["pathlib"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  0b794afa_fd3d_a810_77fd_ed00bf90e394["packaging"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> 0b794afa_fd3d_a810_77fd_ed00bf90e394
  6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7
  66d6194f_d8c1_55b6_f522_311fdad57877["syrupy.assertion"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> 66d6194f_d8c1_55b6_f522_311fdad57877
  36cce5da_d805_04c3_7e86_e1b4dd49b497["langchain_core.load"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> 36cce5da_d805_04c3_7e86_e1b4dd49b497
  d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> d758344f_537f_649e_f467_b9d7442e86df
  5b417886_56dd_6afa_13ab_a3cfc1dbcccd["langchain_core.prompt_values"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> 5b417886_56dd_6afa_13ab_a3cfc1dbcccd
  e6b4f61e_7b98_6666_3641_26b069517d4a["langchain_core.prompts"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> e6b4f61e_7b98_6666_3641_26b069517d4a
  e45722a2_0136_a972_1f58_7b5987500404["langchain_core.prompts.chat"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> e45722a2_0136_a972_1f58_7b5987500404
  63bafb65_e3c1_8fca_d02a_332411ce701e["langchain_core.prompts.message"]
  bf3138ca_0068_68ea_f479_35376e264d13 --> 63bafb65_e3c1_8fca_d02a_332411ce701e
  style bf3138ca_0068_68ea_f479_35376e264d13 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import re
import warnings
from pathlib import Path
from typing import Any

import pytest
from packaging import version
from pydantic import ValidationError
from syrupy.assertion import SnapshotAssertion

from langchain_core.load import dumpd, load
from langchain_core.messages import (
    AIMessage,
    BaseMessage,
    HumanMessage,
    SystemMessage,
    ToolMessage,
    get_buffer_string,
)
from langchain_core.prompt_values import ChatPromptValue
from langchain_core.prompts import PromptTemplate
from langchain_core.prompts.chat import (
    AIMessagePromptTemplate,
    ChatMessagePromptTemplate,
    ChatPromptTemplate,
    HumanMessagePromptTemplate,
    MessagesPlaceholder,
    SystemMessagePromptTemplate,
    _convert_to_message_template,
)
from langchain_core.prompts.message import BaseMessagePromptTemplate
from langchain_core.prompts.string import PromptTemplateFormat
from langchain_core.utils.pydantic import PYDANTIC_VERSION
from tests.unit_tests.pydantic_utils import _normalize_schema

CUR_DIR = Path(__file__).parent.absolute().resolve()


@pytest.fixture
def messages() -> list[BaseMessagePromptTemplate]:
    """Create messages."""
    system_message_prompt = SystemMessagePromptTemplate(
        prompt=PromptTemplate(
            template="Here's some context: {context}",
            input_variables=["context"],
        )
    )
    human_message_prompt = HumanMessagePromptTemplate(
        prompt=PromptTemplate(
            template="Hello {foo}, I'm {bar}. Thanks for the {context}",
            input_variables=["foo", "bar", "context"],
        )
    )
    ai_message_prompt = AIMessagePromptTemplate(
        prompt=PromptTemplate(
            template="I'm an AI. I'm {foo}. I'm {bar}.",
            input_variables=["foo", "bar"],
        )
    )
    chat_message_prompt = ChatMessagePromptTemplate(
// ... (1926 more lines)

Subdomains

Functions

Dependencies

  • langchain_core.load
  • langchain_core.messages
  • langchain_core.prompt_values
  • langchain_core.prompts
  • langchain_core.prompts.chat
  • langchain_core.prompts.message
  • langchain_core.prompts.string
  • langchain_core.utils.pydantic
  • packaging
  • pathlib
  • pydantic
  • pytest
  • re
  • syrupy.assertion
  • tests.unit_tests.pydantic_utils
  • typing
  • warnings

Frequently Asked Questions

What does test_chat.py do?
test_chat.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.py?
test_chat.py defines 63 function(s): chat_prompt_template, messages, test_chat_input_schema, test_chat_invalid_input_variables_extra, test_chat_invalid_input_variables_missing, test_chat_message_partial, test_chat_message_partial_composition, test_chat_prompt_message_dict, test_chat_prompt_message_placeholder_dict, test_chat_prompt_message_placeholder_partial, and 53 more.
What does test_chat.py depend on?
test_chat.py imports 17 module(s): langchain_core.load, langchain_core.messages, langchain_core.prompt_values, langchain_core.prompts, langchain_core.prompts.chat, langchain_core.prompts.message, langchain_core.prompts.string, langchain_core.utils.pydantic, and 9 more.
Where is test_chat.py in the architecture?
test_chat.py is located at libs/core/tests/unit_tests/prompts/test_chat.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/core/tests/unit_tests/prompts).

Analyze Your Own Codebase

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

Try Supermodel Free