Execute a Pipeline
Basic Execution
When you have a pre-built pipeline, here is how you can execute it:
# Initialize the pipeline
pipeline = step_1 | step_2 | step_3 # or replace it with your prebuilt pipeline
# Prepare initial state
initial_state = {
"user_query": "What is machine learning?",
"history": "",
"context": ""
}
# Execute the pipeline
final_state = await pipeline.invoke(initial_state)
# Access the results
response = final_state["response"]
references = final_state["references"]
Execution with Configuration
You can also run the pipeline with configuration. Configuration can include debugging, caching, timeouts, retries, and other runtime parameters (top_k
for retriever, etc). The configuration is passed to the invoke() method and affects how the pipeline executes.
# Execute with custom configuration
config = {
"debug_state": True, # Include state logs in output
"cache_enabled": True,
"timeout": 30, # seconds
"max_retries": 3
# other configuration
}
final_state = await pipeline.invoke(
initial_state=initial_state,
config=config
)
Last updated