Class for interacting with and fetching data from the Wikipedia API. It extends the Tool class.

Example

const wikipediaQuery = new WikipediaQueryRun({
topKResults: 3,
maxDocContentLength: 4000,
});
const result = await wikipediaQuery.call("Langchain");

Hierarchy

  • Tool
    • WikipediaQueryRun

Constructors

Properties

description: string = "A tool for interacting with and fetching data from the Wikipedia API."
name: string = "wikipedia-api"
baseUrl: string = "https://en.wikipedia.org/w/api.php"
maxDocContentLength: number = 4000
topKResults: number = 3

Methods

  • Fetches the content of a specific Wikipedia page. It returns the extracted content as a string.

    Parameters

    • page: string

      The specific Wikipedia page to fetch its content.

    • redirect: boolean = true

      A boolean value to indicate whether to redirect or not.

    Returns Promise<string>

    The extracted content of the specific Wikipedia page as a string.

  • Builds a URL for the Wikipedia API using the provided parameters.

    Type Parameters

    • P extends UrlParameters

    Parameters

    • parameters: P

      The parameters to be used in building the URL.

    Returns string

    A string representing the built URL.

Generated using TypeDoc