MCPcopy Create free account
hub / github.com/AntiHub-Project/AntiHub / ToolOutput

Function ToolOutput

components/ai-elements/tool.tsx:127–165  ·  view source on GitHub ↗
({
  className,
  output,
  errorText,
  ...props
}: ToolOutputProps)

Source from the content-addressed store, hash-verified

125};
126
127export const ToolOutput = ({
128 className,
129 output,
130 errorText,
131 ...props
132}: ToolOutputProps) => {
133 if (!(output || errorText)) {
134 return null;
135 }
136
137 let Output = <div>{output as ReactNode}</div>;
138
139 if (typeof output === "object" && !isValidElement(output)) {
140 Output = (
141 <CodeBlock code={JSON.stringify(output, null, 2)} language="json" />
142 );
143 } else if (typeof output === "string") {
144 Output = <CodeBlock code={output} language="json" />;
145 }
146
147 return (
148 <div className={cn("space-y-2 p-4", className)} {...props}>
149 <h4 className="font-medium text-muted-foreground text-xs uppercase tracking-wide">
150 {errorText ? "Error" : "Result"}
151 </h4>
152 <div
153 className={cn(
154 "overflow-x-auto rounded-md text-xs [&_table]:w-full",
155 errorText
156 ? "bg-destructive/10 text-destructive"
157 : "bg-muted/50 text-foreground"
158 )}
159 >
160 {errorText && <div>{errorText}</div>}
161 {Output}
162 </div>
163 </div>
164 );
165};

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected