Donew’s as provisions
Yea you read it right, donews are also provisions. This is not a run of the mill chaining of LLM flows. They are isolated, reusable, and soon going to be portable. donew tasks can be composed in powerful ways, facilitating both horizontal and vertical composition. Whether you’re combining multiple tasks side-by-side or nesting tasks within tasks, the sky is the limit. This flexible composition model empowers you to create complex workflows that remain elegant and maintainable. The composability of donew tasks is designed without arbitrary limits. You can nest tasks to an arbitrary depth or define multiple horizontal task groups. The design ensures that tasks remain organized and maintain a clear separation of concerns, regardless of the level of nesting or the number of concurrent tasks.
Key Benefits
- Seamless integration of multiple independent tasks
- Task isolation and independence. Each task can use its own set of libraries tools and models.
- Each task is a self-contained unit with a clear purpose and responsibility
- Intuitive nesting for complex workflows
- Scalable design that adapts to growing complexity
- Clear separation of task responsibilities making debugging and maintenance easier
Use Cases
- Orchestrating data pipelines with independent fetch, process, and analysis tasks
- Managing complex user interactions where one action triggers a series of nested tasks
- Building modular AI workflows where tasks can be recombined or extended effortlessly
Horizontal Composition
Horizontal composition allows you to combine multiple specialized donews into an aggregated provision. Each donew is enhanced with a specific realm item and a custom envision transformation, creating a more robust composition.
from donew import DO
from donew.new import LiteLLMModel
from donew.new.provisions.mcp_task import NewMCPRunTask
from donew.new.provisions.browse import Browse
from your_project.report_analyzer import ReportAnalyzer
# Assuming ReportAnalyzer is available for realm composition.
model = LiteLLMModel(model_id="gpt-4o-mini")
# Create specialized donews with specific realm items and envision transformations
super_doer_a = (DO.New(model, name="DoBrowser", purpose="Fetch web content")
.realm([DO.Browse(headless=False)])
.envision(...)
super_doer_b = (DO.New(model, name="MCPRunner", purpose="Perform multi-core tasks")
.realm([NewMCPRunTask(task="...")])
.envision(...))
super_doer_c = (DO.New(model, name="ReportGenerator", purpose="Generate analytical reports")
.realm([ReportAnalyzer()])
.envision(...))
# Compose donews horizontally into an aggregated realm
super_doer_root = (DO.New(model, name="Aggregator", purpose="Aggregate specialized tasks")
.realm([super_doer_a, super_doer_b, super_doer_c]))
final_result = super_doer_root.enact("Combine outputs to produce a final report")
Vertical Composition
Vertical composition lets you nest donews in a hierarchy, each adding its own flair with specialized realm items and envision transformations. This layered approach creates a rich, multi-step workflow.
from donew import DO, LiteLLMModel
model = LiteLLMModel(model_id="gpt-4o-mini")
class Analysis(BaseModel):
"""A computation"""
...
# Create a base donew with a specialized realm item
report_analyzer = (DO.New(model, name="ReportAnalyzer", purpose="Gets a report and analyzes it. Easy")
.realm([ReportAnalyzer()]) # this is your custom donew
.envision(Analysis))
class Computation(BaseModel):
"""A computation"""
# Nest the base donew within an intermediate donew that combines additional tools
data_processor = (DO.New(model, name="DataProcessor", purpose="Analyzes given raw data, computes sums and stuff")
.realm([report_analyzer, MCPRun(task="compute_csv_sums", ...).init() ])
.envision(Computation))
# Further nest the intermediate donew within a top-level donew complemented by report analysis tools
top_level_super_doer = (DO.New(model, name="AnalysisSuperDoer", purpose="Retrieves data from the web and analyzes it")\
.realm([data_processor, DO.Browse(headless=False)])
final_result = top_level_super_doer.enact("Goto XXX and get the latest data, compute the sums and save the results to a file")
Infinite Nesting and Scalability
With infinite composability, donew tasks open a world of possibilities for building robust, flexible, and scalable automation workflows. Experiment with both horizontal and vertical compositions to fully leverage the power of donew and transform your task orchestration strategies.
Happy composing!