mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Fix updating specific conversation by id from the chat API endpoint
- Use the conversation id of the retrieved conversation rather than the potentially unset conversation id passed via API - await creating new chat when no chat id provided and no existing conversations exist
This commit is contained in:
parent
ec6dc0daaf
commit
aed4313cfc
2 changed files with 5 additions and 5 deletions
|
@ -395,7 +395,7 @@ class ConversationAdapters:
|
|||
@staticmethod
|
||||
def get_conversation_by_user(
|
||||
user: KhojUser, client_application: ClientApplication = None, conversation_id: int = None
|
||||
):
|
||||
) -> Optional[Conversation]:
|
||||
if conversation_id:
|
||||
conversation = (
|
||||
Conversation.objects.filter(user=user, client=client_application, id=conversation_id)
|
||||
|
@ -437,7 +437,7 @@ class ConversationAdapters:
|
|||
@staticmethod
|
||||
async def aget_conversation_by_user(
|
||||
user: KhojUser, client_application: ClientApplication = None, conversation_id: int = None, title: str = None
|
||||
):
|
||||
) -> Optional[Conversation]:
|
||||
if conversation_id:
|
||||
return await Conversation.objects.filter(user=user, client=client_application, id=conversation_id).afirst()
|
||||
elif title:
|
||||
|
@ -445,7 +445,7 @@ class ConversationAdapters:
|
|||
else:
|
||||
return await (
|
||||
Conversation.objects.filter(user=user, client=client_application).order_by("-updated_at").afirst()
|
||||
) or Conversation.objects.acreate(user=user, client=client_application)
|
||||
) or await Conversation.objects.acreate(user=user, client=client_application)
|
||||
|
||||
@staticmethod
|
||||
async def adelete_conversation_by_user(
|
||||
|
|
|
@ -330,7 +330,7 @@ async def chat(
|
|||
intent_type=intent_type,
|
||||
inferred_queries=[improved_image_prompt],
|
||||
client_application=request.user.client_app,
|
||||
conversation_id=conversation_id,
|
||||
conversation_id=conversation.id,
|
||||
compiled_references=compiled_references,
|
||||
online_results=online_results,
|
||||
)
|
||||
|
@ -347,7 +347,7 @@ async def chat(
|
|||
conversation_commands,
|
||||
user,
|
||||
request.user.client_app,
|
||||
conversation_id,
|
||||
conversation.id,
|
||||
location,
|
||||
user_name,
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue