A team in FloAI is a group of agents working together towards a common goal. Just like a team in your workplace, each FloAI team is structured around a router that manages the flow of tasks between agents. The router acts like the team manager, ensuring that the right agent is called for the right task at the right time.
Currently, FloAI supports the supervisor router for teams, but additional router types will be introduced soon.
Defining a team
To create a team in FloAI, you define it in the YAML configuration. Here’s an example of how you can set up a team using a supervisor router:
apiVersion: flo/alpha-v1
kind: FloRoutedTeam
name: support-email-handler
team:
name: SupportTicketHandler
router:
name: SupportSupervisor
kind: supervisor
agents:
- name: HousingLoanTeamLead
role: Housing Loan Specialist
job: Fetch the housing loan information from the DB and answer the question
tools:
- name: HousingLoanTool
- name: RBIRegulationAgent
role: RBI Compliance Specialist
job: Your job is to answer any questions about RBI regulations
tools:
- name: RBITool
In this example:
The team SupportTicketHandler is led by a supervisor router named SupportSupervisor.
An agent, HousingLoanTeamLead & RBIRegulationAgent, is part of this team and has the role of handling housing loan queries using the HousingLoanTool & RBITool
Here is how to do the similar using code:
llm = ChatOpenAI(temperature=0, model_name='gpt-4o')
session = FloSession(llm).register_tool(
name="TavilySearchResults",
tool=TavilySearchResults()
)
researcher = FloAgent.create(
session,
name="Researcher",
role="Internet Researcher", # optional
job="Do a research on the internet and find articles of relevent to the topic asked by the user",
tools=[TavilySearchResults()]
)
blogger = FloAgent.create(
session,
name="BlogWriter",
role="Thought Leader", # optional
job="Able to write a blog using information provided",
tools=[TavilySearchResults()]
)
marketing_team = FloTeam.create(session, "Marketing", [researcher, blogger])
head_of_marketing = FloSupervisor.create(session, "Head-of-Marketing", marketing_team)
marketing_flo = Flo.create(session, routed_team=head_of_marketing)
Composing Teams
Teams in FloAI can also have sub-teams, allowing you to organize agents into smaller groups for more specific tasks. This feature is designed for complex workflows where a task might need to be broken down into several smaller tasks, each handled by a specialized team.
Here’s an example of a YAML configuration with sub-teams:
apiVersion: flo/alpha-v1
kind: FloRoutedTeam
name: blogging-team
team:
name: BloggingTeam
router:
name: supervisor
kind: supervisor
subteams:
- name: ResearchTeam
router:
name: ResearchSupervisor
kind: supervisor
agents:
- name: Researcher
job: Research the latest articles on a given topic.
tools:
- name: TavilySearchResults
- name: WritingTeam
router:
name: WritingSupervisor
kind: supervisor
agents:
- name: Blogger
job: Write a 300-word blog using the research documents provided by the researcher.
tools:
- name: BloggingTool
In this example:
The BloggingTeam has two sub-teams: ResearchTeam and WritingTeam.
The ResearchTeam has an agent, Researcher, who collects relevant articles using the TavilySearchResults tool.
The WritingTeam has a Blogger agent who writes a blog based on the research
Composing using code and creating subteams
chief_editorial = FloLLMAgent.create(
session,
name="Senior-Editor",
job="Have a look at the article created and give editorial suggestions"
)
edit_team = FloTeam.create(
session,
name="Editorial-Team",
members=[chief_editorial]
)
editor = FloSupervisor.create(
session,
name="Editor-Team-Routing",
team=edit_team
)
editorial_flo = Flo.create(session, routed_team=editor)
journal_company = FloTeam.create(session, "Newspaper", [marketing_flo, editorial_flo])
r3 = FloLinear.create(
session,
"linear-router",
journal_company
)
master_flo = Flo.create(session, routed_team=r3)
The master flo here is the parent of the two team flos