ChatMessageHistory and message_from_dict
question
#20792
XiaoConstantine
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context:
I m trying to persist
ChatMessageHistory
to sqlite for session memory control purpose, and noticed following issue (maybe it's expected and I m missing something)Say I have the following chat history
I can serialize it to json string with
cm.json()
without issueWhen I try to deserialize it back to messages:
All the messages are using the base type (BaseMessage) instead of original AIMessage, HumanMessage.
Then I found that there's an utility does handle conversion between
BaseMessage
and its subclasses, when i try:I got:
What's
**message["data"]
? shouldn't it be justHumanMessage(**message)
?Why does
parse_obj
doesn't do the additional step which check the message type and initialize it as the proper message? (maybe because it's the pydantic native function?)Beta Was this translation helpful? Give feedback.
All reactions