From 1086bfe1bac1a13b3232f53d3858c944e62328c5 Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Tue, 21 Jan 2025 07:19:02 +0530 Subject: [PATCH] fix: wrong role in req messages --- application/llm/google_ai.py | 3 +++ application/retriever/classic_rag.py | 13 +++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/application/llm/google_ai.py b/application/llm/google_ai.py index 7e67a4cd..5b1eeb74 100644 --- a/application/llm/google_ai.py +++ b/application/llm/google_ai.py @@ -17,6 +17,9 @@ class GoogleLLM(BaseLLM): role = message.get("role") content = message.get("content") + if role == "assistant": + role = "model" + parts = [] if role and content is not None: if isinstance(content, str): diff --git a/application/retriever/classic_rag.py b/application/retriever/classic_rag.py index 2e355513..b3735a96 100644 --- a/application/retriever/classic_rag.py +++ b/application/retriever/classic_rag.py @@ -5,7 +5,6 @@ from application.tools.agent import Agent from application.vectorstore.vector_creator import VectorCreator - class ClassicRAG(BaseRetriever): def __init__( @@ -74,13 +73,11 @@ class ClassicRAG(BaseRetriever): if len(self.chat_history) > 1: for i in self.chat_history: - if "prompt" in i and "response" in i: - messages_combine.append( - {"role": "user", "content": i["prompt"]} - ) - messages_combine.append( - {"role": "system", "content": i["response"]} - ) + if "prompt" in i and "response" in i: + messages_combine.append({"role": "user", "content": i["prompt"]}) + messages_combine.append( + {"role": "assistant", "content": i["response"]} + ) messages_combine.append({"role": "user", "content": self.question}) # llm = LLMCreator.create_llm( # settings.LLM_NAME, api_key=settings.API_KEY, user_api_key=self.user_api_key