Skip to content
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

Fix JSON Serialization Error by Correctly Handling cl.Message Type #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gnoparus
Copy link

When executing the original code, it fails with a JSON serialization error indicating that an object of type Message is not JSON serializable. The specific errors encountered are:

UI Error: Object of type Message is not JSON serializable
Console Error: TypeError: Object of type Message is not JSON serializable
The stack trace reveals that this error occurs in main.py and is related to the handling of the cl.Message object.

After reviewing the relevant ChainLit documentation (API Reference on on_message), it became evident that the issue arises because the message parameter in on_message expects a cl.Message object rather than a str.

To resolve this issue, I've adjusted the code to pass cl.Message correctly, as expected by the ChainLit API.

The fix was verified locally by running the modified code. The serialization error no longer appears, and the functionality works as intended.

The cl.on_message API has been updated recently, specifically 4 days ago. The function signature has been modified and it no longer accepts a string as its parameter; it now requires a cl.Message object instead.

For more details, refer to the official release notes: ChainLit v0.7.3 Release Notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant