Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

fix inputs pipe controllers

thomashebrard99925a64f1b1
diff --git a/pipelex/libraries/pipelines/builder/builder.py b/pipelex/libraries/pipelines/builder/builder.py
index 4e8dabebf..928ac0bcf 100644
--- a/pipelex/libraries/pipelines/builder/builder.py
+++ b/pipelex/libraries/pipelines/builder/builder.py
@@ -268,7 +268,7 @@ async def validate_bundle_spec(pipelex_bundle_spec: PipelexBundleSpec):
)
raise PipelexBundleError(message=pipe_loading_error.message, pipe_definition_errors=[pipe_definition_error_data]) from pipe_loading_error
- dry_run_result = await dry_run_pipes(pipes=pipes, raise_on_failure=False)
+ dry_run_result = await dry_run_pipes(pipes=pipes, raise_on_failure=True)
library_manager.remove_from_blueprint(blueprint=pipelex_bundle_blueprint)
pipe_type_to_spec_class = {
diff --git a/pipelex/libraries/pipelines/builder/builder_loop.py b/pipelex/libraries/pipelines/builder/builder_loop.py
index 99219b16b..462b5493e 100644
--- a/pipelex/libraries/pipelines/builder/builder_loop.py
+++ b/pipelex/libraries/pipelines/builder/builder_loop.py
@@ -1,5 +1,8 @@
from pipelex import log, pretty_print
from pipelex.client.protocol import ImplicitMemory
+from pipelex.core.pipes.pipe_blueprint import AllowedPipeCategories
+from pipelex.exceptions import StaticValidationErrorType
+from pipelex.hub import get_required_pipe
from pipelex.language.plx_factory import PlxFactory
from pipelex.libraries.pipelines.builder.builder import (
PipelexBundleSpec,
@@ -30,13 +33,34 @@ class BuilderLoop:
await validate_bundle_spec(pipelex_bundle_spec=pipelex_bundle_spec)
except PipelexBundleError as bundle_error:
pretty_print(bundle_error.as_structured_content(), title="Pipelex Bundle Error")
- log.error("Some pipes are failing, we should fix them but it's not implemented yet...")
+ log.error("Some pipes are failing, we should fix them but it's not implemented yet: ", bundle_error.message)
fixed_pipes: list[PipeSpecUnion] = []
- # TODO: fixe the pipes)
- pipelex_bundle_spec = await reconstruct_bundle_with_pipe_fixes(pipelex_bundle_spec=pipelex_bundle_spec, fixed_pipes=fixed_pipes)
- # pretty_print(pipelex_bundle_spec, title="Pipelex Bundle Spec • 2nd iteration")
- # plx_content = PlxFactory.make_plx_content(blueprint=pipelex_bundle_spec.to_blueprint())
- # save_text_to_path(text=plx_content, path="results/generated_pipeline_2nd_iteration.plx")
+
+ # Fix static validation errors for PipeController inputs
+ if bundle_error.static_validation_error:
+ static_error = bundle_error.static_validation_error
+ if static_error.error_type in (
+ StaticValidationErrorType.MISSING_INPUT_VARIABLE,
+ StaticValidationErrorType.EXTRANEOUS_INPUT_VARIABLE,
+ ):
+ if static_error.pipe_code and pipelex_bundle_spec.pipe:
+ pipe_spec = pipelex_bundle_spec.pipe.get(static_error.pipe_code)
+ if pipe_spec and pipe_spec.category == AllowedPipeCategories.PIPE_CONTROLLER:
+ pipe = get_required_pipe(pipe_code=static_error.pipe_code)
+ needed_inputs = pipe.needed_inputs()
+ # Build the new inputs dict from needed_inputs
+ new_inputs: dict[str, str] = {}
+ for named_requirement in needed_inputs.named_input_requirements:
+ new_inputs[named_requirement.variable_name] = named_requirement.concept.code
+ # Update the pipe spec inputs
+ pipe_spec.inputs = new_inputs
+ fixed_pipes.append(pipe_spec)
+
+ if fixed_pipes:
+ pipelex_bundle_spec = await reconstruct_bundle_with_pipe_fixes(pipelex_bundle_spec=pipelex_bundle_spec, fixed_pipes=fixed_pipes)
+ pretty_print(pipelex_bundle_spec, title="Pipelex Bundle Spec • 2nd iteration")
+ plx_content = PlxFactory.make_plx_content(blueprint=pipelex_bundle_spec.to_blueprint())
+ save_text_to_path(text=plx_content, path="results/generated_pipeline_2nd_iteration.plx")
return pipelex_bundle_spec
diff --git a/pipelex/libraries/pipelines/builder/pipe/pipe_design.plx b/pipelex/libraries/pipelines/builder/pipe/pipe_design.plx
index 92f3dc2ab..1406894ef 100644
--- a/pipelex/libraries/pipelines/builder/pipe/pipe_design.plx
+++ b/pipelex/libraries/pipelines/builder/pipe/pipe_design.plx
@@ -155,6 +155,13 @@ llm = "llm_to_engineer"
prompt_template = """
Your job is to design a PipeComposeSpec to render a jinja2 template.
+For now, the only 2 jinja2 filters that are supported are:
+- `tag`
+- `format`
+
+The `tag` filter is used to add tags to the output.
+The `format` filter is used to format the output.
+
This PipeCompose is part of a larger pipeline:
@plan_draft
diff --git a/pipelex/libraries/pipelines/builder/pipe/pipe_signature.py b/pipelex/libraries/pipelines/builder/pipe/pipe_signature.py
index 423255469..f40edb0c1 100644
--- a/pipelex/libraries/pipelines/builder/pipe/pipe_signature.py
+++ b/pipelex/libraries/pipelines/builder/pipe/pipe_signature.py
@@ -27,6 +27,7 @@ class PipeSignature(StructuredContent):
description="variable_name for the result of the pipe. Must be snake_case. It could be referenced as input in a following pipe."
)
output: str = Field(description="Just the output ConceptCode in PascalCase")
+ pipe_dependencies: list[str] = Field(description="List of pipe codes that this pipe depends on. This is for the PipeControllers")
class PipeSpec(StructuredContent):