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 Error: TypeError: Object of type object is not JSON serializable #468

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Huarong
Copy link

@Huarong Huarong commented Mar 7, 2024

Make json dump more robust. Support object type.
Fix the error like this, which occur in using langraph.

  File "/Users/huohuarong/.pyenv/versions/3.11.2/lib/python3.11/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           │           └ {'id': 'd4b690a2-78b9-4bc3-bda0-98e5e6c62366', 'type': 'span-update', 'body': {'output': <object object at 0x120809540>, 'id'...
           └ <_json.Encoder object at 0x1253fa080>
  File "/Users/huohuarong/llm/doctorgpt/.venv/lib/python3.11/site-packages/langfuse/serializer.py", line 55, in default
    return JSONEncoder.default(self, obj)
           │           │       │     └ <object object at 0x120809540>
           │           │       └ <langfuse.serializer.EventSerializer object at 0x1253b3050>
           │           └ <function JSONEncoder.default at 0x101e6d580>
           └ <class 'json.encoder.JSONEncoder'>
  File "/Users/huohuarong/.pyenv/versions/3.11.2/lib/python3.11/json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '

TypeError: Object of type object is not JSON serializable

@CLAassistant
Copy link

CLAassistant commented Mar 7, 2024

CLA assistant check
All committers have signed the CLA.

@Huarong Huarong force-pushed the fix-object-json-serializable-error branch from 72257a6 to c3e4623 Compare March 8, 2024 05:50
@maxdeichmann
Copy link
Member

@Huarong thanks for the change. Unfortunately, the string representation of an object would not really be helpful, as our users would see the object name and the memory address in the UI.
Do you know which type of object langraph is trying to send here? Do you mind sharing your graph with us?

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.

None yet

3 participants