Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dh-5003/updating prompts to always retrieve instructions #249

Merged
Merged
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
13 changes: 7 additions & 6 deletions dataherald/utils/agent_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Here is the plan you have to follow:
{agent_plan}
#
Always use the get_current_datetime tool if there is any time or date in the given question.
Using `current_date()` or `current_datetime()` in SQL queries is banned, use system_time tool to get the exact time of the query execution.
If the question does not seem related to the database, just return "I don't know" as the answer.
If the there is a very similar question among the fewshot examples, modify the SQL query to fit the given question and return the answer.
The SQL query MUST have in-line comments to explain what each clause does.
Expand All @@ -16,7 +16,7 @@
2) Use the db_tables_with_relevance_scores tool to find the a second set of possibly relevant tables.
3) Use the db_relevant_tables_schema tool to obtain the schema of the both sets of possibly relevant tables to identify the possibly relevant columns.
4) Use the db_relevant_columns_info tool to gather more information about the possibly relevant columns, filtering them to find the relevant ones.
5) [Optional based on the question] Use the get_current_datetime tool if the question has any mentions of time or dates.
5) [Optional based on the question] Use the system_time tool if the question has any mentions of time or dates.
6) [Optional based on the question] Always use the db_column_entity_checker tool to make sure that relevant columns have the cell-values.
7) Use the get_admin_instructions tool to retrieve the DB admin instructions before generating the SQL query.
8) Write a {dialect} query and use sql_db_query tool the Execute the SQL query on the database to obtain the results.
Expand All @@ -25,27 +25,28 @@
tip1) For complex questions that has many relevant columns and tables request for more examples of Question/SQL pairs.
tip2) The maximum number of Question/SQL pairs you can request is {max_examples}.
tip3) If the SQL query resulted in errors, rewrite the SQL query and try again.
tip4) If you are still unsure about which columns and tables to use, ask for more Question/SQL pairs.
tip4) Always call the get_admin_instructions tool before generating the SQL query, it will give you rules to follow when writing the SQL query.
tip5) The Question/SQL pairs are labelled as correct pairs, so you can use them to learn how to construct the SQL query.
""" # noqa: E501

PLAN_WITH_INSTRUCTIONS = """1) Use the db_tables_with_relevance_scores tool to find the a set of possibly relevant tables.
2) Use the db_relevant_tables_schema tool to obtain the schema of possibly relevant tables to identify the possibly relevant columns.
3) Use the db_relevant_columns_info tool to gather more information about the possibly relevant columns, filtering them to find the relevant ones.
4) [Optional based on the question] Use the get_current_datetime tool if the question has any mentions of time or dates.
4) [Optional based on the question] Use the system_time tool if the question has any mentions of time or dates.
5) [Optional based on the question] Always use the db_column_entity_checker tool to make sure that relevant columns have the cell-values.
6) Use the get_admin_instructions tool to retrieve the DB admin instructions before generating the SQL query.
7) Write a {dialect} query and use sql_db_query tool the Execute the SQL query on the database to obtain the results.
#
Some tips to always keep in mind:
tip1) If the SQL query resulted in errors, rewrite the SQL query and try again.
tip2) Always call the get_admin_instructions tool before generating the SQL query, it will give you rules to follow when writing the SQL query.
""" # noqa: E501

PLAN_WITH_FEWSHOT_EXAMPLES = """1) Use the fewshot_examples_retriever tool to retrieve a first set of possibly relevant tables and columns and the SQL syntax to use.
2) Use the db_tables_with_relevance_scores tool to find the a second set of possibly relevant tables.
3) Use the db_relevant_tables_schema tool to obtain the schema of the both sets of possibly relevant tables to identify the possibly relevant columns.
4) Use the db_relevant_columns_info tool to gather more information about the possibly relevant columns, filtering them to find the relevant ones.
5) [Optional based on the question] Use the get_current_datetime tool if the question has any mentions of time or dates.
5) [Optional based on the question] Use the system_time tool if the question has any mentions of time or dates.
6) [Optional based on the question] Always use the db_column_entity_checker tool to make sure that relevant columns have the cell-values.
7) Write a {dialect} query and use sql_db_query tool the Execute the SQL query on the database to obtain the results.
#
Expand All @@ -60,7 +61,7 @@
PLAN_BASE = """1) Use the db_tables_with_relevance_scores tool to find the a set of possibly relevant tables.
2) Use the db_relevant_tables_schema tool to obtain the schema of possibly relevant tables to identify the possibly relevant columns.
3) Use the db_relevant_columns_info tool to gather more information about the possibly relevant columns, filtering them to find the relevant ones.
4) [Optional based on the question] Use the get_current_datetime tool if the question has any mentions of time or dates.
4) [Optional based on the question] Use the system_time tool if the question has any mentions of time or dates.
5) [Optional based on the question] Always use the db_column_entity_checker tool to make sure that relevant columns have the cell-values.
6) Write a {dialect} query and use sql_db_query tool the Execute the SQL query on the database to obtain the results.
#
Expand Down