langchain-ai / opengpts

MIT License
6.48k stars 864 forks source link

Change stream format to include only changed messages #249

Closed nfcampos closed 7 months ago

nfcampos commented 8 months ago
mkorpela commented 7 months ago

I'm getting the following when trying to access an existing thread:

opengpts-backend   | ModuleNotFoundError: No module named 'langgraph.pregel.reserved'
opengpts-backend   | INFO:     172.21.0.4:55638 - "GET /threads/decd4358-4d6b-4a3a-b430-68187a6a211f/messages HTTP/1.1" 500 Internal Server Error
opengpts-backend   | ERROR:    Exception in ASGI application
opengpts-backend   | Traceback (most recent call last):
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
opengpts-backend   |     result = await app(  # type: ignore[func-returns-value]
opengpts-backend   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
opengpts-backend   |     return await self.app(scope, receive, send)
opengpts-backend   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 292, in __call__
opengpts-backend   |     await super().__call__(scope, receive, send)
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
opengpts-backend   |     await self.middleware_stack(scope, receive, send)
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
opengpts-backend   |     raise exc
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
opengpts-backend   |     await self.app(scope, receive, _send)
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
opengpts-backend   |     raise exc
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
opengpts-backend   |     await self.app(scope, receive, sender)
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
opengpts-backend   |     raise e
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
opengpts-backend   |     await self.app(scope, receive, send)
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
opengpts-backend   |     await route.handle(scope, receive, send)
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
opengpts-backend   |     await self.app(scope, receive, send)
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
opengpts-backend   |     response = await func(request)
opengpts-backend   |                ^^^^^^^^^^^^^^^^^^^
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 273, in app
opengpts-backend   |     raw_response = await run_endpoint_function(
opengpts-backend   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 190, in run_endpoint_function
opengpts-backend   |     return await dependant.call(**values)
opengpts-backend   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
opengpts-backend   |   File "/backend/app/api/threads.py", line 42, in get_thread_messages
opengpts-backend   |     return await storage.get_thread_messages(opengpts_user_id, tid)
opengpts-backend   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
opengpts-backend   |   File "/backend/app/storage.py", line 104, in get_thread_messages
opengpts-backend   |     state = await app.aget_state({"configurable": {"thread_id": thread_id}})
opengpts-backend   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
opengpts-backend   |   File "/usr/local/lib/python3.11/site-packages/langgraph/pregel/__init__.py", line 329, in aget_state
opengpts-backend   |     saved = await self.checkpointer.aget_tuple(config)
opengpts-backend   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
opengpts-backend   |   File "/backend/app/checkpoint.py", line 95, in aget_tuple
opengpts-backend   |     pickle.loads(value[0]),
opengpts-backend   |     ^^^^^^^^^^^^^^^^^^^^^^
opengpts-backend   | ModuleNotFoundError: No module named 'langgraph.pregel.reserved'
mkorpela commented 7 months ago

Seems to be related to deserializing old threads. Data migration issue?

nfcampos commented 7 months ago

Hmm yea that wouldn't be easy to fix through pickle I think