test_chat.py — langchain Source File
Architecture documentation for test_chat.py, a python file in the langchain codebase. 17 imports, 0 dependents.
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)
Domain
Subdomains
Functions
- 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()
- test_chat_prompt_message_placeholder_tuple()
- test_chat_prompt_template()
- test_chat_prompt_template_append_and_extend()
- test_chat_prompt_template_data_prompt_from_message()
- test_chat_prompt_template_from_messages()
- test_chat_prompt_template_from_messages_jinja2()
- test_chat_prompt_template_from_messages_mustache()
- test_chat_prompt_template_from_messages_using_message_classes()
- test_chat_prompt_template_from_messages_using_role_strings()
- test_chat_prompt_template_image_prompt_from_message()
- test_chat_prompt_template_indexing()
- test_chat_prompt_template_message_class_tuples_append()
- test_chat_prompt_template_message_class_tuples_concatenation()
- test_chat_prompt_template_message_class_tuples_empty_template()
- test_chat_prompt_template_message_class_tuples_extend()
- test_chat_prompt_template_message_class_tuples_input_variables()
- test_chat_prompt_template_message_class_tuples_mixed_syntax()
- test_chat_prompt_template_message_class_tuples_multiple_variables()
- test_chat_prompt_template_message_class_tuples_mustache_format()
- test_chat_prompt_template_message_class_tuples_partial_variables()
- test_chat_prompt_template_message_class_tuples_slicing()
- test_chat_prompt_template_message_class_tuples_special_characters()
- test_chat_prompt_template_message_class_tuples_static_text()
- test_chat_prompt_template_message_class_tuples_with_invoke()
- test_chat_prompt_template_message_class_tuples_with_placeholder()
- test_chat_prompt_template_variable_names()
- test_chat_prompt_template_with_messages()
- test_chat_prompt_w_msgs_placeholder_ser_des()
- test_chat_tmpl_dict_msg()
- test_chat_tmpl_from_messages_multipart_formatting_with_path()
- test_chat_tmpl_from_messages_multipart_image()
- test_chat_tmpl_from_messages_multipart_text()
- test_chat_tmpl_from_messages_multipart_text_with_template()
- test_chat_tmpl_serdes()
- test_chat_valid_infer_variables()
- test_chat_valid_with_partial_variables()
- test_convert_to_message()
- test_convert_to_message_is_strict()
- test_create_chat_prompt_template_from_template()
- test_create_chat_prompt_template_from_template_partial()
- test_create_system_message_prompt_list_template()
- test_create_system_message_prompt_list_template_partial_variables_not_null()
- test_create_system_message_prompt_template_from_template_partial()
- test_data_prompt_template_deserializable()
- test_dict_message_prompt_template_errors_on_jinja2()
- test_fstring_rejects_invalid_identifier_variable_names()
- test_infer_variables()
- test_message_prompt_template_from_template_file()
- test_messages_placeholder()
- test_messages_placeholder_with_max()
- test_messages_prompt_accepts_list()
- test_mustache_template_attribute_access_vulnerability()
- test_rendering_prompt_with_conditionals_no_empty_text_blocks()
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
Source
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