Skip to content

Commit 9b2981a

Browse files
committed
feat: add new web scraping tools and components
- Introduced BatchWebScraperTool component for batch scraping functionality. - Added LinkExtractorTool component for extracting links from web pages. - Implemented SiteMapExtractorTool component for generating site maps. - Enhanced WebScraperTool component with improved UI and functionality. - Updated index files to export new tools for easier access. - Removed unused tool-part-transform helper file to clean up the codebase.
1 parent 89d2023 commit 9b2981a

9 files changed

Lines changed: 696 additions & 220 deletions

File tree

app/chat/components/agent-tools.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ import type { DynamicToolUIPart } from "ai"
1212
import { cn } from "@/lib/utils"
1313
import { useMemo } from "react"
1414

15+
// Import custom tool components
16+
//import {
17+
// WebScraperTool,
18+
// BatchWebScraperTool,
19+
// SiteMapExtractorTool,
20+
// LinkExtractorTool,
21+
//} from "@/src/components/ai-elements/tools"
22+
1523
export interface AgentToolsProps {
1624
tools: Array<ToolInvocationState | DynamicToolUIPart>
1725
className?: string
@@ -86,6 +94,56 @@ export function AgentTools({ tools, className }: AgentToolsProps) {
8694
.map(getProgressMessage)
8795
.filter((m): m is string => typeof m === "string" && m.length > 0)
8896

97+
// Check if this is a web scraper tool and render custom component
98+
// if (toolName === "web:scraper" && hasOutput) {
99+
// return (
100+
// <WebScraperTool
101+
// key={`${id}-${toolName}-${toolState}-${groupIdx}`}
102+
// toolCallId={id}
103+
// input={latest.input as WebScraperUITool["input"]}
104+
// output={latest.output as WebScraperUITool["output"]}
105+
// errorText={errorText}
106+
// />
107+
// )
108+
// }
109+
110+
// if (toolName === "batch-web-scraper" && hasOutput) {
111+
// return (
112+
// <BatchWebScraperTool
113+
// key={`${id}-${toolName}-${toolState}-${groupIdx}`}
114+
// toolCallId={id}
115+
// input={latest.input as BatchWebScraperUITool["input"]}
116+
// output={latest.output as BatchWebScraperUITool["output"]}
117+
// errorText={errorText}
118+
// />
119+
// )
120+
// }
121+
122+
// if (toolName === "site-map-extractor" && hasOutput) {
123+
// return (
124+
// <SiteMapExtractorTool
125+
// key={`${id}-${toolName}-${toolState}-${groupIdx}`}
126+
// toolCallId={id}
127+
// input={latest.input as SiteMapExtractorUITool["input"]}
128+
// output={latest.output as SiteMapExtractorUITool["output"]}
129+
// errorText={errorText}
130+
// />
131+
// )
132+
// }
133+
134+
//if (toolName === "link-extractor" && hasOutput) {
135+
// return (
136+
// <LinkExtractorTool
137+
// key={`${id}-${toolName}-${toolState}-${groupIdx}`}
138+
// toolCallId={id}
139+
// input={latest.input as LinkExtractorUITool["input"]}
140+
// output={latest.output as LinkExtractorUITool["output"]}
141+
// errorText={errorText}
142+
// />
143+
// )
144+
// }
145+
146+
// Default rendering for other tools
89147
return (
90148
<Tool
91149
key={`${id}-${toolName}-${toolState}-${groupIdx}`}

app/chat/helpers/tool-part-transform.ts

Lines changed: 0 additions & 219 deletions
This file was deleted.

0 commit comments

Comments
 (0)