Skip to content

Commit

Permalink
Dh 4992/new agent (#254)
Browse files Browse the repository at this point in the history
* DH-4992/our new agent

* DH-4992/ add the env var to the .env.example

* Update the prompts

* DH-4992/reformat with black

* Dh-4992/update prompt

* Update prompts
  • Loading branch information
MohammadrezaPourreza authored Nov 17, 2023
1 parent d54fe25 commit f5b237a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dataherald/sql_generator/dataherald_finetuning_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,12 @@ def create_sql_agent(
**kwargs: Dict[str, Any],
) -> AgentExecutor:
tools = toolkit.get_tools()
prefix = prefix.format(dialect=toolkit.dialect)
admin_instructions = ""
for index, instruction in enumerate(toolkit.instructions):
admin_instructions += f"{index+1}) {instruction['instruction']}\n"
prefix = prefix.format(
dialect=toolkit.dialect, admin_instructions=admin_instructions
)
prompt = ZeroShotAgent.create_prompt(
tools,
prefix=prefix,
Expand Down
4 changes: 4 additions & 0 deletions dataherald/utils/agent_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
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 running the SQL query results in an error, rewrite the SQL query and try again. You can use db_schema tool to get the schema of the database.
only rewrite the query when the execution returned an error or it does not follow the instructions provided by the database administrator.
Only rely on generate_sql tool to generate the SQL query.
If the question does not seem related to the database, explain why you cannot answer the question.
Here are the database admin instructions, that all queries must follow:
{admin_instructions}
""" # noqa: E501

0 comments on commit f5b237a

Please sign in to comment.