From c0f4b95aa9961724ab4569049b4c3bc12ebbacfc Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Sun, 10 Dec 2023 23:33:02 -0500 Subject: [PATCH] RunnableWithMessageHistory: Fix input schema (#14516) Input schema should not have history key --- libs/core/langchain_core/runnables/history.py | 2 -- libs/core/tests/unit_tests/runnables/test_history.py | 1 - 2 files changed, 3 deletions(-) diff --git a/libs/core/langchain_core/runnables/history.py b/libs/core/langchain_core/runnables/history.py index 98c6b1a09123e..e0bb9281ffd5e 100644 --- a/libs/core/langchain_core/runnables/history.py +++ b/libs/core/langchain_core/runnables/history.py @@ -197,8 +197,6 @@ def get_input_schema( fields[self.input_messages_key] = (Sequence[BaseMessage], ...) else: fields["__root__"] = (Sequence[BaseMessage], ...) - if self.history_messages_key: - fields[self.history_messages_key] = (Sequence[BaseMessage], ...) return create_model( # type: ignore[call-overload] "RunnableWithChatHistoryInput", **fields, diff --git a/libs/core/tests/unit_tests/runnables/test_history.py b/libs/core/tests/unit_tests/runnables/test_history.py index c5f02c931337a..49f68825ba239 100644 --- a/libs/core/tests/unit_tests/runnables/test_history.py +++ b/libs/core/tests/unit_tests/runnables/test_history.py @@ -178,7 +178,6 @@ def test_output_dict() -> None: def test_get_input_schema_input_dict() -> None: class RunnableWithChatHistoryInput(BaseModel): input: Union[str, BaseMessage, Sequence[BaseMessage]] - history: Sequence[BaseMessage] runnable = RunnableLambda( lambda input: {