From 53a9d6115ebc448527d23db387b7b74f0ea7bbb2 Mon Sep 17 00:00:00 2001 From: Nan LI Date: Thu, 28 Sep 2023 21:52:15 +0800 Subject: [PATCH] Xata chat memory FIX (#11145) - **Description:** Changed data type from `text` to `json` in xata for improved performance. Also corrected the `additionalKwargs` key in the `messages()` function to `additional_kwargs` to adhere to `BaseMessage` requirements. - **Issue:** The Chathisroty.messages() will return {} of `additional_kwargs`, as the name is wrong for `additionalKwargs` . - **Dependencies:** N/A - **Tag maintainer:** N/A - **Twitter handle:** N/A My PR is passing linting and testing before submitting. --- .../langchain/langchain/memory/chat_message_histories/xata.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/langchain/langchain/memory/chat_message_histories/xata.py b/libs/langchain/langchain/memory/chat_message_histories/xata.py index de358888a0..a51da97a46 100644 --- a/libs/langchain/langchain/memory/chat_message_histories/xata.py +++ b/libs/langchain/langchain/memory/chat_message_histories/xata.py @@ -56,7 +56,7 @@ class XataChatMessageHistory(BaseChatMessageHistory): {"name": "role", "type": "string"}, {"name": "content", "type": "text"}, {"name": "name", "type": "string"}, - {"name": "additionalKwargs", "type": "text"}, + {"name": "additionalKwargs", "type": "json"}, ] }, ) @@ -101,7 +101,7 @@ class XataChatMessageHistory(BaseChatMessageHistory): "content": m["content"], "role": m.get("role"), "name": m.get("name"), - "additionalKwargs": json.loads(m["additionalKwargs"]), + "additional_kwargs": json.loads(m["additionalKwargs"]), }, } for m in r["records"]