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() conversation.updated_at = django_timezone.now()
await conversation.asave() await conversation.asave()
else: else:
await Conversation.objects.acreate( conversation = await Conversation.objects.acreate(
user=user, conversation_log=cleaned_conversation_log, client=client_application, slug=slug user=user, conversation_log=cleaned_conversation_log, client=client_application, slug=slug
) )
return conversation
@staticmethod @staticmethod
def get_conversation_processor_options(): def get_conversation_processor_options():

View File

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