LettreAI Documentation
  • Home
  • User Guide
  • Nutshell
  • Manual
  • Examples
  • API
  1. API Reference
  2. Pipeline API
  • Getting Started
    • AI Task Documentation
    • Installation
    • Quick Start
  • User Guide
    • User Guide
  • Nutshell
    • AI-Task in a Nutshell
  • Manual
    • Core Concepts
    • Configuration
    • Instructions
    • Productions
    • Functions
    • LLM Integration - Claude
  • Examples
    • Basic Examples
    • Advanced Examples
    • Instruction Examples
    • Production Examples
  • Reports
    • AI Task Reports
  • API Reference
    • Pipeline API
    • Engine API
    • Functions API
  • Development
    • Contributing
    • Architecture
  1. API Reference
  2. Pipeline API

Pipeline API

Pipeline API Reference

The ai_task.task module provides the core functionality for defining and executing AI pipelines.

Pipeline Class

The Pipeline class (formerly called Task) is the main entry point for defining and executing AI pipelines.

from ai_task.task import Pipeline

# Create a pipeline from a configuration file
pipeline = Pipeline.from_file("example.ai")

# Execute the pipeline
result = pipeline.execute()

Methods

from_file(file_path)

Creates a Pipeline instance from a configuration file.

Parameters:

  • file_path (str): Path to the configuration file

Returns:

  • Pipeline: A new Pipeline instance

execute(input_data=None, monitor=False)

Executes the pipeline with the given input data.

Parameters:

  • input_data (dict, optional): Input data for the pipeline
  • monitor (bool, optional): Whether to enable detailed monitoring

Returns:

  • dict: The result of the pipeline execution

generate_report(report_file=None, preview=False)

Generates a report of the pipeline execution.

Parameters:

  • report_file (str, optional): Path to the report file
  • preview (bool, optional): Whether to preview the report in a web browser

Returns:

  • str: Path to the generated report

create_production_instance()

Creates a new instance for this pipeline within its production.

Parameters:

  • None

Returns:

  • str: The ID of the new production instance

run_in_production(instance_id, input_data=None)

Runs the pipeline within a specific production instance.

Parameters:

  • instance_id (str): The ID of the production instance
  • input_data (dict, optional): Input data for the pipeline

Returns:

  • dict: The result of the pipeline execution

PipelineConfig Class

The PipelineConfig class (formerly called TaskConfig) represents the configuration for a pipeline.

from ai_task.task import PipelineConfig

# Create a pipeline configuration
config = PipelineConfig(
    name="Example Pipeline",
    description="An example pipeline",
    production={
        "name": "examples",
        "home": "./productions"
    },
    pipe=[
        {
            "type": "function",
            "name": "input_loader",
            "func": "aisource",
            "args": {"file": "input.txt"}
        },
        {
            "type": "llm",
            "name": "processor",
            "tmpl": "process",
            "model": "claude-3-7-sonnet-latest"
        },
        {
            "type": "function",
            "name": "output_writer",
            "func": "airesult",
            "args": {"file": "output.txt", "format": "text"}
        }
    ]
)

# Create a pipeline from the configuration
pipeline = Pipeline(config)

Attributes

  • name (str): The name of the pipeline
  • description (str): A description of what the pipeline does
  • instruction_dir (str): The directory where instructions are stored
  • production (dict, optional): Production configuration
  • pipe (list): The sequence of tasks that make up the pipeline

Command-Line Interface

The CLI provides a command-line interface for executing pipelines.

aitask example.ai [options]

Available options:

  • --monitor: Enable detailed monitoring of the pipeline execution
  • --report: Generate a report of the pipeline execution
  • --report-file FILE: Specify the name of the report file
  • --preview: Preview the report in a web browser after generation
  • --input KEY=VALUE: Provide input values for the pipeline
  • --production-new: Create a new production instance and run the pipeline in it
  • --production-instance ID: Run the pipeline in an existing production instance
  • --production-list: List all instances of a production

Next Steps

  • Learn about the engine API
  • Discover the built-in functions
AI Task Reports
Engine API

LettreAI Documentation

 
  • Edit this page
  • Report an issue
  • License: MIT