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")):
yield result
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
agent: Agent | None = None
@@ -1383,7 +1383,6 @@ async def chat(
conversation_commands,
user,
request.user.client_app,
conversation_id,
location,
user_name,
researched_results,

View File

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