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.

Making blueprints and toml

Louis Choquel6770db872012
diff --git a/pipelex/cli/commands/build_cmd.py b/pipelex/cli/commands/build_cmd.py
index 061799c30..c08d402bf 100644
--- a/pipelex/cli/commands/build_cmd.py
+++ b/pipelex/cli/commands/build_cmd.py
@@ -17,6 +17,10 @@ build_app = typer.Typer(help="Build artifacts like pipeline blueprints")
@build_app.command("draft")
def build_draft_pipeline_cmd(
+ pipeline_name: Annotated[
+ str,
+ typer.Argument(help="Name/code of the pipeline to generate (used inside the draft)"),
+ ],
requirements: Annotated[
Optional[str],
typer.Option("--requirements", "-r", help="Requirements text to generate the pipeline blueprint from"),
@@ -60,6 +64,7 @@ def build_draft_pipeline_cmd(
if raw:
asyncio.run(
do_draft_pipeline_text(
+ pipeline_name=pipeline_name,
requirements=requirements_text,
output_path=output_path,
)
@@ -67,6 +72,7 @@ def build_draft_pipeline_cmd(
else:
asyncio.run(
do_draft_pipeline(
+ pipeline_name=pipeline_name,
requirements=requirements_text,
output_path=output_path,
)
@@ -75,6 +81,10 @@ def build_draft_pipeline_cmd(
@build_app.command("blueprint")
def build_blueprint_cmd(
+ pipeline_name: Annotated[
+ str,
+ typer.Argument(help="Name/code of the pipeline to generate (used inside the draft)"),
+ ],
requirements: Annotated[
Optional[str],
typer.Option("--requirements", "-r", help="Requirements text to generate the pipeline blueprint from"),
@@ -117,6 +127,7 @@ def build_blueprint_cmd(
asyncio.run(
do_build_blueprint(
+ pipeline_name=pipeline_name,
requirements=requirements_text,
output_path=output_path,
validate=validate,
diff --git a/pipelex/cogt/content_generation/content_generator.py b/pipelex/cogt/content_generation/content_generator.py
index 9afa75a89..e5e4e088c 100644
--- a/pipelex/cogt/content_generation/content_generator.py
+++ b/pipelex/cogt/content_generation/content_generator.py
@@ -46,7 +46,7 @@ class ContentGenerator(ContentGeneratorProtocol):
llm_prompt_for_text: LLMPrompt,
) -> str:
log.verbose(f"{self.__class__.__name__} make_llm_text: {llm_prompt_for_text}")
- log.debug(f"llm_setting_main: {llm_setting_main}")
+ log.info(f"llm_setting_main: {llm_setting_main}")
llm_assignment = LLMAssignment(
job_metadata=job_metadata,
llm_setting=llm_setting_main,
diff --git a/pipelex/create/build_blueprint.py b/pipelex/create/build_blueprint.py
index d73460547..f786b6d4f 100644
--- a/pipelex/create/build_blueprint.py
+++ b/pipelex/create/build_blueprint.py
@@ -7,6 +7,7 @@ import typer
from pydantic import ValidationError
from pipelex import pretty_print
+from pipelex.create.helpers import get_rules
from pipelex.exceptions import PipeDefinitionError, PipelexCLIError
from pipelex.hub import get_library_manager
from pipelex.libraries.library_manager import LibraryManager
@@ -20,14 +21,17 @@ from pipelex.tools.typing.pydantic_utils import format_pydantic_validation_error
async def do_build_blueprint(
+ pipeline_name: str,
requirements: str,
output_path: Optional[str],
validate: bool,
) -> None:
pipe_output = await execute_pipeline(
- pipe_code="draft_pipeline",
+ pipe_code="build_blueprint",
input_memory={
+ "pipeline_name": pipeline_name,
"requirements": requirements,
+ "rules": get_rules(),
},
)
blueprint = pipe_output.main_stuff_as(content_type=PipelineLibraryBlueprint)
diff --git a/pipelex/create/draft_pipeline.py b/pipelex/create/draft_pipeline.py
index 5eac24479..4a43f31fd 100644
--- a/pipelex/create/draft_pipeline.py
+++ b/pipelex/create/draft_pipeline.py
@@ -7,6 +7,7 @@ import typer
from pydantic import ValidationError
from pipelex import pretty_print
+from pipelex.create.helpers import get_rules
from pipelex.exceptions import PipeDefinitionError, PipelexCLIError
from pipelex.hub import get_library_manager
from pipelex.libraries.library_manager import LibraryManager
@@ -19,19 +20,17 @@ from pipelex.tools.misc.file_utils import load_text_from_path, save_text_to_path
from pipelex.tools.typing.pydantic_utils import format_pydantic_validation_error
-def _get_rules() -> str:
- return load_text_from_path(".pipelex/design_pipelines.md")
-
-
async def do_draft_pipeline_text(
+ pipeline_name: str,
requirements: str,
output_path: Optional[str],
) -> None:
pipe_output = await execute_pipeline(
pipe_code="draft_pipeline_text",
input_memory={
- "rules": _get_rules(),
+ "pipeline_name": pipeline_name,
"requirements": requirements,
+ "rules": get_rules(),
},
)
draft_text = pipe_output.main_stuff_as_str
@@ -44,13 +43,16 @@ async def do_draft_pipeline_text(
async def do_draft_pipeline(
+ pipeline_name: str,
requirements: str,
output_path: Optional[str],
) -> None:
pipe_output = await execute_pipeline(
pipe_code="draft_pipeline",
input_memory={
+ "pipeline_name": pipeline_name,
"requirements": requirements,
+ "rules": get_rules(),
},
)
draft = pipe_output.main_stuff_as(content_type=PipelineDraft)
diff --git a/pipelex/create/helpers.py b/pipelex/create/helpers.py
new file mode 100644
index 000000000..176878d1a
--- /dev/null
+++ b/pipelex/create/helpers.py
@@ -0,0 +1,5 @@
+from pipelex.tools.misc.file_utils import load_text_from_path
+
+
+def get_rules() -> str:
+ return load_text_from_path(".pipelex/design_pipelines.md")
diff --git a/pipelex/libraries/pipelines/meta/meta_pipeline.toml b/pipelex/libraries/pipelines/meta/meta_pipeline.toml
index 263e73c90..1d443e2b7 100644
--- a/pipelex/libraries/pipelines/meta/meta_pipeline.toml
+++ b/pipelex/libraries/pipelines/meta/meta_pipeline.toml
@@ -14,7 +14,7 @@ PipeBlueprint = "Details enabling to create a pipe"
[pipe.draft_pipeline_text]
type = "PipeLLM"
definition = "Generate a rough pipeline draft from natural language requirements"
-inputs = { rules = "Text", requirements = "Text" }
+inputs = { rules = "Text", requirements = "Text", pipeline_name = "Text" }
output = "PipelineDraftText"
llm = "llm_to_engineer"
prompt_template = """
@@ -23,6 +23,8 @@ You are a Pipelex pipeline architect. Build a pipeline draft text showing how we
@rules
@requirements
+
+Name of the pipeline, i.e. name of the main pipe: $pipeline_name.
"""
@@ -48,11 +50,17 @@ Think on the pipeline requirements: what are the pipeline's inputs and what is t
[pipe.build_blueprint]
type = "PipeLLM"
definition = "Generate a pipeline blueprint from natural language requirements"
-inputs = { requirements = "Text" }
+inputs = { rules = "Text", requirements = "Text", pipeline_name = "Text" }
output = "PipelineLibraryBlueprint"
+llm = "llm_to_engineer"
+# structuring_method = "preliminary_text"
prompt_template = """
-You are a Pipelex pipeline architect. Build a pipeline blueprint showing how we solve the problem.
+You are a Pipelex pipeline architect. Build a pipeline draft text showing how we solve the problem.
+
+@rules
@requirements
+
+Name of the pipeline, i.e. name of the main pipe: $pipeline_name.
"""