Search Wikipedia using ReAct

This notebook is a minimal implementation of ReAct: Synergizing Reasoning and Acting in Language Models with the Google gemini-2.5-flash model. You’ll use ReAct prompting to configure a model to search Wikipedia to find the answer to a user’s question.

In this walkthrough, you will learn how to:

  1. Set up your development environment and API access to use Gemini.
  2. Use a ReAct few-shot prompt.
  3. Use the newly prompted model for multi-turn conversations (chat).
  4. Connect the model to the Wikipedia API.
  5. Have conversations with the model (try asking it questions like “how tall is the Eiffel Tower?”) and watch it search Wikipedia.
Important

The non-source code materials on this page are licensed under Creative Commons - Attribution-ShareAlike CC-BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/legalcode.

Setup

Install the Google GenAI SDK

Install the Google GenAI SDK from npm.

$ npm install @google/genai

Setup your API key

You can create your API key using Google AI Studio with a single click.

Remember to treat your API key like a password. Don’t accidentally save it in a notebook or source file you later commit to GitHub. In this notebook we will be storing the API key in a .env file. You can also set it as an environment variable or use a secret manager.

Here’s how to set it up in a .env file:

$ touch .env
$ echo "GEMINI_API_KEY=<YOUR_API_KEY>" >> .env
Tip

Another option is to set the API key as an environment variable. You can do this in your terminal with the following command:

$ export GEMINI_API_KEY="<YOUR_API_KEY>"

Load the API key

To load the API key from the .env file, we will use the dotenv package. This package loads environment variables from a .env file into process.env.

$ npm install dotenv

Then, we can load the API key in our code:

const dotenv = require("dotenv") as typeof import("dotenv");

dotenv.config({
  path: "../.env",
});

const GEMINI_API_KEY = process.env.GEMINI_API_KEY ?? "";
if (!GEMINI_API_KEY) {
  throw new Error("GEMINI_API_KEY is not set in the environment variables");
}
console.log("GEMINI_API_KEY is set in the environment variables");
GEMINI_API_KEY is set in the environment variables
Note

In our particular case the .env is is one directory up from the notebook, hence we need to use ../ to go up one directory. If the .env file is in the same directory as the notebook, you can omit it altogether.

│
├── .env
└── examples
    └── Search_Wikipedia_using_ReAct.ipynb

Initialize SDK Client

With the new SDK, now you only need to initialize a client with you API key (or OAuth if using Vertex AI). The model is now set in each call.

const google = require("@google/genai") as typeof import("@google/genai");

const ai = new google.GoogleGenAI({ apiKey: GEMINI_API_KEY });

Select a model

Now select the model you want to use in this guide, either by selecting one in the list or writing it down. Keep in mind that some models, like the 2.5 ones are thinking models and thus take slightly more time to respond (cf. thinking notebook for more details and in particular learn how to switch the thiking off).

const tslab = require("tslab") as typeof import("tslab");

const MODEL_ID = "gemini-2.0-flash";

The ReAct prompt

The prompts used in the paper are available at https://github.com/ysymyth/ReAct/tree/master/prompts

Here, you will be working with the following ReAct prompt with a few minor adjustments.

Note

The prompt and in-context examples used here are borrowed from https://github.com/ysymyth/ReAct which is published under a MIT license.

const MODEL_INSTRUCTION = `
  Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, Observation is understanding relevant information from an Action's output and Action can be of three types:
  (1) search, which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search and you can try to search the information from those topics.
  (2) lookup, which returns the next sentence containing keyword in the current context. This only does exact matches, so keep your searches short.
  (3) finish, which returns the answer and finishes the task.

  </search/> : Perform a Wikipedia search via external API. Example: "<search>What is the capital of France?</search>".
  </lookup/> : Lookup for specific information on a page with the Wikipedia API. So say once you search and get a page, you can follow up with a lookup to get more information. Example: "<lookup>What is the capital of France?</lookup>".
  </finish/> : Stop the execution of the model and return the answer. Example: "<finish>The capital of France is Paris.</finish>".

  Make sure to use the </search/>, </lookup/> and </finish/> tags to indicate the type of action you want to perform and enclose the content of the action in the tags.
  If you want to search for a specific entity, use the </search/> tag. If you want to look up a specific piece of information, use the </lookup/> tag. If you want to finish the task and return the answer, use the </finish/> tag.
`;

Few-shot prompting to enable in-context learning with Gemini

While large language models show good understanding of the instructions they are prompted with, they still may perform poorly on complex tasks in a zero-shot setting. Hence, you will now provide a few examples along with your prompt to steer the model’s output according to your needs. This in-context learning improves the model’s performance significantly.

const examples = `
Here are some examples.

Example 1
Question:
What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into?

Thought 1
I need to search "Colorado orogeny" to find what area the eastern sector extends into.

Action 1

<search>Colorado orogeny</search>
Observation 1
The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas.

Thought 2
The article does not mention the eastern sector. I need to look up "eastern sector".

Action 2
<lookup>eastern sector</lookup>

Observation 2
The eastern sector extends into the High Plains and is called the Central Plains orogeny.

Thought 3
The eastern sector extends into the High Plains. I now need to search "High Plains (United States)" to find the elevation range.

Action 3

<search>High Plains (United States)</search>
Observation 3
The High Plains are a subregion of the Great Plains. From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130 m).

Thought 4
The elevation range is 1,800 to 7,000 ft.

Action 4
<finish>The elevation range is 1,800 to 7,000 ft.</finish>

Example 2
Question:
Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who?

Thought 1
I should search "Milhouse" to find out who he was named after.

Action 1

<search>Milhouse</search>
Observation 1
Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening.

Thought 2
The paragraph does not mention who Milhouse is named after. I will look up "named after".

Action 2
<lookup>named after</lookup>

Observation 2
Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous.

Thought 3
Milhouse was named after Richard Nixon.

Action 3
<finish>Milhouse was named after U.S. president Richard Nixon.</finish>

Example 3
Question:
Which documentary is about Finnish rock groups, Adam Clayton Powell or The Saimaa Gesture?

Thought 1
Search "Adam Clayton Powell" to determine if it's about Finnish rock groups.

Action 1

<search>Adam Clayton Powell</search>
Observation 1
Could not find [Adam Clayton Powell]. Similar: ['Adam Clayton Powell III', 'Adam Clayton Powell Jr. State Office Building', 'Adam Clayton Powell (film)', etc.]

Thought 2
Try searching the documentary specifically: "Adam Clayton Powell (film)".

Action 2

<search>Adam Clayton Powell (film)</search>
Observation 2
Adam Clayton Powell is a 1989 American documentary film about the rise and fall of African-American politician Adam Clayton Powell Jr.

Thought 3
It is not about Finnish rock groups. Now search "The Saimaa Gesture".

Action 3

<search>The Saimaa Gesture</search>
Observation 3
The Saimaa Gesture is a 1981 Finnish documentary film about Finnish rock bands Eppu Normaali, Hassisen Kone, and Juice Leskinen Slam on tour.

Thought 4
The Saimaa Gesture is about Finnish rock groups.

Action 4
<finish>The Saimaa Gesture is the documentary about Finnish rock groups.</finish>

Example 4
Question:
What profession do Nicholas Ray and Elia Kazan have in common?

Thought 1
Search "Nicholas Ray" and identify his professions.

Action 1

<search>Nicholas Ray</search>
Observation 1
Nicholas Ray was an American film director, screenwriter, and actor best known for the film Rebel Without a Cause.

Thought 2
Now search "Elia Kazan" to compare professions.

Action 2

<search>Elia Kazan</search>
Observation 2
Elia Kazan was a film and theatre director, producer, screenwriter, and actor.

Thought 3
Both were directors, screenwriters, and actors.

Action 3
<finish>Nicholas Ray and Elia Kazan were both directors, screenwriters, and actors.</finish>

Example 5
Question:
Which magazine was started first, Arthur's Magazine or First for Women?

Thought 1
Search "Arthur's Magazine" to find the start year.

Action 1

<search>Arthur's Magazine</search>
Observation 1
Arthur's Magazine (1844–1846) was a literary periodical published in the 19th century.

Thought 2
Arthur's Magazine started in 1844. Now search "First for Women".

Action 2

<search>First for Women</search>
Observation 2
First for Women is a magazine published in the USA. It was started in 1989.

Thought 3
Arthur's Magazine (1844) was started earlier than First for Women (1989).

Action 3
<finish>Arthur's Magazine was started first.</finish>

Example 6
Question:
Were Pavel Urysohn and Leonid Levin known for the same type of work?

Thought 1
Search "Pavel Urysohn" and find his field of work.

Action 1

<search>Pavel Urysohn</search>
Observation 1
Pavel Urysohn was a Soviet mathematician best known for contributions to dimension theory.

Thought 2
Now search "Leonid Levin" and compare.

Action 2

<search>Leonid Levin</search>
Observation 2
Leonid Levin is a Soviet-American mathematician and computer scientist.

Thought 3
Both were mathematicians, so yes—they were known for the same type of work.

Action 3
<finish>Yes, both Pavel Urysohn and Leonid Levin were known for work in mathematics.</finish>

Question
{question}
`;

Copy the instructions along with examples in a file called model_instructions.txt

const fs = require("fs") as typeof import("fs");
const path = require("path") as typeof import("path");

const MODEL_INSTRUCTIONS_FILE = path.join("../assets/ReAct", "model_instructions.txt");
if (!fs.existsSync(MODEL_INSTRUCTIONS_FILE)) {
  fs.mkdirSync(path.dirname(MODEL_INSTRUCTIONS_FILE), { recursive: true });
  fs.writeFileSync(MODEL_INSTRUCTIONS_FILE, MODEL_INSTRUCTION + examples);
}

The Gemini-ReAct pipeline

Define tools

As instructed by the prompt, the model will be generating Thought-Action-Observation traces, where every Action trace could be one of the following tokens:

  • </search/> : Perform a Wikipedia search via external API.
  • </lookup/> : Lookup for specific information on a page with the Wikipedia API.
  • </finish/> : Stop the execution of the model and return the answer.

If the model encounters any of these tokens, the model should make use of the tools made available to the model. This understanding of the model to leverage acquired toolsets to collect information from the external world is often referred to as function calling. Therefore, the next goal is to imitate this function calling technique in order to allow ReAct prompted Gemini model to access the external groundtruth.

The Gemini API supports function calling and you could use this feature to set up your tools. However, for this tutorial, you will learn to simulate it using stop_sequences parameter.

Define the tools:

function AddMethod(methodName: string, method: (...args: unknown[]) => unknown) {
  return function (constructor: new (...args: unknown[]) => unknown) {
    Object.defineProperty(constructor.prototype, methodName, {
      value: method,
      writable: true,
      configurable: true,
    });
  };
}

Lookup

Look for a specific phrase on the Wikipedia page.

/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */

async function lookup(phrase: string, contextLength = 1000): Promise<string> {
  // get the last searched Wikipedia page and find `phrase` in it.
  // @ts-expect-error invalid types
  const page = await wikipedia.page(this._searchHistory[this._searchHistory.length - 1]);
  const cleanedPage = this.clean(await page.content()) as string;
  const startIndex = cleanedPage.indexOf(phrase);

  // extract sentences considering the context length defined
  const result = cleanedPage.substring(
    Math.max(0, startIndex - contextLength),
    startIndex + phrase.length + contextLength
  );
  console.log(`Information Source: ${this._searchUrls[this._searchUrls.length - 1]}`);
  return result;
}

Finish

Instruct the pipline to terminate its execution.

/* eslint-disable @typescript-eslint/no-unsafe-member-access */

function finish(_: unknown): void {
  // Instruct the pipline to terminate its execution.
  this._shouldContinue = false;
  console.log(`Information Sources: ${this._searchUrls}`);
}

Setup

You will now build an end-to-end pipeline to facilitate multi-turn chat with the ReAct-prompted Gemini model.

/* eslint-disable @typescript-eslint/no-unnecessary-condition */

import { Chat, GenerateContentConfig } from "@google/genai";

@AddMethod("search", search)
@AddMethod("lookup", lookup)
@AddMethod("finish", finish)
class ReActPipeline {
  private chat: Chat;
  private _reactPrompt: string;
  private _shouldContinue = true;
  private _searchHistory: string[] = [];
  private _searchUrls: string[] = [];

  constructor(modelId: string, prompt: string) {
    this.chat = ai.chats.create({
      model: modelId,
    });
    if (fs.existsSync(prompt)) {
      this._reactPrompt = fs.readFileSync(prompt, "utf-8");
    } else {
      this._reactPrompt = prompt;
    }
  }

  async query(question: string, maxCalls = 15, generateConfig: GenerateContentConfig = {}) {
    console.assert(maxCalls > 0 && maxCalls <= 15, "max_calls must be between 1 and 15");

    let modelPrompt =
      this.chat.getHistory().length === 0 ? this._reactPrompt.replace("{question}", question) : question;

    // const callableEntities = ["", "", ""];
    this._shouldContinue = true;

    for (let i = 0; i < maxCalls && this._shouldContinue; i++) {
      const response = await this.chat.sendMessage({
        message: modelPrompt,
        config: {
          ...generateConfig,
          // stopSequences: callableEntities,
        },
      });
      const text = response.text ?? "";
      tslab.display.markdown(text);

      const chatHistory = this.chat.getHistory();
      const chatHistoryParts = chatHistory[chatHistory.length - 1].parts;
      const lastPart = (chatHistoryParts[chatHistoryParts.length - 1].text ?? "").trim();

      const match = /<([^>]+)>(.*)<\/\1>/.exec(lastPart);
      if (match) {
        const cmd = match[1].trim();
        const query = match[2].trim();
        console.log(`Command: ${cmd}, Query: ${query}`);
        const observation = await this[cmd](query);
        if (!this._shouldContinue) {
          break;
        }
        const streamMessage = `\nObservation ${i + 1}\n${observation}`;
        console.log(streamMessage);
        modelPrompt = `<${cmd}>${query}${cmd}'s Output: ${streamMessage}`;
      } else {
        console.warn(
          "No valid command found in the response. Please ensure the model is generating valid thought-action-observation traces."
        );
        modelPrompt = "Please try to generate thought-action-observation traces as instructed by the prompt.";
      }
      await new Promise((resolve) => setTimeout(resolve, 5000)); // wait for 1 second before the next iteration
    }
  }

  clean(text: string): string {
    return text.replace("\n", " ");
  }
}

Test ReAct prompted Gemini model

const reactChat = new ReActPipeline(MODEL_ID, MODEL_INSTRUCTIONS_FILE);
await reactChat.query(
  "What are the total of ages of the main trio from the new Percy Jackson and the Olympians TV series in real life?",
  15,
  { temperature: 0.4 }
);

Thought 1 I need to find the ages of the main trio from the new Percy Jackson and the Olympians TV series in real life. I will start by searching for “Percy Jackson and the Olympians (TV series)”.

Action 1

<search>Percy Jackson and the Olympians (TV series)</search>
Command: search, Query: Percy Jackson and the Olympians (TV series)
Information Source: https://en.wikipedia.org/wiki/Percy_Jackson_and_the_Olympians_(TV_series)

Observation 1
This is a concise and accurate description of the Percy Jackson and the Olympians TV series. It covers the following key information:

*   **Type of media:** American fantasy television series
*   **Creators:** Rick Riordan and Jonathan E. Steinberg
*   **Platform:** Disney+
*   **Source Material:** Based on the book series by Rick Riordan
*   **Main Cast:** Walker Scobell, Leah Sava Jeffries, and Aryan Simhadri
*   **Main Character Roles:** Percy Jackson, Annabeth Chase, and Grover Underwood

It's a good, basic summary for someone who is unfamiliar with the series.

Thought 2 Now I know the names of the main trio: Walker Scobell, Leah Sava Jeffries, and Aryan Simhadri. I need to find their ages. I will search for “Walker Scobell age”.

Action 2

<search>Walker Scobell age</search>
Command: search, Query: Walker Scobell age

Observation 2
Could not find ["Walker Scobell age"]. Similar: {"results":[{"ns":0,"title":"Walker Scobell","pageid":70525114},{"ns":0,"title":"The Adam Project","pageid":65867428},{"ns":0,"title":"Percy Jackson","pageid":21327279},{"ns":0,"title":"Aryan Simhadri","pageid":74932124},{"ns":0,"title":"Walker (given name)","pageid":68329314},{"ns":0,"title":"Fairview Township, Erie County, Pennsylvania","pageid":132483},{"ns":0,"title":"Hiro Kanagawa","pageid":7200805},{"ns":0,"title":"January 5","pageid":19279054},{"ns":0,"title":"Deadpool & Wolverine","pageid":52234178},{"ns":0,"title":"List of characters played by multiple actors in the same film","pageid":6781845}]}. You should search for one of those instead.

Thought 3 I should search for the “Walker Scobell” page.

Action 3

<search>Walker Scobell</search>
Command: search, Query: Walker Scobell
Information Source: https://en.wikipedia.org/wiki/Walker_Scobell

Observation 3
This is a good, concise summary of Walker Scobell's career so far. It highlights key information like:

*   **Nationality and birthplace:** American, born in Virginia.
*   **Age and debut:** Began acting at age 13.
*   **Early success:** Immediate recognition for lead roles in *The Adam Project* and *Secret Headquarters*.
*   **Current leading role:** *Percy Jackson and the Olympians* on Disney+.

It effectively summarizes his career trajectory, starting with his breakthrough and ending with his current prominent role.

Thought 4 The summary says he began acting at age 13. I should look for his birthdate to calculate his age.

Action 4

<lookup>age</lookup>
Command: lookup, Query: age
Information Source: https://en.wikipedia.org/wiki/Walker_Scobell

Observation 4
Walker Scobell (born January 5, 2009) is an American actor. Born in Virginia, he made his professional acting debut at age 13 and gained immediate recognition for his lead roles in the science fiction streaming films The Adam Project and Secret Headquarters (both 2022). Scobell received continued recognition with his leading titular role in the Disney+ fantasy series Percy Jackson and the Olympians (2023–present). 

== Life and career ==


=== Early life and acting background (2009–2021) ===
Scobell was born on January 5, 2009, in Virginia Beach, Virginia, to Heather Scobell and Pete Scobell in a military family. He has an older sister and younger brother. Scobell lived in Colorado until the family moved to Fairview, Pennsylvania, where his parents grew up. In elementary school, he attended drama class. He went to Fairview Middle School and acted in the school's production of Mary Poppins. Shortly after, he attended a John D'Aquino acting workshop, hired a manager and signed to an agency. When not traveling or on set, he goes to Fairview High School.


=== Acting breakthrough (2022–present) ===
Scobell au

Thought 5 Walker Scobell was born on January 5, 2009. It is currently November 26, 2024. So he is 15 years old. Now I need to find Leah Sava Jeffries’ age.

Action 5

<search>Leah Sava Jeffries age</search>
Command: search, Query: Leah Sava Jeffries age

Observation 5
Could not find ["Leah Sava Jeffries age"]. Similar: {"results":[{"ns":0,"title":"Leah Jeffries","pageid":74933311},{"ns":0,"title":"Aryan Simhadri","pageid":74932124},{"ns":0,"title":"Rel (TV series)","pageid":57387941},{"ns":0,"title":"Children's and Family Emmy Award for Outstanding Younger Performer","pageid":75815851},{"ns":0,"title":"Camp Half-Blood Chronicles","pageid":11155395},{"ns":0,"title":"X-Men","pageid":34218},{"ns":0,"title":"56th NAACP Image Awards","pageid":78827527},{"ns":0,"title":"A&F Quarterly","pageid":2963556},{"ns":0,"title":"List of American films of 2020","pageid":47216268},{"ns":0,"title":"List of victims of the September 11 attacks (O–Z)","pageid":71965641}]}. You should search for one of those instead.

Thought 6 I should search for “Leah Jeffries”.

Action 6

<search>Leah Jeffries</search>
Command: search, Query: Leah Jeffries
Information Source: https://en.wikipedia.org/wiki/Leah_Jeffries

Observation 6
This is a good, concise biography of Leah Sava Jeffries. It highlights key aspects of her career, including:

*   **Her acting debut:** Empire (2015)
*   **Her feature film debut:** Beast (2022)
*   **Her breakthrough role:** Annabeth Chase in Percy Jackson & the Olympians
*   **Her awards and nominations:** Two NAACP Image Awards and a Children's and Family Emmy Award nomination.

The information is accurate and presented in a clear, easy-to-understand manner. It effectively summarizes her rising prominence in the acting world.

Thought 7 I need to find her age.

Action 7

<lookup>age</lookup>
Command: lookup, Query: age
Information Source: https://en.wikipedia.org/wiki/Leah_Jeffries

Observation 7
Leah Sava Jeffries (; born September 25, 2009) is an American actress. Jeffries made her acting debut on the American musical drama, Empire (2015) and later her feature film debut in the action-thriller Beast (2022). In 2022, Jeffries was cast as Annabeth Chase in the television adaptation of Rick Riordan's fantasy novel series, Percy Jackson & the Olympians, which earned her two NAACP Image Awards, along with a nomination for the Children's and Family Emmy Award for Outstanding Younger Performer. 

== Early life ==
Jeffries was born in Detroit, Michigan to Leah Jeffries and Floyd S. Jeffries Jr. She has an older brother, Floyd Jeffries, who is also an actor and model. She attended school in the Novi Community School District.


== Career ==
Prior to her acting debut, Jeffries worked as a model for children's products for Carol's Daughter. Jeffries' acting debut was at age 5 as Lola Lyon on Empire.
On May 5, 2022, Jeffries was announced as Annabeth Chase in Percy Jackson and the Olympians. Immediately following the casting announcement, Jeffries received harassment online because she was African-American, while her character, Annabeth Chase, was portrayed as white in the book series the show was based on. On May 10, the books' author, Rick Riordan, posted a blog post in which he condemned the backlash against Jeffries and reaffirmed his support of her. Alexandra Daddario,

Thought 8 Leah Sava Jeffries was born on September 25, 2009. It is currently November 26, 2024. So she is 15 years old. Now I need to find Aryan Simhadri’s age.

Action 8

<search>Aryan Simhadri age</search>
Command: search, Query: Aryan Simhadri age

Observation 8
Could not find ["Aryan Simhadri age"]. Similar: {"results":[{"ns":0,"title":"Aryan Simhadri","pageid":74932124},{"ns":0,"title":"Leah Jeffries","pageid":74933311},{"ns":0,"title":"Spin (2021 film)","pageid":63400176},{"ns":0,"title":"2006 in film","pageid":302754},{"ns":0,"title":"Hiro Kanagawa","pageid":7200805},{"ns":0,"title":"Savitribai Phule","pageid":4172250},{"ns":0,"title":"Freaky Friday (franchise)","pageid":63633041},{"ns":0,"title":"Sharat Saxena","pageid":12611800},{"ns":0,"title":"Cheaper by the Dozen (franchise)","pageid":61462161},{"ns":0,"title":"Camp Half-Blood Chronicles","pageid":11155395}]}. You should search for one of those instead.

Thought 9 I should search for “Aryan Simhadri”.

Action 9

<search>Aryan Simhadri</search>
Command: search, Query: Aryan Simhadri
Information Source: https://en.wikipedia.org/wiki/Aryan_Simhadri

Observation 9
This statement is accurate. Aryan Simhadri is indeed an American actor and is well-known for playing Grover Underwood in the Disney+ series "Percy Jackson and the Olympians."

Thought 10 I need to find his age.

Action 10

<lookup>age</lookup>
Command: lookup, Query: age
Information Source: https://en.wikipedia.org/wiki/Aryan_Simhadri

Observation 10
Aryan Simhadri ( ; born May 6, 2006) is an American actor best known for his role as Grover Underwood in the Disney+ series Percy Jackson and the Olympians. In 2021, Simhadri played Walter in the off-Broadway production of Trevor: The Musical.


== Career ==
Following short appearances in the comedy series Just Roll with It (2019) and the children's animated series Mira, Royal Detective (2020), Simhadri made his feature film debut with a supporting role in Netflix's The Main Event in 2020. His first starring role came in the Avantika Vandanapu-led Spin (2021) alongside Meera Syal and Abhay Deol. Simhadri followed this with a supporting role in Disney+'s Cheaper by the Dozen in 2022.
In 2023, Simhadri made a major breakthrough in his career with the Disney+ series, Percy Jackson and the Olympians, alongside Walker Scobell and Leah Sava Jeffries. Adapted from the novel of the same name, he played Grover Underwood, Jackson's satyr guardian. Writing for IndieWire, Proma Khosla described Simh

Thought 11 Aryan Simhadri was born on May 6, 2006. It is currently November 26, 2024. So he is 18 years old.

Walker Scobell is 15. Leah Sava Jeffries is 15. Aryan Simhadri is 18.

15 + 15 + 18 = 48

Action 11

<finish>The total of the ages of the main trio from the new Percy Jackson and the Olympians TV series in real life is 48.</finish>
Command: finish, Query: The total of the ages of the main trio from the new Percy Jackson and the Olympians TV series in real life is 48.
Information Sources: https://en.wikipedia.org/wiki/Percy_Jackson_and_the_Olympians_(TV_series),https://en.wikipedia.org/wiki/Walker_Scobell,https://en.wikipedia.org/wiki/Leah_Jeffries,https://en.wikipedia.org/wiki/Aryan_Simhadri

Now, try asking the same question to gemini-2.0-flash model without the ReAct prompt.

const response = await ai.models.generateContent({
  model: MODEL_ID,
  contents:
    "What are the total of ages of the main trio from the new Percy Jackson and the Olympians TV series in real life?",
});
console.log(response.text ?? "No response text available.");
Okay, here are the real-life ages of the actors who play the main trio in the new *Percy Jackson and the Olympians* TV series, and their combined age:

*   **Walker Scobell (Percy Jackson):** Born January 6, 2009, making him **15 years old**.
*   **Leah Sava Jeffries (Annabeth Chase):** Born September 25, 2011, making her **12 years old**.
*   **Aryan Simhadri (Grover Underwood):** Born June 6, 2006, making him **17 years old**.

**Total:** 15 + 12 + 17 = **44 years**

The combined age of the main trio is 44 years.

Summary

The ReAct prompted Gemini model is grounded by external information sources and hence is less prone to hallucination. Furthermore, Thought-Action-Observation traces generated by the model enhance human interpretability and trustworthiness by allowing users to witness the model’s reasoning process for answering the user’s query.