import React from 'react'; import { Database, CheckCircle, AlertTriangle, Loader2, Briefcase, Home, ShoppingBag, TrendingUp, Users, MessageCircle, Code, Settings, ChevronRight, Globe } from 'lucide-react'; import { ToolViewProps } from '../types'; import { formatTimestamp, getToolTitle } from '../utils'; import { cn } from '@/lib/utils'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { extractDataProviderCallData } from './_utils'; const PROVIDER_CONFIG = { 'linkedin': { name: 'LinkedIn Data Provider', icon: Users, color: 'from-blue-500 to-blue-600', bgColor: 'bg-blue-50 dark:bg-blue-900/20', textColor: 'text-blue-700 dark:text-blue-300', borderColor: 'border-blue-200 dark:border-blue-800' }, 'twitter': { name: 'Twitter Data Provider', icon: MessageCircle, color: 'from-sky-400 to-sky-500', bgColor: 'bg-sky-50 dark:bg-sky-900/20', textColor: 'text-sky-700 dark:text-sky-300', borderColor: 'border-sky-200 dark:border-sky-800' }, 'zillow': { name: 'Zillow Data Provider', icon: Home, color: 'from-emerald-500 to-emerald-600', bgColor: 'bg-emerald-50 dark:bg-emerald-900/20', textColor: 'text-emerald-700 dark:text-emerald-300', borderColor: 'border-emerald-200 dark:border-emerald-800' }, 'amazon': { name: 'Amazon Data Provider', icon: ShoppingBag, color: 'from-orange-500 to-orange-600', bgColor: 'bg-orange-50 dark:bg-orange-900/20', textColor: 'text-orange-700 dark:text-orange-300', borderColor: 'border-orange-200 dark:border-orange-800' }, 'yahoo_finance': { name: 'Yahoo Finance Data Provider', icon: TrendingUp, color: 'from-purple-500 to-purple-600', bgColor: 'bg-purple-50 dark:bg-purple-900/20', textColor: 'text-purple-700 dark:text-purple-300', borderColor: 'border-purple-200 dark:border-purple-800' }, 'active_jobs': { name: 'Active Jobs Data Provider', icon: Briefcase, color: 'from-indigo-500 to-indigo-600', bgColor: 'bg-indigo-50 dark:bg-indigo-900/20', textColor: 'text-indigo-700 dark:text-indigo-300', borderColor: 'border-indigo-200 dark:border-indigo-800' } }; export function ExecuteDataProviderCallToolView({ name = 'execute-data-provider-call', assistantContent, toolContent, assistantTimestamp, toolTimestamp, isSuccess = true, isStreaming = false, }: ToolViewProps) { const { serviceName, route, payload, output, actualIsSuccess, actualToolTimestamp, actualAssistantTimestamp } = extractDataProviderCallData( assistantContent, toolContent, isSuccess, toolTimestamp, assistantTimestamp ); const providerKey = serviceName?.toLowerCase() as keyof typeof PROVIDER_CONFIG; const providerConfig = providerKey && PROVIDER_CONFIG[providerKey] ? PROVIDER_CONFIG[providerKey] : PROVIDER_CONFIG['linkedin']; const IconComponent = providerConfig.icon; return (
Data Provider
{!isStreaming && ( {actualIsSuccess ? ( ) : ( )} {actualIsSuccess ? 'Executed' : 'Failed'} )}
{isStreaming ? (

Executing call...

Calling {serviceName || 'data provider'}

) : (

{providerConfig.name}

{serviceName && (

Service: {serviceName}

)}
{route && ( {route} )}
{output && !actualIsSuccess && (
Execution Failed

{output}

)} {payload && (
Call Parameters
{Object.entries(payload).map(([key, value]) => (
{key}
{typeof value === 'string' ? `"${value}"` : String(value)}
))}
Raw JSON
                      {JSON.stringify(payload, null, 2)}
                    
)} {!serviceName && !route && !payload && (

Will be populated when the call is executed...

)}
)}
{!isStreaming && serviceName && ( {serviceName} )}
{actualToolTimestamp && !isStreaming ? formatTimestamp(actualToolTimestamp) : actualAssistantTimestamp ? formatTimestamp(actualAssistantTimestamp) : ''}
); }