Skip to content

Commit

Permalink
deleted old cold, fixed spacing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rishsriv committed Aug 14, 2023
1 parent a275674 commit 4a54dfc
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions query_generators/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,19 @@ def generate_query(self, question: str) -> dict:
self.err = ""
self.query = ""
self.reason = ""
# with open(self.prompt_file) as file:
# chat_prompt_yaml = yaml.safe_load(file)

# sys_prompt_yaml = chat_prompt_yaml["sys_prompt"]
# sys_prompt = sys_prompt_yaml.format(
# date_now=datetime.datetime.utcnow().date().isoformat(),
# )

# user_prompt_yaml = chat_prompt_yaml["user_prompt"]
# user_prompt = user_prompt_yaml.format(
# user_question=question,
# table_metadata_string=prune_metadata_str(question, self.db_name),
# )
# assistant_prompt = chat_prompt_yaml["assistant_prompt"]

with open(self.prompt_file) as file:
chat_prompt = file.read()

sys_prompt = chat_prompt.split("###Input:")[0]
user_prompt = chat_prompt.split("###Input:")[1].split("### Generated SQL:")[0]
sys_prompt = chat_prompt.split("### Input:")[0]
user_prompt = chat_prompt.split("### Input:")[1].split("### Generated SQL:")[0]
assistant_prompt = chat_prompt.split("### Generated SQL:")[1]

user_prompt = user_prompt.format(
user_question=question,
table_metadata_string=prune_metadata_str(question, self.db_name),
)

messages = []
messages.append({"role": "system", "content": sys_prompt})
messages.append({"role": "user", "content": user_prompt})
Expand Down

0 comments on commit 4a54dfc

Please sign in to comment.