Advanced Execution
This page covers more advanced features and techniques for executing tasks, utilizing agents, and orchestrating complex workflows with DigitalFate. For those who have mastered the basic task execution, these advanced strategies will help optimize performance and unlock deeper functionality.
π§ Using Multiple Agents
DigitalFate allows you to create and configure multiple agents that work together on a task. These agents can be specialized for different roles and collaborate to solve more complex problems.
Multi-Agent Collaboration
You can distribute tasks across multiple agents to solve problems collaboratively. This is useful for tasks that require multiple skill sets or specialized knowledge areas.
Example: Collaborative Task Execution
pythonCopyEditfrom digitalfate import digitalfateClient, Task, AgentConfiguration
# Initialize client
client = digitalfateClient("localserver")
client.set_config("OPENAI_API_KEY", "YOUR_API_KEY")
# Define agents with different roles
agent1 = AgentConfiguration(
job_title="Research Assistant",
company_url="https://digitalfate.ai",
company_objective="Assist in research tasks"
)
agent2 = AgentConfiguration(
job_title="Data Analyst",
company_url="https://digitalfate.ai",
company_objective="Analyze data collected from research"
)
# Define tasks
task1 = Task(description="Collect research data on DigitalFate")
task2 = Task(description="Analyze collected data for trends")
# Execute tasks across multiple agents
client.multi_agent([agent1, agent2], [task1, task2])
# Collect results
for agent, task in zip([agent1, agent2], [task1, task2]):
print(f"Results from {agent.job_title}:")
print(task.response)
In this example, agent1 gathers research data, while agent2 analyzes the data. You can expand this by including more agents for specific roles, such as a content creator, a debugger, or a project manager.
π Task Chaining
Task chaining allows you to link tasks together by using the output of one task as input for the next. This enables complex workflows where the result of one task drives the next, creating a seamless pipeline.
Example: Chaining Tasks
pythonCopyEditfrom digitalfate import digitalfateClient, Task
# Initialize client
client = digitalfateClient("localserver")
client.set_config("OPENAI_API_KEY", "YOUR_API_KEY")
# Define initial task
task1 = Task(description="Gather market analysis data for DigitalFate")
# Define follow-up task based on the result of task1
task2 = Task(description="Generate insights based on market data from task1")
# Execute task1 first, then task2
client.call(task1)
task2.context = [task1.response] # Use task1's output as input for task2
client.call(task2)
# Display task2 results
print(task2.response)
This method ensures that your agents can handle complex dependencies between tasks and work with dynamic inputs.
π§βπΌ Task Execution with Advanced Agent Configuration
DigitalFate provides flexibility in configuring agents for specific tasks. You can fine-tune the agentβs memory, context, and even give them reflection capabilities, enabling them to reconsider and improve their responses.
Reflection Mechanism
Reflection allows agents to self-evaluate their responses and improve over time. This can lead to higher quality outputs as agents learn from their mistakes and successes.
pythonCopyEditfrom digitalfate import AgentConfiguration
# Enable reflection for an agent
product_manager_agent = AgentConfiguration(
job_title="Product Manager",
company_url="https://digitalfate.ai",
company_objective="To build an AI agent framework",
reflection=True # Enable reflection for agent to validate and improve responses
)
# Execute task with reflective agent
task1 = Task(description="Research AI market trends")
client.agent(product_manager_agent, task1)
Memory Configuration
By enabling memory, agents can store context between task executions, allowing them to perform long-running or context-dependent tasks with better continuity.
pythonCopyEditproduct_manager_agent = AgentConfiguration(
job_title="Product Manager",
memory=True, # Enable memory for contextual understanding over time
)
# Define task
task1 = Task(description="Manage project progress")
# Execute task
client.agent(product_manager_agent, task1)
This configuration is particularly useful when an agent needs to maintain context between different phases of a project or handle complex workflows over an extended period.
π Distributed Task Execution
Digital Fate can scale your execution to handle larger, distributed workflows. You can split tasks across multiple servers or use multiple agents that execute tasks concurrently, which is especially useful for large-scale production systems.
Example: Distributed Task Execution Using Cloud Deployment
When deploying Digital Fate on a cloud platform such as AWS or GCP, you can distribute tasks to different instances for increased parallelism.
pythonCopyEdit# Configuration for cloud deployment (e.g., AWS)
client.set_config("AWS_ACCESS_KEY_ID", "YOUR_AWS_ACCESS_KEY_ID")
client.set_config("AWS_SECRET_ACCESS_KEY", "YOUR_AWS_SECRET_ACCESS_KEY")
client.set_config("AWS_REGION", "us-east-1")
# Define distributed tasks
task1 = Task(description="Analyze large dataset on AWS EC2 instance")
task2 = Task(description="Process results on a separate instance")
# Execute tasks across different cloud instances
client.multi_agent([agent1, agent2], [task1, task2])
By distributing tasks to separate instances, Digital Fate can handle resource-intensive tasks with high efficiency and scalability.
π Task Context Management
Task context plays a crucial role in guiding agents to produce relevant and accurate results. You can manually manage context by attaching additional files, data sources, or external knowledge bases to tasks.
Example: Adding Knowledge Base to Task
pythonCopyEditfrom digitalfate import KnowledgeBase
# Create a knowledge base with relevant context
kb = KnowledgeBase(files=["market_analysis.pdf", "https://digitalfate.ai"])
# Attach knowledge base to task
task1 = Task(description="Analyze market trends", context=[kb])
# Execute task with additional context
client.call(task1)
# Print results
print(task1.response)
In this example, the task is enhanced with additional context from a knowledge base, improving the agent's ability to generate accurate insights.
π οΈ Optimizing Task Execution with Cost Efficiency
Digital Fate offers mechanisms for optimizing both cost and latency during task execution. You can control when to directly call an LLM (Large Language Model) versus when to use agents, depending on the task's complexity.
Example: Using LLM Calls Directly for Simpler Tasks
pythonCopyEdit# For simpler tasks, directly call the LLM to save cost and time
task1 = Task(description="Generate a summary of the latest AI trends")
client.call(task1)
This reduces the overhead of using agents and makes task execution more efficient for straightforward tasks.
π― Conclusion
By leveraging Digital Fateβs powerful execution features, you can scale and optimize your task workflows, create more complex collaborative agents, and manage tasks across multiple environments. Whether you are deploying in the cloud, chaining tasks, or refining your agentsβ abilities with memory and reflection, Digital Fate empowers you to automate and optimize with ease.
These advanced strategies provide the foundation for building sophisticated AI systems that can handle real-world applications at scale.
Last updated