Skip to content

Commit

Permalink
Merge pull request #19 from alkem-io/vc-expert-18
Browse files Browse the repository at this point in the history
Answers in the question language
  • Loading branch information
valentinyanakiev authored May 31, 2024
2 parents a0a1480 + 13d2f56 commit 303e265
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions ai_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
+++
Expand All @@ -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(
[
Expand Down Expand Up @@ -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
)
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "EUPL-1.2"
Expand Down

0 comments on commit 303e265

Please sign in to comment.