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.
Docs/pipe llm multiplicity (#106)
Louis Choquelbabf75d6880d
diff --git a/.github/workflows/guard-branches.yml b/.github/workflows/guard-branches.ymlindex 0e3289fb1..0cab35651 100644--- a/.github/workflows/guard-branches.yml+++ b/.github/workflows/guard-branches.yml@@ -36,7 +36,7 @@ jobs:if [[ "$HEAD" == "dev" ]]; thenexit 0fi- if [[ ! "$HEAD" =~ ^(fix|feature|refactor|chore|doc|ci-cd|changelog|codex)\/[A-Za-z0-9._\/\<\>\=\-]+$ ]]; then+ if [[ ! "$HEAD" =~ ^(fix|feature|refactor|chore|docs|ci-cd|changelog|codex)\/[A-Za-z0-9._\/\<\>\=\-]+$ ]]; thenecho "::error::Branch must start with fix/, feature/, refactor/, chore/, docs/, or ci-cd/."exit 1fidiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 41107823c..06d4ff1b2 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -12,7 +12,7 @@ We are open to contributions in all areas of our core Pipelex library:- **Feature**: New API, CLI flag, module, test coverage- **Refactor**: Rethink architecture- **Chore**: Dependency updates, config tweaks, file renames-- **Doc**: Main docs, SWE Agent rules, tutorials, examples, READMEs+- **Docs**: Main docs, SWE Agent rules, tutorials, examples, READMEs- **CI/CD**: GitHub Actions, packaging, release tooling## Contribution process@@ -22,7 +22,7 @@ We are open to contributions in all areas of our core Pipelex library:- Install dependencies: `make install` (creates .venv and installs dependencies)- Copy `.env.example` to `.env` and fill in required API keys (at least OpenAI)- Run checks to make sure all is good: `make check` & `make test`-- Create a branch with the format user_name/category/short_slug where category is one of: `feature`, `fix`, `refactor`, `doc`, `cicd` or `chore`+- Create a branch with the format user_name/category/short_slug where category is one of: `feature`, `fix`, `refactor`, `docs`, `cicd` or `chore`- Make and commit changes- Push your local branch to your fork- Open a PR that [links to an existing Issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) which does not include the `needs triage` labeldiff --git a/docs/pages/build-reliable-ai-workflows-with-pipelex/pipe-operators/PipeLLM.md b/docs/pages/build-reliable-ai-workflows-with-pipelex/pipe-operators/PipeLLM.mdindex 6690f823a..93c1b8bf4 100644--- a/docs/pages/build-reliable-ai-workflows-with-pipelex/pipe-operators/PipeLLM.md+++ b/docs/pages/build-reliable-ai-workflows-with-pipelex/pipe-operators/PipeLLM.md@@ -121,6 +121,18 @@ Analyze the document page shown in the image and explain how it relates to the p| `images` | list of strings | **Deprecated**: Use the `inputs` section to declare image inputs instead. | No || `structuring_method` | string | The method for generating structured output. Can be `direct` or `preliminary_text`. Defaults to the global configuration. | No || `prompt_template_to_structure` | string | The prompt template for the second step in `preliminary_text` mode. | No |+| `nb_output` | integer | Specifies exactly how many outputs to generate (e.g., `nb_output = 3` for exactly 3 outputs). Use when you need a fixed number of results. Mutually exclusive with `multiple_output`. | No |+| `multiple_output` | boolean | Controls output generation mode. Default is `false` (single output). Set to `true` for variable-length list generation when you need an indeterminate number of outputs. Mutually exclusive with `nb_output`. | No |++### Output Generation Modes++`PipeLLM` supports three different output generation modes:++1. **Single Output** (default): Don't specify `nb_output` or `multiple_output`, or set `multiple_output = false`. The LLM generates exactly one result.++2. **Fixed Multiple Outputs**: Use `nb_output = N` (where N is a positive integer) when you need exactly N outputs. For example, `nb_output = 3` will try to generate 3 results. The parameter `_nb_output` will be available in the prompt template, e.g. "Give me the names of $_nb_output flowers".++3. **Variable Multiple Outputs**: Use `multiple_output = true` when you need a variable-length list where the LLM determines how many outputs to generate based on the content and context.| `output_multiplicity` | string or integer | Defines the number of outputs. Use `"list"` for a variable-length list, or an integer (e.g., `3`) for a fixed-size list. | No |## Examplesdiff --git a/pipelex/pipe_operators/pipe_img_gen.py b/pipelex/pipe_operators/pipe_img_gen.pyindex 0e53ac9ff..26216fa78 100644--- a/pipelex/pipe_operators/pipe_img_gen.py+++ b/pipelex/pipe_operators/pipe_img_gen.py@@ -283,7 +283,7 @@ class PipeImgGen(PipeOperator):pipe_run_params: PipeRunParams,output_name: Optional[str] = None,) -> PipeOutput:- log.warning(f"PipeImgGen: dry run operator pipe: {self.code}")+ log.info(f"PipeImgGen: dry run operator pipe: {self.code}")content_generator_dry = ContentGeneratorDry()pipe_output = await self._run_operator_pipe(job_metadata=job_metadata,diff --git a/pipelex/pipe_operators/pipe_jinja2.py b/pipelex/pipe_operators/pipe_jinja2.pyindex 43fa4444e..9dc3c5517 100644--- a/pipelex/pipe_operators/pipe_jinja2.py+++ b/pipelex/pipe_operators/pipe_jinja2.py@@ -141,10 +141,10 @@ class PipeJinja2(PipeOperator):) -> PipeOutput:content_generator_used: ContentGeneratorProtocolif get_config().pipelex.dry_run_config.apply_to_jinja2_rendering:- log.warning(f"PipeJinja2: using dry run operator pipe for jinja2 rendering: {self.code}")+ log.info(f"PipeJinja2: using dry run operator pipe for jinja2 rendering: {self.code}")content_generator_used = ContentGeneratorDry()else:- log.warning(f"PipeJinja2: using regular operator pipe for jinja2 rendering (dry run not applied to jinja2): {self.code}")+ log.info(f"PipeJinja2: using regular operator pipe for jinja2 rendering (dry run not applied to jinja2): {self.code}")content_generator_used = get_content_generator()pipe_output = await self._run_operator_pipe(job_metadata=job_metadata,diff --git a/pipelex/pipe_operators/pipe_llm.py b/pipelex/pipe_operators/pipe_llm.pyindex d1f540cef..d4d46552d 100644--- a/pipelex/pipe_operators/pipe_llm.py+++ b/pipelex/pipe_operators/pipe_llm.py@@ -489,7 +489,7 @@ class PipeLLM(PipeOperator):pipe_run_params: PipeRunParams,output_name: Optional[str] = None,) -> PipeOutput:- log.warning(f"PipeLLM: dry run operator pipe: {self.code}")+ log.info(f"PipeLLM: dry run operator pipe: {self.code}")content_generator_dry = ContentGeneratorDry()pipe_output = await self._run_operator_pipe(job_metadata=job_metadata,diff --git a/pipelex/pipe_operators/pipe_ocr.py b/pipelex/pipe_operators/pipe_ocr.pyindex bbb98d0cd..744f499c7 100644--- a/pipelex/pipe_operators/pipe_ocr.py+++ b/pipelex/pipe_operators/pipe_ocr.py@@ -228,7 +228,7 @@ class PipeOcr(PipeOperator):pipe_run_params: PipeRunParams,output_name: Optional[str] = None,) -> PipeOutput:- log.warning(f"PipeOcr: dry run operator pipe: {self.code}")+ log.info(f"PipeOcr: dry run operator pipe: {self.code}")content_generator_dry = ContentGeneratorDry()pipe_output = await self._run_operator_pipe(job_metadata=job_metadata,diff --git a/pipelex/pipe_operators/pipe_operator.py b/pipelex/pipe_operators/pipe_operator.pyindex cc4a8eb65..c006c72a1 100644--- a/pipelex/pipe_operators/pipe_operator.py+++ b/pipelex/pipe_operators/pipe_operator.py@@ -73,7 +73,7 @@ class PipeOperator(PipeAbstract):pipe_run_params: PipeRunParams,output_name: Optional[str] = None,) -> PipeOutput:- log.warning(+ log.info(f"PipeOperator: dry run method called for operator pipe: {self.code}, but no dry run method is implemented for {self.__class__.__name__}")return await self._run_operator_pipe(