From f69861d58c66945f239d0443412167bafee675e7 Mon Sep 17 00:00:00 2001 From: Jeannot Damoiseaux <62134006+jeannotdamoiseaux@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:19:21 +0000 Subject: [PATCH 01/27] move-prompts-to-jinja-templates --- app/backend/approaches/chatapproach.py | 53 +++++++----------- .../approaches/chatreadretrieveread.py | 14 ++--- .../approaches/chatreadretrievereadvision.py | 18 ++---- .../approaches/prompts/ask/few_shots.jinja | 10 ++++ .../prompts/ask/system_message.jinja | 5 ++ .../prompts/ask/system_message_vision.jinja | 7 +++ .../prompts/chat/follow_up_questions.jinja | 7 +++ .../prompts/chat/query_few_shots.jinja | 18 ++++++ .../prompts/chat/query_template.jinja | 8 +++ .../prompts/chat/system_message.jinja | 6 ++ .../prompts/chat/system_message_vision.jinja | 19 +++++++ app/backend/approaches/retrievethenread.py | 56 ++++++++++++------- .../approaches/retrievethenreadvision.py | 15 ++--- 13 files changed, 152 insertions(+), 84 deletions(-) create mode 100644 app/backend/approaches/prompts/ask/few_shots.jinja create mode 100644 app/backend/approaches/prompts/ask/system_message.jinja create mode 100644 app/backend/approaches/prompts/ask/system_message_vision.jinja create mode 100644 app/backend/approaches/prompts/chat/follow_up_questions.jinja create mode 100644 app/backend/approaches/prompts/chat/query_few_shots.jinja create mode 100644 app/backend/approaches/prompts/chat/query_template.jinja create mode 100644 app/backend/approaches/prompts/chat/system_message.jinja create mode 100644 app/backend/approaches/prompts/chat/system_message_vision.jinja diff --git a/app/backend/approaches/chatapproach.py b/app/backend/approaches/chatapproach.py index ea1857da3b..caf096b102 100644 --- a/app/backend/approaches/chatapproach.py +++ b/app/backend/approaches/chatapproach.py @@ -2,39 +2,26 @@ import re from abc import ABC, abstractmethod from typing import Any, AsyncGenerator, Optional +from jinja2 import Environment, FileSystemLoader from openai.types.chat import ChatCompletion, ChatCompletionMessageParam from approaches.approach import Approach - class ChatApproach(Approach, ABC): - query_prompt_few_shots: list[ChatCompletionMessageParam] = [ - {"role": "user", "content": "How did crypto do last year?"}, - {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, - {"role": "user", "content": "What are my health plans?"}, - {"role": "assistant", "content": "Show available health plans"}, - ] - NO_RESPONSE = "0" - - follow_up_questions_prompt_content = """Generate 3 very brief follow-up questions that the user would likely ask next. - Enclose the follow-up questions in double angle brackets. Example: - <> - <> - <> - Do no repeat questions that have already been asked. - Make sure the last question ends with ">>". - """ - - query_prompt_template = """Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base. - You have access to Azure AI Search index with 100's of documents. - Generate a search query based on the conversation and the new question. - Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms. - Do not include any text inside [] or <<>> in the search query terms. - Do not include any special characters like '+'. - If the question is not in English, translate the question to English before generating the search query. - If you cannot generate a search query, return just the number 0. - """ + def __init__(self): + self._initialize_templates() + self.NO_RESPONSE = "0" + + def _initialize_templates(self): + self.env = Environment(loader=FileSystemLoader('approaches/prompts/chat')) + self.query_prompt_few_shots: list[ChatCompletionMessageParam] = json.loads( + self.env.get_template('query_few_shots.jinja').render() + ) + self.query_prompt_template = self.env.get_template('query_template.jinja').render() + self.follow_up_questions_prompt = self.env.get_template('follow_up_questions.jinja').render() + self.system_message_chat_conversation_template = self.env.get_template('system_message.jinja') + self.system_message_chat_conversation_vision_template = self.env.get_template('system_message_vision.jinja') @property @abstractmethod @@ -47,15 +34,17 @@ async def run_until_final_call(self, messages, overrides, auth_claims, should_st def get_system_prompt(self, override_prompt: Optional[str], follow_up_questions_prompt: str) -> str: if override_prompt is None: - return self.system_message_chat_conversation.format( - injected_prompt="", follow_up_questions_prompt=follow_up_questions_prompt + return self.system_message_chat_conversation_template.render( + follow_up_questions_prompt=follow_up_questions_prompt, + injected_prompt="" ) elif override_prompt.startswith(">>>"): - return self.system_message_chat_conversation.format( - injected_prompt=override_prompt[3:] + "\n", follow_up_questions_prompt=follow_up_questions_prompt + return self.system_message_chat_conversation_template.render( + follow_up_questions_prompt=follow_up_questions_prompt, + injected_prompt=override_prompt[3:] + "\n" ) else: - return override_prompt.format(follow_up_questions_prompt=follow_up_questions_prompt) + return override_prompt.format(follow_up_questions_prompt=follow_up_questions_prompt) ## check if correct def get_search_query(self, chat_completion: ChatCompletion, user_query: str): response_message = chat_completion.choices[0].message diff --git a/app/backend/approaches/chatreadretrieveread.py b/app/backend/approaches/chatreadretrieveread.py index b752547e71..2780da3255 100644 --- a/app/backend/approaches/chatreadretrieveread.py +++ b/app/backend/approaches/chatreadretrieveread.py @@ -39,6 +39,7 @@ def __init__( query_language: str, query_speller: str, ): + super().__init__() self.search_client = search_client self.openai_client = openai_client self.auth_helper = auth_helper @@ -55,13 +56,10 @@ def __init__( @property def system_message_chat_conversation(self): - return """Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers. - Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question. - If the question is not in English, answer in the language used in the question. - Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]. - {follow_up_questions_prompt} - {injected_prompt} - """ + return self.system_message_chat_conversation_template.render( + follow_up_questions_prompt="", + injected_prompt="" + ) @overload async def run_until_final_call( @@ -177,7 +175,7 @@ async def run_until_final_call( # Allow client to replace the entire prompt, or to inject into the exiting prompt using >>> system_message = self.get_system_prompt( overrides.get("prompt_template"), - self.follow_up_questions_prompt_content if overrides.get("suggest_followup_questions") else "", + self.follow_up_questions_prompt_content if overrides.get("suggest_followup_questions") else "" ) response_token_limit = 1024 diff --git a/app/backend/approaches/chatreadretrievereadvision.py b/app/backend/approaches/chatreadretrievereadvision.py index 6b48643077..075243961c 100644 --- a/app/backend/approaches/chatreadretrievereadvision.py +++ b/app/backend/approaches/chatreadretrievereadvision.py @@ -46,6 +46,7 @@ def __init__( vision_endpoint: str, vision_token_provider: Callable[[], Awaitable[str]] ): + super().__init__() self.search_client = search_client self.blob_container_client = blob_container_client self.openai_client = openai_client @@ -67,19 +68,10 @@ def __init__( @property def system_message_chat_conversation(self): - return """ - You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images. - Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName: - Each text source starts in a new line and has the file name followed by colon and the actual information - Always include the source name from the image or text for each fact you use in the response in the format: [filename] - Answer the following question using only the data provided in the sources below. - If asking a clarifying question to the user would help, ask the question. - Be brief in your answers. - The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned - If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts. - {follow_up_questions_prompt} - {injected_prompt} - """ + return self.system_message_chat_conversation_vision_template.render( + follow_up_questions_prompt="", + injected_prompt="" + ) async def run_until_final_call( self, diff --git a/app/backend/approaches/prompts/ask/few_shots.jinja b/app/backend/approaches/prompts/ask/few_shots.jinja new file mode 100644 index 0000000000..6ad6d9debc --- /dev/null +++ b/app/backend/approaches/prompts/ask/few_shots.jinja @@ -0,0 +1,10 @@ +{ + "question": "'What is the deductible for the employee plan for a visit to Overlake in Bellevue?' + +Sources: +info1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family. +info2.pdf: Overlake is in-network for the employee plan. +info3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue. +info4.pdf: In-network institutions include Overlake, Swedish and others in the region.", + "answer": "In-network deductibles are $500 for employee and $1000 for family [info1.txt] and Overlake is in-network for the employee plan [info2.pdf][info4.pdf]." +} \ No newline at end of file diff --git a/app/backend/approaches/prompts/ask/system_message.jinja b/app/backend/approaches/prompts/ask/system_message.jinja new file mode 100644 index 0000000000..6873dec18a --- /dev/null +++ b/app/backend/approaches/prompts/ask/system_message.jinja @@ -0,0 +1,5 @@ +You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. +Use 'you' to refer to the individual asking the questions even if they ask with 'I'. +Answer the following question using only the data provided in the sources below. +Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. +If you cannot answer using the sources below, say you don't know. Use below example to answer \ No newline at end of file diff --git a/app/backend/approaches/prompts/ask/system_message_vision.jinja b/app/backend/approaches/prompts/ask/system_message_vision.jinja new file mode 100644 index 0000000000..963b137ed3 --- /dev/null +++ b/app/backend/approaches/prompts/ask/system_message_vision.jinja @@ -0,0 +1,7 @@ +You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images. +Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:. +Each text source starts in a new line and has the file name followed by colon and the actual information. +Always include the source name from the image or text for each fact you use in the response in the format: [filename]. +Answer the following question using only the data provided in the sources below. +The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned. +If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts. \ No newline at end of file diff --git a/app/backend/approaches/prompts/chat/follow_up_questions.jinja b/app/backend/approaches/prompts/chat/follow_up_questions.jinja new file mode 100644 index 0000000000..1eaf118252 --- /dev/null +++ b/app/backend/approaches/prompts/chat/follow_up_questions.jinja @@ -0,0 +1,7 @@ +Generate 3 very brief follow-up questions that the user would likely ask next. +Enclose the follow-up questions in double angle brackets. Example: +<> +<> +<> +Do not repeat questions that have already been asked. +Make sure the last question ends with ">>". \ No newline at end of file diff --git a/app/backend/approaches/prompts/chat/query_few_shots.jinja b/app/backend/approaches/prompts/chat/query_few_shots.jinja new file mode 100644 index 0000000000..f22ea73a5f --- /dev/null +++ b/app/backend/approaches/prompts/chat/query_few_shots.jinja @@ -0,0 +1,18 @@ +[ + { + "role": "user", + "content": "How did crypto do last year?" + }, + { + "role": "assistant", + "content": "Summarize Cryptocurrency Market Dynamics from last year" + }, + { + "role": "user", + "content": "What are my health plans?" + }, + { + "role": "assistant", + "content": "Show available health plans" + } +] diff --git a/app/backend/approaches/prompts/chat/query_template.jinja b/app/backend/approaches/prompts/chat/query_template.jinja new file mode 100644 index 0000000000..d9ecd59d0b --- /dev/null +++ b/app/backend/approaches/prompts/chat/query_template.jinja @@ -0,0 +1,8 @@ +Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base. +You have access to Azure AI Search index with 100's of documents. +Generate a search query based on the conversation and the new question. +Do not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms. +Do not include any text inside [] or <<>> in the search query terms. +Do not include any special characters like '+'. +If the question is not in English, translate the question to English before generating the search query. +If you cannot generate a search query, return just the number 0. diff --git a/app/backend/approaches/prompts/chat/system_message.jinja b/app/backend/approaches/prompts/chat/system_message.jinja new file mode 100644 index 0000000000..022d6a1343 --- /dev/null +++ b/app/backend/approaches/prompts/chat/system_message.jinja @@ -0,0 +1,6 @@ +Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers. +Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question. +If the question is not in English, answer in the language used in the question. +Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]. +{{ follow_up_questions_prompt }} +{{ injected_prompt }} \ No newline at end of file diff --git a/app/backend/approaches/prompts/chat/system_message_vision.jinja b/app/backend/approaches/prompts/chat/system_message_vision.jinja new file mode 100644 index 0000000000..bb8b6c9d62 --- /dev/null +++ b/app/backend/approaches/prompts/chat/system_message_vision.jinja @@ -0,0 +1,19 @@ +You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images. +Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName: +Each text source starts in a new line and has the file name followed by colon and the actual information +Always include the source name from the image or text for each fact you use in the response in the format: [filename] +Answer the following question using only the data provided in the sources below. +If asking a clarifying question to the user would help, ask the question. +Be brief in your answers. +The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned +If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts. +{follow_up_questions_prompt} +{injected_prompt} + +"You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images. " + + "Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName: " + + "Each text source starts in a new line and has the file name followed by colon and the actual information " + + "Always include the source name from the image or text for each fact you use in the response in the format: [filename] " + + "Answer the following question using only the data provided in the sources below. " + + "The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned " + + "If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts " \ No newline at end of file diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index 5c73def39e..c62ae6bdc9 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -1,10 +1,14 @@ from typing import Any, Optional +import json +import re +import ast from azure.search.documents.aio import SearchClient from azure.search.documents.models import VectorQuery from openai import AsyncOpenAI from openai.types.chat import ChatCompletionMessageParam from openai_messages_token_helper import build_messages, get_token_limit +from jinja2 import Environment, FileSystemLoader from approaches.approach import Approach, ThoughtStep from core.authentication import AuthenticationHelper @@ -17,26 +21,6 @@ class RetrieveThenReadApproach(Approach): (answer) with that prompt. """ - system_chat_template = ( - "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. " - + "Use 'you' to refer to the individual asking the questions even if they ask with 'I'. " - + "Answer the following question using only the data provided in the sources below. " - + "Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. " - + "If you cannot answer using the sources below, say you don't know. Use below example to answer" - ) - - # shots/sample conversation - question = """ -'What is the deductible for the employee plan for a visit to Overlake in Bellevue?' - -Sources: -info1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family. -info2.pdf: Overlake is in-network for the employee plan. -info3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue. -info4.pdf: In-network institutions include Overlake, Swedish and others in the region -""" - answer = "In-network deductibles are $500 for employee and $1000 for family [info1.txt] and Overlake is in-network for the employee plan [info2.pdf][info4.pdf]." - def __init__( self, *, @@ -68,6 +52,36 @@ def __init__( self.query_speller = query_speller self.chatgpt_token_limit = get_token_limit(chatgpt_model, self.ALLOW_NON_GPT_MODELS) + self._initialize_templates() + + def _initialize_templates(self): + self.env = Environment(loader=FileSystemLoader('approaches/prompts/ask')) + self.system_chat_template = self.env.get_template('system_message.jinja').render() + self.few_shots = self._process_few_shots() + + def _process_few_shots(self) -> Any: + raw_few_shots = self.env.get_template('few_shots.jinja').render() + json_str_few_shots = self._clean_json_string(raw_few_shots) + processed_few_shots = self._escape_newlines_in_json(json_str_few_shots) + return json.loads(processed_few_shots) + + @staticmethod + def _clean_json_string(json_str: str) -> str: + return re.sub(r'^\s+|\s+$', '', json_str) + + @staticmethod + def _escape_newlines_in_json(json_str: str) -> str: + in_string = False + result = [] + for char in json_str: + if char == '"' and (not result or result[-1] != '\\'): + in_string = not in_string + elif char == '\n' and in_string: + result.append('\\n') + continue + result.append(char) + return ''.join(result) + async def run( self, messages: list[ChatCompletionMessageParam], @@ -118,7 +132,7 @@ async def run( updated_messages = build_messages( model=self.chatgpt_model, system_prompt=overrides.get("prompt_template", self.system_chat_template), - few_shots=[{"role": "user", "content": self.question}, {"role": "assistant", "content": self.answer}], + few_shots=[{"role": "user", "content": self.few_shots["question"]}, {"role": "assistant", "content": self.few_shots["answer"]}], new_user_content=user_content, max_tokens=self.chatgpt_token_limit - response_token_limit, fallback_to_default=self.ALLOW_NON_GPT_MODELS, diff --git a/app/backend/approaches/retrievethenreadvision.py b/app/backend/approaches/retrievethenreadvision.py index cd0bf0d08d..cf8b0bda91 100644 --- a/app/backend/approaches/retrievethenreadvision.py +++ b/app/backend/approaches/retrievethenreadvision.py @@ -9,6 +9,7 @@ ChatCompletionMessageParam, ) from openai_messages_token_helper import build_messages, get_token_limit +from jinja2 import Environment, FileSystemLoader from approaches.approach import Approach, ThoughtStep from core.authentication import AuthenticationHelper @@ -22,16 +23,6 @@ class RetrieveThenReadVisionApproach(Approach): (answer) with that prompt. """ - system_chat_template_gpt4v = ( - "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images. " - + "Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName: " - + "Each text source starts in a new line and has the file name followed by colon and the actual information " - + "Always include the source name from the image or text for each fact you use in the response in the format: [filename] " - + "Answer the following question using only the data provided in the sources below. " - + "The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned " - + "If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts " - ) - def __init__( self, *, @@ -68,6 +59,10 @@ def __init__( self.vision_token_provider = vision_token_provider self.gpt4v_token_limit = get_token_limit(gpt4v_model, self.ALLOW_NON_GPT_MODELS) + self.env = Environment(loader=FileSystemLoader('approaches/prompts/ask')) + self.system_chat_template_gpt4v = self.env.get_template('system_message_vision.jinja').render() + + async def run( self, messages: list[ChatCompletionMessageParam], From eda629227b693685e268b67bc372a4c8b57ff043 Mon Sep 17 00:00:00 2001 From: Jeannot Damoiseaux <62134006+jeannotdamoiseaux@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:59:21 +0000 Subject: [PATCH 02/27] refactor: convert few_shots to JSON format and clean up comments --- app/backend/approaches/chatapproach.py | 11 ++--- .../approaches/prompts/ask/few_shots.jinja | 10 ----- .../approaches/prompts/ask/few_shots.json | 10 +++++ ...y_few_shots.jinja => query_few_shots.json} | 0 .../prompts/chat/system_message_vision.jinja | 10 +---- app/backend/approaches/retrievethenread.py | 40 ++++++++----------- 6 files changed, 33 insertions(+), 48 deletions(-) delete mode 100644 app/backend/approaches/prompts/ask/few_shots.jinja create mode 100644 app/backend/approaches/prompts/ask/few_shots.json rename app/backend/approaches/prompts/chat/{query_few_shots.jinja => query_few_shots.json} (100%) diff --git a/app/backend/approaches/chatapproach.py b/app/backend/approaches/chatapproach.py index caf096b102..5499abd1d6 100644 --- a/app/backend/approaches/chatapproach.py +++ b/app/backend/approaches/chatapproach.py @@ -9,15 +9,16 @@ from approaches.approach import Approach class ChatApproach(Approach, ABC): + + NO_RESPONSE = "0" + def __init__(self): self._initialize_templates() - self.NO_RESPONSE = "0" def _initialize_templates(self): self.env = Environment(loader=FileSystemLoader('approaches/prompts/chat')) - self.query_prompt_few_shots: list[ChatCompletionMessageParam] = json.loads( - self.env.get_template('query_few_shots.jinja').render() - ) + json_content = self.env.loader.get_source(self.env, 'query_few_shots.json')[0] + self.query_prompt_few_shots: list[ChatCompletionMessageParam] = json.loads(json_content) self.query_prompt_template = self.env.get_template('query_template.jinja').render() self.follow_up_questions_prompt = self.env.get_template('follow_up_questions.jinja').render() self.system_message_chat_conversation_template = self.env.get_template('system_message.jinja') @@ -44,7 +45,7 @@ def get_system_prompt(self, override_prompt: Optional[str], follow_up_questions_ injected_prompt=override_prompt[3:] + "\n" ) else: - return override_prompt.format(follow_up_questions_prompt=follow_up_questions_prompt) ## check if correct + return override_prompt.format(follow_up_questions_prompt=follow_up_questions_prompt) def get_search_query(self, chat_completion: ChatCompletion, user_query: str): response_message = chat_completion.choices[0].message diff --git a/app/backend/approaches/prompts/ask/few_shots.jinja b/app/backend/approaches/prompts/ask/few_shots.jinja deleted file mode 100644 index 6ad6d9debc..0000000000 --- a/app/backend/approaches/prompts/ask/few_shots.jinja +++ /dev/null @@ -1,10 +0,0 @@ -{ - "question": "'What is the deductible for the employee plan for a visit to Overlake in Bellevue?' - -Sources: -info1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family. -info2.pdf: Overlake is in-network for the employee plan. -info3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue. -info4.pdf: In-network institutions include Overlake, Swedish and others in the region.", - "answer": "In-network deductibles are $500 for employee and $1000 for family [info1.txt] and Overlake is in-network for the employee plan [info2.pdf][info4.pdf]." -} \ No newline at end of file diff --git a/app/backend/approaches/prompts/ask/few_shots.json b/app/backend/approaches/prompts/ask/few_shots.json new file mode 100644 index 0000000000..3413ba1f25 --- /dev/null +++ b/app/backend/approaches/prompts/ask/few_shots.json @@ -0,0 +1,10 @@ +{ + "question": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?", + "sources": { + "info1.txt": "deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.", + "info2.pdf": "Overlake is in-network for the employee plan.", + "info3.pdf": "Overlake is the name of the area that includes a park and ride near Bellevue.", + "info4.pdf": "In-network institutions include Overlake, Swedish and others in the region." + }, + "answer": "In-network deductibles are $500 for employee and $1000 for family [info1.txt] and Overlake is in-network for the employee plan [info2.pdf][info4.pdf]." +} \ No newline at end of file diff --git a/app/backend/approaches/prompts/chat/query_few_shots.jinja b/app/backend/approaches/prompts/chat/query_few_shots.json similarity index 100% rename from app/backend/approaches/prompts/chat/query_few_shots.jinja rename to app/backend/approaches/prompts/chat/query_few_shots.json diff --git a/app/backend/approaches/prompts/chat/system_message_vision.jinja b/app/backend/approaches/prompts/chat/system_message_vision.jinja index bb8b6c9d62..2747f32db7 100644 --- a/app/backend/approaches/prompts/chat/system_message_vision.jinja +++ b/app/backend/approaches/prompts/chat/system_message_vision.jinja @@ -8,12 +8,4 @@ Be brief in your answers. The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts. {follow_up_questions_prompt} -{injected_prompt} - -"You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images. " - + "Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName: " - + "Each text source starts in a new line and has the file name followed by colon and the actual information " - + "Always include the source name from the image or text for each fact you use in the response in the format: [filename] " - + "Answer the following question using only the data provided in the sources below. " - + "The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned " - + "If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts " \ No newline at end of file +{injected_prompt} \ No newline at end of file diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index c62ae6bdc9..4f955208f3 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -57,30 +57,11 @@ def __init__( def _initialize_templates(self): self.env = Environment(loader=FileSystemLoader('approaches/prompts/ask')) self.system_chat_template = self.env.get_template('system_message.jinja').render() - self.few_shots = self._process_few_shots() - - def _process_few_shots(self) -> Any: - raw_few_shots = self.env.get_template('few_shots.jinja').render() - json_str_few_shots = self._clean_json_string(raw_few_shots) - processed_few_shots = self._escape_newlines_in_json(json_str_few_shots) - return json.loads(processed_few_shots) - - @staticmethod - def _clean_json_string(json_str: str) -> str: - return re.sub(r'^\s+|\s+$', '', json_str) - - @staticmethod - def _escape_newlines_in_json(json_str: str) -> str: - in_string = False - result = [] - for char in json_str: - if char == '"' and (not result or result[-1] != '\\'): - in_string = not in_string - elif char == '\n' and in_string: - result.append('\\n') - continue - result.append(char) - return ''.join(result) + json_content = self.env.loader.get_source(self.env, 'few_shots.json')[0] + print(f"HOOOOI2: {json_content}") + self.few_shots = json.loads(json_content) + + # self.few_shots = self._process_few_shots() async def run( self, @@ -128,6 +109,17 @@ async def run( content = "\n".join(sources_content) user_content = q + "\n" + f"Sources:\n {content}" + few_shots = [ + { + "role": "user", + "content": f"{self.few_shots['question']}\nSources:\n" + "\n".join([f"{k}: {v}" for k, v in self.few_shots['sources'].items()]) + }, + { + "role": "assistant", + "content": self.few_shots["answer"] + } + ] + response_token_limit = 1024 updated_messages = build_messages( model=self.chatgpt_model, From e25468c0339289b936c7b34b40da8c2658964185 Mon Sep 17 00:00:00 2001 From: Jeannot Damoiseaux <62134006+jeannotdamoiseaux@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:06:46 +0000 Subject: [PATCH 03/27] Clean retreivethenread.py --- app/backend/approaches/retrievethenread.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index 4f955208f3..dcd6a70f53 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -58,11 +58,8 @@ def _initialize_templates(self): self.env = Environment(loader=FileSystemLoader('approaches/prompts/ask')) self.system_chat_template = self.env.get_template('system_message.jinja').render() json_content = self.env.loader.get_source(self.env, 'few_shots.json')[0] - print(f"HOOOOI2: {json_content}") self.few_shots = json.loads(json_content) - # self.few_shots = self._process_few_shots() - async def run( self, messages: list[ChatCompletionMessageParam], From c78ffeddadf507eae262c1032505f8f661d97036 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 19 Nov 2024 13:50:44 -0800 Subject: [PATCH 04/27] Port to prompty --- app/backend/approaches/approach.py | 11 ++++ app/backend/approaches/chatapproach.py | 52 +++++++---------- .../approaches/chatreadretrieveread.py | 58 ++++++------------- .../approaches/chatreadretrievereadvision.py | 46 ++++++++------- .../prompts/ask/answer_question.prompty | 29 ++++++++++ .../ask/answer_question_vision.prompty | 31 ++++++++++ .../approaches/prompts/ask/few_shots.json | 10 ---- .../prompts/ask/system_message.jinja | 5 -- .../prompts/ask/system_message_vision.jinja | 7 --- ..._message.jinja => answer_question.prompty} | 26 ++++++++- ...n.jinja => answer_question_vision.prompty} | 26 ++++++++- .../prompts/chat/follow_up_questions.jinja | 7 --- .../prompts/chat/query_few_shots.json | 18 ------ ...y_template.jinja => query_rewrite.prompty} | 24 ++++++++ .../prompts/chat/query_rewrite_tools.json | 17 ++++++ app/backend/approaches/retrievethenread.py | 32 ++-------- .../approaches/retrievethenreadvision.py | 13 ++--- app/backend/requirements.in | 1 + app/backend/requirements.txt | 20 +++++-- 19 files changed, 254 insertions(+), 179 deletions(-) create mode 100644 app/backend/approaches/prompts/ask/answer_question.prompty create mode 100644 app/backend/approaches/prompts/ask/answer_question_vision.prompty delete mode 100644 app/backend/approaches/prompts/ask/few_shots.json delete mode 100644 app/backend/approaches/prompts/ask/system_message.jinja delete mode 100644 app/backend/approaches/prompts/ask/system_message_vision.jinja rename app/backend/approaches/prompts/chat/{system_message.jinja => answer_question.prompty} (56%) rename app/backend/approaches/prompts/chat/{system_message_vision.jinja => answer_question_vision.prompty} (61%) delete mode 100644 app/backend/approaches/prompts/chat/follow_up_questions.jinja delete mode 100644 app/backend/approaches/prompts/chat/query_few_shots.json rename app/backend/approaches/prompts/chat/{query_template.jinja => query_rewrite.prompty} (66%) create mode 100644 app/backend/approaches/prompts/chat/query_rewrite_tools.json diff --git a/app/backend/approaches/approach.py b/app/backend/approaches/approach.py index ab445738b1..7970e5d12d 100644 --- a/app/backend/approaches/approach.py +++ b/app/backend/approaches/approach.py @@ -1,4 +1,6 @@ +import json import os +import pathlib from abc import ABC from dataclasses import dataclass from typing import ( @@ -14,6 +16,7 @@ from urllib.parse import urljoin import aiohttp +import prompty from azure.search.documents.aio import SearchClient from azure.search.documents.models import ( QueryCaptionResult, @@ -96,6 +99,8 @@ class Approach(ABC): # Useful for using local small language models, for example ALLOW_NON_GPT_MODELS = True + PROMPTS_DIRECTORY = pathlib.Path(__file__).parent / "prompts" + def __init__( self, search_client: SearchClient, @@ -122,6 +127,12 @@ def __init__( self.vision_endpoint = vision_endpoint self.vision_token_provider = vision_token_provider + def load_prompty(self, path: str): + return prompty.load(self.PROMPTS_DIRECTORY / path) + + def load_tools(self, path: str): + return json.loads(open(self.PROMPTS_DIRECTORY / path).read()) + def build_filter(self, overrides: dict[str, Any], auth_claims: dict[str, Any]) -> Optional[str]: include_category = overrides.get("include_category") exclude_category = overrides.get("exclude_category") diff --git a/app/backend/approaches/chatapproach.py b/app/backend/approaches/chatapproach.py index 5499abd1d6..d47668ecdd 100644 --- a/app/backend/approaches/chatapproach.py +++ b/app/backend/approaches/chatapproach.py @@ -2,50 +2,40 @@ import re from abc import ABC, abstractmethod from typing import Any, AsyncGenerator, Optional -from jinja2 import Environment, FileSystemLoader +import prompty from openai.types.chat import ChatCompletion, ChatCompletionMessageParam from approaches.approach import Approach -class ChatApproach(Approach, ABC): - - NO_RESPONSE = "0" - def __init__(self): - self._initialize_templates() - - def _initialize_templates(self): - self.env = Environment(loader=FileSystemLoader('approaches/prompts/chat')) - json_content = self.env.loader.get_source(self.env, 'query_few_shots.json')[0] - self.query_prompt_few_shots: list[ChatCompletionMessageParam] = json.loads(json_content) - self.query_prompt_template = self.env.get_template('query_template.jinja').render() - self.follow_up_questions_prompt = self.env.get_template('follow_up_questions.jinja').render() - self.system_message_chat_conversation_template = self.env.get_template('system_message.jinja') - self.system_message_chat_conversation_vision_template = self.env.get_template('system_message_vision.jinja') +class ChatApproach(Approach, ABC): - @property - @abstractmethod - def system_message_chat_conversation(self) -> str: - pass + NO_RESPONSE = "0" @abstractmethod async def run_until_final_call(self, messages, overrides, auth_claims, should_stream) -> tuple: pass - def get_system_prompt(self, override_prompt: Optional[str], follow_up_questions_prompt: str) -> str: - if override_prompt is None: - return self.system_message_chat_conversation_template.render( - follow_up_questions_prompt=follow_up_questions_prompt, - injected_prompt="" - ) - elif override_prompt.startswith(">>>"): - return self.system_message_chat_conversation_template.render( - follow_up_questions_prompt=follow_up_questions_prompt, - injected_prompt=override_prompt[3:] + "\n" + def get_messages( + self, override_prompt: Optional[str], include_follow_up_questions: bool, user_query: str, content: str + ) -> list[ChatCompletionMessageParam]: + if override_prompt is None or override_prompt.startswith(">>>"): + injected_prompt = "" if override_prompt is None else override_prompt[3:] + return prompty.prepare( + self.answer_prompt, + { + "include_follow_up_questions": include_follow_up_questions, + "injected_prompt": injected_prompt, + "user_query": user_query, + "content": content, + }, ) else: - return override_prompt.format(follow_up_questions_prompt=follow_up_questions_prompt) + # TODO: Warn if follow-up is specified, follow-up won't be injected + return prompty.prepare( + self.answer_prompt, {"override_prompt": override_prompt, "user_query": user_query, "content": content} + ) def get_search_query(self, chat_completion: ChatCompletion, user_query: str): response_message = chat_completion.choices[0].message @@ -153,4 +143,4 @@ async def run_stream( ) -> AsyncGenerator[dict[str, Any], None]: overrides = context.get("overrides", {}) auth_claims = context.get("auth_claims", {}) - return self.run_with_streaming(messages, overrides, auth_claims, session_state) + return self.run_with_streaming(messages, overrides, auth_claims, session_state) # diff --git a/app/backend/approaches/chatreadretrieveread.py b/app/backend/approaches/chatreadretrieveread.py index 2780da3255..fb86dbb259 100644 --- a/app/backend/approaches/chatreadretrieveread.py +++ b/app/backend/approaches/chatreadretrieveread.py @@ -1,5 +1,6 @@ from typing import Any, Coroutine, List, Literal, Optional, Union, overload +import prompty from azure.search.documents.aio import SearchClient from azure.search.documents.models import VectorQuery from openai import AsyncOpenAI, AsyncStream @@ -39,7 +40,6 @@ def __init__( query_language: str, query_speller: str, ): - super().__init__() self.search_client = search_client self.openai_client = openai_client self.auth_helper = auth_helper @@ -53,13 +53,9 @@ def __init__( self.query_language = query_language self.query_speller = query_speller self.chatgpt_token_limit = get_token_limit(chatgpt_model, default_to_minimum=self.ALLOW_NON_GPT_MODELS) - - @property - def system_message_chat_conversation(self): - return self.system_message_chat_conversation_template.render( - follow_up_questions_prompt="", - injected_prompt="" - ) + self.query_rewrite_prompt = self.load_prompty("chat/query_rewrite.prompty") + self.query_rewrite_tools = self.load_tools("chat/query_rewrite_tools.json") + self.answer_prompt = self.load_prompty("chat/answer_question.prompty") @overload async def run_until_final_call( @@ -99,37 +95,20 @@ async def run_until_final_call( original_user_query = messages[-1]["content"] if not isinstance(original_user_query, str): raise ValueError("The most recent message content must be a string.") - user_query_request = "Generate search query for: " + original_user_query - - tools: List[ChatCompletionToolParam] = [ - { - "type": "function", - "function": { - "name": "search_sources", - "description": "Retrieve sources from the Azure AI Search index", - "parameters": { - "type": "object", - "properties": { - "search_query": { - "type": "string", - "description": "Query string to retrieve documents from azure search eg: 'Health care plan'", - } - }, - "required": ["search_query"], - }, - }, - } - ] + + # Use prompty to prepare the query prompt + query_messages = prompty.prepare(self.query_rewrite_prompt, inputs={"user_query": original_user_query}) + tools: List[ChatCompletionToolParam] = self.query_rewrite_tools # STEP 1: Generate an optimized keyword search query based on the chat history and the last question query_response_token_limit = 100 query_messages = build_messages( model=self.chatgpt_model, - system_prompt=self.query_prompt_template, - tools=tools, - few_shots=self.query_prompt_few_shots, + system_prompt=query_messages[0]["content"], + few_shots=query_messages[1:-1], past_messages=messages[:-1], - new_user_content=user_query_request, + new_user_content=query_messages[-1]["content"], + tools=tools, max_tokens=self.chatgpt_token_limit - query_response_token_limit, fallback_to_default=self.ALLOW_NON_GPT_MODELS, ) @@ -172,19 +151,20 @@ async def run_until_final_call( # STEP 3: Generate a contextual and content specific answer using the search results and chat history - # Allow client to replace the entire prompt, or to inject into the exiting prompt using >>> - system_message = self.get_system_prompt( + # Allow client to replace the entire prompt, or to inject into the existing prompt using >>> + formatted_messages = self.get_messages( overrides.get("prompt_template"), - self.follow_up_questions_prompt_content if overrides.get("suggest_followup_questions") else "" + include_follow_up_questions=bool(overrides.get("suggest_followup_questions")), + user_query=original_user_query, + content=content, ) response_token_limit = 1024 messages = build_messages( model=self.chatgpt_model, - system_prompt=system_message, + system_prompt=formatted_messages[0]["content"], past_messages=messages[:-1], - # Model does not handle lengthy system messages well. Moving sources to latest user conversation to solve follow up questions prompt. - new_user_content=original_user_query + "\n\nSources:\n" + content, + new_user_content=formatted_messages[-1]["content"], max_tokens=self.chatgpt_token_limit - response_token_limit, fallback_to_default=self.ALLOW_NON_GPT_MODELS, ) diff --git a/app/backend/approaches/chatreadretrievereadvision.py b/app/backend/approaches/chatreadretrievereadvision.py index 075243961c..8b3daa0f8d 100644 --- a/app/backend/approaches/chatreadretrievereadvision.py +++ b/app/backend/approaches/chatreadretrievereadvision.py @@ -1,5 +1,6 @@ -from typing import Any, Awaitable, Callable, Coroutine, Optional, Union +from typing import Any, Awaitable, Callable, Coroutine, List, Optional, Union +import prompty from azure.search.documents.aio import SearchClient from azure.storage.blob.aio import ContainerClient from openai import AsyncOpenAI, AsyncStream @@ -9,6 +10,7 @@ ChatCompletionContentPartImageParam, ChatCompletionContentPartParam, ChatCompletionMessageParam, + ChatCompletionToolParam, ) from openai_messages_token_helper import build_messages, get_token_limit @@ -46,7 +48,6 @@ def __init__( vision_endpoint: str, vision_token_provider: Callable[[], Awaitable[str]] ): - super().__init__() self.search_client = search_client self.blob_container_client = blob_container_client self.openai_client = openai_client @@ -65,13 +66,9 @@ def __init__( self.vision_endpoint = vision_endpoint self.vision_token_provider = vision_token_provider self.chatgpt_token_limit = get_token_limit(gpt4v_model, default_to_minimum=self.ALLOW_NON_GPT_MODELS) - - @property - def system_message_chat_conversation(self): - return self.system_message_chat_conversation_vision_template.render( - follow_up_questions_prompt="", - injected_prompt="" - ) + self.query_rewrite_prompt = self.load_prompty("chat/query_rewrite.prompty") + self.query_rewrite_tools = self.load_tools("chat/query_rewrite_tools.json") + self.answer_prompt = self.load_prompty("chat/answer_question_vision.prompty") async def run_until_final_call( self, @@ -97,29 +94,32 @@ async def run_until_final_call( original_user_query = messages[-1]["content"] if not isinstance(original_user_query, str): raise ValueError("The most recent message content must be a string.") - past_messages: list[ChatCompletionMessageParam] = messages[:-1] - # STEP 1: Generate an optimized keyword search query based on the chat history and the last question - user_query_request = "Generate search query for: " + original_user_query + # Use prompty to prepare the query prompt + query_messages = prompty.prepare(self.query_rewrite_prompt, inputs={"user_query": original_user_query}) + tools: List[ChatCompletionToolParam] = self.query_rewrite_tools + # STEP 1: Generate an optimized keyword search query based on the chat history and the last question query_response_token_limit = 100 query_model = self.chatgpt_model query_deployment = self.chatgpt_deployment query_messages = build_messages( model=query_model, - system_prompt=self.query_prompt_template, - few_shots=self.query_prompt_few_shots, - past_messages=past_messages, - new_user_content=user_query_request, + system_prompt=query_messages[0]["content"], + few_shots=query_messages[1:-1], + past_messages=messages[:-1], + new_user_content=query_messages[-1]["content"], max_tokens=self.chatgpt_token_limit - query_response_token_limit, ) chat_completion: ChatCompletion = await self.openai_client.chat.completions.create( - model=query_deployment if query_deployment else query_model, messages=query_messages, + # Azure OpenAI takes the deployment name as the model name + model=query_deployment if query_deployment else query_model, temperature=0.0, # Minimize creativity for search query generation max_tokens=query_response_token_limit, n=1, + tools=tools, seed=seed, ) @@ -156,12 +156,16 @@ async def run_until_final_call( # STEP 3: Generate a contextual and content specific answer using the search results and chat history # Allow client to replace the entire prompt, or to inject into the existing prompt using >>> - system_message = self.get_system_prompt( + formatted_messages = self.get_messages( overrides.get("prompt_template"), - self.follow_up_questions_prompt_content if overrides.get("suggest_followup_questions") else "", + include_follow_up_questions=bool(overrides.get("suggest_followup_questions")), + user_query=original_user_query, + content=content, ) - user_content: list[ChatCompletionContentPartParam] = [{"text": original_user_query, "type": "text"}] + user_content: list[ChatCompletionContentPartParam] = [ + {"text": formatted_messages[-1]["content"], "type": "text"} + ] image_list: list[ChatCompletionContentPartImageParam] = [] if send_text_to_gptvision: @@ -176,7 +180,7 @@ async def run_until_final_call( response_token_limit = 1024 messages = build_messages( model=self.gpt4v_model, - system_prompt=system_message, + system_prompt=formatted_messages[0]["content"], past_messages=messages[:-1], new_user_content=user_content, max_tokens=self.chatgpt_token_limit - response_token_limit, diff --git a/app/backend/approaches/prompts/ask/answer_question.prompty b/app/backend/approaches/prompts/ask/answer_question.prompty new file mode 100644 index 0000000000..7cc09f9689 --- /dev/null +++ b/app/backend/approaches/prompts/ask/answer_question.prompty @@ -0,0 +1,29 @@ +--- +model: + api: chat +--- +You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. +Use 'you' to refer to the individual asking the questions even if they ask with 'I'. +Answer the following question using only the data provided in the sources below. +Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. +If you cannot answer using the sources below, say you don't know. Use below example to answer. + +example: + +user: +What is the deductible for the employee plan for a visit to Overlake in Bellevue + +Sources: +info1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.", +info2.pdf: Overlake is in-network for the employee plan.", +info3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.", +info4.pdf: In-network institutions include Overlake, Swedish and others in the region." + +assistant: +In-network deductibles are $500 for employee and $1000 for family [info1.txt] and Overlake is in-network for the employee plan [info2.pdf][info4.pdf]. + +user: +{{ user_query }} + +Sources: +{{ content }} diff --git a/app/backend/approaches/prompts/ask/answer_question_vision.prompty b/app/backend/approaches/prompts/ask/answer_question_vision.prompty new file mode 100644 index 0000000000..949a0422c6 --- /dev/null +++ b/app/backend/approaches/prompts/ask/answer_question_vision.prompty @@ -0,0 +1,31 @@ +--- +model: + api: chat +--- +You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images. +Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:. +Each text source starts in a new line and has the file name followed by colon and the actual information. +Always include the source name from the image or text for each fact you use in the response in the format: [filename]. +Answer the following question using only the data provided in the sources below. +The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned. +If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts. + +example: + +user: +What is the deductible for the employee plan for a visit to Overlake in Bellevue + +Sources: +info1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.", +info2.pdf: Overlake is in-network for the employee plan.", +info3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.", +info4.pdf: In-network institutions include Overlake, Swedish and others in the region." + +assistant: +In-network deductibles are $500 for employee and $1000 for family [info1.txt] and Overlake is in-network for the employee plan [info2.pdf][info4.pdf]. + +user: +{{ user_query }} + +Sources: +{{ content }} diff --git a/app/backend/approaches/prompts/ask/few_shots.json b/app/backend/approaches/prompts/ask/few_shots.json deleted file mode 100644 index 3413ba1f25..0000000000 --- a/app/backend/approaches/prompts/ask/few_shots.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "question": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?", - "sources": { - "info1.txt": "deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.", - "info2.pdf": "Overlake is in-network for the employee plan.", - "info3.pdf": "Overlake is the name of the area that includes a park and ride near Bellevue.", - "info4.pdf": "In-network institutions include Overlake, Swedish and others in the region." - }, - "answer": "In-network deductibles are $500 for employee and $1000 for family [info1.txt] and Overlake is in-network for the employee plan [info2.pdf][info4.pdf]." -} \ No newline at end of file diff --git a/app/backend/approaches/prompts/ask/system_message.jinja b/app/backend/approaches/prompts/ask/system_message.jinja deleted file mode 100644 index 6873dec18a..0000000000 --- a/app/backend/approaches/prompts/ask/system_message.jinja +++ /dev/null @@ -1,5 +0,0 @@ -You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. -Use 'you' to refer to the individual asking the questions even if they ask with 'I'. -Answer the following question using only the data provided in the sources below. -Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. -If you cannot answer using the sources below, say you don't know. Use below example to answer \ No newline at end of file diff --git a/app/backend/approaches/prompts/ask/system_message_vision.jinja b/app/backend/approaches/prompts/ask/system_message_vision.jinja deleted file mode 100644 index 963b137ed3..0000000000 --- a/app/backend/approaches/prompts/ask/system_message_vision.jinja +++ /dev/null @@ -1,7 +0,0 @@ -You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images. -Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:. -Each text source starts in a new line and has the file name followed by colon and the actual information. -Always include the source name from the image or text for each fact you use in the response in the format: [filename]. -Answer the following question using only the data provided in the sources below. -The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned. -If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts. \ No newline at end of file diff --git a/app/backend/approaches/prompts/chat/system_message.jinja b/app/backend/approaches/prompts/chat/answer_question.prompty similarity index 56% rename from app/backend/approaches/prompts/chat/system_message.jinja rename to app/backend/approaches/prompts/chat/answer_question.prompty index 022d6a1343..d2bcec132d 100644 --- a/app/backend/approaches/prompts/chat/system_message.jinja +++ b/app/backend/approaches/prompts/chat/answer_question.prompty @@ -1,6 +1,28 @@ +--- +model: + api: chat +--- +{% if override_prompt %} +{{ override_prompt }} +{% else %} Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers. Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question. If the question is not in English, answer in the language used in the question. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]. -{{ follow_up_questions_prompt }} -{{ injected_prompt }} \ No newline at end of file +{% if include_follow_up_questions %} +Generate 3 very brief follow-up questions that the user would likely ask next. +Enclose the follow-up questions in double angle brackets. Example: +<> +<> +<> +Do not repeat questions that have already been asked. +Make sure the last question ends with ">>". +{% endif %} +{{ extra_prompt }} +{% endif %} + +user: +{{ user_query }} + +Sources: +{{ content }} diff --git a/app/backend/approaches/prompts/chat/system_message_vision.jinja b/app/backend/approaches/prompts/chat/answer_question_vision.prompty similarity index 61% rename from app/backend/approaches/prompts/chat/system_message_vision.jinja rename to app/backend/approaches/prompts/chat/answer_question_vision.prompty index 2747f32db7..36776426d1 100644 --- a/app/backend/approaches/prompts/chat/system_message_vision.jinja +++ b/app/backend/approaches/prompts/chat/answer_question_vision.prompty @@ -1,3 +1,10 @@ +--- +model: + api: chat +--- +{% if override_prompt %} +{{ override_prompt }} +{% else %} You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images. Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName: Each text source starts in a new line and has the file name followed by colon and the actual information @@ -7,5 +14,20 @@ If asking a clarifying question to the user would help, ask the question. Be brief in your answers. The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts. -{follow_up_questions_prompt} -{injected_prompt} \ No newline at end of file +{% if include_follow_up_questions %} +Generate 3 very brief follow-up questions that the user would likely ask next. +Enclose the follow-up questions in double angle brackets. Example: +<> +<> +<> +Do not repeat questions that have already been asked. +Make sure the last question ends with ">>". +{% endif %} +{{injected_prompt}} +{% endif %} + +user: +{{ user_query }} + +Sources: +{{ content }} diff --git a/app/backend/approaches/prompts/chat/follow_up_questions.jinja b/app/backend/approaches/prompts/chat/follow_up_questions.jinja deleted file mode 100644 index 1eaf118252..0000000000 --- a/app/backend/approaches/prompts/chat/follow_up_questions.jinja +++ /dev/null @@ -1,7 +0,0 @@ -Generate 3 very brief follow-up questions that the user would likely ask next. -Enclose the follow-up questions in double angle brackets. Example: -<> -<> -<> -Do not repeat questions that have already been asked. -Make sure the last question ends with ">>". \ No newline at end of file diff --git a/app/backend/approaches/prompts/chat/query_few_shots.json b/app/backend/approaches/prompts/chat/query_few_shots.json deleted file mode 100644 index f22ea73a5f..0000000000 --- a/app/backend/approaches/prompts/chat/query_few_shots.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "role": "user", - "content": "How did crypto do last year?" - }, - { - "role": "assistant", - "content": "Summarize Cryptocurrency Market Dynamics from last year" - }, - { - "role": "user", - "content": "What are my health plans?" - }, - { - "role": "assistant", - "content": "Show available health plans" - } -] diff --git a/app/backend/approaches/prompts/chat/query_template.jinja b/app/backend/approaches/prompts/chat/query_rewrite.prompty similarity index 66% rename from app/backend/approaches/prompts/chat/query_template.jinja rename to app/backend/approaches/prompts/chat/query_rewrite.prompty index d9ecd59d0b..e7e86c682e 100644 --- a/app/backend/approaches/prompts/chat/query_template.jinja +++ b/app/backend/approaches/prompts/chat/query_rewrite.prompty @@ -1,3 +1,10 @@ +--- +model: + api: chat + parameters: + tools: ${file:query_rewrite_tools.json} +--- +system: Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base. You have access to Azure AI Search index with 100's of documents. Generate a search query based on the conversation and the new question. @@ -6,3 +13,20 @@ Do not include any text inside [] or <<>> in the search query terms. Do not include any special characters like '+'. If the question is not in English, translate the question to English before generating the search query. If you cannot generate a search query, return just the number 0. + +Examples: + +user: +How did crypto do last year?" + +assistant: +Summarize Cryptocurrency Market Dynamics from last year + +user: +What are my health plans? + +assistant: +Show available health plans" + +user: +Generate search query for: {{ user_query }} diff --git a/app/backend/approaches/prompts/chat/query_rewrite_tools.json b/app/backend/approaches/prompts/chat/query_rewrite_tools.json new file mode 100644 index 0000000000..cf1743483c --- /dev/null +++ b/app/backend/approaches/prompts/chat/query_rewrite_tools.json @@ -0,0 +1,17 @@ +[{ + "type": "function", + "function": { + "name": "search_sources", + "description": "Retrieve sources from the Azure AI Search index", + "parameters": { + "type": "object", + "properties": { + "search_query": { + "type": "string", + "description": "Query string to retrieve documents from azure search eg: 'Health care plan'" + } + }, + "required": ["search_query"] + } + } +}] diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index dcd6a70f53..a4fa011ad4 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -1,14 +1,11 @@ from typing import Any, Optional -import json -import re -import ast +import prompty from azure.search.documents.aio import SearchClient from azure.search.documents.models import VectorQuery from openai import AsyncOpenAI from openai.types.chat import ChatCompletionMessageParam from openai_messages_token_helper import build_messages, get_token_limit -from jinja2 import Environment, FileSystemLoader from approaches.approach import Approach, ThoughtStep from core.authentication import AuthenticationHelper @@ -51,14 +48,7 @@ def __init__( self.query_language = query_language self.query_speller = query_speller self.chatgpt_token_limit = get_token_limit(chatgpt_model, self.ALLOW_NON_GPT_MODELS) - - self._initialize_templates() - - def _initialize_templates(self): - self.env = Environment(loader=FileSystemLoader('approaches/prompts/ask')) - self.system_chat_template = self.env.get_template('system_message.jinja').render() - json_content = self.env.loader.get_source(self.env, 'few_shots.json')[0] - self.few_shots = json.loads(json_content) + self.answer_prompt = self.load_prompty("ask/answer_question.prompty") async def run( self, @@ -104,25 +94,15 @@ async def run( # Append user message content = "\n".join(sources_content) - user_content = q + "\n" + f"Sources:\n {content}" - few_shots = [ - { - "role": "user", - "content": f"{self.few_shots['question']}\nSources:\n" + "\n".join([f"{k}: {v}" for k, v in self.few_shots['sources'].items()]) - }, - { - "role": "assistant", - "content": self.few_shots["answer"] - } - ] + messages = prompty.prepare(self.answer_prompt, {"user_query": q, "content": content}) response_token_limit = 1024 updated_messages = build_messages( model=self.chatgpt_model, - system_prompt=overrides.get("prompt_template", self.system_chat_template), - few_shots=[{"role": "user", "content": self.few_shots["question"]}, {"role": "assistant", "content": self.few_shots["answer"]}], - new_user_content=user_content, + system_prompt=overrides.get("prompt_template", messages[0]["content"]), + few_shots=messages[1:-1], + new_user_content=messages[-1]["content"], max_tokens=self.chatgpt_token_limit - response_token_limit, fallback_to_default=self.ALLOW_NON_GPT_MODELS, ) diff --git a/app/backend/approaches/retrievethenreadvision.py b/app/backend/approaches/retrievethenreadvision.py index cf8b0bda91..1fce6df7c2 100644 --- a/app/backend/approaches/retrievethenreadvision.py +++ b/app/backend/approaches/retrievethenreadvision.py @@ -1,5 +1,6 @@ from typing import Any, Awaitable, Callable, Optional +import prompty from azure.search.documents.aio import SearchClient from azure.storage.blob.aio import ContainerClient from openai import AsyncOpenAI @@ -9,7 +10,6 @@ ChatCompletionMessageParam, ) from openai_messages_token_helper import build_messages, get_token_limit -from jinja2 import Environment, FileSystemLoader from approaches.approach import Approach, ThoughtStep from core.authentication import AuthenticationHelper @@ -58,10 +58,7 @@ def __init__( self.vision_endpoint = vision_endpoint self.vision_token_provider = vision_token_provider self.gpt4v_token_limit = get_token_limit(gpt4v_model, self.ALLOW_NON_GPT_MODELS) - - self.env = Environment(loader=FileSystemLoader('approaches/prompts/ask')) - self.system_chat_template_gpt4v = self.env.get_template('system_message_vision.jinja').render() - + self.answer_prompt = self.load_prompty("ask/answer_question_vision.prompty") async def run( self, @@ -129,11 +126,13 @@ async def run( image_list.append({"image_url": url, "type": "image_url"}) user_content.extend(image_list) + messages = prompty.prepare(self.answer_prompt, {"user_query": q, "content": content}) + response_token_limit = 1024 updated_messages = build_messages( model=self.gpt4v_model, - system_prompt=overrides.get("prompt_template", self.system_chat_template_gpt4v), - new_user_content=user_content, + system_prompt=overrides.get("prompt_template", messages[0]["content"]), + new_user_content=messages[-1]["content"], max_tokens=self.gpt4v_token_limit - response_token_limit, fallback_to_default=self.ALLOW_NON_GPT_MODELS, ) diff --git a/app/backend/requirements.in b/app/backend/requirements.in index 765a72c486..5bf6691474 100644 --- a/app/backend/requirements.in +++ b/app/backend/requirements.in @@ -31,3 +31,4 @@ types-beautifulsoup4 msgraph-sdk==1.1.0 openai-messages-token-helper python-dotenv +prompty diff --git a/app/backend/requirements.txt b/app/backend/requirements.txt index 2efe32b484..8fbeb36e78 100644 --- a/app/backend/requirements.txt +++ b/app/backend/requirements.txt @@ -1,11 +1,13 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # pip-compile requirements.in # aiofiles==24.1.0 - # via quart + # via + # prompty + # quart aiohappyeyeballs==2.4.0 # via aiohttp aiohttp==3.10.11 @@ -82,6 +84,7 @@ charset-normalizer==3.3.2 click==8.1.7 # via # flask + # prompty # quart # uvicorn cryptography==43.0.1 @@ -152,6 +155,7 @@ itsdangerous==2.2.0 jinja2==3.1.4 # via # flask + # prompty # quart jiter==0.5.0 # via openai @@ -328,6 +332,8 @@ portalocker==2.10.1 # via msal-extensions priority==2.0.0 # via hypercorn +prompty==0.1.39 + # via -r requirements.in propcache==0.2.0 # via yarl psutil==5.9.8 @@ -335,7 +341,9 @@ psutil==5.9.8 pycparser==2.22 # via cffi pydantic==2.8.2 - # via openai + # via + # openai + # prompty pydantic-core==2.20.1 # via pydantic pyjwt[crypto]==2.9.0 @@ -354,7 +362,11 @@ python-dateutil==2.9.0.post0 # pendulum # time-machine python-dotenv==1.0.1 - # via -r requirements.in + # via + # -r requirements.in + # prompty +pyyaml==6.0.2 + # via prompty quart==0.19.7 # via # -r requirements.in From 6fac970ebc41490ac036834acb51ba465ee8e4a7 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 7 Jan 2025 12:47:05 -0800 Subject: [PATCH 05/27] Configure Azure Developer Pipeline From 04b225447be8ea25bbc67aa1018927f979a03469 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Thu, 9 Jan 2025 14:44:08 -0800 Subject: [PATCH 06/27] Refactor to use a PromptManager --- app/backend/app.py | 11 ++- app/backend/approaches/approach.py | 11 --- app/backend/approaches/chatapproach.py | 30 +++++--- .../approaches/chatreadretrieveread.py | 34 ++++++---- .../approaches/chatreadretrievereadvision.py | 35 ++++++---- app/backend/approaches/promptmanager.py | 68 +++++++++++++++++++ .../prompts/ask/answer_question.prompty | 4 +- .../prompts/chat/answer_question.prompty | 4 +- .../prompts/chat/query_rewrite.prompty | 10 +-- app/backend/approaches/retrievethenread.py | 16 +++-- .../approaches/retrievethenreadvision.py | 21 +++--- 11 files changed, 169 insertions(+), 75 deletions(-) create mode 100644 app/backend/approaches/promptmanager.py diff --git a/app/backend/app.py b/app/backend/app.py index b9d904b476..f802725c19 100644 --- a/app/backend/app.py +++ b/app/backend/app.py @@ -51,6 +51,7 @@ from approaches.approach import Approach from approaches.chatreadretrieveread import ChatReadRetrieveReadApproach from approaches.chatreadretrievereadvision import ChatReadRetrieveReadVisionApproach +from approaches.promptmanager import PromptyManager from approaches.retrievethenread import RetrieveThenReadApproach from approaches.retrievethenreadvision import RetrieveThenReadVisionApproach from chat_history.cosmosdb import chat_history_cosmosdb_bp @@ -642,8 +643,9 @@ async def setup_clients(): current_app.config[CONFIG_CHAT_HISTORY_BROWSER_ENABLED] = USE_CHAT_HISTORY_BROWSER current_app.config[CONFIG_CHAT_HISTORY_COSMOS_ENABLED] = USE_CHAT_HISTORY_COSMOS - # Various approaches to integrate GPT and external knowledge, most applications will use a single one of these patterns - # or some derivative, here we include several for exploration purposes + prompt_manager = PromptyManager() + + # Used by the /ask tab current_app.config[CONFIG_ASK_APPROACH] = RetrieveThenReadApproach( search_client=search_client, openai_client=openai_client, @@ -657,8 +659,10 @@ async def setup_clients(): content_field=KB_FIELDS_CONTENT, query_language=AZURE_SEARCH_QUERY_LANGUAGE, query_speller=AZURE_SEARCH_QUERY_SPELLER, + prompt_manager=prompt_manager, ) + # Used by the /chat tab current_app.config[CONFIG_CHAT_APPROACH] = ChatReadRetrieveReadApproach( search_client=search_client, openai_client=openai_client, @@ -672,6 +676,7 @@ async def setup_clients(): content_field=KB_FIELDS_CONTENT, query_language=AZURE_SEARCH_QUERY_LANGUAGE, query_speller=AZURE_SEARCH_QUERY_SPELLER, + prompt_manager=prompt_manager, ) if USE_GPT4V: @@ -696,6 +701,7 @@ async def setup_clients(): content_field=KB_FIELDS_CONTENT, query_language=AZURE_SEARCH_QUERY_LANGUAGE, query_speller=AZURE_SEARCH_QUERY_SPELLER, + prompt_manager=prompt_manager, ) current_app.config[CONFIG_CHAT_VISION_APPROACH] = ChatReadRetrieveReadVisionApproach( @@ -716,6 +722,7 @@ async def setup_clients(): content_field=KB_FIELDS_CONTENT, query_language=AZURE_SEARCH_QUERY_LANGUAGE, query_speller=AZURE_SEARCH_QUERY_SPELLER, + prompt_manager=prompt_manager, ) diff --git a/app/backend/approaches/approach.py b/app/backend/approaches/approach.py index 7970e5d12d..ab445738b1 100644 --- a/app/backend/approaches/approach.py +++ b/app/backend/approaches/approach.py @@ -1,6 +1,4 @@ -import json import os -import pathlib from abc import ABC from dataclasses import dataclass from typing import ( @@ -16,7 +14,6 @@ from urllib.parse import urljoin import aiohttp -import prompty from azure.search.documents.aio import SearchClient from azure.search.documents.models import ( QueryCaptionResult, @@ -99,8 +96,6 @@ class Approach(ABC): # Useful for using local small language models, for example ALLOW_NON_GPT_MODELS = True - PROMPTS_DIRECTORY = pathlib.Path(__file__).parent / "prompts" - def __init__( self, search_client: SearchClient, @@ -127,12 +122,6 @@ def __init__( self.vision_endpoint = vision_endpoint self.vision_token_provider = vision_token_provider - def load_prompty(self, path: str): - return prompty.load(self.PROMPTS_DIRECTORY / path) - - def load_tools(self, path: str): - return json.loads(open(self.PROMPTS_DIRECTORY / path).read()) - def build_filter(self, overrides: dict[str, Any], auth_claims: dict[str, Any]) -> Optional[str]: include_category = overrides.get("include_category") exclude_category = overrides.get("exclude_category") diff --git a/app/backend/approaches/chatapproach.py b/app/backend/approaches/chatapproach.py index d47668ecdd..389ba18d42 100644 --- a/app/backend/approaches/chatapproach.py +++ b/app/backend/approaches/chatapproach.py @@ -3,10 +3,10 @@ from abc import ABC, abstractmethod from typing import Any, AsyncGenerator, Optional -import prompty from openai.types.chat import ChatCompletion, ChatCompletionMessageParam from approaches.approach import Approach +from approaches.promptmanager import RenderedPrompt class ChatApproach(Approach, ABC): @@ -17,24 +17,36 @@ class ChatApproach(Approach, ABC): async def run_until_final_call(self, messages, overrides, auth_claims, should_stream) -> tuple: pass - def get_messages( - self, override_prompt: Optional[str], include_follow_up_questions: bool, user_query: str, content: str - ) -> list[ChatCompletionMessageParam]: + def render_answer_prompt( + self, + override_prompt: Optional[str], + include_follow_up_questions: bool, + past_messages: list, + user_query: str, + sources: str, + ) -> RenderedPrompt: if override_prompt is None or override_prompt.startswith(">>>"): injected_prompt = "" if override_prompt is None else override_prompt[3:] - return prompty.prepare( + return self.prompt_manager.render_prompt( self.answer_prompt, { "include_follow_up_questions": include_follow_up_questions, "injected_prompt": injected_prompt, + "past_messages": past_messages, "user_query": user_query, - "content": content, + "sources": sources, }, ) else: # TODO: Warn if follow-up is specified, follow-up won't be injected - return prompty.prepare( - self.answer_prompt, {"override_prompt": override_prompt, "user_query": user_query, "content": content} + return self.prompt_manager.render_prompt( + self.answer_prompt, + { + "override_prompt": override_prompt, + "past_messages": past_messages, + "user_query": user_query, + "sources": sources, + }, ) def get_search_query(self, chat_completion: ChatCompletion, user_query: str): @@ -143,4 +155,4 @@ async def run_stream( ) -> AsyncGenerator[dict[str, Any], None]: overrides = context.get("overrides", {}) auth_claims = context.get("auth_claims", {}) - return self.run_with_streaming(messages, overrides, auth_claims, session_state) # + return self.run_with_streaming(messages, overrides, auth_claims, session_state) diff --git a/app/backend/approaches/chatreadretrieveread.py b/app/backend/approaches/chatreadretrieveread.py index fb86dbb259..aed9cbc822 100644 --- a/app/backend/approaches/chatreadretrieveread.py +++ b/app/backend/approaches/chatreadretrieveread.py @@ -1,6 +1,5 @@ from typing import Any, Coroutine, List, Literal, Optional, Union, overload -import prompty from azure.search.documents.aio import SearchClient from azure.search.documents.models import VectorQuery from openai import AsyncOpenAI, AsyncStream @@ -14,6 +13,7 @@ from approaches.approach import ThoughtStep from approaches.chatapproach import ChatApproach +from approaches.promptmanager import PromptManager from core.authentication import AuthenticationHelper @@ -39,6 +39,7 @@ def __init__( content_field: str, query_language: str, query_speller: str, + prompt_manager: PromptManager ): self.search_client = search_client self.openai_client = openai_client @@ -53,9 +54,10 @@ def __init__( self.query_language = query_language self.query_speller = query_speller self.chatgpt_token_limit = get_token_limit(chatgpt_model, default_to_minimum=self.ALLOW_NON_GPT_MODELS) - self.query_rewrite_prompt = self.load_prompty("chat/query_rewrite.prompty") - self.query_rewrite_tools = self.load_tools("chat/query_rewrite_tools.json") - self.answer_prompt = self.load_prompty("chat/answer_question.prompty") + self.prompt_manager = prompt_manager + self.query_rewrite_prompt = self.prompt_manager.load_prompt("chat/query_rewrite.prompty") + self.query_rewrite_tools = self.prompt_manager.load_tools("chat/query_rewrite_tools.json") + self.answer_prompt = self.prompt_manager.load_prompt("chat/answer_question.prompty") @overload async def run_until_final_call( @@ -96,18 +98,19 @@ async def run_until_final_call( if not isinstance(original_user_query, str): raise ValueError("The most recent message content must be a string.") - # Use prompty to prepare the query prompt - query_messages = prompty.prepare(self.query_rewrite_prompt, inputs={"user_query": original_user_query}) + rendered_query_prompt = self.prompt_manager.render_prompt( + self.query_rewrite_prompt, {"user_query": original_user_query} + ) tools: List[ChatCompletionToolParam] = self.query_rewrite_tools # STEP 1: Generate an optimized keyword search query based on the chat history and the last question query_response_token_limit = 100 query_messages = build_messages( model=self.chatgpt_model, - system_prompt=query_messages[0]["content"], - few_shots=query_messages[1:-1], - past_messages=messages[:-1], - new_user_content=query_messages[-1]["content"], + system_prompt=rendered_query_prompt.system_content, + few_shots=rendered_query_prompt.few_shot_messages, + past_messages=rendered_query_prompt.past_messages, + new_user_content=rendered_query_prompt.new_user_content, tools=tools, max_tokens=self.chatgpt_token_limit - query_response_token_limit, fallback_to_default=self.ALLOW_NON_GPT_MODELS, @@ -152,19 +155,20 @@ async def run_until_final_call( # STEP 3: Generate a contextual and content specific answer using the search results and chat history # Allow client to replace the entire prompt, or to inject into the existing prompt using >>> - formatted_messages = self.get_messages( + rendered_answer_prompt = self.render_answer_prompt( overrides.get("prompt_template"), include_follow_up_questions=bool(overrides.get("suggest_followup_questions")), + past_messages=messages[:-1], user_query=original_user_query, - content=content, + sources=content, ) response_token_limit = 1024 messages = build_messages( model=self.chatgpt_model, - system_prompt=formatted_messages[0]["content"], - past_messages=messages[:-1], - new_user_content=formatted_messages[-1]["content"], + system_prompt=rendered_answer_prompt.system_content, + past_messages=rendered_answer_prompt.past_messages, + new_user_content=rendered_answer_prompt.new_user_content, max_tokens=self.chatgpt_token_limit - response_token_limit, fallback_to_default=self.ALLOW_NON_GPT_MODELS, ) diff --git a/app/backend/approaches/chatreadretrievereadvision.py b/app/backend/approaches/chatreadretrievereadvision.py index 8b3daa0f8d..d6784d2389 100644 --- a/app/backend/approaches/chatreadretrievereadvision.py +++ b/app/backend/approaches/chatreadretrievereadvision.py @@ -1,6 +1,5 @@ from typing import Any, Awaitable, Callable, Coroutine, List, Optional, Union -import prompty from azure.search.documents.aio import SearchClient from azure.storage.blob.aio import ContainerClient from openai import AsyncOpenAI, AsyncStream @@ -16,6 +15,7 @@ from approaches.approach import ThoughtStep from approaches.chatapproach import ChatApproach +from approaches.promptmanager import PromptManager from core.authentication import AuthenticationHelper from core.imageshelper import fetch_image @@ -46,7 +46,8 @@ def __init__( query_language: str, query_speller: str, vision_endpoint: str, - vision_token_provider: Callable[[], Awaitable[str]] + vision_token_provider: Callable[[], Awaitable[str]], + prompt_manager: PromptManager, ): self.search_client = search_client self.blob_container_client = blob_container_client @@ -66,9 +67,10 @@ def __init__( self.vision_endpoint = vision_endpoint self.vision_token_provider = vision_token_provider self.chatgpt_token_limit = get_token_limit(gpt4v_model, default_to_minimum=self.ALLOW_NON_GPT_MODELS) - self.query_rewrite_prompt = self.load_prompty("chat/query_rewrite.prompty") - self.query_rewrite_tools = self.load_tools("chat/query_rewrite_tools.json") - self.answer_prompt = self.load_prompty("chat/answer_question_vision.prompty") + self.prompt_manager = prompt_manager + self.query_rewrite_prompt = self.prompt_manager.load_prompt("chat/query_rewrite.prompty") + self.query_rewrite_tools = self.prompt_manager.load_tools("chat/query_rewrite_tools.json") + self.answer_prompt = self.prompt_manager.load_prompt("chat/answer_question_vision.prompty") async def run_until_final_call( self, @@ -96,7 +98,9 @@ async def run_until_final_call( raise ValueError("The most recent message content must be a string.") # Use prompty to prepare the query prompt - query_messages = prompty.prepare(self.query_rewrite_prompt, inputs={"user_query": original_user_query}) + rendered_query_prompt = self.prompt_manager.render_prompt( + self.query_rewrite_prompt, {"user_query": original_user_query} + ) tools: List[ChatCompletionToolParam] = self.query_rewrite_tools # STEP 1: Generate an optimized keyword search query based on the chat history and the last question @@ -105,10 +109,10 @@ async def run_until_final_call( query_deployment = self.chatgpt_deployment query_messages = build_messages( model=query_model, - system_prompt=query_messages[0]["content"], - few_shots=query_messages[1:-1], - past_messages=messages[:-1], - new_user_content=query_messages[-1]["content"], + system_prompt=rendered_query_prompt.system_content, + few_shots=rendered_query_prompt.few_shot_messages, + past_messages=rendered_query_prompt.past_messages, + new_user_content=rendered_query_prompt.new_user_content, max_tokens=self.chatgpt_token_limit - query_response_token_limit, ) @@ -156,15 +160,16 @@ async def run_until_final_call( # STEP 3: Generate a contextual and content specific answer using the search results and chat history # Allow client to replace the entire prompt, or to inject into the existing prompt using >>> - formatted_messages = self.get_messages( + rendered_answer_prompt = self.render_answer_prompt( overrides.get("prompt_template"), include_follow_up_questions=bool(overrides.get("suggest_followup_questions")), + past_messages=messages[:-1], user_query=original_user_query, - content=content, + sources=content, ) user_content: list[ChatCompletionContentPartParam] = [ - {"text": formatted_messages[-1]["content"], "type": "text"} + {"text": rendered_answer_prompt.new_user_content, "type": "text"} ] image_list: list[ChatCompletionContentPartImageParam] = [] @@ -180,8 +185,8 @@ async def run_until_final_call( response_token_limit = 1024 messages = build_messages( model=self.gpt4v_model, - system_prompt=formatted_messages[0]["content"], - past_messages=messages[:-1], + system_prompt=rendered_answer_prompt.system_content, + past_messages=rendered_answer_prompt.past_messages, new_user_content=user_content, max_tokens=self.chatgpt_token_limit - response_token_limit, fallback_to_default=self.ALLOW_NON_GPT_MODELS, diff --git a/app/backend/approaches/promptmanager.py b/app/backend/approaches/promptmanager.py new file mode 100644 index 0000000000..8a30ef5cc4 --- /dev/null +++ b/app/backend/approaches/promptmanager.py @@ -0,0 +1,68 @@ +import json +import pathlib +from dataclasses import dataclass + +import prompty + + +@dataclass +class RenderedPrompt: + system_content: str + few_shot_messages: list[str] + past_messages: list[str] + new_user_content: str + + +class PromptManager: + + def load_prompt(self, path: str): + raise NotImplementedError + + def load_tools(self, path: str): + raise NotImplementedError + + def render_prompt(self, prompt, data) -> list: + raise NotImplementedError + + +class PromptyManager(PromptManager): + + PROMPTS_DIRECTORY = pathlib.Path(__file__).parent / "prompts" + + def load_prompt(self, path: str): + return prompty.load(self.PROMPTS_DIRECTORY / path) + + def load_tools(self, path: str): + return json.loads(open(self.PROMPTS_DIRECTORY / path).read()) + + def render_prompt(self, prompt, data) -> RenderedPrompt: + # Assumes that the first message is the system message, the last message is the user message, + # and the messages in-between are either examples or past messages. + + messages: list = prompty.prepare(prompt, data) + + system_content = None + if messages[0]["role"] == "system": + system_content = messages[0]["content"] + messages.pop(0) + + new_user_content = None + if messages[-1]["role"] == "user": + new_user_content = messages[-1]["content"] + messages.pop(-1) + + few_shot_messages = [] + past_messages = [] + for user_message, assistant_message in zip(messages[0::2], messages[1::2]): + if user_message["content"].startswith("(EXAMPLE)"): + user_message["content"] = user_message["content"][9:].lstrip() + few_shot_messages.extend([user_message, assistant_message]) + else: + past_messages.extend([user_message, assistant_message]) + + return RenderedPrompt( + system_content=system_content, + few_shot_messages=few_shot_messages, + past_messages=past_messages, + new_user_content=new_user_content, + ) diff --git a/app/backend/approaches/prompts/ask/answer_question.prompty b/app/backend/approaches/prompts/ask/answer_question.prompty index 7cc09f9689..f758785dd6 100644 --- a/app/backend/approaches/prompts/ask/answer_question.prompty +++ b/app/backend/approaches/prompts/ask/answer_question.prompty @@ -8,10 +8,8 @@ Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer. -example: - user: -What is the deductible for the employee plan for a visit to Overlake in Bellevue +(EXAMPLE) What is the deductible for the employee plan for a visit to Overlake in Bellevue Sources: info1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.", diff --git a/app/backend/approaches/prompts/chat/answer_question.prompty b/app/backend/approaches/prompts/chat/answer_question.prompty index d2bcec132d..adcb0aece0 100644 --- a/app/backend/approaches/prompts/chat/answer_question.prompty +++ b/app/backend/approaches/prompts/chat/answer_question.prompty @@ -21,8 +21,10 @@ Make sure the last question ends with ">>". {{ extra_prompt }} {% endif %} +{{ past_messages }} + user: {{ user_query }} Sources: -{{ content }} +{{ sources }} diff --git a/app/backend/approaches/prompts/chat/query_rewrite.prompty b/app/backend/approaches/prompts/chat/query_rewrite.prompty index e7e86c682e..d0ca48fda5 100644 --- a/app/backend/approaches/prompts/chat/query_rewrite.prompty +++ b/app/backend/approaches/prompts/chat/query_rewrite.prompty @@ -14,19 +14,19 @@ Do not include any special characters like '+'. If the question is not in English, translate the question to English before generating the search query. If you cannot generate a search query, return just the number 0. -Examples: - user: -How did crypto do last year?" +(EXAMPLE) How did crypto do last year?" assistant: Summarize Cryptocurrency Market Dynamics from last year user: -What are my health plans? +(EXAMPLE) What are my health plans? assistant: -Show available health plans" +Show available health plans + +{{ past_messages }} user: Generate search query for: {{ user_query }} diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index a4fa011ad4..3cb7a7e121 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -1,6 +1,5 @@ from typing import Any, Optional -import prompty from azure.search.documents.aio import SearchClient from azure.search.documents.models import VectorQuery from openai import AsyncOpenAI @@ -8,6 +7,7 @@ from openai_messages_token_helper import build_messages, get_token_limit from approaches.approach import Approach, ThoughtStep +from approaches.promptmanager import PromptManager from core.authentication import AuthenticationHelper @@ -33,6 +33,7 @@ def __init__( content_field: str, query_language: str, query_speller: str, + prompt_manager: PromptManager, ): self.search_client = search_client self.chatgpt_deployment = chatgpt_deployment @@ -48,7 +49,8 @@ def __init__( self.query_language = query_language self.query_speller = query_speller self.chatgpt_token_limit = get_token_limit(chatgpt_model, self.ALLOW_NON_GPT_MODELS) - self.answer_prompt = self.load_prompty("ask/answer_question.prompty") + self.prompt_manager = prompt_manager + self.answer_prompt = self.prompt_manager.load_prompt("ask/answer_question.prompty") async def run( self, @@ -95,14 +97,16 @@ async def run( # Append user message content = "\n".join(sources_content) - messages = prompty.prepare(self.answer_prompt, {"user_query": q, "content": content}) + rendered_answer_prompt = self.prompt_manager.render_prompt( + self.answer_prompt, {"user_query": q, "content": content} + ) response_token_limit = 1024 updated_messages = build_messages( model=self.chatgpt_model, - system_prompt=overrides.get("prompt_template", messages[0]["content"]), - few_shots=messages[1:-1], - new_user_content=messages[-1]["content"], + system_prompt=overrides.get("prompt_template", rendered_answer_prompt.system_content), + few_shots=rendered_answer_prompt.few_shot_messages, + new_user_content=rendered_answer_prompt.new_user_content, max_tokens=self.chatgpt_token_limit - response_token_limit, fallback_to_default=self.ALLOW_NON_GPT_MODELS, ) diff --git a/app/backend/approaches/retrievethenreadvision.py b/app/backend/approaches/retrievethenreadvision.py index 1fce6df7c2..bd58859fbe 100644 --- a/app/backend/approaches/retrievethenreadvision.py +++ b/app/backend/approaches/retrievethenreadvision.py @@ -1,6 +1,5 @@ from typing import Any, Awaitable, Callable, Optional -import prompty from azure.search.documents.aio import SearchClient from azure.storage.blob.aio import ContainerClient from openai import AsyncOpenAI @@ -12,6 +11,7 @@ from openai_messages_token_helper import build_messages, get_token_limit from approaches.approach import Approach, ThoughtStep +from approaches.promptmanager import PromptManager from core.authentication import AuthenticationHelper from core.imageshelper import fetch_image @@ -40,7 +40,8 @@ def __init__( query_language: str, query_speller: str, vision_endpoint: str, - vision_token_provider: Callable[[], Awaitable[str]] + vision_token_provider: Callable[[], Awaitable[str]], + prompt_manager: PromptManager, ): self.search_client = search_client self.blob_container_client = blob_container_client @@ -58,7 +59,8 @@ def __init__( self.vision_endpoint = vision_endpoint self.vision_token_provider = vision_token_provider self.gpt4v_token_limit = get_token_limit(gpt4v_model, self.ALLOW_NON_GPT_MODELS) - self.answer_prompt = self.load_prompty("ask/answer_question_vision.prompty") + self.prompt_manager = prompt_manager + self.answer_prompt = self.prompt_manager.load_prompt("ask/answer_question_vision.prompty") async def run( self, @@ -126,14 +128,17 @@ async def run( image_list.append({"image_url": url, "type": "image_url"}) user_content.extend(image_list) - messages = prompty.prepare(self.answer_prompt, {"user_query": q, "content": content}) + rendered_answer_prompt = self.prompt_manager.render_prompt( + self.answer_prompt, {"user_query": q, "content": content} + ) response_token_limit = 1024 updated_messages = build_messages( - model=self.gpt4v_model, - system_prompt=overrides.get("prompt_template", messages[0]["content"]), - new_user_content=messages[-1]["content"], - max_tokens=self.gpt4v_token_limit - response_token_limit, + model=self.chatgpt_model, + system_prompt=overrides.get("prompt_template", rendered_answer_prompt.system_content), + few_shots=rendered_answer_prompt.few_shot_messages, + new_user_content=rendered_answer_prompt.new_user_content, + max_tokens=self.chatgpt_token_limit - response_token_limit, fallback_to_default=self.ALLOW_NON_GPT_MODELS, ) chat_completion = await self.openai_client.chat.completions.create( From 3a6152b90289bd6232e925fabd171587d3d571f2 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Thu, 9 Jan 2025 14:53:29 -0800 Subject: [PATCH 07/27] Inject followup at the end --- app/backend/approaches/chatapproach.py | 1 - .../approaches/prompts/ask/answer_question_vision.prompty | 4 +--- .../approaches/prompts/chat/answer_question.prompty | 5 +++-- .../approaches/prompts/chat/answer_question_vision.prompty | 7 +++++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/backend/approaches/chatapproach.py b/app/backend/approaches/chatapproach.py index 389ba18d42..dce648311d 100644 --- a/app/backend/approaches/chatapproach.py +++ b/app/backend/approaches/chatapproach.py @@ -38,7 +38,6 @@ def render_answer_prompt( }, ) else: - # TODO: Warn if follow-up is specified, follow-up won't be injected return self.prompt_manager.render_prompt( self.answer_prompt, { diff --git a/app/backend/approaches/prompts/ask/answer_question_vision.prompty b/app/backend/approaches/prompts/ask/answer_question_vision.prompty index 949a0422c6..399e0387f9 100644 --- a/app/backend/approaches/prompts/ask/answer_question_vision.prompty +++ b/app/backend/approaches/prompts/ask/answer_question_vision.prompty @@ -10,10 +10,8 @@ Answer the following question using only the data provided in the sources below. The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned. If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts. -example: - user: -What is the deductible for the employee plan for a visit to Overlake in Bellevue +(EXAMPLE) What is the deductible for the employee plan for a visit to Overlake in Bellevue Sources: info1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.", diff --git a/app/backend/approaches/prompts/chat/answer_question.prompty b/app/backend/approaches/prompts/chat/answer_question.prompty index adcb0aece0..fb01ee73e8 100644 --- a/app/backend/approaches/prompts/chat/answer_question.prompty +++ b/app/backend/approaches/prompts/chat/answer_question.prompty @@ -9,6 +9,9 @@ Assistant helps the company employees with their healthcare plan questions, and Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question. If the question is not in English, answer in the language used in the question. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]. +{{ extra_prompt }} +{% endif %} + {% if include_follow_up_questions %} Generate 3 very brief follow-up questions that the user would likely ask next. Enclose the follow-up questions in double angle brackets. Example: @@ -18,8 +21,6 @@ Enclose the follow-up questions in double angle brackets. Example: Do not repeat questions that have already been asked. Make sure the last question ends with ">>". {% endif %} -{{ extra_prompt }} -{% endif %} {{ past_messages }} diff --git a/app/backend/approaches/prompts/chat/answer_question_vision.prompty b/app/backend/approaches/prompts/chat/answer_question_vision.prompty index 36776426d1..c596157d9d 100644 --- a/app/backend/approaches/prompts/chat/answer_question_vision.prompty +++ b/app/backend/approaches/prompts/chat/answer_question_vision.prompty @@ -14,6 +14,9 @@ If asking a clarifying question to the user would help, ask the question. Be brief in your answers. The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts. +{{injected_prompt}} +{% endif %} + {% if include_follow_up_questions %} Generate 3 very brief follow-up questions that the user would likely ask next. Enclose the follow-up questions in double angle brackets. Example: @@ -23,8 +26,8 @@ Enclose the follow-up questions in double angle brackets. Example: Do not repeat questions that have already been asked. Make sure the last question ends with ">>". {% endif %} -{{injected_prompt}} -{% endif %} + +{{ past_messages }} user: {{ user_query }} From 3b3f163b8cf5b01e4bc8f520cce04267d952cf19 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Thu, 9 Jan 2025 15:23:11 -0800 Subject: [PATCH 08/27] Make mypy so happy, remove conversation truncation for ask approaches --- app/backend/approaches/approach.py | 3 ++ app/backend/approaches/chatapproach.py | 2 ++ app/backend/approaches/promptmanager.py | 30 ++++++++++++------- app/backend/approaches/retrievethenread.py | 18 +++-------- .../approaches/retrievethenreadvision.py | 17 +++-------- pyproject.toml | 1 + 6 files changed, 33 insertions(+), 38 deletions(-) diff --git a/app/backend/approaches/approach.py b/app/backend/approaches/approach.py index ab445738b1..ca70c97eba 100644 --- a/app/backend/approaches/approach.py +++ b/app/backend/approaches/approach.py @@ -24,6 +24,7 @@ from openai import AsyncOpenAI from openai.types.chat import ChatCompletionMessageParam +from approaches.promptmanager import PromptManager from core.authentication import AuthenticationHelper from text import nonewlines @@ -109,6 +110,7 @@ def __init__( openai_host: str, vision_endpoint: str, vision_token_provider: Callable[[], Awaitable[str]], + prompt_manager: PromptManager, ): self.search_client = search_client self.openai_client = openai_client @@ -121,6 +123,7 @@ def __init__( self.openai_host = openai_host self.vision_endpoint = vision_endpoint self.vision_token_provider = vision_token_provider + self.prompt_manager = prompt_manager def build_filter(self, overrides: dict[str, Any], auth_claims: dict[str, Any]) -> Optional[str]: include_category = overrides.get("include_category") diff --git a/app/backend/approaches/chatapproach.py b/app/backend/approaches/chatapproach.py index dce648311d..d6832c02bc 100644 --- a/app/backend/approaches/chatapproach.py +++ b/app/backend/approaches/chatapproach.py @@ -13,6 +13,8 @@ class ChatApproach(Approach, ABC): NO_RESPONSE = "0" + answer_prompt = NotImplemented + @abstractmethod async def run_until_final_call(self, messages, overrides, auth_claims, should_stream) -> tuple: pass diff --git a/app/backend/approaches/promptmanager.py b/app/backend/approaches/promptmanager.py index 8a30ef5cc4..4ee277d24c 100644 --- a/app/backend/approaches/promptmanager.py +++ b/app/backend/approaches/promptmanager.py @@ -3,13 +3,15 @@ from dataclasses import dataclass import prompty +from openai.types.chat import ChatCompletionMessageParam @dataclass class RenderedPrompt: + all_messages: list[ChatCompletionMessageParam] system_content: str - few_shot_messages: list[str] - past_messages: list[str] + few_shot_messages: list[ChatCompletionMessageParam] + past_messages: list[ChatCompletionMessageParam] new_user_content: str @@ -21,7 +23,7 @@ def load_prompt(self, path: str): def load_tools(self, path: str): raise NotImplementedError - def render_prompt(self, prompt, data) -> list: + def render_prompt(self, prompt, data) -> RenderedPrompt: raise NotImplementedError @@ -39,21 +41,26 @@ def render_prompt(self, prompt, data) -> RenderedPrompt: # Assumes that the first message is the system message, the last message is the user message, # and the messages in-between are either examples or past messages. - messages: list = prompty.prepare(prompt, data) + all_messages: list = prompty.prepare(prompt, data) + remaining_messages = all_messages.copy() system_content = None - if messages[0]["role"] == "system": - system_content = messages[0]["content"] - messages.pop(0) + if all_messages[0]["role"] == "system": + system_content = all_messages[0]["content"] + remaining_messages.pop(0) + else: + raise ValueError("The first message in the prompt must be a system message.") new_user_content = None - if messages[-1]["role"] == "user": - new_user_content = messages[-1]["content"] - messages.pop(-1) + if all_messages[-1]["role"] == "user": + new_user_content = all_messages[-1]["content"] + remaining_messages.pop(-1) + else: + raise ValueError("The last message in the prompt must be a user message.") few_shot_messages = [] past_messages = [] - for user_message, assistant_message in zip(messages[0::2], messages[1::2]): + for user_message, assistant_message in zip(remaining_messages[0::2], remaining_messages[1::2]): if user_message["content"].startswith("(EXAMPLE)"): user_message["content"] = user_message["content"][9:].lstrip() few_shot_messages.extend([user_message, assistant_message]) @@ -61,6 +68,7 @@ def render_prompt(self, prompt, data) -> RenderedPrompt: past_messages.extend([user_message, assistant_message]) return RenderedPrompt( + all_messages=all_messages, system_content=system_content, few_shot_messages=few_shot_messages, past_messages=past_messages, diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index 3cb7a7e121..e5e4dd90fc 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -4,7 +4,7 @@ from azure.search.documents.models import VectorQuery from openai import AsyncOpenAI from openai.types.chat import ChatCompletionMessageParam -from openai_messages_token_helper import build_messages, get_token_limit +from openai_messages_token_helper import get_token_limit from approaches.approach import Approach, ThoughtStep from approaches.promptmanager import PromptManager @@ -101,22 +101,12 @@ async def run( self.answer_prompt, {"user_query": q, "content": content} ) - response_token_limit = 1024 - updated_messages = build_messages( - model=self.chatgpt_model, - system_prompt=overrides.get("prompt_template", rendered_answer_prompt.system_content), - few_shots=rendered_answer_prompt.few_shot_messages, - new_user_content=rendered_answer_prompt.new_user_content, - max_tokens=self.chatgpt_token_limit - response_token_limit, - fallback_to_default=self.ALLOW_NON_GPT_MODELS, - ) - chat_completion = await self.openai_client.chat.completions.create( # Azure OpenAI takes the deployment name as the model name model=self.chatgpt_deployment if self.chatgpt_deployment else self.chatgpt_model, - messages=updated_messages, + messages=rendered_answer_prompt.all_messages, temperature=overrides.get("temperature", 0.3), - max_tokens=response_token_limit, + max_tokens=1024, n=1, seed=seed, ) @@ -143,7 +133,7 @@ async def run( ), ThoughtStep( "Prompt to generate answer", - updated_messages, + rendered_answer_prompt.all_messages, ( {"model": self.chatgpt_model, "deployment": self.chatgpt_deployment} if self.chatgpt_deployment diff --git a/app/backend/approaches/retrievethenreadvision.py b/app/backend/approaches/retrievethenreadvision.py index bd58859fbe..dd5667cb93 100644 --- a/app/backend/approaches/retrievethenreadvision.py +++ b/app/backend/approaches/retrievethenreadvision.py @@ -8,7 +8,7 @@ ChatCompletionContentPartParam, ChatCompletionMessageParam, ) -from openai_messages_token_helper import build_messages, get_token_limit +from openai_messages_token_helper import get_token_limit from approaches.approach import Approach, ThoughtStep from approaches.promptmanager import PromptManager @@ -132,20 +132,11 @@ async def run( self.answer_prompt, {"user_query": q, "content": content} ) - response_token_limit = 1024 - updated_messages = build_messages( - model=self.chatgpt_model, - system_prompt=overrides.get("prompt_template", rendered_answer_prompt.system_content), - few_shots=rendered_answer_prompt.few_shot_messages, - new_user_content=rendered_answer_prompt.new_user_content, - max_tokens=self.chatgpt_token_limit - response_token_limit, - fallback_to_default=self.ALLOW_NON_GPT_MODELS, - ) chat_completion = await self.openai_client.chat.completions.create( model=self.gpt4v_deployment if self.gpt4v_deployment else self.gpt4v_model, - messages=updated_messages, + messages=rendered_answer_prompt.all_messages, temperature=overrides.get("temperature", 0.3), - max_tokens=response_token_limit, + max_tokens=1024, n=1, seed=seed, ) @@ -177,7 +168,7 @@ async def run( ), ThoughtStep( "Prompt to generate answer", - updated_messages, + rendered_answer_prompt.all_messages, ( {"model": self.gpt4v_model, "deployment": self.gpt4v_deployment} if self.gpt4v_deployment diff --git a/pyproject.toml b/pyproject.toml index 9e12e399f0..7655107c52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,5 +33,6 @@ module = [ "azure.cognitiveservices.*", "azure.cognitiveservices.speech.*", "pymupdf.*", + "prompty.*", ] ignore_missing_imports = true From e42d0d0b1d504fd34c14b439fec69b8cd928cfe0 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Thu, 9 Jan 2025 15:31:34 -0800 Subject: [PATCH 09/27] Refactor text.py since it doesnt need to be its own very short file --- app/backend/approaches/approach.py | 5 ++++- app/backend/text.py | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 app/backend/text.py diff --git a/app/backend/approaches/approach.py b/app/backend/approaches/approach.py index ca70c97eba..af5344465f 100644 --- a/app/backend/approaches/approach.py +++ b/app/backend/approaches/approach.py @@ -26,7 +26,6 @@ from approaches.promptmanager import PromptManager from core.authentication import AuthenticationHelper -from text import nonewlines @dataclass @@ -208,6 +207,10 @@ async def search( def get_sources_content( self, results: List[Document], use_semantic_captions: bool, use_image_citation: bool ) -> list[str]: + + def nonewlines(s: str) -> str: + return s.replace("\n", " ").replace("\r", " ") + if use_semantic_captions: return [ (self.get_citation((doc.sourcepage or ""), use_image_citation)) diff --git a/app/backend/text.py b/app/backend/text.py deleted file mode 100644 index 98d099d8d1..0000000000 --- a/app/backend/text.py +++ /dev/null @@ -1,2 +0,0 @@ -def nonewlines(s: str) -> str: - return s.replace("\n", " ").replace("\r", " ") From b4ccc08f6efe45638f293d1f8777001120a8c5a4 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Thu, 9 Jan 2025 16:05:59 -0800 Subject: [PATCH 10/27] Fix Chat approach tests --- tests/test_chatapproach.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_chatapproach.py b/tests/test_chatapproach.py index 0f3a0c44f7..2fa845fec3 100644 --- a/tests/test_chatapproach.py +++ b/tests/test_chatapproach.py @@ -6,6 +6,7 @@ from openai.types.chat import ChatCompletion from approaches.chatreadretrieveread import ChatReadRetrieveReadApproach +from approaches.promptmanager import PromptyManager from .mocks import ( MOCK_EMBEDDING_DIMENSIONS, @@ -33,6 +34,7 @@ def chat_approach(): content_field="", query_language="en-us", query_speller="lexicon", + prompt_manager=PromptyManager(), ) @@ -178,6 +180,7 @@ async def test_search_results_filtering_by_scores( content_field="", query_language="en-us", query_speller="lexicon", + prompt_manager=PromptyManager(), ) monkeypatch.setattr(SearchClient, "search", mock_search) From 4cfd7ca9f6e81b1e3bb727f2d2b96abe407bae78 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Fri, 10 Jan 2025 12:09:23 -0800 Subject: [PATCH 11/27] More prompty updates, test updates --- .vscode/launch.json | 1 + app/backend/approaches/chatapproach.py | 36 +++---------- .../approaches/chatreadretrieveread.py | 25 ++++------ .../approaches/chatreadretrievereadvision.py | 50 ++++++++----------- .../prompts/ask/answer_question.prompty | 17 ++++--- .../ask/answer_question_vision.prompty | 24 ++++----- .../prompts/chat/answer_question.prompty | 11 +++- .../chat/answer_question_vision.prompty | 15 ++++-- .../prompts/chat/query_rewrite.prompty | 7 ++- app/backend/approaches/retrievethenread.py | 10 ++-- .../approaches/retrievethenreadvision.py | 21 +++----- app/backend/core/imageshelper.py | 5 +- app/backend/requirements.txt | 2 +- tests/conftest.py | 10 ++-- .../test_ask_rtr_hybrid/client0/result.json | 6 +-- .../test_ask_rtr_hybrid/client1/result.json | 6 +-- .../test_ask_rtr_text/client0/result.json | 6 +-- .../test_ask_rtr_text/client1/result.json | 6 +-- .../auth_client0/result.json | 6 +-- .../auth_public_documents_client0/result.json | 6 +-- .../client0/result.json | 6 +-- .../client1/result.json | 6 +-- .../client0/result.json | 6 +-- .../client1/result.json | 6 +-- .../test_ask_vision/client0/result.json | 6 +-- .../test_ask_vision/client1/result.json | 20 +++----- .../test_chat_followup/client0/result.json | 6 +-- .../test_chat_followup/client1/result.json | 6 +-- .../test_chat_hybrid/client0/result.json | 6 +-- .../test_chat_hybrid/client1/result.json | 6 +-- .../client0/result.json | 6 +-- .../client1/result.json | 6 +-- .../client0/result.json | 6 +-- .../client1/result.json | 6 +-- .../client0/result.json | 4 +- .../client1/result.json | 4 +- .../client0/result.json | 6 +-- .../client1/result.json | 6 +-- .../test_chat_seed/client0/result.json | 6 +-- .../test_chat_seed/client1/result.json | 6 +-- .../client0/result.json | 6 +-- .../client1/result.json | 6 +-- .../client0/result.jsonlines | 2 +- .../client1/result.jsonlines | 2 +- .../client0/result.jsonlines | 2 +- .../client1/result.jsonlines | 2 +- .../client0/result.jsonlines | 2 +- .../client1/result.jsonlines | 2 +- .../auth_client0/result.jsonlines | 2 +- .../client0/result.jsonlines | 2 +- .../client1/result.jsonlines | 2 +- .../test_chat_text/client0/result.json | 6 +-- .../test_chat_text/client1/result.json | 6 +-- .../auth_client0/result.json | 6 +-- .../auth_public_documents_client0/result.json | 6 +-- .../client0/result.json | 6 +-- .../client1/result.json | 6 +-- .../client0/result.json | 6 +-- .../client1/result.json | 6 +-- .../client0/result.json | 6 +-- .../client1/result.json | 6 +-- .../test_chat_vector/client0/result.json | 6 +-- .../test_chat_vector/client1/result.json | 6 +-- .../client0/result.json | 6 +-- .../client1/result.json | 6 +-- .../test_chat_vision/client0/result.json | 6 +-- .../test_chat_vision/client1/result.json | 18 +++---- .../client0/result.json | 6 +-- .../client1/result.json | 18 +++---- .../client0/result.json | 14 ++---- .../client1/result.json | 14 ++---- .../client0/result.json | 14 ++---- .../client1/result.json | 14 ++---- tests/test_chatvisionapproach.py | 2 + 74 files changed, 273 insertions(+), 347 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 46bd4f00d4..6d4ca1c2b2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -36,6 +36,7 @@ { "name": "Tests (Python)", "type": "debugpy", + "python": "${workspaceFolder}/.venv/bin/python", "request": "launch", "program": "${file}", "purpose": ["debug-test"], diff --git a/app/backend/approaches/chatapproach.py b/app/backend/approaches/chatapproach.py index d6832c02bc..d40fdbc66d 100644 --- a/app/backend/approaches/chatapproach.py +++ b/app/backend/approaches/chatapproach.py @@ -19,36 +19,14 @@ class ChatApproach(Approach, ABC): async def run_until_final_call(self, messages, overrides, auth_claims, should_stream) -> tuple: pass - def render_answer_prompt( - self, - override_prompt: Optional[str], - include_follow_up_questions: bool, - past_messages: list, - user_query: str, - sources: str, - ) -> RenderedPrompt: - if override_prompt is None or override_prompt.startswith(">>>"): - injected_prompt = "" if override_prompt is None else override_prompt[3:] - return self.prompt_manager.render_prompt( - self.answer_prompt, - { - "include_follow_up_questions": include_follow_up_questions, - "injected_prompt": injected_prompt, - "past_messages": past_messages, - "user_query": user_query, - "sources": sources, - }, - ) + def get_system_prompt_variables(self, override_prompt: Optional[str]) -> RenderedPrompt: + # Allows client to replace the entire prompt, or to inject into the existing prompt using >>> + if override_prompt is None: + return {} + elif override_prompt.startswith("<<<"): + return {"injected_prompt": override_prompt[3:]} else: - return self.prompt_manager.render_prompt( - self.answer_prompt, - { - "override_prompt": override_prompt, - "past_messages": past_messages, - "user_query": user_query, - "sources": sources, - }, - ) + return {"override_prompt": override_prompt} def get_search_query(self, chat_completion: ChatCompletion, user_query: str): response_message = chat_completion.choices[0].message diff --git a/app/backend/approaches/chatreadretrieveread.py b/app/backend/approaches/chatreadretrieveread.py index aed9cbc822..a147ca019a 100644 --- a/app/backend/approaches/chatreadretrieveread.py +++ b/app/backend/approaches/chatreadretrieveread.py @@ -149,18 +149,17 @@ async def run_until_final_call( minimum_reranker_score, ) - sources_content = self.get_sources_content(results, use_semantic_captions, use_image_citation=False) - content = "\n".join(sources_content) - # STEP 3: Generate a contextual and content specific answer using the search results and chat history - - # Allow client to replace the entire prompt, or to inject into the existing prompt using >>> - rendered_answer_prompt = self.render_answer_prompt( - overrides.get("prompt_template"), - include_follow_up_questions=bool(overrides.get("suggest_followup_questions")), - past_messages=messages[:-1], - user_query=original_user_query, - sources=content, + text_sources = self.get_sources_content(results, use_semantic_captions, use_image_citation=False) + rendered_answer_prompt = self.prompt_manager.render_prompt( + self.answer_prompt, + self.get_system_prompt_variables(overrides.get("prompt_template")) + | { + "include_follow_up_questions": bool(overrides.get("suggest_followup_questions")), + "past_messages": messages[:-1], + "user_query": original_user_query, + "text_sources": text_sources, + }, ) response_token_limit = 1024 @@ -173,10 +172,8 @@ async def run_until_final_call( fallback_to_default=self.ALLOW_NON_GPT_MODELS, ) - data_points = {"text": sources_content} - extra_info = { - "data_points": data_points, + "data_points": {"text": text_sources}, "thoughts": [ ThoughtStep( "Prompt to generate search query", diff --git a/app/backend/approaches/chatreadretrievereadvision.py b/app/backend/approaches/chatreadretrievereadvision.py index d6784d2389..ac9122a066 100644 --- a/app/backend/approaches/chatreadretrievereadvision.py +++ b/app/backend/approaches/chatreadretrievereadvision.py @@ -6,8 +6,6 @@ from openai.types.chat import ( ChatCompletion, ChatCompletionChunk, - ChatCompletionContentPartImageParam, - ChatCompletionContentPartParam, ChatCompletionMessageParam, ChatCompletionToolParam, ) @@ -154,51 +152,45 @@ async def run_until_final_call( minimum_search_score, minimum_reranker_score, ) - sources_content = self.get_sources_content(results, use_semantic_captions, use_image_citation=True) - content = "\n".join(sources_content) # STEP 3: Generate a contextual and content specific answer using the search results and chat history - - # Allow client to replace the entire prompt, or to inject into the existing prompt using >>> - rendered_answer_prompt = self.render_answer_prompt( - overrides.get("prompt_template"), - include_follow_up_questions=bool(overrides.get("suggest_followup_questions")), - past_messages=messages[:-1], - user_query=original_user_query, - sources=content, - ) - - user_content: list[ChatCompletionContentPartParam] = [ - {"text": rendered_answer_prompt.new_user_content, "type": "text"} - ] - image_list: list[ChatCompletionContentPartImageParam] = [] - + text_sources = [] + image_sources = [] if send_text_to_gptvision: - user_content.append({"text": "\n\nSources:\n" + content, "type": "text"}) + text_sources = self.get_sources_content(results, use_semantic_captions, use_image_citation=True) if send_images_to_gptvision: for result in results: url = await fetch_image(self.blob_container_client, result) if url: - image_list.append({"image_url": url, "type": "image_url"}) - user_content.extend(image_list) + image_sources.append(url) + + rendered_answer_prompt = self.prompt_manager.render_prompt( + self.answer_prompt, + self.get_system_prompt_variables(overrides.get("prompt_template")) + | { + "include_follow_up_questions": bool(overrides.get("suggest_followup_questions")), + "past_messages": messages[:-1], + "user_query": original_user_query, + "text_sources": text_sources, + "image_sources": image_sources, + }, + ) response_token_limit = 1024 messages = build_messages( model=self.gpt4v_model, system_prompt=rendered_answer_prompt.system_content, past_messages=rendered_answer_prompt.past_messages, - new_user_content=user_content, + new_user_content=rendered_answer_prompt.new_user_content, max_tokens=self.chatgpt_token_limit - response_token_limit, fallback_to_default=self.ALLOW_NON_GPT_MODELS, ) - data_points = { - "text": sources_content, - "images": [d["image_url"] for d in image_list], - } - extra_info = { - "data_points": data_points, + "data_points": { + "text": text_sources, + "images": image_sources, + }, "thoughts": [ ThoughtStep( "Prompt to generate search query", diff --git a/app/backend/approaches/prompts/ask/answer_question.prompty b/app/backend/approaches/prompts/ask/answer_question.prompty index f758785dd6..1876c26967 100644 --- a/app/backend/approaches/prompts/ask/answer_question.prompty +++ b/app/backend/approaches/prompts/ask/answer_question.prompty @@ -6,22 +6,23 @@ You are an intelligent assistant helping Contoso Inc employees with their health Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. -If you cannot answer using the sources below, say you don't know. Use below example to answer. +If you cannot answer using the sources below, say you don't know. Use below example to answer user: -(EXAMPLE) What is the deductible for the employee plan for a visit to Overlake in Bellevue +(EXAMPLE) What is the deductible for the employee plan for a visit to Overlake in Bellevue? Sources: -info1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.", -info2.pdf: Overlake is in-network for the employee plan.", -info3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.", -info4.pdf: In-network institutions include Overlake, Swedish and others in the region." +info1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family. +info2.pdf: Overlake is in-network for the employee plan. +info3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue. +info4.pdf: In-network institutions include Overlake, Swedish and others in the region. assistant: In-network deductibles are $500 for employee and $1000 for family [info1.txt] and Overlake is in-network for the employee plan [info2.pdf][info4.pdf]. user: {{ user_query }} - Sources: -{{ content }} +{% for text_source in text_sources %} +{{ text_source }} +{% endfor %} diff --git a/app/backend/approaches/prompts/ask/answer_question_vision.prompty b/app/backend/approaches/prompts/ask/answer_question_vision.prompty index 399e0387f9..4b7756ac11 100644 --- a/app/backend/approaches/prompts/ask/answer_question_vision.prompty +++ b/app/backend/approaches/prompts/ask/answer_question_vision.prompty @@ -1,4 +1,6 @@ --- +name: Ask with vision +description: Answer a single question (with no chat history) using both text and image sources. model: api: chat --- @@ -10,20 +12,14 @@ Answer the following question using only the data provided in the sources below. The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned. If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts. -user: -(EXAMPLE) What is the deductible for the employee plan for a visit to Overlake in Bellevue - -Sources: -info1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.", -info2.pdf: Overlake is in-network for the employee plan.", -info3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.", -info4.pdf: In-network institutions include Overlake, Swedish and others in the region." - -assistant: -In-network deductibles are $500 for employee and $1000 for family [info1.txt] and Overlake is in-network for the employee plan [info2.pdf][info4.pdf]. - user: {{ user_query }} - +{% for image_source in image_sources %} +![Image]({{image_source}}) +{% endfor %} +{% if text_sources is defined %} Sources: -{{ content }} +{% for text_source in text_sources %} +{{ text_source }} +{% endfor %} +{% endif %} diff --git a/app/backend/approaches/prompts/chat/answer_question.prompty b/app/backend/approaches/prompts/chat/answer_question.prompty index fb01ee73e8..af1030ecf3 100644 --- a/app/backend/approaches/prompts/chat/answer_question.prompty +++ b/app/backend/approaches/prompts/chat/answer_question.prompty @@ -1,4 +1,6 @@ --- +name: Chat with vision +description: Answer a question (with chat history) using both text and image sources. model: api: chat --- @@ -22,10 +24,15 @@ Do not repeat questions that have already been asked. Make sure the last question ends with ">>". {% endif %} -{{ past_messages }} +{% for message in past_messages %} +{{ message["role"] }}: +{{ message["content"] }} +{% endfor %} user: {{ user_query }} Sources: -{{ sources }} +{% for text_source in text_sources %} +{{ text_source }} +{% endfor %} diff --git a/app/backend/approaches/prompts/chat/answer_question_vision.prompty b/app/backend/approaches/prompts/chat/answer_question_vision.prompty index c596157d9d..b7b44a3937 100644 --- a/app/backend/approaches/prompts/chat/answer_question_vision.prompty +++ b/app/backend/approaches/prompts/chat/answer_question_vision.prompty @@ -27,10 +27,19 @@ Do not repeat questions that have already been asked. Make sure the last question ends with ">>". {% endif %} -{{ past_messages }} +{% for message in past_messages %} +{{ message["role"] }}: +{{ message["content"] }} +{% endfor %} user: {{ user_query }} - +{% for image_source in image_sources %} +![Image]({{image_source}}) +{% endfor %} +{% if text_sources is defined %} Sources: -{{ content }} +{% for text_source in text_sources %} +{{ text_source }} +{% endfor %} +{% endif %} diff --git a/app/backend/approaches/prompts/chat/query_rewrite.prompty b/app/backend/approaches/prompts/chat/query_rewrite.prompty index d0ca48fda5..1b286dc211 100644 --- a/app/backend/approaches/prompts/chat/query_rewrite.prompty +++ b/app/backend/approaches/prompts/chat/query_rewrite.prompty @@ -15,7 +15,7 @@ If the question is not in English, translate the question to English before gene If you cannot generate a search query, return just the number 0. user: -(EXAMPLE) How did crypto do last year?" +(EXAMPLE) How did crypto do last year? assistant: Summarize Cryptocurrency Market Dynamics from last year @@ -26,7 +26,10 @@ user: assistant: Show available health plans -{{ past_messages }} +{% for message in past_messages %} +{{ message["role"] }}: +{{ message["content"] }} +{% endfor %} user: Generate search query for: {{ user_query }} diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index e5e4dd90fc..974b555b69 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -92,13 +92,9 @@ async def run( ) # Process results - sources_content = self.get_sources_content(results, use_semantic_captions, use_image_citation=False) - - # Append user message - content = "\n".join(sources_content) - + text_sources = self.get_sources_content(results, use_semantic_captions, use_image_citation=False) rendered_answer_prompt = self.prompt_manager.render_prompt( - self.answer_prompt, {"user_query": q, "content": content} + self.answer_prompt, {"user_query": q, "text_sources": text_sources} ) chat_completion = await self.openai_client.chat.completions.create( @@ -111,7 +107,7 @@ async def run( seed=seed, ) - data_points = {"text": sources_content} + data_points = {"text": text_sources} extra_info = { "data_points": data_points, "thoughts": [ diff --git a/app/backend/approaches/retrievethenreadvision.py b/app/backend/approaches/retrievethenreadvision.py index dd5667cb93..1183aba967 100644 --- a/app/backend/approaches/retrievethenreadvision.py +++ b/app/backend/approaches/retrievethenreadvision.py @@ -4,8 +4,6 @@ from azure.storage.blob.aio import ContainerClient from openai import AsyncOpenAI from openai.types.chat import ( - ChatCompletionContentPartImageParam, - ChatCompletionContentPartParam, ChatCompletionMessageParam, ) from openai_messages_token_helper import get_token_limit @@ -112,24 +110,19 @@ async def run( minimum_reranker_score, ) - image_list: list[ChatCompletionContentPartImageParam] = [] - user_content: list[ChatCompletionContentPartParam] = [{"text": q, "type": "text"}] - # Process results - sources_content = self.get_sources_content(results, use_semantic_captions, use_image_citation=True) - + text_sources = [] + image_sources = [] if send_text_to_gptvision: - content = "\n".join(sources_content) - user_content.append({"text": content, "type": "text"}) + text_sources = "\n".join(self.get_sources_content(results, use_semantic_captions, use_image_citation=True)) if send_images_to_gptvision: for result in results: url = await fetch_image(self.blob_container_client, result) if url: - image_list.append({"image_url": url, "type": "image_url"}) - user_content.extend(image_list) + image_sources.append(url) rendered_answer_prompt = self.prompt_manager.render_prompt( - self.answer_prompt, {"user_query": q, "content": content} + self.answer_prompt, {"user_query": q, "text_sources": text_sources, "image_sources": image_sources} ) chat_completion = await self.openai_client.chat.completions.create( @@ -142,8 +135,8 @@ async def run( ) data_points = { - "text": sources_content, - "images": [d["image_url"] for d in image_list], + "text": text_sources, + "images": image_sources, } extra_info = { diff --git a/app/backend/core/imageshelper.py b/app/backend/core/imageshelper.py index d35f659766..399fecb453 100644 --- a/app/backend/core/imageshelper.py +++ b/app/backend/core/imageshelper.py @@ -36,8 +36,5 @@ async def download_blob_as_base64(blob_container_client: ContainerClient, file_p async def fetch_image(blob_container_client: ContainerClient, result: Document) -> Optional[ImageURL]: if result.sourcepage: img = await download_blob_as_base64(blob_container_client, result.sourcepage) - if img: - return {"url": img, "detail": "auto"} - else: - return None + return img return None diff --git a/app/backend/requirements.txt b/app/backend/requirements.txt index 1bd2835098..28d804bf29 100644 --- a/app/backend/requirements.txt +++ b/app/backend/requirements.txt @@ -219,7 +219,7 @@ openai==1.59.4 # via # -r requirements.in # openai-messages-token-helper -openai-messages-token-helper==0.1.10 +openai-messages-token-helper==0.1.11 # via -r requirements.in opentelemetry-api==1.26.0 # via diff --git a/tests/conftest.py b/tests/conftest.py index 157770b186..90d6e112aa 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -189,7 +189,7 @@ async def mock_acreate(*args, **kwargs): answer = "capital of France" elif last_question == "Generate search query for: Are interest rates high?": answer = "interest rates" - elif isinstance(last_question, list) and last_question[2].get("image_url"): + elif isinstance(last_question, list) and any([part.get("image_url") for part in last_question]): answer = "From the provided sources, the impact of interest rates and GDP growth on financial markets can be observed through the line graph. [Financial Market Analysis Report 2023-7.png]" else: answer = "The capital of France is Paris. [Benefit_Options-2.pdf]." @@ -319,7 +319,7 @@ def mock_env(monkeypatch, request): yield -@pytest_asyncio.fixture() +@pytest_asyncio.fixture(scope="function") async def client( monkeypatch, mock_env, @@ -338,7 +338,7 @@ async def client( yield test_app.test_client() -@pytest_asyncio.fixture() +@pytest_asyncio.fixture(scope="function") async def client_with_expiring_token( monkeypatch, mock_env, @@ -358,7 +358,7 @@ async def client_with_expiring_token( yield test_app.test_client() -@pytest_asyncio.fixture(params=auth_envs) +@pytest_asyncio.fixture(params=auth_envs, scope="function") async def auth_client( monkeypatch, mock_openai_chatcompletion, @@ -397,7 +397,7 @@ async def auth_client( yield client -@pytest_asyncio.fixture(params=auth_public_envs) +@pytest_asyncio.fixture(params=auth_public_envs, scope="function") async def auth_public_documents_client( monkeypatch, mock_openai_chatcompletion, diff --git a/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json index bf52b372ca..c8ff001c5f 100644 --- a/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json @@ -47,11 +47,11 @@ { "description": [ { - "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer", + "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions.\nUse 'you' to refer to the individual asking the questions even if they ask with 'I'.\nAnswer the following question using only the data provided in the sources below.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response.\nIf you cannot answer using the sources below, say you don't know. Use below example to answer", "role": "system" }, { - "content": "\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\n", + "content": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region.", "role": "user" }, { @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources:\n Benefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json index ed09cd39a6..4ca69bc01b 100644 --- a/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json @@ -47,11 +47,11 @@ { "description": [ { - "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer", + "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions.\nUse 'you' to refer to the individual asking the questions even if they ask with 'I'.\nAnswer the following question using only the data provided in the sources below.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response.\nIf you cannot answer using the sources below, say you don't know. Use below example to answer", "role": "system" }, { - "content": "\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\n", + "content": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region.", "role": "user" }, { @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources:\n Benefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json index c11293882e..7542001006 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json @@ -47,11 +47,11 @@ { "description": [ { - "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer", + "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions.\nUse 'you' to refer to the individual asking the questions even if they ask with 'I'.\nAnswer the following question using only the data provided in the sources below.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response.\nIf you cannot answer using the sources below, say you don't know. Use below example to answer", "role": "system" }, { - "content": "\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\n", + "content": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region.", "role": "user" }, { @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources:\n Benefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json index e2f4527695..fa068a61ec 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json @@ -47,11 +47,11 @@ { "description": [ { - "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer", + "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions.\nUse 'you' to refer to the individual asking the questions even if they ask with 'I'.\nAnswer the following question using only the data provided in the sources below.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response.\nIf you cannot answer using the sources below, say you don't know. Use below example to answer", "role": "system" }, { - "content": "\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\n", + "content": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region.", "role": "user" }, { @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources:\n Benefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json index 5c22651705..514177b621 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json @@ -47,11 +47,11 @@ { "description": [ { - "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer", + "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions.\nUse 'you' to refer to the individual asking the questions even if they ask with 'I'.\nAnswer the following question using only the data provided in the sources below.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response.\nIf you cannot answer using the sources below, say you don't know. Use below example to answer", "role": "system" }, { - "content": "\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\n", + "content": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region.", "role": "user" }, { @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources:\n Benefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json index 07fcb3cd40..6402f002f0 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json @@ -47,11 +47,11 @@ { "description": [ { - "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer", + "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions.\nUse 'you' to refer to the individual asking the questions even if they ask with 'I'.\nAnswer the following question using only the data provided in the sources below.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response.\nIf you cannot answer using the sources below, say you don't know. Use below example to answer", "role": "system" }, { - "content": "\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\n", + "content": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region.", "role": "user" }, { @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources:\n Benefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json index 84ce594ac4..71f06bd321 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json @@ -47,11 +47,11 @@ { "description": [ { - "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer", + "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions.\nUse 'you' to refer to the individual asking the questions even if they ask with 'I'.\nAnswer the following question using only the data provided in the sources below.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response.\nIf you cannot answer using the sources below, say you don't know. Use below example to answer", "role": "system" }, { - "content": "\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\n", + "content": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region.", "role": "user" }, { @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources:\n Benefit_Options-2.pdf: Caption: A whistleblower policy.", + "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json index ba0591bcff..a0dacbfe90 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json @@ -47,11 +47,11 @@ { "description": [ { - "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer", + "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions.\nUse 'you' to refer to the individual asking the questions even if they ask with 'I'.\nAnswer the following question using only the data provided in the sources below.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response.\nIf you cannot answer using the sources below, say you don't know. Use below example to answer", "role": "system" }, { - "content": "\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\n", + "content": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region.", "role": "user" }, { @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources:\n Benefit_Options-2.pdf: Caption: A whistleblower policy.", + "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json index ff67dab680..90b4482f16 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json @@ -47,11 +47,11 @@ { "description": [ { - "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer", + "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions.\nUse 'you' to refer to the individual asking the questions even if they ask with 'I'.\nAnswer the following question using only the data provided in the sources below.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response.\nIf you cannot answer using the sources below, say you don't know. Use below example to answer", "role": "system" }, { - "content": "\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\n", + "content": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region.", "role": "user" }, { @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources:\n Benefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json index 605a5275a4..036bae7d17 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json @@ -47,11 +47,11 @@ { "description": [ { - "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer", + "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions.\nUse 'you' to refer to the individual asking the questions even if they ask with 'I'.\nAnswer the following question using only the data provided in the sources below.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response.\nIf you cannot answer using the sources below, say you don't know. Use below example to answer", "role": "system" }, { - "content": "\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\n", + "content": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region.", "role": "user" }, { @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources:\n Benefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_vision/client0/result.json b/tests/snapshots/test_app/test_ask_vision/client0/result.json index b2f77bb714..90b046b833 100644 --- a/tests/snapshots/test_app/test_ask_vision/client0/result.json +++ b/tests/snapshots/test_app/test_ask_vision/client0/result.json @@ -47,11 +47,11 @@ { "description": [ { - "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer", + "content": "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions.\nUse 'you' to refer to the individual asking the questions even if they ask with 'I'.\nAnswer the following question using only the data provided in the sources below.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response.\nIf you cannot answer using the sources below, say you don't know. Use below example to answer", "role": "system" }, { - "content": "\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\n", + "content": "What is the deductible for the employee plan for a visit to Overlake in Bellevue?\n\nSources:\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\ninfo2.pdf: Overlake is in-network for the employee plan.\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region.", "role": "user" }, { @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "Are interest rates high?\nSources:\n Benefit_Options-2.pdf: There is a whistleblower policy.", + "content": "Are interest rates high?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_vision/client1/result.json b/tests/snapshots/test_app/test_ask_vision/client1/result.json index b217b87cbf..5a3b75e2bb 100644 --- a/tests/snapshots/test_app/test_ask_vision/client1/result.json +++ b/tests/snapshots/test_app/test_ask_vision/client1/result.json @@ -2,14 +2,9 @@ "context": { "data_points": { "images": [ - { - "detail": "auto", - "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==" - } + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==" ], - "text": [ - "Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions " - ] + "text": "Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions " }, "thoughts": [ { @@ -51,7 +46,7 @@ { "description": [ { - "content": "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images. Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName: Each text source starts in a new line and has the file name followed by colon and the actual information Always include the source name from the image or text for each fact you use in the response in the format: [filename] Answer the following question using only the data provided in the sources below. The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts ", + "content": "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images.\nEach image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:.\nEach text source starts in a new line and has the file name followed by colon and the actual information.\nAlways include the source name from the image or text for each fact you use in the response in the format: [filename].\nAnswer the following question using only the data provided in the sources below.\nThe text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned.\nIf you cannot answer using the sources below, say you don't know. Return just the answer without any input texts.", "role": "system" }, { @@ -60,16 +55,15 @@ "text": "Are interest rates high?", "type": "text" }, - { - "text": "Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions ", - "type": "text" - }, { "image_url": { - "detail": "auto", "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==" }, "type": "image_url" + }, + { + "text": "Sources: \n\nF\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\nM\n\na\n\nr\n\nk\n\ne\n\nt\n\n \n\nA\n\nn\n\na\n\nl\n\ny\n\ns\n\ni\n\ns\n\n \n\nR\n\ne\n\np\n\no\n\nr\n\nt\n\n \n\n2\n\n0\n\n2\n\n3\n\n-\n\n6\n\n.\n\np\n\nn\n\ng\n\n:\n\n \n\n3\n\n<\n\n/\n\nt\n\nd\n\n>\n\n<\n\nt\n\nd\n\n>\n\n1\n\n<\n\n/\n\nt\n\nd\n\n>\n\n<\n\n/\n\nt\n\nr\n\n>\n\n<\n\n/\n\nt\n\na\n\nb\n\nl\n\ne\n\n>\n\n \n\nF\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\nm\n\na\n\nr\n\nk\n\ne\n\nt\n\ns\n\n \n\na\n\nr\n\ne\n\n \n\ni\n\nn\n\nt\n\ne\n\nr\n\nc\n\no\n\nn\n\nn\n\ne\n\nc\n\nt\n\ne\n\nd\n\n,\n\n \n\nw\n\ni\n\nt\n\nh\n\n \n\nm\n\no\n\nv\n\ne\n\nm\n\ne\n\nn\n\nt\n\ns\n\n \n\ni\n\nn\n\n \n\no\n\nn\n\ne\n\n \n\ns\n\ne\n\ng\n\nm\n\ne\n\nn\n\nt\n\n \n\no\n\nf\n\nt\n\ne\n\nn\n\n \n\ni\n\nn\n\nf\n\nl\n\nu\n\ne\n\nn\n\nc\n\ni\n\nn\n\ng\n\n \n\no\n\nt\n\nh\n\ne\n\nr\n\ns\n\n.\n\n \n\nT\n\nh\n\ni\n\ns\n\n \n\ns\n\ne\n\nc\n\nt\n\ni\n\no\n\nn\n\n \n\ne\n\nx\n\na\n\nm\n\ni\n\nn\n\ne\n\ns\n\n \n\nt\n\nh\n\ne\n\n \n\nc\n\no\n\nr\n\nr\n\ne\n\nl\n\na\n\nt\n\ni\n\no\n\nn\n\ns\n\n \n\nb\n\ne\n\nt\n\nw\n\ne\n\ne\n\nn\n\n \n\ns\n\nt\n\no\n\nc\n\nk\n\n \n\ni\n\nn\n\nd\n\ni\n\nc\n\ne\n\ns\n\n,\n\n \n\nc\n\nr\n\ny\n\np\n\nt\n\no\n\nc\n\nu\n\nr\n\nr\n\ne\n\nn\n\nc\n\ny\n\n \n\np\n\nr\n\ni\n\nc\n\ne\n\ns\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\nc\n\no\n\nm\n\nm\n\no\n\nd\n\ni\n\nt\n\ny\n\n \n\np\n\nr\n\ni\n\nc\n\ne\n\ns\n\n,\n\n \n\nr\n\ne\n\nv\n\ne\n\na\n\nl\n\ni\n\nn\n\ng\n\n \n\nh\n\no\n\nw\n\n \n\nc\n\nh\n\na\n\nn\n\ng\n\ne\n\ns\n\n \n\ni\n\nn\n\n \n\no\n\nn\n\ne\n\n \n\nm\n\na\n\nr\n\nk\n\ne\n\nt\n\n \n\nc\n\na\n\nn\n\n \n\nh\n\na\n\nv\n\ne\n\n \n\nr\n\ni\n\np\n\np\n\nl\n\ne\n\n \n\ne\n\nf\n\nf\n\ne\n\nc\n\nt\n\ns\n\n \n\na\n\nc\n\nr\n\no\n\ns\n\ns\n\n \n\nt\n\nh\n\ne\n\n \n\nf\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\ne\n\nc\n\no\n\ns\n\ny\n\ns\n\nt\n\ne\n\nm\n\n.\n\nI\n\nm\n\np\n\na\n\nc\n\nt\n\n \n\no\n\nf\n\n \n\nM\n\na\n\nc\n\nr\n\no\n\ne\n\nc\n\no\n\nn\n\no\n\nm\n\ni\n\nc\n\n \n\nF\n\na\n\nc\n\nt\n\no\n\nr\n\ns\n\n \n\nI\n\nm\n\np\n\na\n\nc\n\nt\n\n \n\no\n\nf\n\n \n\nI\n\nn\n\nt\n\ne\n\nr\n\ne\n\ns\n\nt\n\n \n\nR\n\na\n\nt\n\ne\n\ns\n\n,\n\n \n\nI\n\nn\n\nf\n\nl\n\na\n\nt\n\ni\n\no\n\nn\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\nG\n\nD\n\nP\n\n \n\nG\n\nr\n\no\n\nw\n\nt\n\nh\n\n \n\no\n\nn\n\n \n\nF\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\nM\n\na\n\nr\n\nk\n\ne\n\nt\n\ns\n\n \n\n5\n\n \n\n4\n\n \n\n3\n\n \n\n2\n\n \n\n1\n\n \n\n0\n\n \n\n-\n\n1\n\n \n\n2\n\n0\n\n1\n\n8\n\n \n\n2\n\n0\n\n1\n\n9\n\n \n\n-\n\n2\n\n \n\n-\n\n3\n\n \n\n-\n\n4\n\n \n\n-\n\n5\n\n \n\n2\n\n0\n\n2\n\n0\n\n \n\n2\n\n0\n\n2\n\n1\n\n \n\n2\n\n0\n\n2\n\n2\n\n \n\n2\n\n0\n\n2\n\n3\n\n \n\nM\n\na\n\nc\n\nr\n\no\n\ne\n\nc\n\no\n\nn\n\no\n\nm\n\ni\n\nc\n\n \n\nf\n\na\n\nc\n\nt\n\no\n\nr\n\ns\n\n \n\ns\n\nu\n\nc\n\nh\n\n \n\na\n\ns\n\n \n\ni\n\nn\n\nt\n\ne\n\nr\n\ne\n\ns\n\nt\n\n \n\nr\n\na\n\nt\n\ne\n\ns\n\n,\n\n \n\ni\n\nn\n\nf\n\nl\n\na\n\nt\n\ni\n\no\n\nn\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\nG\n\nD\n\nP\n\n \n\ng\n\nr\n\no\n\nw\n\nt\n\nh\n\n \n\np\n\nl\n\na\n\ny\n\n \n\na\n\n \n\np\n\ni\n\nv\n\no\n\nt\n\na\n\nl\n\n \n\nr\n\no\n\nl\n\ne\n\n \n\ni\n\nn\n\n \n\ns\n\nh\n\na\n\np\n\ni\n\nn\n\ng\n\n \n\nf\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\nm\n\na\n\nr\n\nk\n\ne\n\nt\n\ns\n\n.\n\n \n\nT\n\nh\n\ni\n\ns\n\n \n\ns\n\ne\n\nc\n\nt\n\ni\n\no\n\nn\n\n \n\na\n\nn\n\na\n\nl\n\ny\n\nz\n\ne\n\ns\n\n \n\nh\n\no\n\nw\n\n \n\nt\n\nh\n\ne\n\ns\n\ne\n\n \n\nf\n\na\n\nc\n\nt\n\no\n\nr\n\ns\n\n \n\nh\n\na\n\nv\n\ne\n\n \n\ni\n\nn\n\nf\n\nl\n\nu\n\ne\n\nn\n\nc\n\ne\n\nd\n\n \n\ns\n\nt\n\no\n\nc\n\nk\n\n,\n\n \n\nc\n\nr\n\ny\n\np\n\nt\n\no\n\nc\n\nu\n\nr\n\nr\n\ne\n\nn\n\nc\n\ny\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\nc\n\no\n\nm\n\nm\n\no\n\nd\n\ni\n\nt\n\ny\n\n \n\nm\n\na\n\nr\n\nk\n\ne\n\nt\n\ns\n\n \n\no\n\nv\n\ne\n\nr\n\n \n\nr\n\ne\n\nc\n\ne\n\nn\n\nt\n\n \n\ny\n\ne\n\na\n\nr\n\ns\n\n,\n\n \n\np\n\nr\n\no\n\nv\n\ni\n\nd\n\ni\n\nn\n\ng\n\n \n\ni\n\nn\n\ns\n\ni\n\ng\n\nh\n\nt\n\ns\n\n \n\ni\n\nn\n\nt\n\no\n\n \n\nt\n\nh\n\ne\n\n \n\nc\n\no\n\nm\n\np\n\nl\n\ne\n\nx\n\n \n\nr\n\ne\n\nl\n\na\n\nt\n\ni\n\no\n\nn\n\ns\n\nh\n\ni\n\np\n\n \n\nb\n\ne\n\nt\n\nw\n\ne\n\ne\n\nn\n\n \n\nt\n\nh\n\ne\n\n \n\ne\n\nc\n\no\n\nn\n\no\n\nm\n\ny\n\n \n\na\n\nn\n\nd\n\n \n\nf\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\nm\n\na\n\nr\n\nk\n\ne\n\nt\n\n \n\np\n\ne\n\nr\n\nf\n\no\n\nr\n\nm\n\na\n\nn\n\nc\n\ne\n\n.\n\n \n\n-\n\nI\n\nn\n\nt\n\ne\n\nr\n\ne\n\ns\n\nt\n\n \n\nR\n\na\n\nt\n\ne\n\ns\n\n \n\n%\n\n \n\n-\n\nI\n\nn\n\nf\n\nl\n\na\n\nt\n\ni\n\no\n\nn\n\n \n\nD\n\na\n\nt\n\na\n\n \n\n%\n\n \n\nG\n\nD\n\nP\n\n \n\nG\n\nr\n\no\n\nw\n\nt\n\nh\n\n \n\n%\n\n \n\n:\n\nu\n\nn\n\ns\n\ne\n\nl\n\ne\n\nc\n\nt\n\ne\n\nd\n\n:\n\n \n\n:\n\nu\n\nn\n\ns\n\ne\n\nl\n\ne\n\nc\n\nt\n\ne\n\nd\n\n:\n\nF\n\nu\n\nt\n\nu\n\nr\n\ne\n\n \n\nP\n\nr\n\ne\n\nd\n\ni\n\nc\n\nt\n\ni\n\no\n\nn\n\ns\n\n \n\na\n\nn\n\nd\n\n \n\nT\n\nr\n\ne\n\nn\n\nd\n\ns\n\n \n\nR\n\ne\n\nl\n\na\n\nt\n\ni\n\nv\n\ne\n\n \n\nG\n\nr\n\no\n\nw\n\nt\n\nh\n\n \n\nT\n\nr\n\ne\n\nn\n\nd\n\ns\n\n \n\nf\n\no\n\nr\n\n \n\nS\n\n&\n\nP\n\n \n\n5\n\n0\n\n0\n\n,\n\n \n\nB\n\ni\n\nt\n\nc\n\no\n\ni\n\nn\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\nO\n\ni\n\nl\n\n \n\nP\n\nr\n\ni\n\nc\n\ne\n\ns\n\n \n\n(\n\n2\n\n0\n\n2\n\n4\n\n \n\nI\n\nn\n\nd\n\ne\n\nx\n\ne\n\nd\n\n \n\nt\n\no\n\n \n\n1\n\n0\n\n0\n\n)\n\n \n\n2\n\n0\n\n2\n\n8\n\n \n\nB\n\na\n\ns\n\ne\n\nd\n\n \n\no\n\nn\n\n \n\nh\n\ni\n\ns\n\nt\n\no\n\nr\n\ni\n\nc\n\na\n\nl\n\n \n\nd\n\na\n\nt\n\na\n\n,\n\n \n\nc\n\nu\n\nr\n\nr\n\ne\n\nn\n\nt\n\n \n\nt\n\nr\n\ne\n\nn\n\nd\n\ns\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\ne\n\nc\n\no\n\nn\n\no\n\nm\n\ni\n\nc\n\n \n\ni\n\nn\n\nd\n\ni\n\nc\n\na\n\nt\n\no\n\nr\n\ns\n\n,\n\n \n\nt\n\nh\n\ni\n\ns\n\n \n\ns\n\ne\n\nc\n\nt\n\ni\n\no\n\nn\n\n \n\np\n\nr\n\ne\n\ns\n\ne\n\nn\n\nt\n\ns\n\n \n\np\n\nr\n\ne\n\nd\n\ni\n\nc\n\nt\n\ni\n\no\n\nn\n\ns", + "type": "text" } ], "role": "user" diff --git a/tests/snapshots/test_app/test_chat_followup/client0/result.json b/tests/snapshots/test_app/test_chat_followup/client0/result.json index f54fe54b15..4d2bf0a1cf 100644 --- a/tests/snapshots/test_app/test_chat_followup/client0/result.json +++ b/tests/snapshots/test_app/test_chat_followup/client0/result.json @@ -12,7 +12,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -82,11 +82,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n Generate 3 very brief follow-up questions that the user would likely ask next.\n Enclose the follow-up questions in double angle brackets. Example:\n <>\n <>\n <>\n Do no repeat questions that have already been asked.\n Make sure the last question ends with \">>\".\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n\n\n\n\nGenerate 3 very brief follow-up questions that the user would likely ask next.\nEnclose the follow-up questions in double angle brackets. Example:\n<>\n<>\n<>\nDo not repeat questions that have already been asked.\nMake sure the last question ends with \">>\".", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_followup/client1/result.json b/tests/snapshots/test_app/test_chat_followup/client1/result.json index 77d77dcdc0..cc69247ea0 100644 --- a/tests/snapshots/test_app/test_chat_followup/client1/result.json +++ b/tests/snapshots/test_app/test_chat_followup/client1/result.json @@ -12,7 +12,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -83,11 +83,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n Generate 3 very brief follow-up questions that the user would likely ask next.\n Enclose the follow-up questions in double angle brackets. Example:\n <>\n <>\n <>\n Do no repeat questions that have already been asked.\n Make sure the last question ends with \">>\".\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n\n\n\n\nGenerate 3 very brief follow-up questions that the user would likely ask next.\nEnclose the follow-up questions in double angle brackets. Example:\n<>\n<>\n<>\nDo not repeat questions that have already been asked.\nMake sure the last question ends with \">>\".", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_hybrid/client0/result.json b/tests/snapshots/test_app/test_chat_hybrid/client0/result.json index 92c4500159..d19e9bebb2 100644 --- a/tests/snapshots/test_app/test_chat_hybrid/client0/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_hybrid/client1/result.json b/tests/snapshots/test_app/test_chat_hybrid/client1/result.json index e29c933c0f..176021189d 100644 --- a/tests/snapshots/test_app/test_chat_hybrid/client1/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client0/result.json b/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client0/result.json index ecb1ec8a9a..bee8251cab 100644 --- a/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client0/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client1/result.json b/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client1/result.json index 276fb50068..bbbf9c6690 100644 --- a/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client1/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client0/result.json b/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client0/result.json index dbe56f1452..cbabece418 100644 --- a/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client0/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client1/result.json b/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client1/result.json index ac5fc33cb3..8b3ef1be8f 100644 --- a/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client1/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_prompt_template/client0/result.json b/tests/snapshots/test_app/test_chat_prompt_template/client0/result.json index 1936bb9b48..0b767e18d6 100644 --- a/tests/snapshots/test_app/test_chat_prompt_template/client0/result.json +++ b/tests/snapshots/test_app/test_chat_prompt_template/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -83,7 +83,7 @@ "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_prompt_template/client1/result.json b/tests/snapshots/test_app/test_chat_prompt_template/client1/result.json index d9a45967ac..38ac425c85 100644 --- a/tests/snapshots/test_app/test_chat_prompt_template/client1/result.json +++ b/tests/snapshots/test_app/test_chat_prompt_template/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -84,7 +84,7 @@ "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json b/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json index 9c559d6ee6..ef964f4322 100644 --- a/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json +++ b/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n Meow like a cat.\n\n ", + "content": ">>> Meow like a cat.", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json b/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json index 942b517d31..0d4b8f2f27 100644 --- a/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json +++ b/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n Meow like a cat.\n\n ", + "content": ">>> Meow like a cat.", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_seed/client0/result.json b/tests/snapshots/test_app/test_chat_seed/client0/result.json index 92c4500159..d19e9bebb2 100644 --- a/tests/snapshots/test_app/test_chat_seed/client0/result.json +++ b/tests/snapshots/test_app/test_chat_seed/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_seed/client1/result.json b/tests/snapshots/test_app/test_chat_seed/client1/result.json index e29c933c0f..176021189d 100644 --- a/tests/snapshots/test_app/test_chat_seed/client1/result.json +++ b/tests/snapshots/test_app/test_chat_seed/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_session_state_persists/client0/result.json b/tests/snapshots/test_app/test_chat_session_state_persists/client0/result.json index 0fe1cb6f19..d8c166fdfc 100644 --- a/tests/snapshots/test_app/test_chat_session_state_persists/client0/result.json +++ b/tests/snapshots/test_app/test_chat_session_state_persists/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_session_state_persists/client1/result.json b/tests/snapshots/test_app/test_chat_session_state_persists/client1/result.json index 9d6149dedb..af76ba74a4 100644 --- a/tests/snapshots/test_app/test_chat_session_state_persists/client1/result.json +++ b/tests/snapshots/test_app/test_chat_session_state_persists/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_stream_followup/client0/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_followup/client0/result.jsonlines index 6a7b95a5d7..3a7a469b65 100644 --- a/tests/snapshots/test_app/test_chat_stream_followup/client0/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_followup/client0/result.jsonlines @@ -1,4 +1,4 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n "}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n Generate 3 very brief follow-up questions that the user would likely ask next.\n Enclose the follow-up questions in double angle brackets. Example:\n <>\n <>\n <>\n Do no repeat questions that have already been asked.\n Make sure the last question ends with \">>\".\n \n \n "}, {"role": "user", "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n\n\n\n\nGenerate 3 very brief follow-up questions that the user would likely ask next.\nEnclose the follow-up questions in double angle brackets. Example:\n<>\n<>\n<>\nDo not repeat questions that have already been asked.\nMake sure the last question ends with \">>\"."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf]. ", "role": "assistant"}} {"delta": {"role": "assistant"}, "context": {"followup_questions": ["What is the capital of Spain?"]}} diff --git a/tests/snapshots/test_app/test_chat_stream_followup/client1/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_followup/client1/result.jsonlines index b894a2ea6b..375a1cc35a 100644 --- a/tests/snapshots/test_app/test_chat_stream_followup/client1/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_followup/client1/result.jsonlines @@ -1,4 +1,4 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n "}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n Generate 3 very brief follow-up questions that the user would likely ask next.\n Enclose the follow-up questions in double angle brackets. Example:\n <>\n <>\n <>\n Do no repeat questions that have already been asked.\n Make sure the last question ends with \">>\".\n \n \n "}, {"role": "user", "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n\n\n\n\nGenerate 3 very brief follow-up questions that the user would likely ask next.\nEnclose the follow-up questions in double angle brackets. Example:\n<>\n<>\n<>\nDo not repeat questions that have already been asked.\nMake sure the last question ends with \">>\"."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf]. ", "role": "assistant"}} {"delta": {"role": "assistant"}, "context": {"followup_questions": ["What is the capital of Spain?"]}} diff --git a/tests/snapshots/test_app/test_chat_stream_session_state_persists/client0/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_session_state_persists/client0/result.jsonlines index f3286e8289..6e8b58f105 100644 --- a/tests/snapshots/test_app/test_chat_stream_session_state_persists/client0/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_session_state_persists/client0/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n "}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n "}, {"role": "user", "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": {"conversation_id": 1234}} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": {"conversation_id": 1234}} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_session_state_persists/client1/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_session_state_persists/client1/result.jsonlines index 7d4c60cddb..0056df7d73 100644 --- a/tests/snapshots/test_app/test_chat_stream_session_state_persists/client1/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_session_state_persists/client1/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n "}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n "}, {"role": "user", "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": {"conversation_id": 1234}} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": {"conversation_id": 1234}} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_text/client0/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_text/client0/result.jsonlines index 4fd9c89494..3d9f7f4e6b 100644 --- a/tests/snapshots/test_app/test_chat_stream_text/client0/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_text/client0/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n "}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n "}, {"role": "user", "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_text/client1/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_text/client1/result.jsonlines index 46afaf35a3..2c3576786d 100644 --- a/tests/snapshots/test_app/test_chat_stream_text/client1/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_text/client1/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n "}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n "}, {"role": "user", "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_text_filter/auth_client0/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_text_filter/auth_client0/result.jsonlines index 2b34548d52..5ec86d73c0 100644 --- a/tests/snapshots/test_app/test_chat_stream_text_filter/auth_client0/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_text_filter/auth_client0/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n "}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": "category ne 'excluded' and (oids/any(g:search.in(g, 'OID_X')) or groups/any(g:search.in(g, 'GROUP_Y, GROUP_Z')))", "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n "}, {"role": "user", "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": "category ne 'excluded' and (oids/any(g:search.in(g, 'OID_X')) or groups/any(g:search.in(g, 'GROUP_Y, GROUP_Z')))", "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_vision/client0/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_vision/client0/result.jsonlines index b9a6b9e5c5..7bdb90607d 100644 --- a/tests/snapshots/test_app/test_chat_stream_vision/client0/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_vision/client0/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Financial Market Analysis Report 2023.pdf#page=6: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions "]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n "}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: Are interest rates high?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "interest rates", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Financial_Market_Analysis_Report_2023_pdf-46696E616E6369616C204D61726B657420416E616C79736973205265706F727420323032332E706466-page-14", "content": "31\nFinancial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors\nImpact of Interest Rates, Inflation, and GDP Growth on Financial Markets\n5\n4\n3\n2\n1\n0\n-1 2018 2019\n-2\n-3\n-4\n-5\n2020\n2021 2022 2023\nMacroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance.\n-Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends\nRelative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100)\n2028\nBased on historical data, current trends, and economic indicators, this section presents predictions ", "embedding": "[-0.012668486, -0.02251158 ...+8 more]", "imageEmbedding": null, "category": null, "sourcepage": "Financial Market Analysis Report 2023-6.png", "sourcefile": "Financial Market Analysis Report 2023.pdf", "oids": null, "groups": null, "captions": [], "score": 0.04972677677869797, "reranker_score": 3.1704962253570557}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n "}, {"role": "user", "content": "Are interest rates high?\n\nSources:\nFinancial Market Analysis Report 2023.pdf#page=6: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions "}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Financial Market Analysis Report 2023.pdf#page=6: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions "]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: Are interest rates high?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "interest rates", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Financial_Market_Analysis_Report_2023_pdf-46696E616E6369616C204D61726B657420416E616C79736973205265706F727420323032332E706466-page-14", "content": "31\nFinancial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors\nImpact of Interest Rates, Inflation, and GDP Growth on Financial Markets\n5\n4\n3\n2\n1\n0\n-1 2018 2019\n-2\n-3\n-4\n-5\n2020\n2021 2022 2023\nMacroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance.\n-Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends\nRelative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100)\n2028\nBased on historical data, current trends, and economic indicators, this section presents predictions ", "embedding": "[-0.012668486, -0.02251158 ...+8 more]", "imageEmbedding": null, "category": null, "sourcepage": "Financial Market Analysis Report 2023-6.png", "sourcefile": "Financial Market Analysis Report 2023.pdf", "oids": null, "groups": null, "captions": [], "score": 0.04972677677869797, "reranker_score": 3.1704962253570557}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "Are interest rates high?\n\nSources:\n\nFinancial Market Analysis Report 2023.pdf#page=6: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions"}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines index bd4866a51b..39b36de126 100644 --- a/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions "], "images": [{"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==", "detail": "auto"}]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n "}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: Are interest rates high?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "interest rates", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "vector_fields": ["embedding", "imageEmbedding"], "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Financial_Market_Analysis_Report_2023_pdf-46696E616E6369616C204D61726B657420416E616C79736973205265706F727420323032332E706466-page-14", "content": "31\nFinancial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors\nImpact of Interest Rates, Inflation, and GDP Growth on Financial Markets\n5\n4\n3\n2\n1\n0\n-1 2018 2019\n-2\n-3\n-4\n-5\n2020\n2021 2022 2023\nMacroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance.\n-Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends\nRelative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100)\n2028\nBased on historical data, current trends, and economic indicators, this section presents predictions ", "embedding": "[-0.012668486, -0.02251158 ...+8 more]", "imageEmbedding": null, "category": null, "sourcepage": "Financial Market Analysis Report 2023-6.png", "sourcefile": "Financial Market Analysis Report 2023.pdf", "oids": null, "groups": null, "captions": [], "score": 0.04972677677869797, "reranker_score": 3.1704962253570557}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "\n You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images.\n Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:\n Each text source starts in a new line and has the file name followed by colon and the actual information\n Always include the source name from the image or text for each fact you use in the response in the format: [filename]\n Answer the following question using only the data provided in the sources below.\n If asking a clarifying question to the user would help, ask the question.\n Be brief in your answers.\n The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned\n If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts.\n \n \n "}, {"role": "user", "content": [{"text": "Are interest rates high?", "type": "text"}, {"text": "\n\nSources:\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions ", "type": "text"}, {"image_url": {"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==", "detail": "auto"}, "type": "image_url"}]}], "props": {"model": "gpt-4"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions "], "images": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=="]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: Are interest rates high?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "interest rates", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "vector_fields": ["embedding", "imageEmbedding"], "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Financial_Market_Analysis_Report_2023_pdf-46696E616E6369616C204D61726B657420416E616C79736973205265706F727420323032332E706466-page-14", "content": "31\nFinancial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors\nImpact of Interest Rates, Inflation, and GDP Growth on Financial Markets\n5\n4\n3\n2\n1\n0\n-1 2018 2019\n-2\n-3\n-4\n-5\n2020\n2021 2022 2023\nMacroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance.\n-Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends\nRelative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100)\n2028\nBased on historical data, current trends, and economic indicators, this section presents predictions ", "embedding": "[-0.012668486, -0.02251158 ...+8 more]", "imageEmbedding": null, "category": null, "sourcepage": "Financial Market Analysis Report 2023-6.png", "sourcefile": "Financial Market Analysis Report 2023.pdf", "oids": null, "groups": null, "captions": [], "score": 0.04972677677869797, "reranker_score": 3.1704962253570557}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images.\nEach image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:\nEach text source starts in a new line and has the file name followed by colon and the actual information\nAlways include the source name from the image or text for each fact you use in the response in the format: [filename]\nAnswer the following question using only the data provided in the sources below.\nIf asking a clarifying question to the user would help, ask the question.\nBe brief in your answers.\nThe text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned\nIf you cannot answer using the sources below, say you don't know. Return just the answer without any input texts."}, {"role": "user", "content": [{"type": "text", "text": "Are interest rates high?"}, {"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=="}}, {"type": "text", "text": "Sources: \n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions"}]}], "props": {"model": "gpt-4"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "From the provided sources, the impact of interest rates and GDP growth on financial markets can be observed through the line graph. [Financial Market Analysis Report 2023-7.png]", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_text/client0/result.json b/tests/snapshots/test_app/test_chat_text/client0/result.json index ab2e7668b6..924d129764 100644 --- a/tests/snapshots/test_app/test_chat_text/client0/result.json +++ b/tests/snapshots/test_app/test_chat_text/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_text/client1/result.json b/tests/snapshots/test_app/test_chat_text/client1/result.json index c5b8b27424..2b84988fd1 100644 --- a/tests/snapshots/test_app/test_chat_text/client1/result.json +++ b/tests/snapshots/test_app/test_chat_text/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_text_filter/auth_client0/result.json b/tests/snapshots/test_app/test_chat_text_filter/auth_client0/result.json index d29eb3d05a..1c885ab857 100644 --- a/tests/snapshots/test_app/test_chat_text_filter/auth_client0/result.json +++ b/tests/snapshots/test_app/test_chat_text_filter/auth_client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_text_filter_public_documents/auth_public_documents_client0/result.json b/tests/snapshots/test_app/test_chat_text_filter_public_documents/auth_public_documents_client0/result.json index 04fea8c332..aabacbdb86 100644 --- a/tests/snapshots/test_app/test_chat_text_filter_public_documents/auth_public_documents_client0/result.json +++ b/tests/snapshots/test_app/test_chat_text_filter_public_documents/auth_public_documents_client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_text_semantic_ranker/client0/result.json b/tests/snapshots/test_app/test_chat_text_semantic_ranker/client0/result.json index 0562d723c7..c025b2e54c 100644 --- a/tests/snapshots/test_app/test_chat_text_semantic_ranker/client0/result.json +++ b/tests/snapshots/test_app/test_chat_text_semantic_ranker/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_text_semantic_ranker/client1/result.json b/tests/snapshots/test_app/test_chat_text_semantic_ranker/client1/result.json index f86a9c4467..558fb49910 100644 --- a/tests/snapshots/test_app/test_chat_text_semantic_ranker/client1/result.json +++ b/tests/snapshots/test_app/test_chat_text_semantic_ranker/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_text_semanticcaptions/client0/result.json b/tests/snapshots/test_app/test_chat_text_semanticcaptions/client0/result.json index d9562e71b6..6213e7cc02 100644 --- a/tests/snapshots/test_app/test_chat_text_semanticcaptions/client0/result.json +++ b/tests/snapshots/test_app/test_chat_text_semanticcaptions/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_text_semanticcaptions/client1/result.json b/tests/snapshots/test_app/test_chat_text_semanticcaptions/client1/result.json index 71a5586c8d..d75153a6b3 100644 --- a/tests/snapshots/test_app/test_chat_text_semanticcaptions/client1/result.json +++ b/tests/snapshots/test_app/test_chat_text_semanticcaptions/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_text_semanticranker/client0/result.json b/tests/snapshots/test_app/test_chat_text_semanticranker/client0/result.json index 0562d723c7..c025b2e54c 100644 --- a/tests/snapshots/test_app/test_chat_text_semanticranker/client0/result.json +++ b/tests/snapshots/test_app/test_chat_text_semanticranker/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_text_semanticranker/client1/result.json b/tests/snapshots/test_app/test_chat_text_semanticranker/client1/result.json index f86a9c4467..558fb49910 100644 --- a/tests/snapshots/test_app/test_chat_text_semanticranker/client1/result.json +++ b/tests/snapshots/test_app/test_chat_text_semanticranker/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_vector/client0/result.json b/tests/snapshots/test_app/test_chat_vector/client0/result.json index bca2bf5eca..7041676e83 100644 --- a/tests/snapshots/test_app/test_chat_vector/client0/result.json +++ b/tests/snapshots/test_app/test_chat_vector/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_vector/client1/result.json b/tests/snapshots/test_app/test_chat_vector/client1/result.json index 4ede77e2bc..2d745baadb 100644 --- a/tests/snapshots/test_app/test_chat_vector/client1/result.json +++ b/tests/snapshots/test_app/test_chat_vector/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client0/result.json b/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client0/result.json index 75a7a1ffce..31f43c5808 100644 --- a/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client0/result.json +++ b/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client1/result.json b/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client1/result.json index 946d53c514..f98540864c 100644 --- a/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client1/result.json +++ b/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -80,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What is the capital of France?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_vision/client0/result.json b/tests/snapshots/test_app/test_chat_vision/client0/result.json index f9d035f5d2..33767fae6f 100644 --- a/tests/snapshots/test_app/test_chat_vision/client0/result.json +++ b/tests/snapshots/test_app/test_chat_vision/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -73,11 +73,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "Are interest rates high?\n\nSources:\nFinancial Market Analysis Report 2023.pdf#page=6: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions ", + "content": "Are interest rates high?\n\nSources:\n\nFinancial Market Analysis Report 2023.pdf#page=6: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_vision/client1/result.json b/tests/snapshots/test_app/test_chat_vision/client1/result.json index 1733837125..aa51ea866c 100644 --- a/tests/snapshots/test_app/test_chat_vision/client1/result.json +++ b/tests/snapshots/test_app/test_chat_vision/client1/result.json @@ -2,10 +2,7 @@ "context": { "data_points": { "images": [ - { - "detail": "auto", - "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==" - } + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==" ], "text": [ "Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions " @@ -15,7 +12,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -83,7 +80,7 @@ { "description": [ { - "content": "\n You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images.\n Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:\n Each text source starts in a new line and has the file name followed by colon and the actual information\n Always include the source name from the image or text for each fact you use in the response in the format: [filename]\n Answer the following question using only the data provided in the sources below.\n If asking a clarifying question to the user would help, ask the question.\n Be brief in your answers.\n The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned\n If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts.\n \n \n ", + "content": "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images.\nEach image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:\nEach text source starts in a new line and has the file name followed by colon and the actual information\nAlways include the source name from the image or text for each fact you use in the response in the format: [filename]\nAnswer the following question using only the data provided in the sources below.\nIf asking a clarifying question to the user would help, ask the question.\nBe brief in your answers.\nThe text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned\nIf you cannot answer using the sources below, say you don't know. Return just the answer without any input texts.", "role": "system" }, { @@ -92,16 +89,15 @@ "text": "Are interest rates high?", "type": "text" }, - { - "text": "\n\nSources:\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions ", - "type": "text" - }, { "image_url": { - "detail": "auto", "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==" }, "type": "image_url" + }, + { + "text": "Sources: \n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions", + "type": "text" } ], "role": "user" diff --git a/tests/snapshots/test_app/test_chat_vision_vectors/client0/result.json b/tests/snapshots/test_app/test_chat_vision_vectors/client0/result.json index 67e182c310..7b4d85a69b 100644 --- a/tests/snapshots/test_app/test_chat_vision_vectors/client0/result.json +++ b/tests/snapshots/test_app/test_chat_vision_vectors/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -79,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "Are interest rates high?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "Are interest rates high?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json b/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json index 507be8e3f9..f8d69c8343 100644 --- a/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json +++ b/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json @@ -2,10 +2,7 @@ "context": { "data_points": { "images": [ - { - "detail": "auto", - "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==" - } + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==" ], "text": [ "Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions " @@ -15,7 +12,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -83,7 +80,7 @@ { "description": [ { - "content": "\n You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images.\n Each image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:\n Each text source starts in a new line and has the file name followed by colon and the actual information\n Always include the source name from the image or text for each fact you use in the response in the format: [filename]\n Answer the following question using only the data provided in the sources below.\n If asking a clarifying question to the user would help, ask the question.\n Be brief in your answers.\n The text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned\n If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts.\n \n \n ", + "content": "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images.\nEach image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:\nEach text source starts in a new line and has the file name followed by colon and the actual information\nAlways include the source name from the image or text for each fact you use in the response in the format: [filename]\nAnswer the following question using only the data provided in the sources below.\nIf asking a clarifying question to the user would help, ask the question.\nBe brief in your answers.\nThe text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned\nIf you cannot answer using the sources below, say you don't know. Return just the answer without any input texts.", "role": "system" }, { @@ -92,16 +89,15 @@ "text": "Are interest rates high?", "type": "text" }, - { - "text": "\n\nSources:\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions ", - "type": "text" - }, { "image_url": { - "detail": "auto", "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==" }, "type": "image_url" + }, + { + "text": "Sources: \n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions", + "type": "text" } ], "role": "user" diff --git a/tests/snapshots/test_app/test_chat_with_history/client0/result.json b/tests/snapshots/test_app/test_chat_with_history/client0/result.json index 5980c140bb..4ebacd76a7 100644 --- a/tests/snapshots/test_app/test_chat_with_history/client0/result.json +++ b/tests/snapshots/test_app/test_chat_with_history/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -28,14 +28,6 @@ "content": "Show available health plans", "role": "assistant" }, - { - "content": "What happens in a performance review?", - "role": "user" - }, - { - "content": "During a performance review, employees will receive feedback on their performance over the past year, including both successes and areas for improvement. The feedback will be provided by the employee's supervisor and is intended to help the employee develop and grow in their role [employee_handbook-3.pdf]. The review is a two-way dialogue between the employee and their manager, so employees are encouraged to be honest and open during the process [employee_handbook-3.pdf]. The employee will also have the opportunity to discuss their goals and objectives for the upcoming year [employee_handbook-3.pdf]. A written summary of the performance review will be provided to the employee, which will include a rating of their performance, feedback, and goals and objectives for the upcoming year [employee_handbook-3.pdf].", - "role": "assistant" - }, { "content": "Generate search query for: Is dental covered?", "role": "user" @@ -87,7 +79,7 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { @@ -99,7 +91,7 @@ "role": "assistant" }, { - "content": "Is dental covered?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "Is dental covered?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_with_history/client1/result.json b/tests/snapshots/test_app/test_chat_with_history/client1/result.json index 1bddfaac88..429e4a904a 100644 --- a/tests/snapshots/test_app/test_chat_with_history/client1/result.json +++ b/tests/snapshots/test_app/test_chat_with_history/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -28,14 +28,6 @@ "content": "Show available health plans", "role": "assistant" }, - { - "content": "What happens in a performance review?", - "role": "user" - }, - { - "content": "During a performance review, employees will receive feedback on their performance over the past year, including both successes and areas for improvement. The feedback will be provided by the employee's supervisor and is intended to help the employee develop and grow in their role [employee_handbook-3.pdf]. The review is a two-way dialogue between the employee and their manager, so employees are encouraged to be honest and open during the process [employee_handbook-3.pdf]. The employee will also have the opportunity to discuss their goals and objectives for the upcoming year [employee_handbook-3.pdf]. A written summary of the performance review will be provided to the employee, which will include a rating of their performance, feedback, and goals and objectives for the upcoming year [employee_handbook-3.pdf].", - "role": "assistant" - }, { "content": "Generate search query for: Is dental covered?", "role": "user" @@ -88,7 +80,7 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { @@ -100,7 +92,7 @@ "role": "assistant" }, { - "content": "Is dental covered?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "Is dental covered?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json b/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json index bccc607425..29fb7b7a72 100644 --- a/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json +++ b/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -28,14 +28,6 @@ "content": "Show available health plans", "role": "assistant" }, - { - "content": "Is there a dress code?", - "role": "user" - }, - { - "content": "Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]", - "role": "assistant" - }, { "content": "Generate search query for: What does a product manager do?", "role": "user" @@ -87,11 +79,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What does a product manager do?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What does a product manager do?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json b/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json index e329a92813..445bb1746c 100644 --- a/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json +++ b/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json @@ -9,7 +9,7 @@ { "description": [ { - "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\n You have access to Azure AI Search index with 100's of documents.\n Generate a search query based on the conversation and the new question.\n Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.\n Do not include any text inside [] or <<>> in the search query terms.\n Do not include any special characters like '+'.\n If the question is not in English, translate the question to English before generating the search query.\n If you cannot generate a search query, return just the number 0.\n ", + "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0.", "role": "system" }, { @@ -28,14 +28,6 @@ "content": "Show available health plans", "role": "assistant" }, - { - "content": "Is there a dress code?", - "role": "user" - }, - { - "content": "Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]", - "role": "assistant" - }, { "content": "Generate search query for: What does a product manager do?", "role": "user" @@ -88,11 +80,11 @@ { "description": [ { - "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\n Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\n If the question is not in English, answer in the language used in the question.\n Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n \n \n ", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].", "role": "system" }, { - "content": "What does a product manager do?\n\nSources:\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What does a product manager do?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/test_chatvisionapproach.py b/tests/test_chatvisionapproach.py index f117178658..b425bacf28 100644 --- a/tests/test_chatvisionapproach.py +++ b/tests/test_chatvisionapproach.py @@ -8,6 +8,7 @@ from openai.types.chat import ChatCompletion from approaches.chatreadretrievereadvision import ChatReadRetrieveReadVisionApproach +from approaches.promptmanager import PromptyManager from core.authentication import AuthenticationHelper from .mocks import MOCK_EMBEDDING_DIMENSIONS, MOCK_EMBEDDING_MODEL_NAME @@ -63,6 +64,7 @@ def chat_approach(openai_client, mock_confidential_client_success): content_field="", query_language="en-us", query_speller="lexicon", + prompt_manager=PromptyManager(), ) From fa958df8d8f7fd18241e40f53a93fe24664dd9ff Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Fri, 10 Jan 2025 12:24:25 -0800 Subject: [PATCH 12/27] Fix type annotations --- app/backend/approaches/chatapproach.py | 3 +-- app/backend/approaches/retrievethenreadvision.py | 2 +- app/backend/core/imageshelper.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/backend/approaches/chatapproach.py b/app/backend/approaches/chatapproach.py index d40fdbc66d..89d6481b51 100644 --- a/app/backend/approaches/chatapproach.py +++ b/app/backend/approaches/chatapproach.py @@ -6,7 +6,6 @@ from openai.types.chat import ChatCompletion, ChatCompletionMessageParam from approaches.approach import Approach -from approaches.promptmanager import RenderedPrompt class ChatApproach(Approach, ABC): @@ -19,7 +18,7 @@ class ChatApproach(Approach, ABC): async def run_until_final_call(self, messages, overrides, auth_claims, should_stream) -> tuple: pass - def get_system_prompt_variables(self, override_prompt: Optional[str]) -> RenderedPrompt: + def get_system_prompt_variables(self, override_prompt: Optional[str]) -> dict[str, str]: # Allows client to replace the entire prompt, or to inject into the existing prompt using >>> if override_prompt is None: return {} diff --git a/app/backend/approaches/retrievethenreadvision.py b/app/backend/approaches/retrievethenreadvision.py index 1183aba967..b308e8221f 100644 --- a/app/backend/approaches/retrievethenreadvision.py +++ b/app/backend/approaches/retrievethenreadvision.py @@ -114,7 +114,7 @@ async def run( text_sources = [] image_sources = [] if send_text_to_gptvision: - text_sources = "\n".join(self.get_sources_content(results, use_semantic_captions, use_image_citation=True)) + text_sources = self.get_sources_content(results, use_semantic_captions, use_image_citation=True) if send_images_to_gptvision: for result in results: url = await fetch_image(self.blob_container_client, result) diff --git a/app/backend/core/imageshelper.py b/app/backend/core/imageshelper.py index 399fecb453..87e8b8970f 100644 --- a/app/backend/core/imageshelper.py +++ b/app/backend/core/imageshelper.py @@ -33,7 +33,7 @@ async def download_blob_as_base64(blob_container_client: ContainerClient, file_p return None -async def fetch_image(blob_container_client: ContainerClient, result: Document) -> Optional[ImageURL]: +async def fetch_image(blob_container_client: ContainerClient, result: Document) -> Optional[str]: if result.sourcepage: img = await download_blob_as_base64(blob_container_client, result.sourcepage) return img From 4ef717c37a10ad2a092d76455d20625ca0b289ac Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Sun, 12 Jan 2025 19:38:37 -0800 Subject: [PATCH 13/27] Update more snapshots --- app/backend/approaches/retrievethenread.py | 3 +-- app/backend/approaches/retrievethenreadvision.py | 7 +------ .../test_app/test_ask_rtr_hybrid/client0/result.json | 2 +- .../test_app/test_ask_rtr_hybrid/client1/result.json | 2 +- .../test_app/test_ask_rtr_text/client0/result.json | 2 +- .../test_app/test_ask_rtr_text/client1/result.json | 2 +- .../test_ask_rtr_text_filter/auth_client0/result.json | 2 +- .../auth_public_documents_client0/result.json | 2 +- .../test_ask_rtr_text_semanticcaptions/client0/result.json | 2 +- .../test_ask_rtr_text_semanticcaptions/client1/result.json | 2 +- .../test_ask_rtr_text_semanticranker/client0/result.json | 2 +- .../test_ask_rtr_text_semanticranker/client1/result.json | 2 +- .../snapshots/test_app/test_ask_vision/client0/result.json | 2 +- .../snapshots/test_app/test_ask_vision/client1/result.json | 6 ++++-- .../test_chat_stream_vision/client1/result.jsonlines | 2 +- .../test_app/test_chat_vision/client1/result.json | 2 +- .../test_app/test_chat_vision_vectors/client1/result.json | 2 +- tests/test_fetch_image.py | 4 +--- 18 files changed, 21 insertions(+), 27 deletions(-) diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index 974b555b69..7a787dca2f 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -107,9 +107,8 @@ async def run( seed=seed, ) - data_points = {"text": text_sources} extra_info = { - "data_points": data_points, + "data_points": {"text": text_sources}, "thoughts": [ ThoughtStep( "Search using user query", diff --git a/app/backend/approaches/retrievethenreadvision.py b/app/backend/approaches/retrievethenreadvision.py index b308e8221f..b671444e99 100644 --- a/app/backend/approaches/retrievethenreadvision.py +++ b/app/backend/approaches/retrievethenreadvision.py @@ -134,13 +134,8 @@ async def run( seed=seed, ) - data_points = { - "text": text_sources, - "images": image_sources, - } - extra_info = { - "data_points": data_points, + "data_points": {"text": text_sources, "images": image_sources}, "thoughts": [ ThoughtStep( "Search using user query", diff --git a/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json index c8ff001c5f..34c2d1d02f 100644 --- a/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json index 4ca69bc01b..329f9a5a2c 100644 --- a/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json index 7542001006..aae67770d8 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json index fa068a61ec..bb81be6b62 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json index 514177b621..165d67c48b 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json index 6402f002f0..856cb1feb5 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json index 71f06bd321..8dc3f5895f 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", + "content": "What is the capital of France?\nSources:\n\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json index a0dacbfe90..40764515f1 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", + "content": "What is the capital of France?\nSources:\n\nBenefit_Options-2.pdf: Caption: A whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json index 90b4482f16..3081b75a4f 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json index 036bae7d17..b9b375020a 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "What is the capital of France?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "What is the capital of France?\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_vision/client0/result.json b/tests/snapshots/test_app/test_ask_vision/client0/result.json index 90b046b833..3a1af082f2 100644 --- a/tests/snapshots/test_app/test_ask_vision/client0/result.json +++ b/tests/snapshots/test_app/test_ask_vision/client0/result.json @@ -59,7 +59,7 @@ "role": "assistant" }, { - "content": "Are interest rates high?\nSources: \n\nBenefit_Options-2.pdf: There is a whistleblower policy.", + "content": "Are interest rates high?\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy.", "role": "user" } ], diff --git a/tests/snapshots/test_app/test_ask_vision/client1/result.json b/tests/snapshots/test_app/test_ask_vision/client1/result.json index 5a3b75e2bb..e2a7bd383f 100644 --- a/tests/snapshots/test_app/test_ask_vision/client1/result.json +++ b/tests/snapshots/test_app/test_ask_vision/client1/result.json @@ -4,7 +4,9 @@ "images": [ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==" ], - "text": "Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions " + "text": [ + "Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions " + ] }, "thoughts": [ { @@ -62,7 +64,7 @@ "type": "image_url" }, { - "text": "Sources: \n\nF\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\nM\n\na\n\nr\n\nk\n\ne\n\nt\n\n \n\nA\n\nn\n\na\n\nl\n\ny\n\ns\n\ni\n\ns\n\n \n\nR\n\ne\n\np\n\no\n\nr\n\nt\n\n \n\n2\n\n0\n\n2\n\n3\n\n-\n\n6\n\n.\n\np\n\nn\n\ng\n\n:\n\n \n\n3\n\n<\n\n/\n\nt\n\nd\n\n>\n\n<\n\nt\n\nd\n\n>\n\n1\n\n<\n\n/\n\nt\n\nd\n\n>\n\n<\n\n/\n\nt\n\nr\n\n>\n\n<\n\n/\n\nt\n\na\n\nb\n\nl\n\ne\n\n>\n\n \n\nF\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\nm\n\na\n\nr\n\nk\n\ne\n\nt\n\ns\n\n \n\na\n\nr\n\ne\n\n \n\ni\n\nn\n\nt\n\ne\n\nr\n\nc\n\no\n\nn\n\nn\n\ne\n\nc\n\nt\n\ne\n\nd\n\n,\n\n \n\nw\n\ni\n\nt\n\nh\n\n \n\nm\n\no\n\nv\n\ne\n\nm\n\ne\n\nn\n\nt\n\ns\n\n \n\ni\n\nn\n\n \n\no\n\nn\n\ne\n\n \n\ns\n\ne\n\ng\n\nm\n\ne\n\nn\n\nt\n\n \n\no\n\nf\n\nt\n\ne\n\nn\n\n \n\ni\n\nn\n\nf\n\nl\n\nu\n\ne\n\nn\n\nc\n\ni\n\nn\n\ng\n\n \n\no\n\nt\n\nh\n\ne\n\nr\n\ns\n\n.\n\n \n\nT\n\nh\n\ni\n\ns\n\n \n\ns\n\ne\n\nc\n\nt\n\ni\n\no\n\nn\n\n \n\ne\n\nx\n\na\n\nm\n\ni\n\nn\n\ne\n\ns\n\n \n\nt\n\nh\n\ne\n\n \n\nc\n\no\n\nr\n\nr\n\ne\n\nl\n\na\n\nt\n\ni\n\no\n\nn\n\ns\n\n \n\nb\n\ne\n\nt\n\nw\n\ne\n\ne\n\nn\n\n \n\ns\n\nt\n\no\n\nc\n\nk\n\n \n\ni\n\nn\n\nd\n\ni\n\nc\n\ne\n\ns\n\n,\n\n \n\nc\n\nr\n\ny\n\np\n\nt\n\no\n\nc\n\nu\n\nr\n\nr\n\ne\n\nn\n\nc\n\ny\n\n \n\np\n\nr\n\ni\n\nc\n\ne\n\ns\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\nc\n\no\n\nm\n\nm\n\no\n\nd\n\ni\n\nt\n\ny\n\n \n\np\n\nr\n\ni\n\nc\n\ne\n\ns\n\n,\n\n \n\nr\n\ne\n\nv\n\ne\n\na\n\nl\n\ni\n\nn\n\ng\n\n \n\nh\n\no\n\nw\n\n \n\nc\n\nh\n\na\n\nn\n\ng\n\ne\n\ns\n\n \n\ni\n\nn\n\n \n\no\n\nn\n\ne\n\n \n\nm\n\na\n\nr\n\nk\n\ne\n\nt\n\n \n\nc\n\na\n\nn\n\n \n\nh\n\na\n\nv\n\ne\n\n \n\nr\n\ni\n\np\n\np\n\nl\n\ne\n\n \n\ne\n\nf\n\nf\n\ne\n\nc\n\nt\n\ns\n\n \n\na\n\nc\n\nr\n\no\n\ns\n\ns\n\n \n\nt\n\nh\n\ne\n\n \n\nf\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\ne\n\nc\n\no\n\ns\n\ny\n\ns\n\nt\n\ne\n\nm\n\n.\n\nI\n\nm\n\np\n\na\n\nc\n\nt\n\n \n\no\n\nf\n\n \n\nM\n\na\n\nc\n\nr\n\no\n\ne\n\nc\n\no\n\nn\n\no\n\nm\n\ni\n\nc\n\n \n\nF\n\na\n\nc\n\nt\n\no\n\nr\n\ns\n\n \n\nI\n\nm\n\np\n\na\n\nc\n\nt\n\n \n\no\n\nf\n\n \n\nI\n\nn\n\nt\n\ne\n\nr\n\ne\n\ns\n\nt\n\n \n\nR\n\na\n\nt\n\ne\n\ns\n\n,\n\n \n\nI\n\nn\n\nf\n\nl\n\na\n\nt\n\ni\n\no\n\nn\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\nG\n\nD\n\nP\n\n \n\nG\n\nr\n\no\n\nw\n\nt\n\nh\n\n \n\no\n\nn\n\n \n\nF\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\nM\n\na\n\nr\n\nk\n\ne\n\nt\n\ns\n\n \n\n5\n\n \n\n4\n\n \n\n3\n\n \n\n2\n\n \n\n1\n\n \n\n0\n\n \n\n-\n\n1\n\n \n\n2\n\n0\n\n1\n\n8\n\n \n\n2\n\n0\n\n1\n\n9\n\n \n\n-\n\n2\n\n \n\n-\n\n3\n\n \n\n-\n\n4\n\n \n\n-\n\n5\n\n \n\n2\n\n0\n\n2\n\n0\n\n \n\n2\n\n0\n\n2\n\n1\n\n \n\n2\n\n0\n\n2\n\n2\n\n \n\n2\n\n0\n\n2\n\n3\n\n \n\nM\n\na\n\nc\n\nr\n\no\n\ne\n\nc\n\no\n\nn\n\no\n\nm\n\ni\n\nc\n\n \n\nf\n\na\n\nc\n\nt\n\no\n\nr\n\ns\n\n \n\ns\n\nu\n\nc\n\nh\n\n \n\na\n\ns\n\n \n\ni\n\nn\n\nt\n\ne\n\nr\n\ne\n\ns\n\nt\n\n \n\nr\n\na\n\nt\n\ne\n\ns\n\n,\n\n \n\ni\n\nn\n\nf\n\nl\n\na\n\nt\n\ni\n\no\n\nn\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\nG\n\nD\n\nP\n\n \n\ng\n\nr\n\no\n\nw\n\nt\n\nh\n\n \n\np\n\nl\n\na\n\ny\n\n \n\na\n\n \n\np\n\ni\n\nv\n\no\n\nt\n\na\n\nl\n\n \n\nr\n\no\n\nl\n\ne\n\n \n\ni\n\nn\n\n \n\ns\n\nh\n\na\n\np\n\ni\n\nn\n\ng\n\n \n\nf\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\nm\n\na\n\nr\n\nk\n\ne\n\nt\n\ns\n\n.\n\n \n\nT\n\nh\n\ni\n\ns\n\n \n\ns\n\ne\n\nc\n\nt\n\ni\n\no\n\nn\n\n \n\na\n\nn\n\na\n\nl\n\ny\n\nz\n\ne\n\ns\n\n \n\nh\n\no\n\nw\n\n \n\nt\n\nh\n\ne\n\ns\n\ne\n\n \n\nf\n\na\n\nc\n\nt\n\no\n\nr\n\ns\n\n \n\nh\n\na\n\nv\n\ne\n\n \n\ni\n\nn\n\nf\n\nl\n\nu\n\ne\n\nn\n\nc\n\ne\n\nd\n\n \n\ns\n\nt\n\no\n\nc\n\nk\n\n,\n\n \n\nc\n\nr\n\ny\n\np\n\nt\n\no\n\nc\n\nu\n\nr\n\nr\n\ne\n\nn\n\nc\n\ny\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\nc\n\no\n\nm\n\nm\n\no\n\nd\n\ni\n\nt\n\ny\n\n \n\nm\n\na\n\nr\n\nk\n\ne\n\nt\n\ns\n\n \n\no\n\nv\n\ne\n\nr\n\n \n\nr\n\ne\n\nc\n\ne\n\nn\n\nt\n\n \n\ny\n\ne\n\na\n\nr\n\ns\n\n,\n\n \n\np\n\nr\n\no\n\nv\n\ni\n\nd\n\ni\n\nn\n\ng\n\n \n\ni\n\nn\n\ns\n\ni\n\ng\n\nh\n\nt\n\ns\n\n \n\ni\n\nn\n\nt\n\no\n\n \n\nt\n\nh\n\ne\n\n \n\nc\n\no\n\nm\n\np\n\nl\n\ne\n\nx\n\n \n\nr\n\ne\n\nl\n\na\n\nt\n\ni\n\no\n\nn\n\ns\n\nh\n\ni\n\np\n\n \n\nb\n\ne\n\nt\n\nw\n\ne\n\ne\n\nn\n\n \n\nt\n\nh\n\ne\n\n \n\ne\n\nc\n\no\n\nn\n\no\n\nm\n\ny\n\n \n\na\n\nn\n\nd\n\n \n\nf\n\ni\n\nn\n\na\n\nn\n\nc\n\ni\n\na\n\nl\n\n \n\nm\n\na\n\nr\n\nk\n\ne\n\nt\n\n \n\np\n\ne\n\nr\n\nf\n\no\n\nr\n\nm\n\na\n\nn\n\nc\n\ne\n\n.\n\n \n\n-\n\nI\n\nn\n\nt\n\ne\n\nr\n\ne\n\ns\n\nt\n\n \n\nR\n\na\n\nt\n\ne\n\ns\n\n \n\n%\n\n \n\n-\n\nI\n\nn\n\nf\n\nl\n\na\n\nt\n\ni\n\no\n\nn\n\n \n\nD\n\na\n\nt\n\na\n\n \n\n%\n\n \n\nG\n\nD\n\nP\n\n \n\nG\n\nr\n\no\n\nw\n\nt\n\nh\n\n \n\n%\n\n \n\n:\n\nu\n\nn\n\ns\n\ne\n\nl\n\ne\n\nc\n\nt\n\ne\n\nd\n\n:\n\n \n\n:\n\nu\n\nn\n\ns\n\ne\n\nl\n\ne\n\nc\n\nt\n\ne\n\nd\n\n:\n\nF\n\nu\n\nt\n\nu\n\nr\n\ne\n\n \n\nP\n\nr\n\ne\n\nd\n\ni\n\nc\n\nt\n\ni\n\no\n\nn\n\ns\n\n \n\na\n\nn\n\nd\n\n \n\nT\n\nr\n\ne\n\nn\n\nd\n\ns\n\n \n\nR\n\ne\n\nl\n\na\n\nt\n\ni\n\nv\n\ne\n\n \n\nG\n\nr\n\no\n\nw\n\nt\n\nh\n\n \n\nT\n\nr\n\ne\n\nn\n\nd\n\ns\n\n \n\nf\n\no\n\nr\n\n \n\nS\n\n&\n\nP\n\n \n\n5\n\n0\n\n0\n\n,\n\n \n\nB\n\ni\n\nt\n\nc\n\no\n\ni\n\nn\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\nO\n\ni\n\nl\n\n \n\nP\n\nr\n\ni\n\nc\n\ne\n\ns\n\n \n\n(\n\n2\n\n0\n\n2\n\n4\n\n \n\nI\n\nn\n\nd\n\ne\n\nx\n\ne\n\nd\n\n \n\nt\n\no\n\n \n\n1\n\n0\n\n0\n\n)\n\n \n\n2\n\n0\n\n2\n\n8\n\n \n\nB\n\na\n\ns\n\ne\n\nd\n\n \n\no\n\nn\n\n \n\nh\n\ni\n\ns\n\nt\n\no\n\nr\n\ni\n\nc\n\na\n\nl\n\n \n\nd\n\na\n\nt\n\na\n\n,\n\n \n\nc\n\nu\n\nr\n\nr\n\ne\n\nn\n\nt\n\n \n\nt\n\nr\n\ne\n\nn\n\nd\n\ns\n\n,\n\n \n\na\n\nn\n\nd\n\n \n\ne\n\nc\n\no\n\nn\n\no\n\nm\n\ni\n\nc\n\n \n\ni\n\nn\n\nd\n\ni\n\nc\n\na\n\nt\n\no\n\nr\n\ns\n\n,\n\n \n\nt\n\nh\n\ni\n\ns\n\n \n\ns\n\ne\n\nc\n\nt\n\ni\n\no\n\nn\n\n \n\np\n\nr\n\ne\n\ns\n\ne\n\nn\n\nt\n\ns\n\n \n\np\n\nr\n\ne\n\nd\n\ni\n\nc\n\nt\n\ni\n\no\n\nn\n\ns", + "text": "Sources:\n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions", "type": "text" } ], diff --git a/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines index 39b36de126..b8c73dfa3a 100644 --- a/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions "], "images": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=="]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: Are interest rates high?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "interest rates", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "vector_fields": ["embedding", "imageEmbedding"], "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Financial_Market_Analysis_Report_2023_pdf-46696E616E6369616C204D61726B657420416E616C79736973205265706F727420323032332E706466-page-14", "content": "31\nFinancial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors\nImpact of Interest Rates, Inflation, and GDP Growth on Financial Markets\n5\n4\n3\n2\n1\n0\n-1 2018 2019\n-2\n-3\n-4\n-5\n2020\n2021 2022 2023\nMacroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance.\n-Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends\nRelative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100)\n2028\nBased on historical data, current trends, and economic indicators, this section presents predictions ", "embedding": "[-0.012668486, -0.02251158 ...+8 more]", "imageEmbedding": null, "category": null, "sourcepage": "Financial Market Analysis Report 2023-6.png", "sourcefile": "Financial Market Analysis Report 2023.pdf", "oids": null, "groups": null, "captions": [], "score": 0.04972677677869797, "reranker_score": 3.1704962253570557}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images.\nEach image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:\nEach text source starts in a new line and has the file name followed by colon and the actual information\nAlways include the source name from the image or text for each fact you use in the response in the format: [filename]\nAnswer the following question using only the data provided in the sources below.\nIf asking a clarifying question to the user would help, ask the question.\nBe brief in your answers.\nThe text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned\nIf you cannot answer using the sources below, say you don't know. Return just the answer without any input texts."}, {"role": "user", "content": [{"type": "text", "text": "Are interest rates high?"}, {"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=="}}, {"type": "text", "text": "Sources: \n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions"}]}], "props": {"model": "gpt-4"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions "], "images": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=="]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: Are interest rates high?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "interest rates", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "vector_fields": ["embedding", "imageEmbedding"], "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Financial_Market_Analysis_Report_2023_pdf-46696E616E6369616C204D61726B657420416E616C79736973205265706F727420323032332E706466-page-14", "content": "31\nFinancial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors\nImpact of Interest Rates, Inflation, and GDP Growth on Financial Markets\n5\n4\n3\n2\n1\n0\n-1 2018 2019\n-2\n-3\n-4\n-5\n2020\n2021 2022 2023\nMacroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance.\n-Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends\nRelative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100)\n2028\nBased on historical data, current trends, and economic indicators, this section presents predictions ", "embedding": "[-0.012668486, -0.02251158 ...+8 more]", "imageEmbedding": null, "category": null, "sourcepage": "Financial Market Analysis Report 2023-6.png", "sourcefile": "Financial Market Analysis Report 2023.pdf", "oids": null, "groups": null, "captions": [], "score": 0.04972677677869797, "reranker_score": 3.1704962253570557}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images.\nEach image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:\nEach text source starts in a new line and has the file name followed by colon and the actual information\nAlways include the source name from the image or text for each fact you use in the response in the format: [filename]\nAnswer the following question using only the data provided in the sources below.\nIf asking a clarifying question to the user would help, ask the question.\nBe brief in your answers.\nThe text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned\nIf you cannot answer using the sources below, say you don't know. Return just the answer without any input texts."}, {"role": "user", "content": [{"type": "text", "text": "Are interest rates high?"}, {"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=="}}, {"type": "text", "text": "Sources:\n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions"}]}], "props": {"model": "gpt-4"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "From the provided sources, the impact of interest rates and GDP growth on financial markets can be observed through the line graph. [Financial Market Analysis Report 2023-7.png]", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_vision/client1/result.json b/tests/snapshots/test_app/test_chat_vision/client1/result.json index aa51ea866c..ec9dc5fa8f 100644 --- a/tests/snapshots/test_app/test_chat_vision/client1/result.json +++ b/tests/snapshots/test_app/test_chat_vision/client1/result.json @@ -96,7 +96,7 @@ "type": "image_url" }, { - "text": "Sources: \n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions", + "text": "Sources:\n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions", "type": "text" } ], diff --git a/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json b/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json index f8d69c8343..f1817e3475 100644 --- a/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json +++ b/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json @@ -96,7 +96,7 @@ "type": "image_url" }, { - "text": "Sources: \n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions", + "text": "Sources:\n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions", "type": "text" } ], diff --git a/tests/test_fetch_image.py b/tests/test_fetch_image.py index 4794af3604..73d951ea49 100644 --- a/tests/test_fetch_image.py +++ b/tests/test_fetch_image.py @@ -88,9 +88,7 @@ async def close(self): sourcepage="test.pdf#page2", ) image_url = await fetch_image(blob_container_client, test_document) - assert image_url is not None - assert image_url["url"] == "data:image/png;base64,dGVzdCBjb250ZW50" - assert image_url["detail"] == "auto" + assert image_url == "data:image/png;base64,dGVzdCBjb250ZW50" test_document.sourcepage = "notfound.pdf" image_url = await fetch_image(blob_container_client, test_document) From 37d9346b232072c800d51ca22507257c96c9fa8f Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 13 Jan 2025 09:53:57 -0800 Subject: [PATCH 14/27] Add prompty metadata, revert some unneeded changes --- .vscode/launch.json | 1 - app/backend/approaches/chatapproach.py | 2 -- app/backend/approaches/prompts/ask/answer_question.prompty | 2 ++ app/backend/approaches/prompts/chat/answer_question.prompty | 4 ++-- .../approaches/prompts/chat/answer_question_vision.prompty | 2 ++ app/backend/approaches/prompts/chat/query_rewrite.prompty | 2 ++ 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 6d4ca1c2b2..46bd4f00d4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -36,7 +36,6 @@ { "name": "Tests (Python)", "type": "debugpy", - "python": "${workspaceFolder}/.venv/bin/python", "request": "launch", "program": "${file}", "purpose": ["debug-test"], diff --git a/app/backend/approaches/chatapproach.py b/app/backend/approaches/chatapproach.py index 89d6481b51..0b8eb7c2f0 100644 --- a/app/backend/approaches/chatapproach.py +++ b/app/backend/approaches/chatapproach.py @@ -12,8 +12,6 @@ class ChatApproach(Approach, ABC): NO_RESPONSE = "0" - answer_prompt = NotImplemented - @abstractmethod async def run_until_final_call(self, messages, overrides, auth_claims, should_stream) -> tuple: pass diff --git a/app/backend/approaches/prompts/ask/answer_question.prompty b/app/backend/approaches/prompts/ask/answer_question.prompty index 1876c26967..c9ebf2a9d5 100644 --- a/app/backend/approaches/prompts/ask/answer_question.prompty +++ b/app/backend/approaches/prompts/ask/answer_question.prompty @@ -1,4 +1,6 @@ --- +name: Ask +description: Answer a single question (with no chat history) using solely text sources. model: api: chat --- diff --git a/app/backend/approaches/prompts/chat/answer_question.prompty b/app/backend/approaches/prompts/chat/answer_question.prompty index af1030ecf3..121b57a7a7 100644 --- a/app/backend/approaches/prompts/chat/answer_question.prompty +++ b/app/backend/approaches/prompts/chat/answer_question.prompty @@ -1,6 +1,6 @@ --- -name: Chat with vision -description: Answer a question (with chat history) using both text and image sources. +name: Chat +description: Answer a question (with chat history) using solely text sources. model: api: chat --- diff --git a/app/backend/approaches/prompts/chat/answer_question_vision.prompty b/app/backend/approaches/prompts/chat/answer_question_vision.prompty index b7b44a3937..b4990a632e 100644 --- a/app/backend/approaches/prompts/chat/answer_question_vision.prompty +++ b/app/backend/approaches/prompts/chat/answer_question_vision.prompty @@ -1,4 +1,6 @@ --- +name: Chat with vision +description: Answer a question (with chat history) using both text and image sources. model: api: chat --- diff --git a/app/backend/approaches/prompts/chat/query_rewrite.prompty b/app/backend/approaches/prompts/chat/query_rewrite.prompty index 1b286dc211..dd23defeac 100644 --- a/app/backend/approaches/prompts/chat/query_rewrite.prompty +++ b/app/backend/approaches/prompts/chat/query_rewrite.prompty @@ -1,4 +1,6 @@ --- +name: Rewrite RAG query +description: Suggest the optimal search query based on the user's query, examples, and chat history. model: api: chat parameters: From a5074388be2a46249c8cbb4dc1a9324711565907 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 13 Jan 2025 11:37:48 -0800 Subject: [PATCH 15/27] Fix thought process UI keys and data expectations --- .../src/components/AnalysisPanel/ThoughtProcess.tsx | 2 +- .../components/SupportingContent/SupportingContent.tsx | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/frontend/src/components/AnalysisPanel/ThoughtProcess.tsx b/app/frontend/src/components/AnalysisPanel/ThoughtProcess.tsx index b15aef6b30..4c3a62617e 100644 --- a/app/frontend/src/components/AnalysisPanel/ThoughtProcess.tsx +++ b/app/frontend/src/components/AnalysisPanel/ThoughtProcess.tsx @@ -23,7 +23,7 @@ export const ThoughtProcess = ({ thoughts }: Props) => { {t.props && (Object.keys(t.props) || []).map((k: any) => ( - + {k}: {JSON.stringify(t.props?.[k])} ))} diff --git a/app/frontend/src/components/SupportingContent/SupportingContent.tsx b/app/frontend/src/components/SupportingContent/SupportingContent.tsx index 3e9a612cd2..94df0ecca2 100644 --- a/app/frontend/src/components/SupportingContent/SupportingContent.tsx +++ b/app/frontend/src/components/SupportingContent/SupportingContent.tsx @@ -3,7 +3,7 @@ import { parseSupportingContentItem } from "./SupportingContentParser"; import styles from "./SupportingContent.module.css"; interface Props { - supportingContent: string[] | { text: string[]; images?: { url: string }[] }; + supportingContent: string[] | { text: string[]; images?: string[] }; } export const SupportingContent = ({ supportingContent }: Props) => { @@ -14,14 +14,18 @@ export const SupportingContent = ({ supportingContent }: Props) => { {textItems.map((c, ind) => { const parsed = parseSupportingContentItem(c); return ( -
  • +
  • {parsed.title}

  • ); })} {imageItems?.map((img, ind) => { - return ; + return ( +
  • + +
  • + ); })} ); From e4139788c2b994c44faedc07fe74c40e6847def3 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 13 Jan 2025 12:39:42 -0800 Subject: [PATCH 16/27] Resolve issue with injected prompt, update test --- app/backend/approaches/chatapproach.py | 2 +- app/backend/approaches/prompts/chat/answer_question.prompty | 2 +- .../test_chat_prompt_template_concat/client0/result.json | 2 +- .../test_chat_prompt_template_concat/client1/result.json | 2 +- tests/test_app.py | 2 ++ 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/backend/approaches/chatapproach.py b/app/backend/approaches/chatapproach.py index 0b8eb7c2f0..e55fd89c22 100644 --- a/app/backend/approaches/chatapproach.py +++ b/app/backend/approaches/chatapproach.py @@ -20,7 +20,7 @@ def get_system_prompt_variables(self, override_prompt: Optional[str]) -> dict[st # Allows client to replace the entire prompt, or to inject into the existing prompt using >>> if override_prompt is None: return {} - elif override_prompt.startswith("<<<"): + elif override_prompt.startswith(">>>"): return {"injected_prompt": override_prompt[3:]} else: return {"override_prompt": override_prompt} diff --git a/app/backend/approaches/prompts/chat/answer_question.prompty b/app/backend/approaches/prompts/chat/answer_question.prompty index 121b57a7a7..6e3c30da82 100644 --- a/app/backend/approaches/prompts/chat/answer_question.prompty +++ b/app/backend/approaches/prompts/chat/answer_question.prompty @@ -11,7 +11,7 @@ Assistant helps the company employees with their healthcare plan questions, and Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question. If the question is not in English, answer in the language used in the question. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]. -{{ extra_prompt }} +{{ injected_prompt }} {% endif %} {% if include_follow_up_questions %} diff --git a/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json b/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json index ef964f4322..2bc59068c7 100644 --- a/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json +++ b/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json @@ -79,7 +79,7 @@ { "description": [ { - "content": ">>> Meow like a cat.", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n Meow like a cat.", "role": "system" }, { diff --git a/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json b/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json index 0d4b8f2f27..42a9cefe11 100644 --- a/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json +++ b/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json @@ -80,7 +80,7 @@ { "description": [ { - "content": ">>> Meow like a cat.", + "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n Meow like a cat.", "role": "system" }, { diff --git a/tests/test_app.py b/tests/test_app.py index 580e31e5d1..683b2efb6b 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -580,6 +580,8 @@ async def test_chat_prompt_template_concat(client, snapshot): ) assert response.status_code == 200 result = await response.get_json() + assert result["context"]["thoughts"][3]["description"][0]["content"].startswith("Assistant helps") + assert result["context"]["thoughts"][3]["description"][0]["content"].endswith("Meow like a cat.") snapshot.assert_match(json.dumps(result, indent=4), "result.json") From 890b8ad62fc7f504da920ccee69e6f6aa32f66ae Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 13 Jan 2025 12:50:58 -0800 Subject: [PATCH 17/27] Pass in past messages to query rewrite prompt --- app/backend/approaches/chatreadretrieveread.py | 2 +- .../test_chat_with_long_history/client0/result.json | 8 ++++++++ .../test_chat_with_long_history/client1/result.json | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/backend/approaches/chatreadretrieveread.py b/app/backend/approaches/chatreadretrieveread.py index a147ca019a..67598f880f 100644 --- a/app/backend/approaches/chatreadretrieveread.py +++ b/app/backend/approaches/chatreadretrieveread.py @@ -99,7 +99,7 @@ async def run_until_final_call( raise ValueError("The most recent message content must be a string.") rendered_query_prompt = self.prompt_manager.render_prompt( - self.query_rewrite_prompt, {"user_query": original_user_query} + self.query_rewrite_prompt, {"user_query": original_user_query, "past_messages": messages[:-1]} ) tools: List[ChatCompletionToolParam] = self.query_rewrite_tools diff --git a/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json b/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json index 29fb7b7a72..31de3f31f7 100644 --- a/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json +++ b/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json @@ -28,6 +28,14 @@ "content": "Show available health plans", "role": "assistant" }, + { + "content": "Is there a dress code?", + "role": "user" + }, + { + "content": "Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]", + "role": "assistant" + }, { "content": "Generate search query for: What does a product manager do?", "role": "user" diff --git a/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json b/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json index 445bb1746c..68dd8cdbef 100644 --- a/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json +++ b/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json @@ -28,6 +28,14 @@ "content": "Show available health plans", "role": "assistant" }, + { + "content": "Is there a dress code?", + "role": "user" + }, + { + "content": "Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]Yes, there is a dress code at Contoso Electronics. Look sharp! [employee_handbook-1.pdf]", + "role": "assistant" + }, { "content": "Generate search query for: What does a product manager do?", "role": "user" From 794730ded9c0aee0482ade9d10d7a44d9756192f Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 13 Jan 2025 13:57:27 -0800 Subject: [PATCH 18/27] Update snapshots --- .../test_app/test_chat_with_history/client0/result.json | 8 ++++++++ .../test_app/test_chat_with_history/client1/result.json | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/tests/snapshots/test_app/test_chat_with_history/client0/result.json b/tests/snapshots/test_app/test_chat_with_history/client0/result.json index 4ebacd76a7..7c183e306a 100644 --- a/tests/snapshots/test_app/test_chat_with_history/client0/result.json +++ b/tests/snapshots/test_app/test_chat_with_history/client0/result.json @@ -28,6 +28,14 @@ "content": "Show available health plans", "role": "assistant" }, + { + "content": "What happens in a performance review?", + "role": "user" + }, + { + "content": "During a performance review, employees will receive feedback on their performance over the past year, including both successes and areas for improvement. The feedback will be provided by the employee's supervisor and is intended to help the employee develop and grow in their role [employee_handbook-3.pdf]. The review is a two-way dialogue between the employee and their manager, so employees are encouraged to be honest and open during the process [employee_handbook-3.pdf]. The employee will also have the opportunity to discuss their goals and objectives for the upcoming year [employee_handbook-3.pdf]. A written summary of the performance review will be provided to the employee, which will include a rating of their performance, feedback, and goals and objectives for the upcoming year [employee_handbook-3.pdf].", + "role": "assistant" + }, { "content": "Generate search query for: Is dental covered?", "role": "user" diff --git a/tests/snapshots/test_app/test_chat_with_history/client1/result.json b/tests/snapshots/test_app/test_chat_with_history/client1/result.json index 429e4a904a..3a0e189894 100644 --- a/tests/snapshots/test_app/test_chat_with_history/client1/result.json +++ b/tests/snapshots/test_app/test_chat_with_history/client1/result.json @@ -28,6 +28,14 @@ "content": "Show available health plans", "role": "assistant" }, + { + "content": "What happens in a performance review?", + "role": "user" + }, + { + "content": "During a performance review, employees will receive feedback on their performance over the past year, including both successes and areas for improvement. The feedback will be provided by the employee's supervisor and is intended to help the employee develop and grow in their role [employee_handbook-3.pdf]. The review is a two-way dialogue between the employee and their manager, so employees are encouraged to be honest and open during the process [employee_handbook-3.pdf]. The employee will also have the opportunity to discuss their goals and objectives for the upcoming year [employee_handbook-3.pdf]. A written summary of the performance review will be provided to the employee, which will include a rating of their performance, feedback, and goals and objectives for the upcoming year [employee_handbook-3.pdf].", + "role": "assistant" + }, { "content": "Generate search query for: Is dental covered?", "role": "user" From 962791a8245a3e8872c1f0ca9074b46de9fe5ac5 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 Jan 2025 09:10:41 -0800 Subject: [PATCH 19/27] Updated prompty --- app/backend/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/backend/requirements.txt b/app/backend/requirements.txt index 28d804bf29..6746d7dabc 100644 --- a/app/backend/requirements.txt +++ b/app/backend/requirements.txt @@ -342,7 +342,7 @@ portalocker==2.10.1 # via msal-extensions priority==2.0.0 # via hypercorn -prompty==0.1.39 +prompty==0.1.44 # via -r requirements.in propcache==0.2.0 # via yarl From 9492378e9b085956b1e28f09494d9984a441eb6f Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 Jan 2025 09:13:39 -0800 Subject: [PATCH 20/27] Removing prompty from types now that it has them --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7655107c52..1253029595 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,6 @@ module = [ "kiota.*", "azure.cognitiveservices.*", "azure.cognitiveservices.speech.*", - "pymupdf.*", - "prompty.*", + "pymupdf.*" ] ignore_missing_imports = true From c46cb4211b7200b0672db5b3985a59e27c7e9bb3 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 Jan 2025 09:58:06 -0800 Subject: [PATCH 21/27] Add samples to the non-vision approaches --- .../approaches/prompts/ask/answer_question.prompty | 6 ++++++ .../approaches/prompts/chat/answer_question.prompty | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/backend/approaches/prompts/ask/answer_question.prompty b/app/backend/approaches/prompts/ask/answer_question.prompty index c9ebf2a9d5..8d0eb23145 100644 --- a/app/backend/approaches/prompts/ask/answer_question.prompty +++ b/app/backend/approaches/prompts/ask/answer_question.prompty @@ -3,6 +3,12 @@ name: Ask description: Answer a single question (with no chat history) using solely text sources. model: api: chat +sample: + user_query: What does a product manager do? + text_sources: + - "role_library.pdf#page=29: The Manager of Product Management will collaborate with internal teams, such as engineering, sales, marketing, and finance, as well as external partners, suppliers, and customers to ensure successful product execution. Responsibilities: · Lead the product management team and provide guidance on product strategy, design, development, and launch. · Develop and implement product life-cycle management processes. · Monitor and analyze industry trends to identify opportunities for new products. · Develop product marketing plans and go-to-market strategies. · Research customer needs and develop customer-centric product roadmaps. · Collaborate with internal teams to ensure product execution and successful launch. · Develop pricing strategies and cost models. · Oversee product portfolio and performance metrics. · Manage product development budget. · Analyze product performance and customer feedback to identify areas for improvement. Qualifications: · Bachelor's degree in business, engineering, or a related field. · At least 5 years of experience in product management. · Proven track record of successful product launches." + - "role_library.pdf#page=23: Company: Contoso Electronics Location: Anywhere Job Type: Full-Time Salary: Competitive, commensurate with experience Job Summary: The Senior Manager of Product Management will be responsible for leading the product management team at Contoso Electronics. This role includes developing strategies, plans and objectives for the product management team and managing the day-to-day operations. The Senior Manager of Product Management will be responsible for the successful launch of new products and the optimization of existing products. Responsibilities: · Develop and implement product management strategies, plans and objectives to maximize team performance. · Analyze competitive landscape and market trends to develop product strategies. · Lead the product management team in the development of product plans, roadmaps and launch plans. · Monitor the performance of product management team, analyze results and implement corrective action as needed. · Manage the product lifecycle, including product development, launch, and end of life. · Ensure product features and benefits meet customer requirements. · Establish and maintain relationships with key customers, partners, and vendors." + - "role_library.pdf#page=28: · 7+ years of experience in research and development in the electronics sector. · Proven track record of successfully designing, testing, and optimizing products. · Experience leading a team of researchers and engineers. · Excellent problem-solving and analytical skills. · Ability to work in a fast-paced environment and meet tight deadlines.· Knowledge of industry trends, technologies, and regulations. · Excellent communication and presentation skills. Manager of Product Management Job Title: Manager of Product Management, Contoso Electronics Job Summary: The Manager of Product Management is responsible for overseeing the product management team, driving product development and marketing strategy for Contoso Electronics. This individual will be accountable for the successful launch of new products and the implementation of product life-cycle management processes. The Manager of Product Management will collaborate with internal teams, such as engineering, sales, marketing, and finance, as well as external partners, suppliers, and customers to ensure successful product execution." --- You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. diff --git a/app/backend/approaches/prompts/chat/answer_question.prompty b/app/backend/approaches/prompts/chat/answer_question.prompty index 6e3c30da82..4eb28e295f 100644 --- a/app/backend/approaches/prompts/chat/answer_question.prompty +++ b/app/backend/approaches/prompts/chat/answer_question.prompty @@ -3,6 +3,18 @@ name: Chat description: Answer a question (with chat history) using solely text sources. model: api: chat +sample: + user_query: What does a product manager do that a CEO doesn't? + include_follow_up_questions: true + past_messages: + - role: user + content: "What does a CEO do?" + - role: assistant + content: "A CEO, or Chief Executive Officer, is responsible for providing strategic direction and oversight to a company to ensure its long-term success and profitability. They develop and implement strategies and objectives for financial success and growth, provide guidance to the executive team, manage day-to-day operations, ensure compliance with laws and regulations, develop and maintain relationships with stakeholders, monitor industry trends, and represent the company in public events 12. [role_library.pdf#page=1][role_library.pdf#page=3]" + text_sources: + - "role_library.pdf#page=29: The Manager of Product Management will collaborate with internal teams, such as engineering, sales, marketing, and finance, as well as external partners, suppliers, and customers to ensure successful product execution. Responsibilities: · Lead the product management team and provide guidance on product strategy, design, development, and launch. · Develop and implement product life-cycle management processes. · Monitor and analyze industry trends to identify opportunities for new products. · Develop product marketing plans and go-to-market strategies. · Research customer needs and develop customer-centric product roadmaps. · Collaborate with internal teams to ensure product execution and successful launch. · Develop pricing strategies and cost models. · Oversee product portfolio and performance metrics. · Manage product development budget. · Analyze product performance and customer feedback to identify areas for improvement. Qualifications: · Bachelor's degree in business, engineering, or a related field. · At least 5 years of experience in product management. · Proven track record of successful product launches." + - "role_library.pdf#page=23: Company: Contoso Electronics Location: Anywhere Job Type: Full-Time Salary: Competitive, commensurate with experience Job Summary: The Senior Manager of Product Management will be responsible for leading the product management team at Contoso Electronics. This role includes developing strategies, plans and objectives for the product management team and managing the day-to-day operations. The Senior Manager of Product Management will be responsible for the successful launch of new products and the optimization of existing products. Responsibilities: · Develop and implement product management strategies, plans and objectives to maximize team performance. · Analyze competitive landscape and market trends to develop product strategies. · Lead the product management team in the development of product plans, roadmaps and launch plans. · Monitor the performance of product management team, analyze results and implement corrective action as needed. · Manage the product lifecycle, including product development, launch, and end of life. · Ensure product features and benefits meet customer requirements. · Establish and maintain relationships with key customers, partners, and vendors." + - "role_library.pdf#page=28: · 7+ years of experience in research and development in the electronics sector. · Proven track record of successfully designing, testing, and optimizing products. · Experience leading a team of researchers and engineers. · Excellent problem-solving and analytical skills. · Ability to work in a fast-paced environment and meet tight deadlines.· Knowledge of industry trends, technologies, and regulations. · Excellent communication and presentation skills. Manager of Product Management Job Title: Manager of Product Management, Contoso Electronics Job Summary: The Manager of Product Management is responsible for overseeing the product management team, driving product development and marketing strategy for Contoso Electronics. This individual will be accountable for the successful launch of new products and the implementation of product life-cycle management processes. The Manager of Product Management will collaborate with internal teams, such as engineering, sales, marketing, and finance, as well as external partners, suppliers, and customers to ensure successful product execution." --- {% if override_prompt %} {{ override_prompt }} From adba0c7e88c6d0075d96f7811cc4f9a649e971a6 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 Jan 2025 10:37:03 -0800 Subject: [PATCH 22/27] Rename the prompts to match the tabs --- app/backend/approaches/chatreadretrieveread.py | 6 +++--- app/backend/approaches/chatreadretrievereadvision.py | 6 +++--- ...swer_question.prompty => ask_answer_question.prompty} | 0 ...vision.prompty => ask_answer_question_vision.prompty} | 0 ...wer_question.prompty => chat_answer_question.prompty} | 0 ...ision.prompty => chat_answer_question_vision.prompty} | 0 .../query_rewrite.prompty => chat_query_rewrite.prompty} | 9 ++++++++- ..._rewrite_tools.json => chat_query_rewrite_tools.json} | 0 app/backend/approaches/retrievethenread.py | 2 +- app/backend/approaches/retrievethenreadvision.py | 2 +- 10 files changed, 16 insertions(+), 9 deletions(-) rename app/backend/approaches/prompts/{ask/answer_question.prompty => ask_answer_question.prompty} (100%) rename app/backend/approaches/prompts/{ask/answer_question_vision.prompty => ask_answer_question_vision.prompty} (100%) rename app/backend/approaches/prompts/{chat/answer_question.prompty => chat_answer_question.prompty} (100%) rename app/backend/approaches/prompts/{chat/answer_question_vision.prompty => chat_answer_question_vision.prompty} (100%) rename app/backend/approaches/prompts/{chat/query_rewrite.prompty => chat_query_rewrite.prompty} (69%) rename app/backend/approaches/prompts/{chat/query_rewrite_tools.json => chat_query_rewrite_tools.json} (100%) diff --git a/app/backend/approaches/chatreadretrieveread.py b/app/backend/approaches/chatreadretrieveread.py index 67598f880f..7777b9a741 100644 --- a/app/backend/approaches/chatreadretrieveread.py +++ b/app/backend/approaches/chatreadretrieveread.py @@ -55,9 +55,9 @@ def __init__( self.query_speller = query_speller self.chatgpt_token_limit = get_token_limit(chatgpt_model, default_to_minimum=self.ALLOW_NON_GPT_MODELS) self.prompt_manager = prompt_manager - self.query_rewrite_prompt = self.prompt_manager.load_prompt("chat/query_rewrite.prompty") - self.query_rewrite_tools = self.prompt_manager.load_tools("chat/query_rewrite_tools.json") - self.answer_prompt = self.prompt_manager.load_prompt("chat/answer_question.prompty") + self.query_rewrite_prompt = self.prompt_manager.load_prompt("chat_query_rewrite.prompty") + self.query_rewrite_tools = self.prompt_manager.load_tools("chat_query_rewrite_tools.json") + self.answer_prompt = self.prompt_manager.load_prompt("chat_answer_question.prompty") @overload async def run_until_final_call( diff --git a/app/backend/approaches/chatreadretrievereadvision.py b/app/backend/approaches/chatreadretrievereadvision.py index ac9122a066..3723ea6cd2 100644 --- a/app/backend/approaches/chatreadretrievereadvision.py +++ b/app/backend/approaches/chatreadretrievereadvision.py @@ -66,9 +66,9 @@ def __init__( self.vision_token_provider = vision_token_provider self.chatgpt_token_limit = get_token_limit(gpt4v_model, default_to_minimum=self.ALLOW_NON_GPT_MODELS) self.prompt_manager = prompt_manager - self.query_rewrite_prompt = self.prompt_manager.load_prompt("chat/query_rewrite.prompty") - self.query_rewrite_tools = self.prompt_manager.load_tools("chat/query_rewrite_tools.json") - self.answer_prompt = self.prompt_manager.load_prompt("chat/answer_question_vision.prompty") + self.query_rewrite_prompt = self.prompt_manager.load_prompt("chat_query_rewrite.prompty") + self.query_rewrite_tools = self.prompt_manager.load_tools("chat_query_rewrite_tools.json") + self.answer_prompt = self.prompt_manager.load_prompt("chat_answer_question_vision.prompty") async def run_until_final_call( self, diff --git a/app/backend/approaches/prompts/ask/answer_question.prompty b/app/backend/approaches/prompts/ask_answer_question.prompty similarity index 100% rename from app/backend/approaches/prompts/ask/answer_question.prompty rename to app/backend/approaches/prompts/ask_answer_question.prompty diff --git a/app/backend/approaches/prompts/ask/answer_question_vision.prompty b/app/backend/approaches/prompts/ask_answer_question_vision.prompty similarity index 100% rename from app/backend/approaches/prompts/ask/answer_question_vision.prompty rename to app/backend/approaches/prompts/ask_answer_question_vision.prompty diff --git a/app/backend/approaches/prompts/chat/answer_question.prompty b/app/backend/approaches/prompts/chat_answer_question.prompty similarity index 100% rename from app/backend/approaches/prompts/chat/answer_question.prompty rename to app/backend/approaches/prompts/chat_answer_question.prompty diff --git a/app/backend/approaches/prompts/chat/answer_question_vision.prompty b/app/backend/approaches/prompts/chat_answer_question_vision.prompty similarity index 100% rename from app/backend/approaches/prompts/chat/answer_question_vision.prompty rename to app/backend/approaches/prompts/chat_answer_question_vision.prompty diff --git a/app/backend/approaches/prompts/chat/query_rewrite.prompty b/app/backend/approaches/prompts/chat_query_rewrite.prompty similarity index 69% rename from app/backend/approaches/prompts/chat/query_rewrite.prompty rename to app/backend/approaches/prompts/chat_query_rewrite.prompty index dd23defeac..7738a85cd7 100644 --- a/app/backend/approaches/prompts/chat/query_rewrite.prompty +++ b/app/backend/approaches/prompts/chat_query_rewrite.prompty @@ -4,7 +4,14 @@ description: Suggest the optimal search query based on the user's query, example model: api: chat parameters: - tools: ${file:query_rewrite_tools.json} + tools: ${file:chat_query_rewrite_tools.json} +sample: + user_query: Does it include hearing? + past_messages: + - role: user + content: "What is included in my Northwind Health Plus plan that is not in standard?" + - role: assistant + content: "The Northwind Health Plus plan includes coverage for emergency services, mental health and substance abuse coverage, and out-of-network services, which are not included in the Northwind Standard plan. [Benefit_Options.pdf#page=3]" --- system: Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base. diff --git a/app/backend/approaches/prompts/chat/query_rewrite_tools.json b/app/backend/approaches/prompts/chat_query_rewrite_tools.json similarity index 100% rename from app/backend/approaches/prompts/chat/query_rewrite_tools.json rename to app/backend/approaches/prompts/chat_query_rewrite_tools.json diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index 7a787dca2f..89e8852cae 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -50,7 +50,7 @@ def __init__( self.query_speller = query_speller self.chatgpt_token_limit = get_token_limit(chatgpt_model, self.ALLOW_NON_GPT_MODELS) self.prompt_manager = prompt_manager - self.answer_prompt = self.prompt_manager.load_prompt("ask/answer_question.prompty") + self.answer_prompt = self.prompt_manager.load_prompt("ask_answer_question.prompty") async def run( self, diff --git a/app/backend/approaches/retrievethenreadvision.py b/app/backend/approaches/retrievethenreadvision.py index b671444e99..1e71875d02 100644 --- a/app/backend/approaches/retrievethenreadvision.py +++ b/app/backend/approaches/retrievethenreadvision.py @@ -58,7 +58,7 @@ def __init__( self.vision_token_provider = vision_token_provider self.gpt4v_token_limit = get_token_limit(gpt4v_model, self.ALLOW_NON_GPT_MODELS) self.prompt_manager = prompt_manager - self.answer_prompt = self.prompt_manager.load_prompt("ask/answer_question_vision.prompty") + self.answer_prompt = self.prompt_manager.load_prompt("ask_answer_question_vision.prompty") async def run( self, From 06df17f7c617e2e50a7b5e0d6d57ee5d084e8b35 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 Jan 2025 10:42:18 -0800 Subject: [PATCH 23/27] Add back a comment about RAG flow --- app/backend/app.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/backend/app.py b/app/backend/app.py index f802725c19..039bde7369 100644 --- a/app/backend/app.py +++ b/app/backend/app.py @@ -645,7 +645,8 @@ async def setup_clients(): prompt_manager = PromptyManager() - # Used by the /ask tab + # Set up the two default RAG approaches for /ask and /chat + # RetrieveThenReadApproach is used by /ask for single-turn Q&A current_app.config[CONFIG_ASK_APPROACH] = RetrieveThenReadApproach( search_client=search_client, openai_client=openai_client, @@ -662,7 +663,7 @@ async def setup_clients(): prompt_manager=prompt_manager, ) - # Used by the /chat tab + # ChatReadRetrieveReadApproach is used by /chat for multi-turn conversation current_app.config[CONFIG_CHAT_APPROACH] = ChatReadRetrieveReadApproach( search_client=search_client, openai_client=openai_client, From 753f9a76b7cd9a9d6aedf067a2b006671a580487 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 Jan 2025 10:58:14 -0800 Subject: [PATCH 24/27] Add prompty back to pyproject.toml --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1253029595..7655107c52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ module = [ "kiota.*", "azure.cognitiveservices.*", "azure.cognitiveservices.speech.*", - "pymupdf.*" + "pymupdf.*", + "prompty.*", ] ignore_missing_imports = true From f088bdc754c4f83284c9db29c950b3bad234fa60 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 Jan 2025 11:14:01 -0800 Subject: [PATCH 25/27] Update the docs about customization --- docs/customization.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/customization.md b/docs/customization.md index dfe39a7e97..f15290c1b7 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -5,6 +5,11 @@ This guide provides more details for customizing the Chat App. - [Using your own data](#using-your-own-data) - [Customizing the UI](#customizing-the-ui) - [Customizing the backend](#customizing-the-backend) + - [Chat/Ask tabs](#chatask-tabs) + - [Chat approach](#chat-approach) + - [Chat with vision](#chat-with-vision) + - [Ask tab](#ask-tab) + - [Ask with vision](#ask-with-vision) - [Improving answer quality](#improving-answer-quality) - [Identify the problem point](#identify-the-problem-point) - [Improving OpenAI ChatCompletion results](#improving-openai-chatcompletion-results) @@ -31,11 +36,11 @@ Typically, the primary backend code you'll want to customize is the `app/backend The chat tab uses the approach programmed in [chatreadretrieveread.py](https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/chatreadretrieveread.py). -1. It calls the OpenAI ChatCompletion API (with a temperature of 0) to turn the user question into a good search query. +1. It calls the OpenAI ChatCompletion API to turn the user question into a good search query, using the prompt and tools from [chat_query_rewrite.prompty](https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_query_rewrite.prompty). 2. It queries Azure AI Search for search results for that query (optionally using the vector embeddings for that query). -3. It then combines the search results and original user question, and calls the OpenAI ChatCompletion API (with a temperature of 0.7) to answer the question based on the sources. It includes the last 4K of message history as well (or however many tokens are allowed by the deployed model). +3. It then calls the OpenAI ChatCompletion API to answer the question based on the sources, using the prompt from [chat_answer_question.prompty](https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question.prompty). That call includes the past message history as well (or as many messages fit inside the model's token limit). -The `system_message_chat_conversation` variable is currently tailored to the sample data since it starts with "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook." Change that to match your data. +The prompts are currently tailored to the sample data since they start with "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook." Modify the [chat_query_rewrite.prompty](https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_query_rewrite.prompty) and [chat_answer_question.prompty](https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question.prompty) prompts to match your data. ##### Chat with vision @@ -45,23 +50,25 @@ If you followed the instructions in [docs/gpt4v.md](gpt4v.md) to enable a GPT Vi 2. For this step, it also calculates a vector embedding for the user question using [the Computer Vision vectorize text API](https://learn.microsoft.com/azure/ai-services/computer-vision/how-to/image-retrieval#call-the-vectorize-text-api), and passes that to the Azure AI Search to compare against the `imageEmbeddings` fields in the indexed documents. For each matching document, it downloads the image blob and converts it to a base 64 encoding. 3. When it combines the search results and user question, it includes the base 64 encoded images, and sends along both the text and images to the GPT4 Vision model (similar to this [documentation example](https://platform.openai.com/docs/guides/vision/quick-start)). The model generates a response that includes citations to the images, and the UI renders the base64 encoded images when a citation is clicked. +The prompt for step 2 is currently tailored to the sample data since it starts with "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd.". Modify the [chat_answer_question_vision.prompty](https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question_vision.prompty) prompt to match your data. + #### Ask tab The ask tab uses the approach programmed in [retrievethenread.py](https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/retrievethenread.py). 1. It queries Azure AI Search for search results for the user question (optionally using the vector embeddings for that question). -2. It then combines the search results and user question, and calls the OpenAI ChatCompletion API (with a temperature of 0.3) to answer the question based on the sources. +2. It then combines the search results and user question, and calls the OpenAI ChatCompletion API to answer the question based on the sources, using the prompt from [ask_answer_question.prompty](https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question.prompty). -The `system_chat_template` variable is currently tailored to the sample data since it starts with "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions." Change that to match your data. +The prompt for step 2 is currently tailored to the sample data since it starts with "You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions." Modify [ask_answer_question.prompty](https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question.prompty) to match your data. -#### Read with vision +#### Ask with vision If you followed the instructions in [docs/gpt4v.md](gpt4v.md) to enable the GPT-4 Vision model and then select "Use GPT vision model", then the ask tab will use the `retrievethenreadvision.py` approach instead. This approach is similar to the `retrievethenread.py` approach, with a few differences: 1. For this step, it also calculates a vector embedding for the user question using [the Computer Vision vectorize text API](https://learn.microsoft.com/azure/ai-services/computer-vision/how-to/image-retrieval#call-the-vectorize-text-api), and passes that to the Azure AI Search to compare against the `imageEmbeddings` fields in the indexed documents. For each matching document, it downloads the image blob and converts it to a base 64 encoding. 2. When it combines the search results and user question, it includes the base 64 encoded images, and sends along both the text and images to the GPT4 Vision model (similar to this [documentation example](https://platform.openai.com/docs/guides/vision/quick-start)). The model generates a response that includes citations to the images, and the UI renders the base64 encoded images when a citation is clicked. -The `system_message_chat_conversation` variable is currently tailored to the sample data since it starts with "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd". Change that to match your data. +The prompt for step 2 is currently tailored to the sample data since it starts with "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd". Modify the [ask_answer_question_vision.prompty](https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question_vision.prompty) prompt to match your data. #### Making settings overrides permanent From ca4d37b884239239bf20dcb9884f15ae1e482c5b Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 Jan 2025 11:35:59 -0800 Subject: [PATCH 26/27] Update to pyproject now that prompty is typed --- app/backend/requirements.txt | 2 +- pyproject.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/backend/requirements.txt b/app/backend/requirements.txt index 6746d7dabc..09518e0f70 100644 --- a/app/backend/requirements.txt +++ b/app/backend/requirements.txt @@ -342,7 +342,7 @@ portalocker==2.10.1 # via msal-extensions priority==2.0.0 # via hypercorn -prompty==0.1.44 +prompty==0.1.45 # via -r requirements.in propcache==0.2.0 # via yarl diff --git a/pyproject.toml b/pyproject.toml index 7655107c52..9e12e399f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,5 @@ module = [ "azure.cognitiveservices.*", "azure.cognitiveservices.speech.*", "pymupdf.*", - "prompty.*", ] ignore_missing_imports = true From 8354c935619fa42f0c6c289a47f4cfac2d6a31ec Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 Jan 2025 12:12:37 -0800 Subject: [PATCH 27/27] Fix vision approach missing past messages --- app/backend/approaches/chatreadretrievereadvision.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/backend/approaches/chatreadretrievereadvision.py b/app/backend/approaches/chatreadretrievereadvision.py index 3723ea6cd2..3c05d22180 100644 --- a/app/backend/approaches/chatreadretrievereadvision.py +++ b/app/backend/approaches/chatreadretrievereadvision.py @@ -97,7 +97,7 @@ async def run_until_final_call( # Use prompty to prepare the query prompt rendered_query_prompt = self.prompt_manager.render_prompt( - self.query_rewrite_prompt, {"user_query": original_user_query} + self.query_rewrite_prompt, {"user_query": original_user_query, "past_messages": messages[:-1]} ) tools: List[ChatCompletionToolParam] = self.query_rewrite_tools