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.
This commit is contained in:
Nan LI 2023-09-28 21:52:15 +08:00 committed by GitHub
parent 7bb6d04fc7
commit 53a9d6115e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,7 +56,7 @@ class XataChatMessageHistory(BaseChatMessageHistory):
{"name": "role", "type": "string"}, {"name": "role", "type": "string"},
{"name": "content", "type": "text"}, {"name": "content", "type": "text"},
{"name": "name", "type": "string"}, {"name": "name", "type": "string"},
{"name": "additionalKwargs", "type": "text"}, {"name": "additionalKwargs", "type": "json"},
] ]
}, },
) )
@ -101,7 +101,7 @@ class XataChatMessageHistory(BaseChatMessageHistory):
"content": m["content"], "content": m["content"],
"role": m.get("role"), "role": m.get("role"),
"name": m.get("name"), "name": m.get("name"),
"additionalKwargs": json.loads(m["additionalKwargs"]), "additional_kwargs": json.loads(m["additionalKwargs"]),
}, },
} }
for m in r["records"] for m in r["records"]