An Agent in FloAI is an autonomous entity that performs tasks by interacting with different environments, data sources, or APIs. Agents can have tools that can perform certain actions like sending an email or updating a database. FloAI supports different kinds of agents like LLM agents, agentic agents, delegator agents, etc.
The following is the YAML configuration for an agent:
name:WeatherAssistant# name of the agentkind:agentic# type of the agent, optional (default agentic)job:># the job of this agent Given the city name you are capable of answering the latest weather this time of the year by searching the internettools:# All the tools available to the agent - name:InternetSearchTool
In some cases, the configuration might have more fields depending on the type of agent. Check below to know what is additionally needed for each agent
Types of Agents
FloAI offers different agent types designed for specific purposes, helping you craft customizable workflows. You can define the agent type using the kind parameter within the agent block in the YAML configuration. Below are the key types and their use cases:
Agentic Agents(Default)
Purpose: These are the standard agents in FloAI, always associated with a tool.
Use Case: Ideal when agents must interact with external systems (e.g., APIs, databases).
Note: Throws an exception if no tool is provided.
```pythonsimple_weather_checking_agent ="""apiVersion: flo/alpha-v1kind: FloAgentname: weather-assistantagent: name: WeatherAssistant kind: agentic job: > Given the city name you are capable of answering the latest whether this time of the year by searching the internet
tools: - name: InternetSearchTool"""```
Corresponding code example:
from flo_ai import FloAgentweather_agent = FloAgent.create( session=session, name="WeatherAssistant", job="Given the city name you are capable of answering the latest whether this time of the year by searching the internet",
tools=[TavilySearchResults()])agent_flo: Flo = Flo.create(session, weather_agent)agent_flo.draw()agent_flo.invoke("Whats the whether in New Delhi, India ?")
LLM Agents
Purpose: These agents operate without tools, relying on the current execution state.
Use Case: Best suited for language model-driven decision-making without external interactions. For example, summarising information or making decisions based on prior execution results.
simple_llm_agent ="""apiVersion: flo/alpha-v1kind: FloAgentname: llm-assistantagent: name: Ask llm anything kind: llm job: > You are a high school maths teacher. Answer any questions the students ask """
Similar code example:
from flo_ai import FloLLMAgentsimple_llm_agent = FloLLMAgent.create( session=session, name="WeatherAssistant", job="You are a high school maths teacher. Answer any questions the students ask ",)agent_flo: Flo = Flo.create(session, simple_llm_agent)agent_flo.invoke("What is pythagorus theorum, just give me the formula")
Tool Agents
Tools agents are agents that only do a tool call without involving LLM.
Purpose: These agents operate as just tool executors, they don't need llms
Use Case: Best suited for language simple tool executions like retrieving from a vector db.
Purpose: Agents capable of reflecting on the current workflow results and retrying a previous step if necessary.
Use Case: Helpful in workflows where agents need to adjust based on partial failures. For instance, retraining an AI model or reprocessing a data pipeline step after detecting issues.
yaml_data ="""apiVersion: flo/alpha-v1kind: FloRoutedTeamname: adding-teamteam: name: EssayTeam agents: - name: EssayWriter kind: llm job: > You are an essay assistant tasked with writing excellent 300-word essays. Generate the best essay possible for the user's request.
Respond with a revised version of your previous attempts if you are provided a critique view. A maximum of total 100 words
- name: ReflectionAgent kind: reflection retry: 1 to: - name: EssayWriter job: > You are a teacher grading an essay submission. Generate critique and recommendations for the user's submission.
Provide detailed recommendations, including requests for length, depth, style, etc. - name: FinalEssayProducer kind: llm job: > Generate the final assay to be returned to the user router: name: router kind: linear"""
The reflection agent here sends critique feedback back to `EssayWriter` and the essay writer uses the feedback to re-write the essay.
As you can see they have two additional parameters compared to normal agents.
to: The agent to which reflect to, here its `EassyWriter`
retry: The number of times reflection should happen (default 1)
Delegation Agents
Purpose: Agents that delegate the control flow to another agent based on contextual prompts.
Use Case: Useful in complex decision-making scenarios where different agents specialize in different tasks. For example, a customer support bot delegates an issue to a specialized technical agent based on user queries.
yaml_data ="""apiVersion: flo/alpha-v1kind: FloRoutedTeamname: adding-teamteam: name: EssayTeam agents: - name: EssayWriter kind: llm job: > You are an essay assistant tasked with writing an excellent 300-word essay. Generate the best essay possible for the user's request.
Respond with a revised version of your previous attempts if you are provided a critique view. A maximum of total 100 words
- name: DelegatorAgent kind: delegator retry: 1 to: - name: EssayWriter job: > You are a teacher grading an essay submission. Score the essay between 1 to 10, with 10 being perfect If the score is greater than 7 send it to FinalEssayProducer else if it's less than or equal to 7 send it to EssayWriter with suggestions to change - name: FinalEssayProducer kind: llm job: > Generate the final assay to be returned to the user router: name: router kind: linear"""
Like the reflection agent, even a delegator agent needs to and retry param
Currently (v0.0.3), reflection and delegation agents are only supported with linear routers. Support for other routers will be added in future releases.