Skip to content
Merged
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
10 changes: 5 additions & 5 deletions application/api/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ def ask(question: Question) -> Answer:
search_intent_flag = True

if reject_intent_flag:
answer = Answer(query=search_box, query_intent="reject_search", knowledge_search_result=None,
sql_search_result=None, agent_search_result=None, suggested_question=[])
answer = Answer(query=search_box, query_intent="reject_search", knowledge_search_result=knowledge_search_result,
sql_search_result=sql_search_result, agent_search_result=agent_search_response, suggested_question=[])
return answer
elif search_intent_flag:
normal_search_result = normal_text_search(search_box, model_type,
Expand All @@ -233,7 +233,7 @@ def ask(question: Question) -> Answer:

knowledge_search_result.knowledge_response = response
answer = Answer(query=search_box, query_intent="knowledge_search", knowledge_search_result=knowledge_search_result,
sql_search_result=None, agent_search_result=None, suggested_question=[])
sql_search_result=sql_search_result, agent_search_result=agent_search_response, suggested_question=[])
return answer

else:
Expand Down Expand Up @@ -296,8 +296,8 @@ def ask(question: Question) -> Answer:
agent_search_response.agent_summary = agent_data_analyse_result
agent_search_response.agent_sql_search_result = agent_sql_search_result

answer = Answer(query=search_box, query_intent="agent_search", knowledge_search_result=None,
sql_search_result=None, agent_search_result=None, suggested_question=[])
answer = Answer(query=search_box, query_intent="agent_search", knowledge_search_result=knowledge_search_result,
sql_search_result=sql_search_result, agent_search_result=agent_search_response, suggested_question=[])
return answer


Expand Down
134 changes: 112 additions & 22 deletions application/utils/prompts/generate_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@

"""

agent_system_prompt_dict['llama3-70b-instruct-0'] = """
agent_system_prompt_dict['haiku-20240307v1-0'] = """
you are a data analysis expert as well as a retail expert.
Your current task is to conduct an in-depth analysis of the data.

Expand Down Expand Up @@ -712,7 +712,7 @@

"""

agent_system_prompt_dict['llama3-70b-instruct-0'] = """
agent_system_prompt_dict['sonnet-20240229v1-0'] = """
you are a data analysis expert as well as a retail expert.
Your current task is to conduct an in-depth analysis of the data.

Expand Down Expand Up @@ -756,11 +756,11 @@
The user question is : {question}
"""

agent_user_prompt_dict['llama3-70b-instruct-0'] = """
agent_user_prompt_dict['haiku-20240307v1-0'] = """
The user question is : {question}
"""

agent_user_prompt_dict['llama3-70b-instruct-0'] = """
agent_user_prompt_dict['sonnet-20240229v1-0'] = """
The user question is : {question}
"""

Expand All @@ -773,11 +773,11 @@
You are a data analysis expert in the retail industry
"""

agent_analyse_system_prompt_dict['llama3-70b-instruct-0'] = """
agent_analyse_system_prompt_dict['haiku-20240307v1-0'] = """
You are a data analysis expert in the retail industry
"""

agent_analyse_system_prompt_dict['llama3-70b-instruct-0'] = """
agent_analyse_system_prompt_dict['sonnet-20240229v1-0'] = """
You are a data analysis expert in the retail industry
"""

Expand Down Expand Up @@ -817,7 +817,7 @@
Think step by step.
"""

agent_analyse_user_prompt_dict['llama3-70b-instruct-0'] = """
agent_analyse_user_prompt_dict['haiku-20240307v1-0'] = """
As a professional data analyst, you are now asked a question by a user, and you need to analyze the data provided.

<instructions>
Expand All @@ -835,7 +835,7 @@
Think step by step.
"""

agent_analyse_user_prompt_dict['llama3-70b-instruct-0'] = """
agent_analyse_user_prompt_dict['sonnet-20240229v1-0'] = """
As a professional data analyst, you are now asked a question by a user, and you need to analyze the data provided.

<instructions>
Expand Down Expand Up @@ -863,11 +863,11 @@
You are a data analysis expert in the retail industry
"""

data_summary_system_prompt_dict['llama3-70b-instruct-0'] = """
data_summary_system_prompt_dict['haiku-20240307v1-0'] = """
You are a data analysis expert in the retail industry
"""

data_summary_system_prompt_dict['llama3-70b-instruct-0'] = """
data_summary_system_prompt_dict['sonnet-20240229v1-0'] = """
You are a data analysis expert in the retail industry
"""

Expand Down Expand Up @@ -897,7 +897,7 @@
The data is:{data}
"""

data_summary_user_prompt_dict['llama3-70b-instruct-0'] = """
data_summary_user_prompt_dict['haiku-20240307v1-0'] = """
Your task is to analyze the given data and describe it in natural language.

<instructions>
Expand All @@ -910,7 +910,7 @@
The data is:{data}
"""

data_summary_user_prompt_dict['llama3-70b-instruct-0'] = """
data_summary_user_prompt_dict['sonnet-20240229v1-0'] = """
Your task is to analyze the given data and describe it in natural language.

<instructions>
Expand All @@ -926,27 +926,117 @@
# data visualization selection

data_visualization_system_prompt_dict['mixtral-8x7b-instruct-0'] = """
"""
You are a data analysis expert, and now you need to choose the appropriate visualization format based on the user's questions and data.
There are three display types in total: table, bar, pie, and line. The output format is in JSON format.
The fields are as follows:
show_type: The type of display
data: The specific data

data_visualization_system_prompt_dict['llama3-70b-instruct-0'] = """
"""
<instructions>
- The format of format_data is a nested structure of a list, with the first element being the column name.
- If show_type is bar, pie, or line, then format_data needs to select 2 columns from the input data, where the first column is the x-axis and the second column is the y-axis.
- If show_type is table, The number of columns format_data can exceed 2
</instructions>

The example data is:
<example>

{{
"show_type" : "bar",
"format_data" : [['gender', 'num_users'], ['F', 1906], ['M', 1788]]
}}

<example>"""

data_visualization_system_prompt_dict['llama3-70b-instruct-0'] = """
You are a data analysis expert, and now you need to choose the appropriate visualization format based on the user's questions and data.
There are three display types in total: table, bar, pie, and line. The output format is in JSON format.
The fields are as follows:
show_type: The type of display
data: The specific data

<instructions>
- The format of format_data is a nested structure of a list, with the first element being the column name.
- If show_type is bar, pie, or line, then format_data needs to select 2 columns from the input data, where the first column is the x-axis and the second column is the y-axis.
- If show_type is table, The number of columns format_data can exceed 2
</instructions>

The example data is:
<example>

{{
"show_type" : "bar",
"format_data" : [['gender', 'num_users'], ['F', 1906], ['M', 1788]]
}}

<example>
"""

data_visualization_system_prompt_dict['llama3-70b-instruct-0'] = """
data_visualization_system_prompt_dict['haiku-20240307v1-0'] = """
You are a data analysis expert, and now you need to choose the appropriate visualization format based on the user's questions and data.
There are three display types in total: table, bar, pie, and line. The output format is in JSON format.
The fields are as follows:
show_type: The type of display
data: The specific data

<instructions>
- The format of format_data is a nested structure of a list, with the first element being the column name.
- If show_type is bar, pie, or line, then format_data needs to select 2 columns from the input data, where the first column is the x-axis and the second column is the y-axis.
- If show_type is table, The number of columns format_data can exceed 2
</instructions>

The example data is:
<example>

{{
"show_type" : "bar",
"format_data" : [['gender', 'num_users'], ['F', 1906], ['M', 1788]]
}}

<example>
"""

data_visualization_system_prompt_dict['sonnet-20240229v1-0'] = """
You are a data analysis expert, and now you need to choose the appropriate visualization format based on the user's questions and data.
There are three display types in total: table, bar, pie, and line. The output format is in JSON format.
The fields are as follows:
show_type: The type of display
data: The specific data

<instructions>
- The format of format_data is a nested structure of a list, with the first element being the column name.
- If show_type is bar, pie, or line, then format_data needs to select 2 columns from the input data, where the first column is the x-axis and the second column is the y-axis.
- If show_type is table, The number of columns format_data can exceed 2
</instructions>

The example data is:
<example>

{{
"show_type" : "bar",
"format_data" : [['gender', 'num_users'], ['F', 1906], ['M', 1788]]
}}

<example>"""

data_visualization_user_prompt_dict['mixtral-8x7b-instruct-0'] = """
The user question is : {question}
The data is : {data}
"""

data_visualization_user_prompt_dict['llama3-70b-instruct-0'] = """
The user question is : {question}
The data is : {data}
"""

data_visualization_user_prompt_dict['llama3-70b-instruct-0'] = """
data_visualization_user_prompt_dict['haiku-20240307v1-0'] = """
The user question is : {question}
The data is : {data}
"""

data_visualization_user_prompt_dict['llama3-70b-instruct-0'] = """
data_visualization_user_prompt_dict['sonnet-20240229v1-0'] = """
The user question is : {question}
The data is : {data}
"""

# suggest question prompt
Expand All @@ -973,7 +1063,7 @@
</rules>
"""

suggest_question_system_prompt_dict['llama3-70b-instruct-0'] = """
suggest_question_system_prompt_dict['haiku-20240307v1-0'] = """
You are a query generator, and you need to generate queries based on the input query by following below rules.
<rules>
1. The generated query should be related to the input query. For example, the input query is "What is the average price of the products", the 3 generated queries are "What is the highest price of the products", "What is the lowest price of the products", "What is the total price of the products"
Expand All @@ -984,7 +1074,7 @@
</rules>
"""

suggest_question_system_prompt_dict['llama3-70b-instruct-0'] = """
suggest_question_system_prompt_dict['sonnet-20240229v1-0'] = """
You are a query generator, and you need to generate queries based on the input query by following below rules.
<rules>
1. The generated query should be related to the input query. For example, the input query is "What is the average price of the products", the 3 generated queries are "What is the highest price of the products", "What is the lowest price of the products", "What is the total price of the products"
Expand All @@ -1005,12 +1095,12 @@
Please generate queries based on the input query.
"""

suggest_question_user_prompt_dict['llama3-70b-instruct-0'] = """
suggest_question_user_prompt_dict['haiku-20240307v1-0'] = """
Here is the input query: {question}.
Please generate queries based on the input query.
"""

suggest_question_user_prompt_dict['llama3-70b-instruct-0'] = """
suggest_question_user_prompt_dict['sonnet-20240229v1-0'] = """
Here is the input query: {question}.
Please generate queries based on the input query.
"""
Expand Down