Clean usage of conversation_id in chat API function

- Normalize conversation_id type to str instead of str or UUID
- Do not pass conversation_id to agenerate_chat_response as
  the associated conversation is also being passed. So can get its id
  directly.
This commit is contained in:
Debanjum
2025-05-23 14:34:55 -07:00
parent a76032522e
commit e968cca273
2 changed files with 3 additions and 5 deletions

View File

@@ -860,9 +860,9 @@ async def chat(
async for result in send_llm_response(f"Conversation {conversation_id} not found", tracer.get("usage")): async for result in send_llm_response(f"Conversation {conversation_id} not found", tracer.get("usage")):
yield result yield result
return return
conversation_id = conversation.id conversation_id = str(conversation.id)
async for event in send_event(ChatEvent.METADATA, {"conversationId": str(conversation_id), "turnId": turn_id}): async for event in send_event(ChatEvent.METADATA, {"conversationId": conversation_id, "turnId": turn_id}):
yield event yield event
agent: Agent | None = None agent: Agent | None = None
@@ -1383,7 +1383,6 @@ async def chat(
conversation_commands, conversation_commands,
user, user,
request.user.client_app, request.user.client_app,
conversation_id,
location, location,
user_name, user_name,
researched_results, researched_results,

View File

@@ -1359,7 +1359,6 @@ async def agenerate_chat_response(
conversation_commands: List[ConversationCommand] = [ConversationCommand.Default], conversation_commands: List[ConversationCommand] = [ConversationCommand.Default],
user: KhojUser = None, user: KhojUser = None,
client_application: ClientApplication = None, client_application: ClientApplication = None,
conversation_id: str = None,
location_data: LocationData = None, location_data: LocationData = None,
user_name: Optional[str] = None, user_name: Optional[str] = None,
meta_research: str = "", meta_research: str = "",
@@ -1394,7 +1393,7 @@ async def agenerate_chat_response(
operator_results=operator_results, operator_results=operator_results,
inferred_queries=inferred_queries, inferred_queries=inferred_queries,
client_application=client_application, client_application=client_application,
conversation_id=conversation_id, conversation_id=str(conversation.id),
query_images=query_images, query_images=query_images,
train_of_thought=train_of_thought, train_of_thought=train_of_thought,
raw_query_files=raw_query_files, raw_query_files=raw_query_files,