diff options
| author | A.J. Shulman <Shulman.aj@gmail.com> | 2024-07-11 10:21:56 -0400 |
|---|---|---|
| committer | A.J. Shulman <Shulman.aj@gmail.com> | 2024-07-11 10:21:56 -0400 |
| commit | e0e4871224e626240dc899c653cd0eb9f54c3693 (patch) | |
| tree | 36067e21ee81d47977e971e8f9ebced9c7ebeef2 /src/client/views/nodes/ChatBox/tools/WikipediaTool.ts | |
| parent | f82343158f423fdca136a639ec61c1e8d93b5467 (diff) | |
working with new documents
Diffstat (limited to 'src/client/views/nodes/ChatBox/tools/WikipediaTool.ts')
| -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.' }]; + } } } |
