SequentialPlanSynthesis module
SequentialPlan
Bases: Trainable
The sequential step by step plan to achieve the task
Source code in synalinks/src/modules/synthesis/sequential_plan_synthesis.py
SequentialPlanSynthesis
Bases: Module
A module that executes a sequential plan of steps.
This module features a sequential plan as a trainable variable, allowing optimizers to refine the plan during the training loop based on iterative feedback.
Basically learning to plan based on iterative feedback and automatic selection of the best plan.
The module executes each step in the plan sequentially, passing the output of each
step as input to the next step. The runner is responsible for executing
each individual step. The most common runners are usually a FunctionCallingAgent
,
ChainOfThought
or Generator
module, but you can use any Module or Program.
This module start by defaut without any plan, so it is equivalent to a ChainOfThought
module,
iteratively, the plan will be constructed and optimized to solve the task.
This module works ONLY with advanced optimizers (NOT the RandomFewShot
optimizer).
Note: The inputs are forwarded to the runner each time by concatenating the inputs with
the previous steps outputs. So ensure that the runner doesn't returns the inputs, use
return_inputs=False
or return_inputs_with_trajectory=False
when configuring your runner.
Example:
import synalinks
import asyncio
class Query(synalinks.DataModel):
query: str = synalinks.Field(
description="The user query",
)
class FinalReport(synalinks.DataModel):
report: str = synalinks.Field(
description="The final report",
)
class TaskSummary(synalinks.DataModel):
summary: str = synalinks.Field(
description="The summary of the executed task",
)
async def main():
tools = # ... tools definition (see `FunctionCallingAgent`)
inputs = synalinks.Input(data_model=Query)
outputs = await synalinks.SequentialPlanSynthesis(
data_model=FinalReport,
language_model=language_model,
runner=synalinks.FunctionCallingAgent(
data_model=TaskSummary,
language_model=language_model,
tools=tools,
return_inputs_with_trajectory=False,
),
)(inputs)
program = synalinks.Program(
inputs=inputs,
outputs=outputs,
name="planner_agent",
description="An agent that learn a step by step plan to achieve a task",
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema
|
dict
|
The target JSON schema.
If not provided use the |
None
|
data_model
|
DataModel | SymbolicDataModel | JsonDataModel
|
The target data model for structured output. |
None
|
language_model
|
LanguageModel
|
The language model to use. |
None
|
steps
|
list
|
Optional. The default list of steps being a list of strings. |
None
|
seed_steps
|
list
|
Optional. A list of steps to use as seed for the optimization. If not provided, use the default steps as seed. |
None
|
runner
|
Module | Program
|
Required. The runner that executes each step. |
None
|
return_inputs
|
bool
|
Optional. Whether or not to concatenate the inputs to the outputs (Default to False). |
True
|
name
|
str
|
Optional. The name of the module. |
None
|
description
|
str
|
Optional. The description of the module. |
None
|
trainable
|
bool
|
Whether the module's variables should be trainable. |
True
|
Source code in synalinks/src/modules/synthesis/sequential_plan_synthesis.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|