Expert guide for writing and editing Pipelex .plx pipeline files. Validates syntax, structures concepts, and implements pipes following Pipelex declarative language conventions.
Expert guidance for writing and editing pipelines using the Pipelex declarative language in `.plx` files. Pipelex is a declarative language for composable AI workflows.
This skill helps you create and edit Pipelex pipeline files with proper syntax, validation, and structure. It guides you through domain definitions, concept modeling, and pipe implementations following Pipelex best practices.
Before writing any Pipelex code:
1. Write your plan in natural language
2. Identify the concepts (semantic entities) involved
3. Outline the pipeline steps and flow
4. Then transcribe the plan into Pipelex syntax
Every pipeline file has three sections:
**Domain Statement:**
```plx
domain = "domain_name"
description = "Description of the domain"
```
**Concept Definitions:**
```plx
[concept]
ConceptName = "Description of the concept"
```
Naming rules for concepts:
**Pipe Definitions:**
```plx
[pipe.your_pipe_name]
type = "PipeType"
description = "What the pipe does"
inputs = { input_1 = "ConceptName1", input_2 = "ConceptName2" }
output = "ConceptName"
```
Choose one of three approaches:
**A. Concept Only (no structure needed):**
```plx
[concept.Landscape]
description = "A scenic outdoor photograph"
refines = "Image"
```
**B. Inline Structure (RECOMMENDED):**
```plx
[concept.Invoice]
description = "A commercial document"
[concept.Invoice.structure]
invoice_number = "Unique identifier"
total_amount = { type = "number", description = "Total amount", required = true }
issue_date = { type = "date", description = "Issue date", required = true }
line_items = { type = "list", item_type = "text", description = "Items" }
```
Supported types: text, integer, boolean, number, date, list, dict
Properties: type, description, required, default_value, choices, item_type, key_type, value_type
**C. Python StructuredContent Class (for advanced features):**
```python
from pipelex.core.stuffs.structured_content import StructuredContent
from pydantic import Field, field_validator
class Invoice(StructuredContent):
"""A commercial invoice with validation."""
invoice_number: str = Field(description="Unique identifier")
total_amount: float = Field(ge=0, description="Total amount")
@field_validator('tax_amount')
@classmethod
def validate_tax(cls, v, info):
if v > info.data.get('total_amount', 0):
raise ValueError('Tax cannot exceed total')
return v
```
Use Python classes when you need custom validation, computed properties, or reusable structures.
Specify cardinality using bracket notation:
```plx
inputs = { document = "Text" }
inputs = { documents = "Text[]" }
inputs = { comparison_items = "Image[2]" }
```
**Controllers (flow control):**
**Operators (specific tasks):**
**PipeSequence:**
```plx
[pipe.analyze_document]
type = "PipeSequence"
description = "Extract and analyze document"
inputs = { pdf = "PDF" }
output = "Analysis"
steps = [
{ pipe = "extract_text", result = "text" },
{ pipe = "analyze_content", result = "analysis" }
]
```
**PipeCondition:**
```plx
[pipe.route_by_category]
type = "PipeCondition"
description = "Route based on category"
inputs = { data = "Input" }
output = "Text"
expression = "data.category"
default_outcome = "handle_default"
[pipe.route_by_category.outcomes]
small = "process_small"
large = "process_large"
```
**PipeLLM (Text Generation):**
```plx
[pipe.summarize]
type = "PipeLLM"
description = "Summarize text"
inputs = { text = "Text" }
output = "Summary"
prompt = """
Summarize this text:
@text
"""
```
**PipeLLM (Structured Output):**
```plx
[pipe.extract_invoice]
type = "PipeLLM"
description = "Extract invoice data"
inputs = { text = "Text" }
output = "Invoice"
prompt = """
Extract invoice information:
@text
"""
```
**PipeLLM (Vision):**
```plx
[pipe.analyze_image]
type = "PipeLLM"
description = "Analyze image"
inputs = { image = "Image" }
output = "Analysis"
prompt = """
Describe this image:
$image
"""
```
**PipeLLM (Multiple Outputs):**
```plx
[pipe.generate_ideas]
type = "PipeLLM"
description = "Generate ideas"
output = "Idea[3]"
prompt = "Generate 3 creative ideas"
```
**Always validate after writing or editing:**
```bash
source .venv/bin/activate # Linux/Mac
.venv\Scripts\activate # Windows
pipelex validate path_to_file.plx
pipelex validate all
```
If validation fails, iterate and fix errors. Common issues:
**CRITICAL**: Never break inputs across multiple lines.
**CORRECT:**
```plx
inputs = { input_1 = "Type1", input_2 = "Type2", input_3 = "Type3" }
```
**INCORRECT:**
```plx
inputs = {
input_1 = "Type1",
input_2 = "Type2"
}
```
Use batch functionality in PipeSequence steps:
```plx
steps = [
{ pipe = "process_items", batch_over = "input_list", batch_as = "item", result = "processed" }
]
```
**Simple Text Generation:**
```plx
domain = "storytelling"
[concept]
Story = "A creative narrative"
[pipe.generate_story]
type = "PipeLLM"
description = "Generate a short story"
output = "Story"
prompt = "Write a short story about AI"
```
**Structured Data Extraction:**
```plx
domain = "invoice_processing"
[concept.Invoice]
description = "Commercial invoice"
[concept.Invoice.structure]
invoice_number = { type = "text", required = true, description = "Invoice ID" }
total = { type = "number", required = true, description = "Total amount" }
[pipe.extract_invoice]
type = "PipeLLM"
description = "Extract invoice from text"
inputs = { text = "Text" }
output = "Invoice"
prompt = """
Extract invoice information:
@text
"""
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/pipelex-pipeline-development/raw