From 68686d1946bd6dcf24bd22450c174e44338f969f Mon Sep 17 00:00:00 2001 From: Rishabh Srivastava Date: Wed, 26 Jun 2024 11:06:29 +0800 Subject: [PATCH 1/2] updated claude prompt to make it optimal --- prompts/prompt_anthropic.md | 13 +++++-------- query_generators/anthropic.py | 7 ++----- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/prompts/prompt_anthropic.md b/prompts/prompt_anthropic.md index be4358e..0218051 100644 --- a/prompts/prompt_anthropic.md +++ b/prompts/prompt_anthropic.md @@ -1,12 +1,9 @@ -### Instructions: -Your task is to convert a text question to a SQL query that runs on Postgres, given a database schema. Return the SQL as a markdown string, nothing else. +Your task is to convert a text question to a PostgreSQL query, given a database schema. -### Input: -Generate a SQL query that answers the question `{user_question}`. +The question that you must generate a SQL for is this `{user_question}`. {instructions}{glossary} -This query will run on a database whose schema is represented in this string: +This query will run on a database with the following schema: {table_metadata_string} {k_shot_prompt} -### Response: -{cot_instructions}Given the database schema, here is the SQL query that answers `{user_question}`: -```sql + +Just return the SQL query, nothing else. \ No newline at end of file diff --git a/query_generators/anthropic.py b/query_generators/anthropic.py index 3591a98..8be8ab4 100644 --- a/query_generators/anthropic.py +++ b/query_generators/anthropic.py @@ -48,11 +48,8 @@ def get_completion( ): """Get Anthropic chat completion for a given prompt and model""" generated_text = "" - sys_prompt = prompt.split("### Input:")[0] - user_prompt = prompt.split("### Input:")[1].split("### Response:")[0] - messages = [ - {"role": "user", "content": [{"type": "text", "text": user_prompt}]} - ] + prompt + messages = [{"role": "user", "content": [{"type": "text", "text": prompt}]}] try: completion = anthropic.messages.create( model=model, From 7ec90ce76d530c72dcddee20b1c974391b68bfb3 Mon Sep 17 00:00:00 2001 From: Rishabh Srivastava Date: Wed, 26 Jun 2024 13:15:48 +0800 Subject: [PATCH 2/2] deleted unneded file --- query_generators/anthropic.py | 1 - 1 file changed, 1 deletion(-) diff --git a/query_generators/anthropic.py b/query_generators/anthropic.py index 8be8ab4..b710f50 100644 --- a/query_generators/anthropic.py +++ b/query_generators/anthropic.py @@ -48,7 +48,6 @@ def get_completion( ): """Get Anthropic chat completion for a given prompt and model""" generated_text = "" - prompt messages = [{"role": "user", "content": [{"type": "text", "text": prompt}]}] try: completion = anthropic.messages.create(