import { BaseTool } from './BaseTool'; import axios from 'axios'; export class WikipediaTool extends BaseTool<{ title: string }> { constructor() { super( 'wikipedia', 'Search Wikipedia and return a summary', { title: { type: 'string', description: 'The title of the Wikipedia article to search', required: 'true', }, }, 'Provide simply the title you want to search on Wikipedia and nothing more. If re-using this tool, try a different title for different information.', 'Returns a summary from searching an article title on Wikipedia' ); } async execute(args: { title: string }): Promise { const response = await axios.get('https://en.wikipedia.org/w/api.php', { params: { action: 'query', list: 'search', srsearch: args.title, format: 'json', }, }); const result = response.data.query.search[0].snippet; return [{ type: 'text', text: result }]; } }