Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"editor.formatOnSave": true
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "vscode.typescript-language-features",
"editor.formatOnSave": true
},
"[css]": {
Expand Down
20 changes: 18 additions & 2 deletions app/backend/approaches/chatapproach.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@


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"},
# ]
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"},
{"role": "user", "content": "What is Infection Control Policy?"},
{"role": "assistant", "content": "Show available policies"},
]
NO_RESPONSE = "0"

Expand All @@ -36,6 +42,16 @@ class ChatApproach(Approach, ABC):
If you cannot generate a search query, return just the number 0.
"""

# query_prompt_template = """You are an "Whiddon Company Knowledge Assistant" that helps the employees with their Policy and Procedures 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. For tabular information return it as an html table. Do not return markdown format. 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].
# 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.
# """

@property
@abstractmethod
def system_message_chat_conversation(self) -> str:
Expand Down
16 changes: 14 additions & 2 deletions app/backend/approaches/chatreadretrieveread.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,17 @@ def __init__(
self.chatgpt_token_limit = get_token_limit(chatgpt_model)

@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.
# For tabular information return it as an html table. Do not return markdown format. 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}
# """

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.
return """You are an Whiddon Company Knowledge Assistant that helps the employees with their Policy and Procedures questions, and questions about the employee handbook and dont Include Northwind Health Plus Benefits. 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.
For tabular information return it as an html table. Do not return markdown format. 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].
Expand Down Expand Up @@ -113,7 +122,7 @@ async def run_until_final_call(
"properties": {
"search_query": {
"type": "string",
"description": "Query string to retrieve documents from azure search eg: 'Health care plan'",
"description": "Query string to retrieve documents from azure search eg: 'Policy and Procedures'",
}
},
"required": ["search_query"],
Expand All @@ -122,6 +131,9 @@ async def run_until_final_call(
}
]

# "description": "Query string to retrieve documents from azure search eg: 'Health care plan'",


# 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(
Expand Down
19 changes: 17 additions & 2 deletions app/backend/approaches/chatreadretrievereadvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,24 @@ def __init__(
self.chatgpt_token_limit = get_token_limit(gpt4v_model)

@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:<file_name>
# 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.
# For tabular information return it as an html table. Do not return markdown format.
# 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}
# """
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.
You are an intelligent assistant helping analyze the Reports., 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:<file_name>
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]
Expand All @@ -81,7 +96,7 @@ def system_message_chat_conversation(self):
{follow_up_questions_prompt}
{injected_prompt}
"""

async def run_until_final_call(
self,
messages: list[ChatCompletionMessageParam],
Expand Down
13 changes: 12 additions & 1 deletion app/backend/approaches/retrievethenread.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@ 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. "
# + "For tabular information return it as an html table. Do not return markdown format. "
# + "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"
# )


system_chat_template = (
"You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. "
"You are an Whiddon Company Knowledge Assistant that helps the employees with their Policy and Procedures questions, "
+ "and questions about the employee handbook and dont Include Northwind Health Plus Benefits and Contoso. "
+ "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. "
+ "For tabular information return it as an html table. Do not return markdown format. "
Expand Down
14 changes: 13 additions & 1 deletion app/backend/approaches/retrievethenreadvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ 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:<file_name> "
# + "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. "
# + "For tabular information return it as an html table. Do not return markdown format. "
# + "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 "
# )

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. "
"You are an intelligent assistant helping analyze the Reports., 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:<file_name> "
+ "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] "
Expand All @@ -33,6 +44,7 @@ class RetrieveThenReadVisionApproach(Approach):
+ "If you cannot answer using the sources below, say you don't know. Return just the answer without any input texts "
)


def __init__(
self,
*,
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GPT + Enterprise data | Sample</title>
<title>GPT Enterprise</title>
</head>
<body>
<div id="root"></div>
Expand Down
Loading
Loading