Skip to content

Commit df7129c

Browse files
committed
add planner db agent to planner docstring
1 parent df13713 commit df7129c

2 files changed

Lines changed: 36 additions & 36 deletions

File tree

patchwork/common/multiturn_strategy/planning_strategy.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,42 @@ def __init__(
8686
executor_tool_set: dict[str, Tool],
8787
example_json: Union[str, dict[str, Any]] = '{"output":"output text"}',
8888
):
89+
"""
90+
Use this like this::
91+
92+
class DatabaseAgent(Step, input_class=DatabaseAgentInputs, output_class=DatabaseAgentOutputs):
93+
def __init__(self, inputs):
94+
super().__init__(inputs)
95+
96+
llm_client = AioLlmClient.create_aio_client(inputs)
97+
98+
data = inputs.get("prompt_value", {})
99+
self.task = mustache_render(inputs["task"], data)
100+
101+
db_dialect = inputs["db_dialect"]
102+
self.planner = PlanningStrategy(
103+
llm_client,
104+
planner_system_prompt=f'''\\
105+
You are a {db_dialect} database query planning assistant. You are tasked to plan the steps to assist with the provided task.
106+
You will not execute the steps in the plan. The user will do that instead.
107+
The first step of the plan should be as follows:
108+
1. Tell me all tables currently available.
109+
After the list of table names is provided, get the DDL of the tables that is relevant.
110+
Your steps should be clear and concise like the following example:
111+
1. Tell me the column descriptions of the table `orders`.
112+
2. Execute the SQL Query: `SELECT * FROM orders`
113+
After every step, you will be asked to edit the plan so feel free to plan 1 step at a time.
114+
''',
115+
executor_system_prompt=f'''\\
116+
You are a {db_dialect} database query execution assistant. You will be provided instructions on what to do.
117+
''',
118+
)
119+
120+
def run(self) -> dict:
121+
planner_response = self.planner.run(self.task, 10)
122+
return {**planner_response, **self.planner.usage()}
123+
124+
"""
89125
self.planner = Agent(
90126
llm_client,
91127
name="Planner",

patchwork/steps/DatabaseAgent/DatabaseAgent.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,3 @@ def __init__(self, inputs):
4848
def run(self) -> dict:
4949
result = self.agentic_strategy.execute(limit=10)
5050
return {**result, **self.agentic_strategy.usage()}
51-
52-
53-
# class DatabaseAgent(Step, input_class=DatabaseAgentInputs, output_class=DatabaseAgentOutputs):
54-
# def __init__(self, inputs):
55-
# super().__init__(inputs)
56-
#
57-
# llm_client = AioLlmClient.create_aio_client(inputs)
58-
#
59-
# data = inputs.get("prompt_value", {})
60-
# self.task = mustache_render(inputs["task"], data)
61-
#
62-
# db_dialect = inputs["db_dialect"]
63-
# self.planner = PlanningStrategy(
64-
# llm_client,
65-
# planner_system_prompt=f"""\
66-
# You are a {db_dialect} database query planning assistant. You are tasked to plan the steps to assist with the provided task.
67-
# You will not execute the steps in the plan. The user will do that instead.
68-
# The first step of the plan should be as follows:
69-
# 1. Tell me all tables currently available.
70-
#
71-
# After the list of table names is provided, get the DDL of the tables that is relevant.
72-
#
73-
# Your steps should be clear and concise like the following example:
74-
# 1. Tell me the column descriptions of the table `orders`.
75-
# 2. Execute the SQL Query: `SELECT * FROM orders`
76-
#
77-
# After every step, you will be asked to edit the plan so feel free to plan 1 step at a time.
78-
# """,
79-
# executor_system_prompt=f"""\
80-
# You are a {db_dialect} database query execution assistant. You will be provided instructions on what to do.
81-
# """,
82-
# )
83-
#
84-
# def run(self) -> dict:
85-
# planner_response = self.planner.run(self.task, 10)
86-
# return {**planner_response, **self.planner.usage()}

0 commit comments

Comments
 (0)