Log conversation id to help troubleshoot errors faster

This commit is contained in:
Debanjum
2025-07-10 23:01:53 -07:00
parent 25db59e49c
commit b2952236c4
2 changed files with 5 additions and 3 deletions

View File

@@ -1488,9 +1488,10 @@ class ConversationAdapters:
conversation.updated_at = django_timezone.now()
await conversation.asave()
else:
await Conversation.objects.acreate(
conversation = await Conversation.objects.acreate(
user=user, conversation_log=cleaned_conversation_log, client=client_application, slug=slug
)
return conversation
@staticmethod
def get_conversation_processor_options():

View File

@@ -491,8 +491,9 @@ async def save_to_conversation_log(
updated_conversation = None
logger.error(f"Error constructing chat history: {e}")
db_conversation = None
if updated_conversation:
await ConversationAdapters.save_conversation(
db_conversation = await ConversationAdapters.save_conversation(
user,
updated_conversation,
client_application=client_application,
@@ -505,7 +506,7 @@ async def save_to_conversation_log(
logger.info(
f"""
Saved Conversation Turn
Saved Conversation Turn ({db_conversation.id if db_conversation else 'N/A'}):
You ({user.username}): "{q}"
Khoj: "{chat_response}"