Overview
The Graph feature in Upsonic allows you to create complex workflows by connecting multiple AI Tasks together. Tasks can be executed sequentially or in parallel, with outputs from one task flowing into subsequent tasks. This enables building sophisticated AI pipelines where each task builds upon the results of previous ones.Creating a Graph
A Graph is the main structure that manages task execution and workflow. It handles task scheduling, execution order, and state management between tasks.default_agent
: The default agent to use for tasks that don’t specify their ownparallel_execution
: Whether to execute independent tasks in parallelmax_parallel_tasks
: Maximum number of tasks to execute in parallel (default: 4)show_progress
: Whether to display a progress bar during execution (default: True)
Creating Task Nodes
Task nodes are the building blocks of a graph. Each node contains a Task object and connects to other nodes to form a workflow.Note: Tasks in a graph work exactly the same as regular Tasks in Upsonic. You can provide prompts, tools, and context just as you would with standalone tasks.
Using Direct in Graph
The Direct interface provides a simpler way to interact with AI models without creating a full Agent configuration.filename
Creating Decision Nodes
Decision nodes allow you to create conditional branches in your graph, enabling dynamic workflows that can take different paths based on the output of previous tasks. Upsonic provides two types of decision nodes:Decision via Code (DecisionFunc)
TheDecisionFunc
allows you to use a custom Python function to determine which path to take in your graph based on the output of previous tasks.
Decision via LLM (DecisionLLM)
TheDecisionLLM
uses an AI model to make decisions based on the output of previous tasks, allowing for more complex decision-making without writing custom code.