-
Notifications
You must be signed in to change notification settings - Fork 6.4k
fix(chatstore): handle FunctionCall serialization in PostgresChatStor… #20049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(chatstore): handle FunctionCall serialization in PostgresChatStor… #20049
Conversation
You'll need to bump the version too for it to reflect once it gets merged |
@anoopshrma Do I need to edit the GitHub workflow for the core-typecheck or is it something else you are referring to which I need to bump the version of? |
|
||
params = { | ||
"key": key, | ||
"value": [message.model_dump_json() for message in messages], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the better fix here is fixing the pydantic model for the chat message
It already has handling for special objects in additional_kwargs, but probably is just missing a case to handle whatever type you are encountering with google
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@field_serializer("additional_kwargs", check_fields=False) |
…com/iamzimozic/llama_index into fix/postgreschatstore-serialization fix
Fixes #19992
Summary / Description:
Fix PydanticSerializationError when PostgresChatStore tries to store ChatMessage objects containing FunctionCall from Google’s Generative AI.
Added a helper safe_model_dump_json() to serialize non-standard objects safely.
Replaced all model_dump_json() calls in PostgresChatStore with safe_model_dump_json(message).
New Package?
Yes
✅ No
Version Bump?
Yes
✅No (change is internal to existing storage module)
Type of Change
✅Bug fix (non-breaking change which fixes an issue)
New feature
Breaking change
Requires documentation update
How Has This Been Tested?
✅ Added local test verifying safe_model_dump_json() works with FunctionCall.
✅ Verified PostgresChatStore.add_message() and get_messages() (local SQLite or Postgres) works end-to-end.
Suggested Checklist:
✅ Self-reviewed code
✅ Commented code in key areas (safe_model_dump_json)
Documentation updates not needed
No new notebooks added
✅ No new warnings generated
✅ Tests prove the fix works (serialization test)
✅ Existing unit tests pass locally
✅ Ran formatting/lint checks