AsyncPostgresStore prepare model inputs and pass it prebuilt create_react_agent #2838
Unanswered
aditya-ladawa
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
imports:
... necessary fast api imports...
my fastapi lifespan:
What i want to do is, in my FastApi websocket route I want to use the below function to prepare model inputs by fetching the memories from store and prepare them accordingly for the create_react_agent.
this is my Fastapi route which is a websocket to chat with agent:
Now, prepare_system_message actually returns a coroutine, so I dont know how to handle this case for my route.
I also have doubts and i hope Icould get the answer for them as well:
the question is: Given my websocket_llm_chat route will the agent get to know regarding the new info saved in memory without closing the socket and re opening it? If not then what is the alternative
here is the traceback i get:
[1] INFO: connection open
[1] ERROR: Exception in ASGI application
[1] Traceback (most recent call last):
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 242, in run_asgi
[1] result = await self.app(self.scope, self.asgi_receive, self.asgi_send) # type: ignore[func-returns-value]
[1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
[1] return await self.app(scope, receive, send)
[1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in call
[1] await super().call(scope, receive, send)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/applications.py", line 113, in call
[1] await self.middleware_stack(scope, receive, send)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 152, in call
[1] await self.app(scope, receive, send)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 77, in call
[1] await self.app(scope, receive, send)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in call
[1] await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
[1] raise exc
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
[1] await app(scope, receive, sender)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/routing.py", line 715, in call
[1] await self.middleware_stack(scope, receive, send)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/routing.py", line 735, in app
[1] await route.handle(scope, receive, send)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/routing.py", line 362, in handle
[1] await self.app(scope, receive, send)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/routing.py", line 95, in app
[1] await wrap_app_handling_exceptions(app, session)(scope, receive, send)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
[1] raise exc
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
[1] await app(scope, receive, sender)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/starlette/routing.py", line 93, in app
[1] await func(session)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/fastapi/routing.py", line 383, in app
[1] await dependant.call(**solved_result.values)
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/api/index.py", line 611, in websocket_llm_chat
[1] async for event in agent_graph.astream(query, stream_mode="values", config=config):
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/langgraph/pregel/init.py", line 1874, in astream
[1] async for _ in runner.atick(
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/langgraph/pregel/runner.py", line 362, in atick
[1] await arun_with_retry(
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/langgraph/pregel/retry.py", line 132, in arun_with_retry
[1] return await task.proc.ainvoke(task.input, config)
[1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/langgraph/utils/runnable.py", line 445, in ainvoke
[1] input = await step.ainvoke(input, config, **kwargs)
[1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/langgraph/utils/runnable.py", line 224, in ainvoke
[1] ret = await asyncio.create_task(coro, context=context)
[1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/langgraph/prebuilt/chat_agent_executor.py", line 595, in acall_model
[1] response = await model_runnable.ainvoke(state, config)
[1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3066, in ainvoke
[1] input = await asyncio.create_task(part(), context=context) # type: ignore
[1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/langgraph/utils/runnable.py", line 193, in ainvoke
[1] return self.invoke(input, config)
[1] ^^^^^^^^^^^^^^^^^^^^^^^^^^
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/myenv/lib/python3.12/site-packages/langgraph/utils/runnable.py", line 176, in invoke
[1] ret = context.run(self.func, input, **kwargs)
[1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[1] File "/home/aditya-ladawa/Aditya/z_projects/aireas/api/store_memory_ops.py", line 124, in prepare_system_message
[1] user_data = user_data_item.value if user_data_item else {}
[1] ^^^^^^^^^^^^^^^^^^^^
[1] AttributeError: 'coroutine' object has no attribute 'value'
[1] During task with name 'agent' and id '9d994a88-6a25-8211-e1c4-4671591fc31e'
[1] INFO: connection closed
Beta Was this translation helpful? Give feedback.
All reactions