From 13d2f56e9acb28a8f38d1f6f4b22b61a6838bc5c Mon Sep 17 00:00:00 2001 From: Valentin Yanakiev Date: Fri, 31 May 2024 09:18:31 +0300 Subject: [PATCH] Answers in the question language --- ai_adapter.py | 13 ++++++++----- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ai_adapter.py b/ai_adapter.py index 2fa583e..812f0f3 100644 --- a/ai_adapter.py +++ b/ai_adapter.py @@ -26,13 +26,13 @@ chat_system_template = """ You are a friendly and talkative conversational agent, tasked with answering questions based on the context provided below delimited by triple pluses. Use the following step-by-step instructions to respond to user inputs: -1 - If the question is in a different language than Dutch, translate the question to Dutch before answering. +1 - If the question is in a different language than English, translate the question to English before answering. 2 - The text provided in the context delimited by triple pluses is retrieved from the Alkemio platform and is not part of the conversation with the user. 3 - Provide an answer of 250 words or less that is professional, engaging, accurate and exthausive, based on the context delimited by triple pluses. \ If the answer cannot be found within the context, write 'Hmm, I am not sure'. 4 - If the question is not specifically about Alkemio or if the question is not professional write 'Unfortunately, I cannot answer that question'. 5 - Only return the answer from step 3, do not show any code or additional information. -6 - Answer in Dutch. +6 - Answer in the language of the question. +++ {context} +++ @@ -43,7 +43,8 @@ """ -condense_question_prompt = PromptTemplate.from_template(condense_question_template) +condense_question_prompt = PromptTemplate.from_template( + condense_question_template) chat_prompt = ChatPromptTemplate.from_messages( [ @@ -89,7 +90,8 @@ async def query_chain(message, language, history): % (question, knowledge_space_name, context_space_name) ) - chroma_client = chromadb.HttpClient(host=config["db_host"], port=config["db_port"]) + chroma_client = chromadb.HttpClient( + host=config["db_host"], port=config["db_port"]) collection = chroma_client.get_collection( knowledge_space_name, embedding_function=embed_func ) @@ -99,7 +101,8 @@ async def query_chain(message, language, history): ) logger.info(docs["metadatas"]) - logger.info("Documents with ids [%s] selected" % ",".join(list(docs["ids"][0]))) + logger.info("Documents with ids [%s] selected" % + ",".join(list(docs["ids"][0]))) review_system_prompt = SystemMessagePromptTemplate( prompt=PromptTemplate( diff --git a/pyproject.toml b/pyproject.toml index 10a6913..91264a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "virtual-contributor-engine-expert" -version = "0.2.0" +version = "0.3.3" description = "Alkemio Generative AI Virtul Persona" authors = ["Alkemio BV "] license = "EUPL-1.2"