From 688f7b071361f87ea106a6f8bf4a380e28e0b221 Mon Sep 17 00:00:00 2001 From: mohammadrezapourreza Date: Fri, 22 Mar 2024 12:49:54 -0400 Subject: [PATCH] Fix the entity checker --- dataherald/sql_generator/dataherald_sqlagent.py | 1 + dataherald/utils/agent_prompts.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dataherald/sql_generator/dataherald_sqlagent.py b/dataherald/sql_generator/dataherald_sqlagent.py index f49968d3..d18273ed 100644 --- a/dataherald/sql_generator/dataherald_sqlagent.py +++ b/dataherald/sql_generator/dataherald_sqlagent.py @@ -315,6 +315,7 @@ class ColumnEntityChecker(BaseSQLDatabaseTool, BaseTool): Input: Column name and its corresponding table, and an entity. Output: cell-values found in the column similar to the given entity. Use this tool to get cell values similar to the given entity in the given column. + IF this tool returns no results, try to generate a SQL query regardless. Example Input: table1 -> column2, entity """ diff --git a/dataherald/utils/agent_prompts.py b/dataherald/utils/agent_prompts.py index ec303e30..23779def 100644 --- a/dataherald/utils/agent_prompts.py +++ b/dataherald/utils/agent_prompts.py @@ -19,7 +19,7 @@ 4) Use the DbRelevantTablesSchema tool to obtain the schema of possibly relevant tables to identify the possibly relevant columns. 5) Use the DbRelevantColumnsInfo tool to gather more information about the possibly relevant columns, filtering them to find the relevant ones. 6) [Optional based on the question] Use the SystemTime tool if the question has any mentions of time or dates. -7) For string columns, always use the DbColumnEntityChecker tool to make sure the entity values are present in the relevant columns. +7) For string columns, always use the DbColumnEntityChecker tool to make sure the entity values are present in the relevant columns. Even if the you couldn't find any similar entity values from this tool, you should still write a SQL query. 8) Write a {dialect} query and always use SqlDbQuery tool the Execute the SQL query on the database to check if the results are correct. # Some tips to always keep in mind: @@ -37,7 +37,7 @@ 2) Use the DbRelevantTablesSchema tool to obtain the schema of possibly relevant tables to identify the possibly relevant columns. 4) Use the DbRelevantColumnsInfo 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 SystemTime tool if the question has any mentions of time or dates. -6) For string columns, always use the DbColumnEntityChecker tool to make sure the entity values are present in the relevant columns. +6) For string columns, always use the DbColumnEntityChecker tool to make sure the entity values are present in the relevant columns. Even if the you couldn't find any similar entity values from this tool, you should still write a SQL query. 7) Write a {dialect} query and always use SqlDbQuery tool the Execute the SQL query on the database to check if the results are correct. # Some tips to always keep in mind: @@ -53,7 +53,7 @@ 3) Use the DbRelevantTablesSchema tool to obtain the schema of possibly relevant tables to identify the possibly relevant columns. 4) Use the DbRelevantColumnsInfo 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 SystemTime tool if the question has any mentions of time or dates. -6) For string columns, always use the DbColumnEntityChecker tool to make sure the entity values are present in the relevant columns. +6) For string columns, always use the DbColumnEntityChecker tool to make sure the entity values are present in the relevant columns. Even if the you couldn't find any similar entity values from this tool, you should still write a SQL query. 7) Write a {dialect} query and always use SqlDbQuery tool the Execute the SQL query on the database to check if the results are correct. # Some tips to always keep in mind: @@ -69,7 +69,7 @@ 2) Use the DbRelevantTablesSchema tool to obtain the schema of possibly relevant tables to identify the possibly relevant columns. 3) Use the DbRelevantColumnsInfo 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 SystemTime tool if the question has any mentions of time or dates. -5) For string columns, always use the DbColumnEntityChecker tool to make sure the entity values are present in the relevant columns. +5) For string columns, always use the DbColumnEntityChecker tool to make sure the entity values are present in the relevant columns. Even if the you couldn't find any similar entity values from this tool, you should still write a SQL query. 6) Write a {dialect} query and always use SqlDbQuery tool the Execute the SQL query on the database to check if the results are correct. # Some tips to always keep in mind: