tool-output-error.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Derived from vercel/ai-elements (skills/ai-elements/scripts/tool-output-error.tsx).
  3. * Copyright 2023 Vercel, Inc. Licensed under Apache-2.0.
  4. * Modified by ZCode: local integration, formatting and adaptations.
  5. * See THIRD-PARTY-NOTICES.md in the repository root for license and provenance.
  6. */
  7. "use client";
  8. import {
  9. Tool,
  10. ToolContent,
  11. ToolHeader,
  12. ToolInput,
  13. ToolOutput,
  14. } from "@/components/ai-elements/tool";
  15. import type { ToolUIPart } from "ai";
  16. const toolCall: ToolUIPart = {
  17. errorText:
  18. "Connection timeout: The request took longer than 5000ms to complete. Please check your network connection and try again.",
  19. input: {
  20. headers: {
  21. Authorization: "Bearer token123",
  22. "Content-Type": "application/json",
  23. },
  24. method: "GET",
  25. timeout: 5000,
  26. url: "https://api.example.com/data",
  27. },
  28. output: undefined,
  29. state: "output-error" as const,
  30. toolCallId: "api_request_1",
  31. type: "tool-api_request" as const,
  32. };
  33. const Example = () => (
  34. <div style={{ height: "500px" }}>
  35. <Tool>
  36. <ToolHeader state={toolCall.state} type={toolCall.type} />
  37. <ToolContent>
  38. <ToolInput input={toolCall.input} />
  39. {toolCall.state === "output-error" && (
  40. <ToolOutput errorText={toolCall.errorText} output={toolCall.output} />
  41. )}
  42. </ToolContent>
  43. </Tool>
  44. </div>
  45. );
  46. export default Example;