mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
core[patch]: fix chat history circular import (#23182)
This commit is contained in:
parent
883e90d06e
commit
677408bfc9
@ -26,7 +26,6 @@ from langchain_core.messages import (
|
||||
get_buffer_string,
|
||||
)
|
||||
from langchain_core.pydantic_v1 import BaseModel, Field
|
||||
from langchain_core.runnables import run_in_executor
|
||||
|
||||
|
||||
class BaseChatMessageHistory(ABC):
|
||||
@ -102,6 +101,8 @@ class BaseChatMessageHistory(ABC):
|
||||
In general, fetching messages may involve IO to the underlying
|
||||
persistence layer.
|
||||
"""
|
||||
from langchain_core.runnables.config import run_in_executor
|
||||
|
||||
return await run_in_executor(None, lambda: self.messages)
|
||||
|
||||
def add_user_message(self, message: Union[HumanMessage, str]) -> None:
|
||||
@ -172,6 +173,8 @@ class BaseChatMessageHistory(ABC):
|
||||
Args:
|
||||
messages: A list of BaseMessage objects to store.
|
||||
"""
|
||||
from langchain_core.runnables.config import run_in_executor
|
||||
|
||||
await run_in_executor(None, self.add_messages, messages)
|
||||
|
||||
@abstractmethod
|
||||
@ -180,6 +183,8 @@ class BaseChatMessageHistory(ABC):
|
||||
|
||||
async def aclear(self) -> None:
|
||||
"""Remove all messages from the store"""
|
||||
from langchain_core.runnables.config import run_in_executor
|
||||
|
||||
await run_in_executor(None, self.clear)
|
||||
|
||||
def __str__(self) -> str:
|
||||
|
@ -36,6 +36,7 @@ from langchain_core.runnables.config import (
|
||||
run_in_executor,
|
||||
)
|
||||
from langchain_core.runnables.fallbacks import RunnableWithFallbacks
|
||||
from langchain_core.runnables.history import RunnableWithMessageHistory
|
||||
from langchain_core.runnables.passthrough import (
|
||||
RunnableAssign,
|
||||
RunnablePassthrough,
|
||||
@ -78,6 +79,7 @@ __all__ = [
|
||||
"RunnablePick",
|
||||
"RunnableSequence",
|
||||
"RunnableWithFallbacks",
|
||||
"RunnableWithMessageHistory",
|
||||
"get_config_list",
|
||||
"aadd",
|
||||
"add",
|
||||
|
@ -26,6 +26,7 @@ EXPECTED_ALL = [
|
||||
"RunnablePick",
|
||||
"RunnableSequence",
|
||||
"RunnableWithFallbacks",
|
||||
"RunnableWithMessageHistory",
|
||||
"get_config_list",
|
||||
"aadd",
|
||||
"add",
|
||||
|
Loading…
Reference in New Issue
Block a user