Agents
AI agents built on large language models control the path to solving a complex problem. They can typically act on feedback to refine their plan of action, a capability that can improve performance and help them accomplish more sophisticated tasks.
We recommend reading the following article to learn more.
Implementation in Hive Agent Framework
An agent can be thought of as a program powered by LLM. The LLM generates structured output that is then processed by your program.
Your program then decides what to do next based on the retrieved content. It may leverage a tool, reflect, or produce a final answer. Before the agent determines the final answer, it performs a series of steps
. A step might be calling an LLM, parsing the LLM output, or calling a tool.
Steps are grouped in a iteration
, and every update (either complete or partial) is emitted to the user.
Hive Agent
Our Hive Agent is based on the ReAct
(Reason and Act) approach.
Hence, the agent in each iteration produces one of the following outputs.
For the sake of simplicity, imagine that the input prompt is "What is the current weather in Las Vegas?"
First iteration:
[!NOTE]
Agent emitted 3 complete updates in the following order (
thought
,tool_name
,tool_input
) and tons of partial updates in the same order. Partial update means that new tokens are being added to the iteration. Updates are always in strict order: You first get many partial updates for thought, followed by a final update for thought (that means no final updates are coming for a given key).
Second iteration:
For more complex tasks, the agent may do way more iterations.
In the following example, we will transform the knowledge gained into code.
Behaviour
You can alter the agent's behavior in the following ways.
Setting execution policy
[!NOTE]
The default is zero retries and no timeout.
Overriding prompt templates
The agent uses the following prompt templates.
System Prompt
User Prompt (to reformat the user's prompt)
User Empty Prompt
Tool Error
Tool Input Error (validation error)
Tool No Result Error
Tool Not Found Error
Invalid Schema Error (output from LLM cannot be processed)
Please refer to the following example to see how to modify them.
Creating your own agent
To create your own agent, you must implement the agent's base class (BaseAgent
).
The example can be found here.