Flow
Flow Exporter class.
- We gather all the exports (models, skills, agents, chats).
- We first add all the imports from the above exports.
- If we have skills, we include their imports. (their files were generated when exporting the skills).
- Then, we write the all model configs.
- Next, we write the agent definitions (using the
llm_config=...
argument from the model exports). - If additional (nested_chats) are defined, we write their registrations after all agents are defined.
- Next, we write the chat definitions (using the agent names from the agent exports).
- If exporting to py, we add the
run
function and thedef main()
to call the run function. - If the flow is async, the
run
function is async.
FlowExporter(waldiez: Waldiez, for_notebook: bool, output_dir: Optional[Union[str, Path]] = None)
¶
Bases: BaseExporter
, ExporterMixin
Flow exporter.Source code in
waldiez/exporting/flow/flow_exporter.py
initialize() -> None
¶
Get all the names in the flow.
We need to make sure that no duplicate names are used, and that the names can be used as python variables.Source code in
waldiez/exporting/flow/flow_exporter.py
export_flow() -> ExporterReturnType
¶
Export the flow.
Returns:
Type | Description |
---|---|
ExporterReturnType | The exported flow. |
Source code in waldiez/exporting/flow/flow_exporter.py
merge_exports(imports: Tuple[str, ImportPosition], models_output: str, skills_output: str, agents_content: str, chats_content: str, before_chats: str) -> str
¶
Merge all the export contents.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
imports | Tuple[str, ImportPosition] | The imports. | required |
models_output | str | The models output. | required |
skills_output | str | The skills output. | required |
agents_content | str | The agents content. | required |
chats_content | str | The chats content. | required |
before_chats | str | required |
Returns:
Type | Description |
---|---|
str | The merged export contents. |
Source code in waldiez/exporting/flow/flow_exporter.py
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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
|
gather_environment_variables(model_env_vars: Optional[List[Tuple[str, str]]], skill_env_vars: Optional[List[Tuple[str, str]]], chat_env_vars: Optional[List[Tuple[str, str]]]) -> List[Tuple[str, str]]
staticmethod
¶
Gather all the environment variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_env_vars | Optional[List[Tuple[str, str]]] | The model environment variables. | required |
skill_env_vars | Optional[List[Tuple[str, str]]] | The skill environment variables. | required |
chat_env_vars | Optional[List[Tuple[str, str]]] | The chat environment variables. | required |
Returns:
Type | Description |
---|---|
List[Tuple[str, str]] | The gathered environment variables. |
Source code in waldiez/exporting/flow/flow_exporter.py
gather_exports(model_export: Optional[List[Tuple[str, Union[ExportPosition, AgentPosition]]]], skill_export: Optional[List[Tuple[str, Union[ExportPosition, AgentPosition]]]], chat_export: Optional[List[Tuple[str, Union[ExportPosition, AgentPosition]]]]) -> List[Tuple[str, Union[ExportPosition, AgentPosition]]]
staticmethod
¶
Gather all (but agents) the before or after exports.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_export | Optional[List[Tuple[str, Union[ExportPosition, AgentPosition]]]] | The model exports. | required |
skill_export | Optional[List[Tuple[str, Union[ExportPosition, AgentPosition]]]] | The skill exports. | required |
chat_export | Optional[List[Tuple[str, Union[ExportPosition, AgentPosition]]]] | The chat exports. | required |
Returns:
Type | Description |
---|---|
List[Tuple[str, Union[ExportPosition, AgentPosition]]] | The gathered exports. |
Source code in waldiez/exporting/flow/flow_exporter.py
export_models() -> ExporterReturnType
¶
Export the models.
Returns:
Type | Description |
---|---|
str | The exported models. |
Source code in waldiez/exporting/flow/flow_exporter.py
export_skills() -> ExporterReturnType
¶
Export the skills.
Returns:
Type | Description |
---|---|
str | The exported skills. |
Source code in waldiez/exporting/flow/flow_exporter.py
gather_agent_arguments(before_export: List[Tuple[str, Union[ExportPosition, AgentPosition]]], after_export: List[Tuple[str, Union[ExportPosition, AgentPosition]]]) -> List[Tuple[str, AgentPosition]]
staticmethod
¶
Gather the agent arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
before_export | List[Tuple[str, Union[ExportPosition, AgentPosition]]] | The before export. | required |
after_export | List[Tuple[str, Union[ExportPosition, AgentPosition]]] | The after export. | required |
Returns:
Type | Description |
---|---|
List[Tuple[str, AgentPosition]] | The gathered agent arguments. |
Source code in waldiez/exporting/flow/flow_exporter.py
export_agents(before_export: List[Tuple[str, Union[ExportPosition, AgentPosition]]], after_export: List[Tuple[str, Union[ExportPosition, AgentPosition]]]) -> ExporterReturnType
¶
Export the agents.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
before_export | List[Tuple[str, Union[ExportPosition, AgentPosition]]] | The before export. | required |
after_export | List[Tuple[str, Union[ExportPosition, AgentPosition]]] | The after export. | required |
Returns:
Type | Description |
---|---|
str | The exported agents. |
Source code in waldiez/exporting/flow/flow_exporter.py
agent_arguments_resolver(additional_exports: List[Tuple[str, AgentPosition]], agent: WaldiezAgent) -> List[str]
staticmethod
¶
Resolve the arguments for the agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
additional_exports | List[Tuple[str, AgentPosition]] | The additional exports. | required |
agent | WaldiezAgent | The agent. | required |
Returns:
Type | Description |
---|---|
List[str] | The arguments for the agent. |
Source code in waldiez/exporting/flow/flow_exporter.py
export_chats() -> ExporterReturnType
¶
Export the chats.
Returns:
Type | Description |
---|---|
str | The exported chats. |
Source code in waldiez/exporting/flow/flow_exporter.py
export() -> ExporterReturnType
¶
Export the flow.
Returns:
Type | Description |
---|---|
SubExporterReturnType | The exported flow. |