Introduction to Agents
Agents are a powerful concept in AI that allows Language Models (LLMs) to interact with external tools and data sources. Unlike traditional LLMs that are limited to their training data, agents can access real-time information, perform actions, and make decisions based on up-to-date data. In this guide, we’ll explore how to create a simple agent using Bynesoft’s API. This agent will be capable of searching Wikipedia to retrieve relevant information for answering user queries. This guide serves as an introduction to more advanced concepts like Retrieval-Augmented Generation (RAG), which we’ll cover in subsequent guides. Our Agents come in three forms: the restricted Google Agent, free-form API Caller and the RAG agent. With Google Agent, you can enable the LLM to do Google Search, and the free-form enables requests to arbitrary APIs. RAG Agent is covered in the subsequent guide.Why Use Agents?
Agents offer several advantages over traditional LLMs:- Access to external data: Agents can retrieve up-to-date information from various sources.
- Ability to perform actions: They can interact with APIs, databases, and other tools.
- Dynamic responses: Agents can provide more accurate and timely answers based on current information.
- Extensibility: You can add new capabilities to agents by integrating additional tools and data sources.
Key Concepts
Before we dive into building our agent, let’s understand some key concepts:- Execution Layer: Defines the tools and actions available to the agent.
- Template (System Prompt): Guides the agent’s behavior and decision-making process.
- Function Calling: Allows the agent to use external tools or APIs to accomplish tasks.
What’s in this Guide
In this guide, we will:- Create an execution layer for Wikipedia searches
- Define a template to guide the agent’s behavior
- Build an agent that combines the execution layer and template
- Test the agent with a sample query
Prerequisites
- A Bynesoft API key
- Python environment with the
requests
library installed
Creating an Agent
Step 1: Define the Execution Layer
The execution layer is a crucial component of an agent. It specifies the schema for function calls, intercepts them, and executes them. In this example, we’ll create a Google execution layer restricted to Wikipedia searches:Step 2: Create a Template
Templates, also known as system prompts, guide the general behavior of the agent. They provide context on when and how to use the available functions:Step 3: Build the Agent
Now that we have created a Template and an Execution Layer, we can combine them to create our Agent:Using the Agent
Now that we’ve created our agent, let’s test it with a sample query:Understanding the Output
The agent’s response will typically include:- The answer to the query
- References to the sources used (in this case, Wikipedia URLs)
- A unique query ID and conversation ID for tracking purposes