Skip to content

Commit

Permalink
DH-5001/removing the markdowns from queries for gpt-4-turbo
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadrezaPourreza committed Nov 14, 2023
1 parent 38a29f9 commit 5d9a521
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dataherald/sql_generator/dataherald_sqlagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ def _run(
run_manager: CallbackManagerForToolRun | None = None, # noqa: ARG002
) -> str:
"""Execute the query, return the results or an error message."""
if '```sql' in query:
query = query.replace('```sql', '').replace('```', '')
return self.db.run_sql(query, top_k=top_k)[0]

async def _arun(
Expand Down Expand Up @@ -690,7 +692,10 @@ def generate_response(
for step in result["intermediate_steps"]:
action = step[0]
if type(action) == AgentAction and action.tool == "sql_db_query":
sql_query_list.append(self.format_sql_query(action.tool_input))
query = self.format_sql_query(action.tool_input)
if '```sql' in query:
query = query.replace('```sql', '').replace('```', '')
sql_query_list.append(query)
intermediate_steps = self.format_intermediate_representations(
result["intermediate_steps"]
)
Expand Down
2 changes: 2 additions & 0 deletions dataherald/utils/models_context_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
"gpt-3.5-turbo-0613": 4000,
"gpt-3.5-turbo-16k-0613": 16000,
"gpt-3.5-turbo-0301": 4000,
"gpt-4-1106-preview": 128000,
"gpt-3.5-turbo-1106": 16000,
}

0 comments on commit 5d9a521

Please sign in to comment.