test_history.py — langchain Source File
Architecture documentation for test_history.py, a python file in the langchain codebase. 19 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c8bd6ad8_88b0_7cf1_997f_856910b865bd["test_history.py"] 67ec3255_645e_8b6e_1eff_1eb3c648ed95["re"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> 67ec3255_645e_8b6e_1eff_1eb3c648ed95 cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> 120e2591_3e15_b895_72b6_cb26195e40a6 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> 91721f45_4909_e489_8c1f_084f8bd87145 f3bc7443_c889_119d_0744_aacc3620d8d2["langchain_core.callbacks"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> f3bc7443_c889_119d_0744_aacc3620d8d2 38c69580_3a92_51b1_7512_b0ccca9a0ef6["langchain_core.chat_history"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> 38c69580_3a92_51b1_7512_b0ccca9a0ef6 2312f229_c199_ac88_c29f_62e2a2958404["langchain_core.language_models.chat_models"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> 2312f229_c199_ac88_c29f_62e2a2958404 d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> d758344f_537f_649e_f467_b9d7442e86df ac2a9b92_4484_491e_1b48_ec85e71e1d58["langchain_core.outputs"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> ac2a9b92_4484_491e_1b48_ec85e71e1d58 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c["langchain_core.runnables"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c c764ccae_0d75_abec_7c23_6d5d1949a7ba["langchain_core.runnables.base"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> c764ccae_0d75_abec_7c23_6d5d1949a7ba 2971f9da_6393_a3e3_610e_ace3d35ee978["langchain_core.runnables.config"] c8bd6ad8_88b0_7cf1_997f_856910b865bd --> 2971f9da_6393_a3e3_610e_ace3d35ee978 style c8bd6ad8_88b0_7cf1_997f_856910b865bd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import re
from collections.abc import Callable, Sequence
from typing import Any
import pytest
from pydantic import BaseModel, RootModel
from typing_extensions import override
from langchain_core.callbacks import (
CallbackManagerForLLMRun,
)
from langchain_core.chat_history import InMemoryChatMessageHistory
from langchain_core.language_models.chat_models import BaseChatModel
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage, SystemMessage
from langchain_core.outputs import ChatGeneration, ChatResult
from langchain_core.runnables import Runnable
from langchain_core.runnables.base import RunnableBinding, RunnableLambda
from langchain_core.runnables.config import RunnableConfig
from langchain_core.runnables.history import RunnableWithMessageHistory
from langchain_core.runnables.utils import ConfigurableFieldSpec, Input, Output
from langchain_core.tracers import Run
from langchain_core.tracers.root_listeners import (
AsyncListener,
AsyncRootListenersTracer,
RootListenersTracer,
)
from tests.unit_tests.pydantic_utils import _schema
def test_interfaces() -> None:
history = InMemoryChatMessageHistory()
history.add_message(SystemMessage(content="system"))
history.add_message(HumanMessage(content="human 1"))
history.add_message(AIMessage(content="ai"))
assert str(history) == "System: system\nHuman: human 1\nAI: ai"
def _get_get_session_history(
*,
store: dict[str, InMemoryChatMessageHistory] | None = None,
) -> Callable[..., InMemoryChatMessageHistory]:
chat_history_store = store if store is not None else {}
def get_session_history(
session_id: str, **_kwargs: Any
) -> InMemoryChatMessageHistory:
if session_id not in chat_history_store:
chat_history_store[session_id] = InMemoryChatMessageHistory()
return chat_history_store[session_id]
return get_session_history
def test_input_messages() -> None:
runnable = RunnableLambda[Any, str](
lambda messages: (
"you said: "
+ "\n".join(str(m.content) for m in messages if isinstance(m, HumanMessage))
)
)
// ... (847 more lines)
Domain
Subdomains
Functions
- _get_get_session_history()
- test_get_input_schema_input_dict()
- test_get_input_schema_input_messages()
- test_get_output_messages_no_value_error()
- test_get_output_messages_with_value_error()
- test_get_output_schema()
- test_ignore_session_id()
- test_input_dict()
- test_input_dict_async()
- test_input_dict_with_history_key()
- test_input_dict_with_history_key_async()
- test_input_messages()
- test_input_messages_async()
- test_input_messages_output_message()
- test_input_messages_output_message_async()
- test_interfaces()
- test_output_dict()
- test_output_dict_async()
- test_output_message()
- test_output_message_async()
- test_output_messages()
- test_output_messages_async()
- test_using_custom_config_specs()
- test_using_custom_config_specs_async()
Dependencies
- collections.abc
- langchain_core.callbacks
- langchain_core.chat_history
- langchain_core.language_models.chat_models
- langchain_core.messages
- langchain_core.outputs
- langchain_core.runnables
- langchain_core.runnables.base
- langchain_core.runnables.config
- langchain_core.runnables.history
- langchain_core.runnables.utils
- langchain_core.tracers
- langchain_core.tracers.root_listeners
- pydantic
- pytest
- re
- tests.unit_tests.pydantic_utils
- typing
- typing_extensions
Source
Frequently Asked Questions
What does test_history.py do?
test_history.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in test_history.py?
test_history.py defines 24 function(s): _get_get_session_history, test_get_input_schema_input_dict, test_get_input_schema_input_messages, test_get_output_messages_no_value_error, test_get_output_messages_with_value_error, test_get_output_schema, test_ignore_session_id, test_input_dict, test_input_dict_async, test_input_dict_with_history_key, and 14 more.
What does test_history.py depend on?
test_history.py imports 19 module(s): collections.abc, langchain_core.callbacks, langchain_core.chat_history, langchain_core.language_models.chat_models, langchain_core.messages, langchain_core.outputs, langchain_core.runnables, langchain_core.runnables.base, and 11 more.
Where is test_history.py in the architecture?
test_history.py is located at libs/core/tests/unit_tests/runnables/test_history.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/core/tests/unit_tests/runnables).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free