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.

register PipelineBlueprint, generate it with a PipeLLM

Louis Choquel8c1093400b83
diff --git a/pipelex/core/registry_models.py b/pipelex/core/registry_models.py
index 3f400ac52..0d9c0faad 100644
--- a/pipelex/core/registry_models.py
+++ b/pipelex/core/registry_models.py
@@ -17,6 +17,7 @@ from pipelex.core.stuff_content import (
TextAndImagesContent,
TextContent,
)
+from pipelex.libraries.pipeline_blueprint import PipelineLibraryBlueprint
from pipelex.pipe_controllers.pipe_batch import PipeBatch
from pipelex.pipe_controllers.pipe_batch_factory import PipeBatchFactory
from pipelex.pipe_controllers.pipe_condition import PipeCondition
@@ -86,6 +87,7 @@ class PipelexRegistryModels(RegistryModels):
PDFContent,
TextAndImagesContent,
PageContent,
+ PipelineLibraryBlueprint,
]
EXPERIMENTAL: ClassVar[List[ModelType]] = [
diff --git a/pipelex/libraries/pipeline_blueprint.py b/pipelex/libraries/pipeline_blueprint.py
index 5b60fb821..7d5d4177d 100644
--- a/pipelex/libraries/pipeline_blueprint.py
+++ b/pipelex/libraries/pipeline_blueprint.py
@@ -4,6 +4,7 @@ from typing import Any, Dict, Optional, Union
from pydantic import BaseModel, Field
from pipelex.core.concept_factory import ConceptBlueprint
+from pipelex.core.stuff_content import StructuredContent
from pipelex.exceptions import LibraryError
from pipelex.tools.misc.toml_utils import dict_to_toml_string, save_toml_to_path
@@ -42,7 +43,7 @@ class PipeStepBlueprint(BaseModel):
result: str
-class PipelineLibraryBlueprint(BaseModel):
+class PipelineLibraryBlueprint(StructuredContent):
"""Complete blueprint of a pipeline library TOML file."""
# Domain information (required)
diff --git a/pipelex/libraries/pipelines/meta/meta_pipeline.toml b/pipelex/libraries/pipelines/meta/meta_pipeline.toml
new file mode 100644
index 000000000..2ce797cfc
--- /dev/null
+++ b/pipelex/libraries/pipelines/meta/meta_pipeline.toml
@@ -0,0 +1,31 @@
+domain = "meta"
+definition = "Meta domain is the domain of pipelines about pipelines"
+
+[concept]
+PipelineLibraryBlueprint = "Details enabling to create a pipeline"
+ConceptBlueprint = "Details enabling to create a concept"
+PipeBlueprint = "Details enabling to create a pipe"
+
+[pipe]
+
+[pipe.generate_pipeline_blueprint]
+PipeLLM = "Generate a PipelineLibraryBlueprint from natural language requirements"
+inputs = { requirements = "Text" }
+output = "PipelineLibraryBlueprint"
+structuring_method = "preliminary_text"
+prompt_template = """
+You are a Pipelex pipeline architect. Convert the following requirements into a minimal, correct PipelineLibraryBlueprint object.
+
+Rules:
+- Only fill fields that exist on the PipelineLibraryBlueprint schema: domain, definition (optional), concept, pipe.
+- In concept, map ConceptName (PascalCase, singular) to its natural language definition string. Do not redefine native concepts (Text, Image, PDF, TextAndImages, Number, Page).
+- In pipe, define at least one pipe that accomplishes the main goal implied by the requirements. Use operators/controllers supported by Pipelex (e.g., PipeLLM, PipeOcr, PipeSequence...).
+- For pipe definitions, use the concise form (e.g., `PipeLLM = "..."`, then `inputs = { ... }`, `output = "..."`).
+- Ensure all input variables referenced in prompts are listed in the pipe `inputs`.
+- Keep domain code short, lowercase, and meaningful.
+
+Requirements:
+
+@requirements
+"""
+
diff --git a/pipelex/pipelex.py b/pipelex/pipelex.py
index f97129248..068171963 100644
--- a/pipelex/pipelex.py
+++ b/pipelex/pipelex.py
@@ -239,7 +239,10 @@ class Pipelex(metaclass=MetaSingleton):
# TODO: add kwargs to make() so that subclasses can employ specific parameters
@classmethod
def make(
- cls, relative_config_folder_path: Optional[str] = None, absolute_config_folder_path: Optional[str] = None, from_file: Optional[bool] = True
+ cls,
+ relative_config_folder_path: Optional[str] = None,
+ absolute_config_folder_path: Optional[str] = None,
+ from_file: Optional[bool] = True,
) -> Self:
"""Create and initialize a Pipelex instance.
diff --git a/tests/integration/pipelex/pipes/pipe_operator/pipe_llm/test_generate_pipeline_blueprint.py b/tests/integration/pipelex/pipes/pipe_operator/pipe_llm/test_generate_pipeline_blueprint.py
new file mode 100644
index 000000000..80162e6df
--- /dev/null
+++ b/tests/integration/pipelex/pipes/pipe_operator/pipe_llm/test_generate_pipeline_blueprint.py
@@ -0,0 +1,42 @@
+import pytest
+
+from pipelex import pretty_print
+from pipelex.core.pipe_run_params import PipeRunMode
+from pipelex.libraries.pipeline_blueprint import PipelineLibraryBlueprint
+from pipelex.pipeline.execute import execute_pipeline
+
+
[email protected](loop_scope="class")
+ "requirements",
+ [
+ (
+ "Create a domain 'sample' to describe simple demo pipelines. "
+ "Define concept ThingDescription = 'A short natural language description of a thing'. "
+ "Add a pipe write_thing that takes input { text = Text } and outputs ThingDescription using PipeLLM."
+ ),
+ (
+ "Domain: gadgets. Concept: GadgetSpec = 'Technical description of a gadget'. "
+ "Add pipe summarize_gadget: inputs { text = Text } -> output GadgetSpec via PipeLLM."
+ ),
+ ],
+)
+async def test_generate_pipeline_blueprint_dry_run(pipe_run_mode: PipeRunMode, requirements: str):
+ pipe_output = await execute_pipeline(
+ pipe_code="generate_pipeline_blueprint",
+ input_memory={
+ "requirements": requirements,
+ },
+ pipe_run_mode=pipe_run_mode,
+ )
+
+ blueprint = pipe_output.main_stuff_as(content_type=PipelineLibraryBlueprint)
+ assert isinstance(blueprint, PipelineLibraryBlueprint)
+ # Basic sanity checks
+ assert isinstance(blueprint.domain, str) and blueprint.domain != ""
+
+ pretty_print(blueprint, title="PipelineBlueprint")
+ pretty_print(blueprint.to_toml_dict(), title="PipelineBlueprint TOML")