Function searchWikipedia

  • Function to query phrase in Wikipedia Search API and return page titles, images and first few sentences of each result. Wikipedia Search API has complex documentation and is dificult to parse and clean up results.

    Parameters

    • query: string

      search phrase

    • Optionaloptions: {
          plainText: boolean;
          summarySentenceLimit: number;
          limitSearchResults: number;
          images: boolean;
          imageSize: number;
          searchInTitleOnly: boolean;
          filterDisambiguation: boolean;
      } = {}
      • plainText: boolean

        default=false Return plain text instead of HTML

      • summarySentenceLimit: number

        default=3 Limit summary to this many sentences

      • limitSearchResults: number

        default=1 Limit number of search results

      • images: boolean

        default=true Include image in results

      • imageSize: number

        default=200 Image size in pixels

      • searchInTitleOnly: boolean

        default=false Search in title only

      • filterDisambiguation: boolean

        default=true Filter disambiguation pages

    Returns any

    {results: [ {title, summary, image}, ...]}

    await searchWikipedia("JavaScript", { plainText: true })
    

    ai-research-agent (2024)