BaseFlowStep
This module contains the BaseFlowStep used as a base class by all non-async FlowStep classes. Each FlowStep can execute a task, record execution times, and optionally invoke callbacks on the results.
BaseFlowStep
Bases: ABC
Base class for flowsteps in a flow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the flow step. |
required |
output_key |
str
|
The dict key for the output of the flow step. |
required |
callbacks |
Union[list[AsyncBaseCallback]
|
Optional functions to be invoked with the results. |
required |
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the flow step. |
output_key |
str
|
The dict key for the output of the flow step. |
next_steps |
list[BaseFlowStep]
|
The subsequent steps this step connects to. |
parents |
list[BaseFlowStep]
|
The preceding steps that connect to this step. |
callbacks |
Union[list[BaseCallback]
|
Optional callbacks to be invoked with the results. |
Source code in llmflows/flows/base_flowstep.py
16 17 18 19 20 21 22 23 24 25 26 27 28 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 |
|
connect(*steps)
Connects this flow step to one or more subsequent flow steps.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*steps |
BaseFlowStep
|
Flow steps to connect to this step. |
()
|
Raises:
Type | Description |
---|---|
ValueError
|
If connected flow steps have the same output key. |
Source code in llmflows/flows/base_flowstep.py
generate(inputs)
abstractmethod
Executes the language model with the provided inputs and returns result, call data and model configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
dict[str, Any]
|
The inputs to the flow step. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
tuple[Any, Any, Any]
|
result, call data and model configuration. |
Source code in llmflows/flows/base_flowstep.py
run(inputs, verbose=False)
Executes the flow step with the provided inputs and returns a dictionary with execution details.
This includes the start and end times, the prompts and the input to the language model, the output from the language model, details about the model configuration and the result of the step. Callback functions can be executed with the result as well.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
dict[str, str]
|
The inputs to the flow step. |
required |
verbose |
bool
|
If true, the output of the step and callback executions are printed. |
False
|
Returns:
Type | Description |
---|---|
dict[str, str]
|
dict[str, str]: A dictionary with various runtime details and results. |