aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ChatBox/tools/WebsiteInfoScraperTool.ts
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2024-08-15 13:16:32 -0400
committerA.J. Shulman <Shulman.aj@gmail.com>2024-08-15 13:16:32 -0400
commit6f9b8f9b393d411a17f7954b6cc36618efe698e2 (patch)
tree8090d9d0bafdfe3e97b8fd8914da9d1264e4172c /src/client/views/nodes/ChatBox/tools/WebsiteInfoScraperTool.ts
parent0c8001c61a55540cdeeb6ae249fdd2835580121c (diff)
implemented search tool and other tools but scraping doesn't work
Diffstat (limited to 'src/client/views/nodes/ChatBox/tools/WebsiteInfoScraperTool.ts')
-rw-r--r--src/client/views/nodes/ChatBox/tools/WebsiteInfoScraperTool.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/client/views/nodes/ChatBox/tools/WebsiteInfoScraperTool.ts b/src/client/views/nodes/ChatBox/tools/WebsiteInfoScraperTool.ts
new file mode 100644
index 000000000..59fd47b7a
--- /dev/null
+++ b/src/client/views/nodes/ChatBox/tools/WebsiteInfoScraperTool.ts
@@ -0,0 +1,35 @@
+import { Networking } from '../../../../Network';
+import { BaseTool } from './BaseTool';
+import { v4 as uuidv4 } from 'uuid';
+
+export class WebsiteInfoScraperTool extends BaseTool<{ url: string }> {
+ private _addLinkedUrlDoc: (url: string, id: string) => void;
+
+ constructor(addLinkedUrlDoc: (url: string, id: string) => void) {
+ super(
+ 'websiteInfoScraper',
+ 'Scrape detailed information from a specific website identified as the most relevant',
+ {
+ url: {
+ type: 'string',
+ description: 'The URL of the website to scrape',
+ required: true,
+ },
+ },
+ 'Provide the URL of the website that you have identified as the most relevant from the previous search. This tool will scrape and process detailed information from that specific website. It will also create a document from the scraped content for future reference.',
+ 'Returns the full HTML content from the provided URL and creates a document from the content for further analysis.'
+ );
+ this._addLinkedUrlDoc = addLinkedUrlDoc;
+ }
+
+ async execute(args: { url: string }): Promise<any> {
+ try {
+ const { html } = await Networking.PostToServer('/scrapeWebsite', { url: args.url });
+ const id = uuidv4();
+ this._addLinkedUrlDoc(args.url, id);
+ return [{ type: 'text', text: `<chunk chunk_id=${id} chunk_type=text> ${html} </chunk>` }];
+ } catch (error) {
+ return [{ type: 'text', text: 'An error occurred while scraping the website.' }];
+ }
+ }
+}