diff options
Diffstat (limited to 'src/client/views/nodes/ChatBox/tools')
| -rw-r--r-- | src/client/views/nodes/ChatBox/tools/WikipediaTool.ts | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/client/views/nodes/ChatBox/tools/WikipediaTool.ts b/src/client/views/nodes/ChatBox/tools/WikipediaTool.ts index 8ef2830d4..e2c5009a1 100644 --- a/src/client/views/nodes/ChatBox/tools/WikipediaTool.ts +++ b/src/client/views/nodes/ChatBox/tools/WikipediaTool.ts @@ -1,3 +1,5 @@ +import { title } from 'process'; +import { Networking } from '../../../../Network'; import { BaseTool } from './BaseTool'; import axios from 'axios'; @@ -10,7 +12,7 @@ export class WikipediaTool extends BaseTool<{ title: string }> { title: { type: 'string', description: 'The title of the Wikipedia article to search', - required: 'true', + 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.', @@ -19,15 +21,11 @@ export class WikipediaTool extends BaseTool<{ title: string }> { } 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 }]; + try { + const { text } = await Networking.PostToServer('/getWikipediaSummary', { title: args.title }); + return [{ type: 'text', text: text }]; + } catch (error) { + return [{ type: 'text', text: 'An error occurred while fetching the article.' }]; + } } } |
