diff options
| author | A.J. Shulman <Shulman.aj@gmail.com> | 2024-07-10 16:16:26 -0400 |
|---|---|---|
| committer | A.J. Shulman <Shulman.aj@gmail.com> | 2024-07-10 16:16:26 -0400 |
| commit | cab0311e2fd9a6379628c000d11ddcd805e01f64 (patch) | |
| tree | 60cb3f397426cb3931c13ebe3b8a1e8eb98480dd /src/client/views/nodes/ChatBox/tools/WikipediaTool.ts | |
| parent | d0e09ff3526e4f6b9aad824fad1020d083a87631 (diff) | |
first attempt at integrating everything
Diffstat (limited to 'src/client/views/nodes/ChatBox/tools/WikipediaTool.ts')
| -rw-r--r-- | src/client/views/nodes/ChatBox/tools/WikipediaTool.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/client/views/nodes/ChatBox/tools/WikipediaTool.ts b/src/client/views/nodes/ChatBox/tools/WikipediaTool.ts new file mode 100644 index 000000000..0aef58f61 --- /dev/null +++ b/src/client/views/nodes/ChatBox/tools/WikipediaTool.ts @@ -0,0 +1,33 @@ +import { BaseTool } from './BaseTool'; +import axios from 'axios'; + +export class WikipediaTool extends BaseTool { + 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<any> { + 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 }]; + } +} |
