28. June 2024

Generative AI agents: Introduction and application at Evoya AI

A comprehensive overview of generative AI agents, how they work and possible applications, especially with Evoya AI.

Introduction to Generative AI Agents

While traditional AI systems are often rigid and rule-based, meaning that they cannot even decide for themselves which steps to take next, generative AI agents offer a new dimension of flexibility and autonomy.
These agents are able to generate human-like content and perform complex tasks independently, similar to a human.
Generative AI agents are fascinating “entities” with more autonomy than classic AI systems.
In this blog post, you will learn all about generative AI agents, including how they work and how we use this technology at Evoya AI.

Technical basics of AI agents

Algorithm of a LangChain agent

To better understand the concept of generative AI agents, let’s look at the example of LangChain agents.
LangChain agents are systems that use a language model ( LLM) to interact with various tools and perform tasks such as answering questions, interacting with APIs or making decisions based on the results of the model.
The core of LangChain Agents is to use the language model as a decision engine to determine which actions should be executed and in what order, as opposed to hard-coded action sequences in traditional chains.

Components of a LangChain Agent

  • Language Model (LLM): The language model is used to make decisions about which actions should be executed.
    Thanks to LangChain, various LLMs such as OpenAI GPT 4o, Claude Sonnet or the open source model Llama 3 (Meta) can be used.
  • tools: These offer additional functionalities for tasks such as data retrieval or processing or the execution of actions
  • Memory: Allows the agent to store and retrieve information to maintain context during decision making.

Algorithm steps

  1. Initialization of the LLM: Configuration of the language model with parameters such as temperature, which controls the randomness of the model’s output.
  2. Loading the tools: Selecting and loading the tools that offer the agent additional functionalities.
    These tools can either be provided by LangChain or user-defined.
  3. Initialization of the agent: Instantiation of the agent with the initialized LLM and the loaded tools.
    This can be done using the function initialize_agent , which simplifies the creation of the agent with default settings.
  4. Execution of the agent: The agent executes a chain of actions based on a given prompt, interacting with tools and utilizing the decision-making capabilities of the language model.
    The agent observes the results of each action, repeats the process if necessary and ultimately provides a final response to the original input.
  5. Memory management: During execution, the agent uses memory to store information and maintain context for personalized and coherent interactions.
    The memory helps the agent to understand the context of the conversation, accumulate knowledge over time, personalize responses and ensure continuity in interactions.

Example of the implementation of a LangChain agent

Here is an example of how to implement a LangChain agent with multiple tools and multi-input tools:

from langchain.agents import initialize_agent, AgentType
from langchain.llms import OpenAI
from langchain.tools import Tool
from langchain.memory import ConversationBufferMemory
# Initialisierung des Sprachmodells
llm = OpenAI(temperature=0)
# Definieren der Tools
search_tool = Tool(
name="search",
func=lambda query: f"Searching for {query}",
description="Tool to search the web"
)
calculator_tool = Tool(
name="calculator",
func=lambda expression: eval(expression),
description="Tool to perform calculations"
)
# Initialisierung des Agenten mit Tools
agent = initialize_agent(
tools=[search_tool, calculator_tool],
llm=llm,
agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
memory=ConversationBufferMemory()
)
# Ausführung des Agenten mit einem Prompt
prompt = "Wie ist das Wetter in Zürich und was ist 5 + 3?"
response = agent.run(prompt)
# Ausgabe der Antwort
print(response)

Source: LangChain Documentation – Quick Start

REACT: Reasoning and Acting

An important aspect of the functioning of LangChain Agents is the REACT model, which stands for “Reasoning and Acting”.
This model enables the agent not only to act on the basis of predefined rules, but also to make complex considerations and decisions based on the context and available information.

Example procedure

The user asks the question, but sees nothing of the agent’s intermediate steps.
At the end, the agent only returns the final answer to the user.

User: Wie ist das Wetter in Zürich und was ist 5 + 3?
Agent:
1. Reasoning: Um die Frage nach dem Wetter in Zürich zu beantworten, muss ich eine Websuche durchführen.
2. Acting: Verwende das 'search' Tool, um nach dem Wetter in Zürich zu suchen.
3. Result: Das aktuelle Wetter in Zürich ist sonnig bei 25 Grad Celsius.
4. Reasoning: Um die zweite Frage zu beantworten, muss ich eine Berechnung durchführen.
5. Acting: Verwende das 'calculator' Tool, um die Berechnung 5 + 3 durchzuführen.
6. Result: 5 + 3 ergibt 8.
7. Final Answer: Das Wetter in Zürich ist sonnig bei 25 Grad Celsius und 5 + 3 ergibt 8.

Source: LangChain Documentation – Zero Shot React Description

Other agent models at LangChain

In addition to the REACT model, LangChain offers a variety of other agent models that are optimized for different use cases:

  • Zero-Shot ReAct: A model without memory that is suitable for one-off requests.
  • Conversational ReAct: A model with memory that maintains context across multiple interactions.
  • ReAct Docstore: A model specially developed for interaction with document stores.
  • Self-ask with Search: A model that independently asks questions and searches for answers.

Source: LangChain Documentation – Agent Types

How we use AI agents at Evoya

At Evoya AI, we use generative AI agents as the core of the Evoya AI platform to solve a variety of tasks efficiently and intelligently.
We integrate these agents into our systems to provide our customers with customized solutions.
Our agents are able to interact with various tools, including connections to CRM or ERP systems, which is particularly useful for our corporate clients.
As a special feature, we also use specialized agents as a multi-level cooperating team.
We are constantly evaluating the latest approaches and technologies to ensure our agents are always up to date.
If you would like to learn more about how we use generative AI agents and how they can help your business, we are happy to offer a demo.
Get in touch with us here.

Further reading

For those who want to dive deeper into the topic, there are some notable research papers and studies on generative AI agents:

  1. Generative Agents: Interactive Simulacra of Human Behavior This work introduces generative agents that simulate human behavior. Link to the study
  2. Generative AI Agent for Next-Generation MIMO Design This study investigates generative AI agents in the context of MIMO system design. Link to the study
  3. Generative AI at Work This study analyzes the introduction of generative AI-based conversational assistants in customer service. Link to the study