From bc349c7595d0df05f4fc93d0782d3133c3612c84 Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Thu, 2 Jan 2025 15:44:58 +0330 Subject: [PATCH] reversing the message result before sending --- backend/chat/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/chat/views.py b/backend/chat/views.py index a97060c..ef78712 100644 --- a/backend/chat/views.py +++ b/backend/chat/views.py @@ -129,7 +129,7 @@ class ProductChatView(APIView): sender = 'user' if message.role == 'user' else 'ai' formatted_messages.append({'sender': sender, 'content': content.text.value}) - # Paginate results + formatted_messages.reverse() paginator = StructurePagination() paginated_messages = paginator.paginate_queryset(formatted_messages, request) return paginator.get_paginated_response(paginated_messages) @@ -172,7 +172,7 @@ class ProductChatView(APIView): 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() paginator = StructurePagination() paginated_messages = paginator.paginate_queryset(formatted_messages, request) return paginator.get_paginated_response(paginated_messages) \ No newline at end of file