Quickstart
Zytron is an enterprise-grade, production-ready framework designed to facilitate the seamless collaboration of multiple agents at scale. It empowers organizations to orchestrate intelligent agents that work collaboratively to automate complex, real-world tasks with precision and efficiency. This guide provides a streamlined process to get started with Zytron, covering environment setup, agent creation, and the implementation of advanced multi-agent methodologies.
Requirements
Python 3.10 or above
.env
file with API keys from your providers likeOPENAI_API_KEY
,ANTHROPIC_API_KEY
Set an environment variable for your workspace directory:
Installation
To install Zytron, run:
Usage Example: Single Agent
Here’s a simple example of creating a financial analysis agent powered by OpenAI’s GPT-4 model. This agent will analyze financial queries like how to set up a ROTH IRA.
Agent Class
Attributes:
agent_name
: Name of the agent.system_prompt
: System-level instruction guiding the agent's behavior.llm
: Language model used by the agent (e.g., GPT, Anthropic).max_loops
: Max iterations for a task.autosave
: Auto-saves the state after each iteration.Methods:
run(task: str)
: Executes the agent’s task.ingest_docs(doc_path: str)
: Ingests documents into the agent’s knowledge base.filtered_run(task: str)
: Runs agent with a filtered system prompt.
Creating Agents from YAML
Step 1: Define Your Agents in a YAML File
The create_agents_from_yaml
function works by reading agent configurations from a YAML file. Below is an example of what your YAML file (agents_config.yaml
) should look like this. Example YAML Configuration (agents_config.yaml
):
Key Configuration Fields:
agent_name: Name of the agent.
model: Defines the language model settings (e.g., API key, model name, temperature, and max tokens).
system_prompt: The system prompt used to guide the agent’s behavior.
task: (Optional) Task for the agent to execute once created.
Step 2: Create the Main Script
Now, create the main Python script that will use the create_agents_from_yaml
function.
main.py
:
main.py
:Example Run:
This will: 1. Load agent configurations from agents_config.yaml
. 2. Create the agents specified in the YAML file. 3. Run the tasks provided for each agent. 4. Output the task results to the console.
Step 3: Customize the Return Type
The create_agents_from_yaml
function supports multiple return types. You can control what is returned by setting the return_type
parameter to "agents"
, "tasks"
, or "both"
.
Return Only Agents To create agents but not run tasks, set
return_type="agents"
:
Return Only Task Results If you only care about the task results and not the agent objects, set
return_type="tasks"
:
Return Both Agents and Task Results To return both the list of created agents and task results, use
return_type="both"
:
Step 4: YAML Structure for Multiple Agents
The YAML file can define any number of agents, each with its own unique configuration. You can scale this setup by adding more agents and tasks to the agents
list within the YAML file.
Each agent will be initialized according to its configuration, and tasks (if provided) will be executed automatically.
Integrating External Agents
Integrating external agents from other agent frameworks is easy with zytron.
Steps:
Create a new class that inherits
Agent
Create a
.run(task: str) -> str
method that runs the agent and returns the response.The new Agent must return a string of the response. But you may add additional methods to save the output to JSON.
Griptape Example
For example, here's an example on how to create an agent from griptape.
Here’s how you can create a custom Griptape agent that integrates with the Zytron framework by inheriting from the Agent
class in Zytron and overriding the run(task: str) -> str
method.
Key Components:
GriptapeZytronAgent: A custom class that inherits from the
ZytronAgent
class and integrates the Griptape agent.run(task: str) -> str: A method that takes a task string, processes it (e.g., splitting into a URL and filename), and runs the Griptape agent with the provided inputs.
Griptape Tools: The tools integrated into the Griptape agent (e.g.,
WebScraperTool
,PromptSummaryTool
,FileManagerTool
) allow for web scraping, summarization, and file management.
You can now easily plug this custom Griptape agent into the Zytron Framework and use it to run tasks!
Overview of Zytron Architectures in the Zytron Framework
1. Sequential Workflow
Overview: The SequentialWorkflow
enables tasks to be executed one after the other. Each agent processes its task and passes the output to the next agent in the sequence.
Mermaid Graph:
Task Input
Blog Generator Agent
Summarizer Agent
Task Output
Code Example:
2. Agent Rearrange
Overview: AgentRearrange
allows the orchestration of agents in both sequential and parallel configurations. The user can define a flexible flow of tasks between agents.
Mermaid Graph:
Director Agent
Worker 1 Agent
Worker 2 Agent
Task Completed
Code Example:
4. Mixture of Agents
Overview: MixtureOfAgents
is a parallelized architecture where agents perform tasks concurrently and then feed their results back into a loop for final aggregation. This is useful for highly parallelizable tasks.
Mermaid Graph:
Director Agent
Accountant 1
Accountant 2
Final Aggregation
Code Example:
5. Spreadsheet Zytron
Overview: SpreadSheetZytron
enables the management of thousands of agents simultaneously, where each agent operates on its own thread. It’s ideal for overseeing large-scale agent outputs.
Mermaid Graph:
Spreadsheet Zytron
Twitter Agent
Instagram Agent
Facebook Agent
LinkedIn Agent
Email Agent
Code Example:
These are the key zytron architectures available in the Zytron Framework. Each one is designed to solve different types of multi-agent orchestration problems, from sequential tasks to large-scale parallel processing.
Overview of Zytron Architectures
Workflow Classes
SequentialWorkflow:
Chains agents, where one agent's output becomes the next agent’s input.
AgentRearrange:
Dynamically rearranges agent tasks either in parallel or sequentially based on defined flow.
Zytron Architectures
Hierarchical Zytron:
Implements top-down control, where a boss agent coordinates tasks among sub-agents.
Spreadsheet Zytron:
A large-scale zytron architecture for managing multiple agents working concurrently.
Last updated