ai / multi.py
kevinhug's picture
multi agent
f269105
raw
history blame
1.71 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.1-8b-instant') if os.getenv("GROQ_API_KEY") else Ollama(id="llama3.2" )
# Create individual specialized agents
researcher = Agent(
name="Researcher",
role="Expert at finding information by breaking the structure into components",
tools=[DuckDuckGoTools()],
show_tool_calls=True,
model=chat, #OpenAIChat("gpt-4o"),
#debug_mode=True,
)
engineer = Agent(
name="Security Engineer",
role="Security Expert at writing 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 r.messages[-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.content for m in r.messages if m.role == 'assistant'][-1])
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")