import React from 'react'; import './style.scss'; export interface ToolCallData { id: string; function: { name: string; arguments: string; }; result?: { output?: string; error?: string; }; } export interface ToolCallProps { toolCall: ToolCallData; className?: string; showArguments?: boolean; showResult?: boolean; } export const ToolCall: React.FC = ({ toolCall, className = '', showArguments = true, showResult = true }) => { const formatArguments = (args: string) => { try { const parsed = JSON.parse(args); return JSON.stringify(parsed, null, 2); } catch { return args; } }; const formatResult = (result: any) => { if (typeof result === 'string') { return result; } return JSON.stringify(result, null, 2); }; return (
{toolCall.function.name}({showArguments && toolCall.function.arguments && (formatArguments(toolCall.function.arguments))})
{showResult && toolCall.result && (
{toolCall.result.error ? (
                            Error: {toolCall.result.error}
                        
) : (
                            {formatResult(toolCall.result.output)}
                        
)}
)}
); };