Skip to content

Commit

Permalink
Fix conversation look up logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sabaimran committed Jun 24, 2024
1 parent a4d8861 commit 939811e
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/khoj/routers/api_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,8 +890,18 @@ async def chat(
_custom_filters.append("site:khoj.dev")
conversation_commands.append(ConversationCommand.Online)

conversation = await ConversationAdapters.aget_conversation_by_user(user, conversation_id=conversation_id)
conversation = await ConversationAdapters.aget_conversation_by_user(
user, request.user.client_app, conversation_id, title
)
conversation_id = conversation.id if conversation else None

if not conversation:
return Response(
content=f"No conversation found with requested id, title", media_type="text/plain", status_code=400
)
else:
meta_log = conversation.conversation_log

if ConversationCommand.Summarize in conversation_commands:
file_filters = conversation.file_filters
llm_response = ""
Expand Down Expand Up @@ -933,17 +943,6 @@ async def chat(
)
return StreamingResponse(content=llm_response, media_type="text/event-stream", status_code=200)

conversation = await ConversationAdapters.aget_conversation_by_user(
user, request.user.client_app, conversation_id, title
)
conversation_id = conversation.id if conversation else None
if not conversation:
return Response(
content=f"No conversation found with requested id, title", media_type="text/plain", status_code=400
)
else:
meta_log = conversation.conversation_log

is_automated_task = conversation_commands == [ConversationCommand.AutomatedTask]

if conversation_commands == [ConversationCommand.Default] or is_automated_task:
Expand Down

0 comments on commit 939811e

Please sign in to comment.