ai / multi.py
kevinhug's picture
multi agent
05222d8
raw
history blame
1.85 kB
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.team import Team
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.models.ollama import Ollama
from agno.models.groq import Groq
import os
chat=Groq(id='llama-3.3-70b-versatile') if os.getenv("GROQ_API_KEY") else Ollama(id="qwen2.5")
# Create individual specialized agents
researcher = Agent(
name="Researcher",
role="Expert at finding information by breaking the structure into components ie) architecture, code, algorithm, linux system",
tools=[DuckDuckGoTools(fixed_max_results=3)],
show_tool_calls=True,
tool_call_limit=1,
model=chat, #OpenAIChat("gpt-4o"),
#debug_mode=True,
)
engineer = Agent(
name="Security Engineer",
role="Security Expert at writing short, clear, engaging content for hands-on best practices, and common pitfalls with solution",
model=chat, #OpenAIChat("gpt-4o"),
)
# Create a team with these agents
content_team = Team(
name="Content Team",
mode="coordinate",
members=[researcher, engineer],
instructions="You are a team of researchers and writers that work together to create high-quality content.",
model=chat, #OpenAIChat("gpt-4o"),
markdown=True,
)
def bestPractice(topic):
r = content_team.run(topic)
return [m for m in r.messages if m.role == 'assistant'][-1].content
if __name__=='__main__':
from pprint import pprint
from agno.utils.pprint import pprint_run_response
r=content_team.run("Docker Containers")
pprint_run_response(r, markdown=True)
print([m for m in r.messages if m.role == 'assistant'][-1].content)
print("")
pprint(r.messages)
# Run the team with a task
#content_team.print_response("Create a common pitfalls with best practice article about application security for using Docker Containers")