@@ -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" ,
0 commit comments