Introduction to Simple React AI Agent with Search Tools recipe
Introduction to Simple React AI Agent with
Search Tools recipe
The Simple React AI Agent with Search Tools recipe is based on REST and SOAP APIs. The
recipe shows you how to build a simple React Agent with a search tool, Google Search, using the
Serp API. The React AI agent logic alternates between generating thoughts and performing
task-specific actions dynamically.
The Gemini Large Language Model (LLM) follows a step-by-step problem-solving approach,
utilizing the search tool to gather information and perform tasks to answer user queries. The
process orchestrates the whole workflow based on the LLM response.
The process accepts a user query. It passes the query to the LLM with additional system
instructions to respond in a format that includes a question, thought, action, action input,
observation, final thought, and final answer.
After receiving the response from the LLM, the process checks for the presence of the action
and action input fields. If these fields are present, a request for the SearchTool service is
formulated. Otherwise, it creates the final answer.
If the final answer is not set, a request is sent to the SearchTool service. The parent
process is called with new parameters, such as user query and Agent_Scratchpad.
Agent_Scratchpad is a template that contains fields. For example, Action: Action Input:
Observation.
The process repeats until all the actions from the initial LLM response are processed or the
number of repetitions does not exceed the specified limit. When the process execution time
approaches 60 seconds, the process provides a final response. If the process ends prematurely,
the final response might be inaccurate.