Extend LlamaIndex Workflows via Subclassing, Nesting, and Concurrent Execution

LlamaIndex workflow subclassing, nesting and concurrent execution: extend base workflows, build reusable parts and run independent steps in parallel.

LlamaIndex workflows: subclassing, nesting and concurrent execution

This article extends the previous discussion on LlamaIndex workflow branching and loops. It details workflow subclassing, nesting, and concurrent execution.

Subclassing extends existing workflows while preserving core logic. Concurrent execution runs independent tasks simultaneously to improve performance. The following sections detail these features.

LlamaIndex Workflow Subclassing and Nesting

LlamaIndex supports extensibility through subclassing and nesting.

Use Case: Payment Processing System

Consider a payment processing system. The base workflow processes credit card transactions. Some transactions require additional steps, such as fraud checks or invoice generation.

Subclassing extends the base workflow. It adds these steps for special cases. It leaves the core payment logic unchanged.

LlamaIndex Concurrent Workflow Execution

Concurrent execution improves performance. LlamaIndex runs independent workflow steps simultaneously. This method increases speed and resource utilization. It applies to tasks that run in parallel without affecting the final result.

Use Case: Querying Multiple External APIs

Consider an application that queries multiple external APIs. Executing requests concurrently reduces total latency. Sequential execution waits for each response before issuing the next request. LlamaIndex defines the maximum concurrent instances for each step.

Conclusion:

LlamaIndex workflows support subclassing, nesting, and concurrent execution. Subclassing provides custom logic. Nesting organizes complex processes. Concurrent execution reduces processing time. These features improve workflow maintainability and efficiency.

Apply workflow capabilities to improve application design.

See our agentic workflows service for production use of workflows like these.

Start with our LlamaIndex workflow overview, then compare the Swarms framework.

Frequently Asked Questions

What is workflow subclassing in LlamaIndex?
Subclasses add functionality to existing workflows. They reduce code duplication and preserve base-class logic. For example, a base workflow processes credit card transactions. A subclass adds extra steps, such as fraud checks or invoice generation, for special cases and leaves the core payment logic unchanged.
What are nested workflows in LlamaIndex?
Nested workflows decompose complex processes into smaller parts. They create reusable components and simplify modular management. Nesting organizes complex processes, and subclassing supplies custom logic. Together these features improve workflow maintainability and efficiency, so teams can change one part of a process without rebuilding the whole structure.
How does concurrent execution work in LlamaIndex workflows?
LlamaIndex runs independent workflow steps at the same time. This increases speed and resource utilization, and it applies to tasks that run in parallel without affecting the final result. For an application that queries several external APIs, concurrent requests reduce total latency. LlamaIndex defines the maximum concurrent instances for each step.