Skip to content

Commit df13713

Browse files
committed
qol stuff
1 parent ce99726 commit df13713

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

patchwork/common/multiturn_strategy/planning_strategy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,15 @@ def usage(self):
137137
}
138138

139139
def __agent_run(self, agent: Agent, prompt: str, **kwargs) -> AgentRunResult[Any]:
140-
planner_response = agent.run_sync(prompt, **kwargs)
140+
loop = asyncio.new_event_loop()
141+
planner_response = loop.run_until_complete(agent.run(prompt, **kwargs))
142+
loop.close()
141143
self.__request_tokens += planner_response.usage().request_tokens
142144
self.__response_tokens += planner_response.usage().response_tokens
145+
143146
return planner_response
144147

145148
def run(self, task: str, conversation_limit: int = 10) -> dict:
146-
loop = asyncio.new_event_loop()
147149

148150
planner_response = self.__agent_run(self.planner, f"Produce the initial plan for {task}")
149151
planner_history = planner_response.all_messages()
@@ -199,5 +201,4 @@ def run(self, task: str, conversation_limit: int = 10) -> dict:
199201
message_history=planner_history,
200202
)
201203

202-
loop.close()
203204
return final_result.data.dict()

patchwork/common/tools/db_query_tool.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ class DatabaseQueryTool(Tool, tool_name="db_query_tool"):
88
def __init__(self, inputs: dict[str, Any]):
99
super().__init__()
1010
self.db_settings = inputs.copy()
11+
self.db_dialect = inputs.get("db_dialect", "SQL")
1112

1213
@property
1314
def json_schema(self) -> dict:
1415
return {
1516
"name": "db_query_tool",
16-
"description": """\
17-
Run SQL Query on current database.
17+
"description": f"""\
18+
Run SQL Query on current {self.db_dialect} database.
1819
""",
1920
"input_schema": {
2021
"type": "object",

0 commit comments

Comments
 (0)