From 184a81b2f98d678e02e64fa18528d66c5fe788b8 Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Thu, 2 Jan 2025 21:29:18 +0330 Subject: [PATCH] new id --- backend/chat/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/chat/views.py b/backend/chat/views.py index ed81bea..3bc017f 100644 --- a/backend/chat/views.py +++ b/backend/chat/views.py @@ -123,13 +123,14 @@ class ProductChatView(APIView): # Format messages formatted_messages = [] + counter = 1 for message in message_response.data: for content in message.content: if content.type == "text" and 'this is the start of the chat greet the user this chat is about the product with given detail:' not in content.text.value: sender = 'user' if message.role == 'user' else 'ai' - formatted_messages.append({'sender': sender, 'content': content.text.value}) - - # formatted_messages.reverse() + formatted_messages.append({'sender': sender, 'content': content.text.value, 'id': counter}) + counter += 1 + paginator = StructurePagination() paginated_messages = paginator.paginate_queryset(formatted_messages, request) return paginator.get_paginated_response(paginated_messages)