'use client'; import { useState } from 'react'; import { IconChevronDown, IconChevronRight, IconTool } from '@tabler/icons-react'; import { ActionIcon, Code, Collapse, Group, Paper, Text, useMantineTheme } from '@mantine/core'; import { useThemeContext } from '@/components/DynamicThemeProvider'; import classes from './ToolCallDisplay.module.css'; interface ToolCallDisplayProps { toolName: string; args: Record; result: string; } // Friendly tool names const toolDisplayNames: Record = { calculator: 'Calculator', get_current_datetime: 'Date/Time', fetch_url: 'Fetch URL', web_search: 'Web Search', execute_code: 'Code Execution', read_file: 'Read File', write_file: 'Write File', get_weather: 'Weather', generate_image: 'Image Generation', }; export function ToolCallDisplay({ toolName, args, result }: ToolCallDisplayProps) { const [opened, setOpened] = useState(false); const { primaryColor } = useThemeContext(); const theme = useMantineTheme(); const displayName = toolDisplayNames[toolName] || toolName; const isError = result.startsWith('Error:'); // Format args for display const argsDisplay = Object.entries(args) .map(([key, value]) => `${key}: ${JSON.stringify(value)}`) .join(', '); return ( setOpened(!opened)} gap="xs" wrap="nowrap" p="xs" style={{ cursor: 'pointer' }} > {opened ? : } {displayName} {!opened && argsDisplay && ( {argsDisplay} )}
{Object.keys(args).length > 0 && (
Arguments: {JSON.stringify(args, null, 2)}
)}
Result: {result}
); }