Quickstart
Get started in just 5 lines of code
Pre-requisites
To get started with Flo, you should be comfortable with Python 3.8 or higher, including its core concepts like async/await programming, object-oriented programming, and type hints.
You'll need a basic foundation in LangChain, particularly in working with chains, composing prompts, and handling LLM interactions. Additionally, experience with LangChain tools is a plus
Installing Dependencies
Create your first agent: Step by Step Guide
FloAI allows you to compose and execute complex workflows by configuring agents, tools, and their interactions using YAML definitions. We are going to create an AI agent that can research the internet and write a blog on the given topic.
FloAI follows an agent team architecture, where agents are the basic building blocks, and teams can have multiple agents and teams themselves can be part of bigger teams.
Building a working agent or team involves 3 steps:
Create a session using
FloSession
, and register your tools and modelsDefine you agent/team/team of teams using yaml or code
Build and run using
Flo
Step 1: Create an LLM Object
The first step in building a workflow with FloAI is to define the Large Language Model (LLM) that the agents will use for their tasks. FloAI integrates with various LLMs, and here, we’ll use gpt-4
from OpenAI. The LLM object here is an langchain object
Note: FloAI will soon remove the langchain dependency and come up with its own LLM class. For now you can use the langchain packages like langchain_openai
You can install langchain open ai using pip install langchain_openai
Step 2: Define the YAML for your team
Next, define your workflow in YAML. This YAML structure describes the agents, their roles, jobs, and the tools they will use.
The Yaml defines an agent, with the tool `TavilySearchResults`. The tool will be registered in the next step. To learn more check YAML configurations
If you prefer to use code, you can directly use the following:
Step 3: Register Tools and Build Flo
To enable the agents to perform their jobs, you need to register any tools they use. In this case, both agents use the TavilySearchResults
tool, which performs searches on the internet. After registering the tools, you can build the workflow (referred to as "Flo") from the session and the YAML definition.
If you are using code, you can build using the following line:
Step 4: Execute the Flo
Once the Flo is built, you can execute it by streaming or invoking it directly. For this example, let’s stream the output to observe how the agents handle the task step by step.
Here, Flo receives an input prompt requesting a blog on the latest advancements in agentic AI. The agents collaborate to perform the necessary research and write the blog, with the progress being streamed in real time.
In code, this would be
Recap of the Steps
Create an LLM Object: Initialize the language model that the agents will use.
Set Up the YAML: Define the agents, their roles, and tools in a YAML file.
Build the Flo: Register the tools in the session and build the workflow using the YAML configuration.
Execute the Flo: Stream or invoke the Flo to see the agents in action.
By following these steps, you can quickly build and execute complex workflows with agents collaborating to complete tasks in FloAI.
Create your first team
In the above example, we created a single agent with a single tool. In this example, let's create a team consisting of multiple agents.
A team consist of following components:
Multiple agents or teams which are part of the team
A router, which decides how the members of the team work together.
The code is pretty similar to the previous agent example except for the yaml. Check yaml definition to understand more about how yamls can be built.
Here we created a team of 2 agents named Researcher and Blogger. These agents are connected by a router whose name is Team Lead. The router type is denoted by kind, and its supervisor
, these routers work like a team manager. There are multiple other routers available check the routers documentation to know more.
Here is a similar team created using code:
Compose Agents and Teams
Flo simplifies the creation of advanced AI systems through its composable architecture. Our framework offers a rich collection of specialized agents, routers, and team components that can be combined to build sophisticated AI solutions. Whether you need task-specific agents or complex multi-agent systems, Flo's modular design adapts to your requirements
Last updated