The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
core: `chat_*` docstrings (#23412)
Leonid Ganeline75a44fe95120
diff --git a/libs/core/langchain_core/chat_history.py b/libs/core/langchain_core/chat_history.pyindex ffbba96983..8d41c6c77f 100644--- a/libs/core/langchain_core/chat_history.py+++ b/libs/core/langchain_core/chat_history.py@@ -14,6 +14,7 @@AIMessage, HumanMessage, BaseMessage""" # noqa: E501+from __future__ import annotationsfrom abc import ABC, abstractmethod@@ -144,6 +145,10 @@ class BaseChatMessageHistory(ABC):Args:message: A BaseMessage object to store.++ Raises:+ NotImplementedError: If the sub-class has not implemented an efficient+ add_messages method."""if type(self).add_messages != BaseChatMessageHistory.add_messages:# This means that the sub-class has implemented an efficient add_messages@@ -162,16 +167,16 @@ class BaseChatMessageHistory(ABC):in an efficient manner to avoid unnecessary round-trips to the underlying store.Args:- messages: A list of BaseMessage objects to store.+ messages: A sequence of BaseMessage objects to store."""for message in messages:self.add_message(message)async def aadd_messages(self, messages: Sequence[BaseMessage]) -> None:- """Add a list of messages.+ """Async add a list of messages.Args:- messages: A list of BaseMessage objects to store.+ messages: A sequence of BaseMessage objects to store."""from langchain_core.runnables.config import run_in_executor@@ -182,7 +187,7 @@ class BaseChatMessageHistory(ABC):"""Remove all messages from the store"""async def aclear(self) -> None:- """Remove all messages from the store"""+ """Async remove all messages from the store"""from langchain_core.runnables.config import run_in_executorawait run_in_executor(None, self.clear)@@ -199,20 +204,24 @@ class InMemoryChatMessageHistory(BaseChatMessageHistory, BaseModel):"""messages: List[BaseMessage] = Field(default_factory=list)+ """A list of messages stored in memory."""async def aget_messages(self) -> List[BaseMessage]:+ """Async version of getting messages."""return self.messagesdef add_message(self, message: BaseMessage) -> None:- """Add a self-created message to the store"""+ """Add a self-created message to the store."""self.messages.append(message)async def aadd_messages(self, messages: Sequence[BaseMessage]) -> None:- """Add messages to the store"""+ """Async add messages to the store"""self.add_messages(messages)def clear(self) -> None:+ """Clear all messages from the store."""self.messages = []async def aclear(self) -> None:+ """Async clear all messages from the store."""self.clear()diff --git a/libs/core/langchain_core/chat_loaders.py b/libs/core/langchain_core/chat_loaders.pyindex 7bbdd8894d..93c14a4f8f 100644--- a/libs/core/langchain_core/chat_loaders.py+++ b/libs/core/langchain_core/chat_loaders.py@@ -9,8 +9,16 @@ class BaseChatLoader(ABC):@abstractmethoddef lazy_load(self) -> Iterator[ChatSession]:- """Lazy load the chat sessions."""+ """Lazy load the chat sessions.++ Returns:+ An iterator of chat sessions.+ """def load(self) -> List[ChatSession]:- """Eagerly load the chat sessions into memory."""+ """Eagerly load the chat sessions into memory.++ Returns:+ A list of chat sessions.+ """return list(self.lazy_load())diff --git a/libs/core/langchain_core/chat_sessions.py b/libs/core/langchain_core/chat_sessions.pyindex 1379a6b667..d43754729a 100644--- a/libs/core/langchain_core/chat_sessions.py+++ b/libs/core/langchain_core/chat_sessions.py@@ -1,6 +1,5 @@-"""**Chat Sessions** are a collection of messages and function calls.+"""**Chat Sessions** are a collection of messages and function calls."""-"""from typing import Sequence, TypedDictfrom langchain_core.messages import BaseMessage@@ -11,6 +10,6 @@ class ChatSession(TypedDict, total=False):conversation, channel, or other group of messages."""messages: Sequence[BaseMessage]- """The LangChain chat messages loaded from the source."""+ """A sequence of the LangChain chat messages loaded from the source."""functions: Sequence[dict]- """The function calling specs for the messages."""+ """A sequence of the function calling specs for the messages."""