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 newPipelineinstance
execute(input_data=None, monitor=False)
Executes the pipeline with the given input data.
Parameters:
input_data(dict, optional): Input data for the pipelinemonitor(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 filepreview(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 instanceinput_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 pipelinedescription(str): A description of what the pipeline doesinstruction_dir(str): The directory where instructions are storedproduction(dict, optional): Production configurationpipe(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