Welcome to Azcore! This guide will get you building your first multi-agent system in under 5 minutes. We'll create a simple agent team that can answer questions and use tools.
🔑 2. Set Up Your API Key
Create a .env file in your project directory:
# .env
OPENAI_API_KEY=your-openai-api-key-here
⚡ 3. Create Your First Agent Team
Create a file called quick_start.py:
from azcore import Config, TeamBuilder, GraphOrchestrator
from langchain_core.tools import tool
# Load configuration
config = Config.from_env()
llm = config.get_llm()
# Define a simple tool
@tool
def search_web(query: str) -> str:
"""Search the web for information."""
return f"Found information about: {query}"
@tool
def calculate(math_expression: str) -> str:
"""Calculate a mathematical expression."""
try:
result = eval(math_expression)
return f"Result: {result}"
except:
return "Invalid expression"
# Create an agent team
agent_team = (TeamBuilder("assistant_team")
.with_llm(llm)
.with_tools([search_web, calculate])
.with_prompt("You are a helpful assistant that can search the web and do calculations.")
.build())
# Set up a simple orchestrator
orchestrator = GraphOrchestrator()
orchestrator.add_team(agent_team)
orchestrator.set_entry_point("assistant_team")
orchestrator.add_edge("assistant_team", "END")
# Compile the workflow
graph = orchestrator.compile()
# Test it!
result = graph.invoke({
"messages": [{"role": "user", "content": "What is 15 + 27? Also search for information about Python programming."}]
})
print("Agent Response:")
print(result["messages"][-1].content)
▶️ 4. Run Your Agent
Execute the script:
python quick_start.py
You should see output like:
Agent Response:
The sum of 15 + 27 is 42. Regarding Python programming, Python is a high-level programming language known for its simplicity and readability...
🎯 5. Next Steps
Congratulations! You've just created your first multi-agent system. Here's what you can do next:
Add More Tools
Extend your agent with more capabilities:
@tool
def get_weather(city: str) -> str:
"""Get weather information for a city."""
return f"Weather in {city}: Sunny, 72°F"
# Add to your team
agent_team = (TeamBuilder("assistant_team")
.with_llm(llm)
.with_tools([search_web, calculate, get_weather]) # Add new tool
.with_prompt("You are a helpful assistant with web search, calculation, and weather capabilities.")
.build())
Create Multiple Teams
Build a more complex system with specialized teams:
from azcore import Supervisor
# Create specialized teams
research_team = (TeamBuilder("research_team")
.with_llm(llm)
.with_tools([search_web])
.with_prompt("You are a research specialist.")
.build())
math_team = (TeamBuilder("math_team")
.with_llm(llm)
.with_tools([calculate])
.with_prompt("You are a mathematics specialist.")
.build())
# Create supervisor to coordinate teams
supervisor = Supervisor(
llm=llm,
members=["research_team", "math_team"]
)
# Build hierarchical orchestrator
orchestrator = GraphOrchestrator()
orchestrator.set_supervisor(supervisor)
orchestrator.add_team(research_team)
orchestrator.add_team(math_team)
orchestrator.set_entry_point("supervisor")
orchestrator.add_edge("supervisor", "END")
graph = orchestrator.compile()
Enable Reinforcement Learning
Make your agents learn optimal tool usage:
from azcore.rl import RLManager, HeuristicRewardCalculator
# Set up RL
rl_manager = RLManager(
tool_names=["search_web", "calculate"],
q_table_path="rl_data/agent_q_table.pkl"
)
reward_calc = HeuristicRewardCalculator()
# Create RL-enabled team
smart_team = (TeamBuilder("smart_team")
.with_llm(llm)
.with_tools([search_web, calculate])
.with_prompt("You are an intelligent assistant.")
.with_rl(rl_manager, reward_calc) # Enable learning!
.build())
🛠️ Troubleshooting
Common Issues
"ModuleNotFoundError: No module named 'azcore'"
pip install azcore
"AuthenticationError: OpenAI API key required"
- Check your
.envfile has the correct API key - Make sure the
.envfile is in your current directory
"Tool execution failed"
- Verify your tools are properly defined with the
@tooldecorator - Check that tool functions return strings
Need Help?
- Check the Installation Guide for detailed setup
- Visit GitHub Issues for community support
🎉 You're All Set!
You've successfully created your first Azcore multi-agent system! The framework provides:
- Hierarchical Architecture - Coordinator-planner-supervisor-team design
- Flexible Workflows - Sequential, concurrent, swarm, and graph-based patterns
- Reinforcement Learning - Agents that learn optimal tool usage
- Production Ready - Caching, error handling, and monitoring built-in