File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
chatbot-core/api/services Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 1616 RETRIEVER_AGENT_PROMPT ,
1717 SPLIT_QUERY_PROMPT ,
1818)
19- from api .services .memory import get_session
19+
20+ from api .services .memory import get_session , get_session_async
2021from api .services .file_service import format_file_context
2122from api .tools .tools import TOOL_REGISTRY
2223from api .tools .utils import (
@@ -462,7 +463,8 @@ async def get_chatbot_reply_stream(
462463 logger .info ("Streaming message from session '%s'" , session_id )
463464 logger .info ("Handling user query: %s" , user_input )
464465
465- memory = get_session (session_id )
466+ memory = await get_session_async (session_id )
467+
466468 if memory is None :
467469 raise RuntimeError (
468470 f"Session '{ session_id } ' not found in memory store." )
Original file line number Diff line number Diff line change 22Handles in-memory chat session state (conversation memory).
33Provides utility functions for session lifecycle.
44"""
5-
5+ import asyncio
66import uuid
77from datetime import datetime , timedelta
88from threading import Lock
@@ -77,6 +77,12 @@ def get_session(session_id: str) -> ConversationBufferMemory | None:
7777
7878 return memory
7979
80+ async def get_session_async (session_id : str ) -> ConversationBufferMemory | None :
81+ """
82+ Async wrapper for get_session to prevent event loop blocking.
83+ """
84+ return await asyncio .to_thread (get_session , session_id )
85+
8086
8187def persist_session (session_id : str )-> None :
8288 """
You can’t perform that action at this time.
0 commit comments