Use nonlocal for conversation_id when running the event_generator

This commit is contained in:
sabaimran
2024-09-03 11:55:06 -07:00
parent 591f5a522c
commit 912cc0074a
2 changed files with 3 additions and 1 deletions

View File

@@ -358,7 +358,7 @@ async def extract_references_and_questions(
conversation = await sync_to_async(ConversationAdapters.get_conversation_by_id)(conversation_id)
if not conversation:
logger.error(f"Conversation with id {conversation_id} not found.")
logger.error(f"Conversation with id {conversation_id} not found when extracting references.")
yield compiled_references, inferred_queries, defiltered_query
return

View File

@@ -548,6 +548,7 @@ async def chat(
subscribed: bool = has_required_scope(request, ["premium"])
event_delimiter = "␃🔚␗"
q = unquote(q)
nonlocal conversation_id
async def send_event(event_type: ChatEvent, data: str | dict):
nonlocal connection_alive, ttft
@@ -615,6 +616,7 @@ async def chat(
async for result in send_llm_response(f"Conversation {conversation_id} not found"):
yield result
return
conversation_id = conversation.id
await is_ready_to_chat(user)