Overview
In the Upsonic framework, aTask
is a specific assignment completed by an Agent
. Tasks provide all necessary details for execution, such as a description, tools, response format, caching options, and more, facilitating a wide range of action complexities. Tasks within Upsonic can be collaborative, requiring multiple agents to work together through context sharing and task dependencies.
Tasks are executed by agents in a single-threaded manner, with each task processed sequentially. The execution flow includes task validation, context processing, tool processing, agent execution, response processing, and caching.
Task Attributes
The Task class provides comprehensive configuration options to customize task behavior and execution.Core Attributes
Attribute | Type | Description |
---|---|---|
description | str | A clear, concise statement of what the task entails |
tools | List[Any] | The tools/resources the agent can use for this task |
response_format | Union[Type[BaseModel], type[str], None] | The expected output format (string, Pydantic model, or None) |
context | Any | All context for this task - can include other tasks, files, images, documents, knowledge bases, or any other contextual information |
Advanced Configuration
Attribute | Type | Description |
---|---|---|
enable_thinking_tool | Optional[bool] | Whether to enable the thinking tool for complex reasoning |
enable_reasoning_tool | Optional[bool] | Whether to enable the reasoning tool for multi-step analysis |
guardrail | Optional[Callable] | Function to validate task output before proceeding |
guardrail_retries | Optional[int] | Maximum number of retries when guardrail validation fails |
enable_cache | bool | Whether to enable caching for this task |
cache_method | Literal[“vector_search”, “llm_call”] | Method to use for caching |
cache_threshold | float | Similarity threshold for cache hits (0.0-1.0) |
cache_duration_minutes | int | How long to cache results in minutes |
Creating a Task
Tasks in Upsonic are created directly in code using theTask
class constructor. Each task can be customized with specific tools, response formats, caching options, and validation rules to meet your exact requirements.
Basic Task Creation
Task with Tools
Task with Response Format
Adding Tools to a Task
Tasks can be equipped with various tools to extend their capabilities. Tools are added through thetools
parameter and can include custom functions, built-in tools, or tool collections.
Single Tool
Multiple Tools
Tool Collections
Tool Configuration
Adding Tasks to Other Tasks in Context
In Upsonic, you can use the output of one task as context for another task through thecontext
parameter. This enables task chaining and complex workflows.
Basic Task Chaining
Multiple Context Sources
Complex Workflow Example
Putting Knowledge Base to Task
Knowledge bases can be added to tasks to provide RAG (Retrieval-Augmented Generation) capabilities, allowing the agent to access and use external knowledge sources.Basic Knowledge Base Integration
Multiple Knowledge Bases
Knowledge Base with Direct Content
Adding Files and Images to Tasks
Tasks can include files, images, and documents through thecontext
attribute. The framework automatically handles file loading and provides them to the model for analysis.
Single Image/File
Multiple Files and Images
Files with Other Context
Supported File Formats
The framework supports various file formats including:- Images: PNG (.png), JPEG (.jpg, .jpeg), GIF (.gif), BMP (.bmp), TIFF (.tiff)
- Documents: PDF (.pdf), Word (.docx), Text (.txt), Markdown (.md)
- Data: CSV (.csv), JSON (.json), XML (.xml), Excel (.xlsx)
Response Format
Tasks support various response formats to structure the output according to your needs. You can specify the expected format using theresponse_format
parameter.