mirror of
https://github.com/lfnovo/open-notebook.git
synced 2026-05-03 05:40:36 +00:00
fix: complete SqliteSaver async compatibility in chat routers (#525)
* fix: use sync get_state() for SqliteSaver in chat routers Replace async aget_state() calls with sync get_state() wrapped in asyncio.to_thread() to fix SqliteSaver compatibility issues. SqliteSaver does not support async methods, so we need to run the sync version in a separate thread. This is a follow-up to #519 which fixed the same issue in graph_utils.py but missed four locations: - chat.py: get_session() and execute_chat() - source_chat.py: get_source_chat_session() and stream_source_chat_response() Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: translate comments to English --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Luis Novo <lfnovo@gmail.com>
This commit is contained in:
parent
36ac10d5f6
commit
eae429b3bd
2 changed files with 16 additions and 8 deletions
|
|
@ -190,8 +190,10 @@ async def get_session(session_id: str):
|
|||
raise HTTPException(status_code=404, detail="Session not found")
|
||||
|
||||
# Get session state from LangGraph to retrieve messages
|
||||
thread_state = await chat_graph.aget_state(
|
||||
config=RunnableConfig(configurable={"thread_id": full_session_id})
|
||||
# Use sync get_state() in a thread since SqliteSaver doesn't support async
|
||||
thread_state = await asyncio.to_thread(
|
||||
chat_graph.get_state,
|
||||
config=RunnableConfig(configurable={"thread_id": full_session_id}),
|
||||
)
|
||||
|
||||
# Extract messages from state
|
||||
|
|
@ -348,8 +350,10 @@ async def execute_chat(request: ExecuteChatRequest):
|
|||
)
|
||||
|
||||
# Get current state
|
||||
current_state = await chat_graph.aget_state(
|
||||
config=RunnableConfig(configurable={"thread_id": full_session_id})
|
||||
# Use sync get_state() in a thread since SqliteSaver doesn't support async
|
||||
current_state = await asyncio.to_thread(
|
||||
chat_graph.get_state,
|
||||
config=RunnableConfig(configurable={"thread_id": full_session_id}),
|
||||
)
|
||||
|
||||
# Prepare state for execution
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue