Skip to content

Commit

Permalink
updating openai prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
rishsriv committed Jun 26, 2024
1 parent 94d10b2 commit ef714c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 1 addition & 5 deletions prompts/prompt_openai.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
[
{
"role": "system",
"content": "Your role is to convert text question to PostgreSQL queries, given a database schema."
"content": "Your role is to convert a user question to a PostgreSQL query, given a database schema."
},
{
"role": "user",
"content": "Generate a SQL query that answers the question `{user_question}`.\n{instructions}{glossary}\nThis query will run on a database whose schema is represented in this string:\n{table_metadata_string}\n{k_shot_prompt}\nReturn only the SQL query, and nothing else."
},
{
"role": "assistant",
"content": "Given the database schema, here is the SQL query that answers `{user_question}`:\n```sql"
}
]
6 changes: 4 additions & 2 deletions query_generators/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def generate_query(
try:
sys_prompt = chat_prompt[0]["content"]
user_prompt = chat_prompt[1]["content"]
assistant_prompt = chat_prompt[2]["content"]
if len(chat_prompt) == 3:
assistant_prompt = chat_prompt[2]["content"]
except:
raise ValueError("Invalid prompt file. Please use prompt_openai.md")
user_prompt = user_prompt.format(
Expand All @@ -171,7 +172,8 @@ def generate_query(
messages = []
messages.append({"role": "system", "content": sys_prompt})
messages.append({"role": "user", "content": user_prompt})
messages.append({"role": "assistant", "content": assistant_prompt})
if len(chat_prompt) == 3:
messages.append({"role": "assistant", "content": assistant_prompt})

function_to_run = None
package = None
Expand Down

0 comments on commit ef714c0

Please sign in to comment.