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

Ollama models return JSON serializing error #1128

Open
srdas opened this issue Nov 28, 2024 · 1 comment
Open

Ollama models return JSON serializing error #1128

srdas opened this issue Nov 28, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@srdas
Copy link
Collaborator

srdas commented Nov 28, 2024

Description

Ollama models generate error after returning a valid response:
image

Reproduce

Choose any Ollama model (the error is not specific to a particular Ollama model):
image

Then try any prompt. It will return a correct response in one exchange and will follow it up with an unnecessary error as shown above. Error is:

Traceback (most recent call last):
  File "/Users/sanjivda/GitHub/jupyter-ai/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py", line 226, in on_message
    await self.process_message(message)
  File "/Users/sanjivda/GitHub/jupyter-ai/packages/jupyter-ai/jupyter_ai/chat_handlers/default.py", line 71, in process_message
    await self.stream_reply(inputs, message)
  File "/Users/sanjivda/GitHub/jupyter-ai/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py", line 603, in stream_reply
    self._send_stream_chunk(
  File "/Users/sanjivda/GitHub/jupyter-ai/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py", line 518, in _send_stream_chunk
    self.broadcast_message(stream_chunk_msg)
  File "/Users/sanjivda/GitHub/jupyter-ai/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py", line 285, in broadcast_message
    websocket.broadcast_message(message)
  File "/Users/sanjivda/GitHub/jupyter-ai/packages/jupyter-ai/jupyter_ai/handlers.py", line 241, in broadcast_message
    client.write_message(message.dict())
  File "/opt/anaconda3/envs/jupyter-ai/lib/python3.12/site-packages/tornado/websocket.py", line 334, in write_message
    message = tornado.escape.json_encode(message)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/jupyter-ai/lib/python3.12/site-packages/tornado/escape.py", line 96, in json_encode
    return json.dumps(value).replace("</", "<\\/")
           ^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/jupyter-ai/lib/python3.12/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/jupyter-ai/lib/python3.12/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/jupyter-ai/lib/python3.12/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/jupyter-ai/lib/python3.12/json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Message is not JSON serializable

Expected behavior

No JSON serializing error

Environment

Jupyter AI v2.28.2

@srdas srdas added the bug Something isn't working label Nov 28, 2024
@edwardochoaphd
Copy link

getting same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants