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.
Remove obsolete allegations about ocr_input. ocr_input should now just be the name of OcrInput objects
Louis Choqueldb2d33dfcc08
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ca2cbc952..95b03a0cf 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -430,7 +430,6 @@ Simplified input memory:### Changed-- **OCR Input Standardization**: Changed OCR pipe input parameter naming to consistently use `ocr_input` for both image and PDF inputs, improving consistency across the API- **Error Message Improvements**: Updated PipeCondition error messages to reference `expression_template` instead of deprecated `expression_jinja2`## [v0.4.11] - 2025-06-30diff --git a/docs/pages/build-reliable-ai-workflows-with-pipelex/pipe-operators/PipeOcr.md b/docs/pages/build-reliable-ai-workflows-with-pipelex/pipe-operators/PipeOcr.mdindex 130a8cc69..870cc6984 100644--- a/docs/pages/build-reliable-ai-workflows-with-pipelex/pipe-operators/PipeOcr.md+++ b/docs/pages/build-reliable-ai-workflows-with-pipelex/pipe-operators/PipeOcr.md@@ -42,7 +42,7 @@ OCR presets are defined in your model deck configuration and can include paramet| --------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- | -------- || `type` | string | The type of the pipe: `PipeOcr` | Yes || `definition` | string | A description of the OCR operation. | Yes |-| `inputs` | Fixed | The input for the PipeOcr is the key `ocr_input` and the value is either of concept `Image` or `Pdf`. | Yes |+| `inputs` | Fixed | The value is either of concept `Image` or `Pdf`. | Yes || `output` | string | The output concept produced by the OCR operation. | Yes || `page_images` | boolean | If `true`, any images found within the document pages will be extracted and included in the output. Defaults to `false`. | No || `page_views` | boolean | If `true`, a high-fidelity image of each page will be included in the `page_view` field. Defaults to `false`. | No |@@ -65,7 +65,7 @@ refines = "Page"[pipe.extract_text_from_document]type = "PipeOcr"definition = "Extract text from a scanned document"-inputs = { ocr_input = "ScannedDocument" }+inputs = { document = "ScannedDocument" }output = "Page"page_views = truepage_views_dpi = 200diff --git a/pipelex/libraries/pipelines/builder/builder.plx b/pipelex/libraries/pipelines/builder/builder.plxindex 735c95ae1..6ff6abb07 100644--- a/pipelex/libraries/pipelines/builder/builder.plx+++ b/pipelex/libraries/pipelines/builder/builder.plx@@ -77,10 +77,7 @@ We have pipe controllers:- PipeImgGen: A pipe that uses an LLM to generate an image. VERY IMPORTANT: IF YOU DECIDE TO CREATE A PIPEIMGEN, YOU ALSO HAVE TO CREATE A PIPELLM THAT WILL WRITE THE PROMPT, AND THAT NEEDS TO PRECEED THE PIPEIMGEN, based on the necessary elements.That means that in the MAIN pipeline, the prompt should NOT be an input. It should be a step that generates the prompt.- PipeOcr: A pipe that uses an OCR technology to extract text from an image.-VERY IMPORTANT: THE INPUT OF THE PIPEOCR MUST BE NAMED "ocr_input" and it must be either an image or a pdf or a concept which refines one of them.-Usually there is no need to rename a variable or create a new concept, just call it ocr_input, and we'll use the basic PDF concept.-Thats mean that in the sequence, the input should be ocr_input.-So the input of PipeOcr is {ocr_input: "PDF"} or {ocr_input: "Image"} or a concept which refines one of them.+VERY IMPORTANT: THE INPUT OF THE PIPEOCR MUST BE either an image or a pdf or a concept which refines one of them.Be very detailed, process by steps.@@ -225,9 +222,7 @@ THERFORE, the OUTPUT OF THIS PIPELLM should be a VARIABLE NAMED "prompt" that wiThat means that in the MAIN pipeline, the prompt should NOT be an input. It should be a step that generates the prompt.**PipeOcr**: A pipe that uses an LLM to extract text from an image.-- The INPUTS of this pipe is only "ocr_input" and it must be either an image or a pdf or a concept which refines one of them.-- Usually there is no need to rename a variable or create a new concept, just call it ocr_input, and we'll use the basic PDF concept. Thats mean that in the sequence, the input should be ocr_input.-So the input of PipeOcr is {ocr_input: "PDF"} or {ocr_input: "Image"} or a concept which refines one of them.+- The INPUTS of PipeOcr must be either an image or a pdf or a concept which refines one of them.**PipeFunc**: A pipe that executes a custom Python function.- function_name: Name of the Python function to calldiff --git a/pipelex/libraries/pipelines/builder/pipe/pipe.plx b/pipelex/libraries/pipelines/builder/pipe/pipe.plxindex db8d2b838..90eb88d22 100644--- a/pipelex/libraries/pipelines/builder/pipe/pipe.plx+++ b/pipelex/libraries/pipelines/builder/pipe/pipe.plx@@ -182,7 +182,7 @@ output = "PipeOcrSpec"prompt_template = """Return a PipeOcrSpec for this signature.-VERY IMPORTANT: THE INPUT OF THE PIPEOCR MUST BE NAMED "ocr_input" and it must be either an image or a pdf or a concept which refines one of them.+VERY IMPORTANT: THE INPUT OF THE PIPEOCR MUST BE either an image or a pdf or a concept which refines one of them.Signature:@pipe_signature@@ -337,7 +337,7 @@ llm = "llm_to_engineer"prompt_template = """Fix this failing PipeOcr spec.-VERY IMPORTANT: THE INPUT OF THE PIPEOCR MUST BE NAMED "ocr_input" and it must be either an image or a pdf or a concept which refines one of them.+VERY IMPORTANT: THE INPUT OF THE PIPEOCR must be either an image or a pdf or a concept which refines one of them.Failing pipe:@failed_pipe.pipe@@ -345,7 +345,7 @@ Error message:@failed_pipe.error_messagePlease provide only the corrected PipeOcrSpec. Common OCR pipe issues to fix:-- Input must be named 'ocr_input' and be of type Image or PDF+- Input must be of type Image or PDF- Output should typically be Page (native concept)- Missing or incorrect input concept types"""diff --git a/pipelex/libraries/pipelines/builder/pipe/pipe_ocr_spec.py b/pipelex/libraries/pipelines/builder/pipe/pipe_ocr_spec.pyindex 2a377d064..e9598e673 100644--- a/pipelex/libraries/pipelines/builder/pipe/pipe_ocr_spec.py+++ b/pipelex/libraries/pipelines/builder/pipe/pipe_ocr_spec.py@@ -14,12 +14,12 @@ class PipeOcrSpec(PipeSpec):Supports various OCR platforms and output configurations including image detection,caption generation, and page rendering.- VERY IMPORTANT: THE INPUT OF THE PIPEOCR MUST BE NAMED "ocr_input" and it must be either an image or a pdf or a concept which refines one of them.+ VERY IMPORTANT: THE INPUT OF THE PIPEOCR MUST BE either an image or a pdf or a concept which refines one of them.Attributes:the_pipe_code: Pipe code. Must be snake_case.type: Fixed to "PipeOcr" for this pipe type.- ocr: Needs to be "base_ocr_mistral".+ ocr: name of the OCR model or handle or preset or settingpage_images: Whether to include detected images in the OCR output. When enabled,extracts and returns embedded images found in documents.page_image_captions: Whether to generate captions for detected images using AI.@@ -29,18 +29,12 @@ class PipeOcrSpec(PipeSpec):page_views_dpi: DPI (dots per inch) resolution for rendered page views.Higher values provide better quality but larger file sizes.Defaults to configuration setting.-- Validation Rules:- 1. OCR model must be "base_ocr_mistral".- 2. Boolean flags (page_images, page_image_captions, page_views) are optional.- 3. page_views_dpi should be a positive integer when specified.-"""type: Literal["PipeOcr"] = "PipeOcr"category: Literal["PipeOperator"] = "PipeOperator"the_pipe_code: str = Field(description="Pipe code. Must be snake_case.")- ocr: str = "base_ocr_mistral"+ ocr: strpage_images: bool | None = Nonepage_image_captions: bool | None = Nonepage_views: bool | None = Nonediff --git a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_data.py b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_data.pyindex 06786ebdc..87339d30a 100644--- a/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_data.py+++ b/tests/unit/pipelex/libraries/pipelines/builder/pipe/pipe_operators/pipe_ocr/test_data.py@@ -12,13 +12,13 @@ class PipeOcrTestCases:PipeOcrSpec(the_pipe_code="ocr_extractor",definition="Extract text from image",- inputs={"ocr_input": InputRequirementSpec(concept="Image")},+ inputs={"image": InputRequirementSpec(concept="Image")},output="ExtractedText",ocr="mistral-pixtral",),PipeOcrBlueprint(definition="Extract text from image",- inputs={"ocr_input": InputRequirementBlueprint(concept="Image")},+ inputs={"image": InputRequirementBlueprint(concept="Image")},output="ExtractedText",type="PipeOcr",category="PipeOperator",@@ -31,7 +31,7 @@ class PipeOcrTestCases:PipeOcrSpec(the_pipe_code="advanced_ocr",definition="OCR with page options",- inputs={"ocr_input": InputRequirementSpec(concept="PDF")},+ inputs={"document": InputRequirementSpec(concept="PDF")},output="PageContent",ocr="tesseract",page_images=True,@@ -41,7 +41,7 @@ class PipeOcrTestCases:),PipeOcrBlueprint(definition="OCR with page options",- inputs={"ocr_input": InputRequirementBlueprint(concept="PDF")},+ inputs={"document": InputRequirementBlueprint(concept="PDF")},output="PageContent",type="PipeOcr",category="PipeOperator",