Tasks
Tasks are the fundamental unit of work in the system. Each task represents a specific objective that needs to be accomplished, along with the instructions and tools needed to complete it.
Task Structure
A task consists of:
- Objective: The clear goal that needs to be achieved
- Instructions: Step-by-step guidance for accomplishing the goal
- Tools: Required capabilities to complete the task
- Experts: Required domain knowledge or expertise
Chat Tasks
Chat tasks handle interactive conversations with users. Here's an example from our chat system:
async def setup_chat_task(db: Session, chat_request: ChatRequest):
"""
Sets up a chat task with the necessary configuration.
- Handles user messages
- Manages conversation context
- Integrates with tools and agents
"""
RAG Tasks
Retrieval-Augmented Generation (RAG) tasks combine search and generation:
async def rag_flow(
rag_request: RAGRequest,
max_llm_calls: int = 5,
):
"""
Handles RAG requests with:
- Query processing
- Document retrieval
- Response generation
"""
Web Event Tasks
Tasks can also handle web-based events and interactions:
async def handle_web_event(
event_type: str,
event_data: dict,
):
"""
Processes web events with:
- Event validation
- Data transformation
- Response handling
"""
Task Builders
The system includes task builders to help construct complex tasks:
class TaskBuilder:
"""
Helps construct tasks with:
- Proper configuration
- Tool assignment
- Expert selection
"""
Best Practices
When working with tasks:
- Define clear, specific objectives
- Provide detailed instructions
- Specify required tools and experts
- Handle errors gracefully
- Monitor task progress