inline-citation.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Derived from vercel/ai-elements (skills/ai-elements/scripts/inline-citation.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. InlineCitation,
  10. InlineCitationCard,
  11. InlineCitationCardBody,
  12. InlineCitationCardTrigger,
  13. InlineCitationCarousel,
  14. InlineCitationCarouselContent,
  15. InlineCitationCarouselHeader,
  16. InlineCitationCarouselIndex,
  17. InlineCitationCarouselItem,
  18. InlineCitationCarouselNext,
  19. InlineCitationCarouselPrev,
  20. InlineCitationSource,
  21. InlineCitationText,
  22. } from "@/components/ai-elements/inline-citation";
  23. const citation = {
  24. sources: [
  25. {
  26. description:
  27. "A comprehensive study on the recent developments in natural language processing technologies and their applications.",
  28. title: "Advances in Natural Language Processing",
  29. url: "https://example.com/nlp-advances",
  30. },
  31. {
  32. description:
  33. "An overview of the most significant machine learning breakthroughs in the past year.",
  34. title: "Breakthroughs in Machine Learning",
  35. url: "https://mlnews.org/breakthroughs",
  36. },
  37. {
  38. description:
  39. "A report on how artificial intelligence is transforming healthcare and diagnostics.",
  40. title: "AI in Healthcare: Current Trends",
  41. url: "https://healthai.com/trends",
  42. },
  43. {
  44. description:
  45. "A discussion on the ethical considerations and challenges in the development of AI.",
  46. title: "Ethics of Artificial Intelligence",
  47. url: "https://aiethics.org/overview",
  48. },
  49. {
  50. description:
  51. "Insights into the technical challenges and solutions for scaling deep learning architectures.",
  52. title: "Scaling Deep Learning Models",
  53. url: "https://deeplearninghub.com/scaling-models",
  54. },
  55. {
  56. description:
  57. "A summary of the latest benchmarks and evaluation metrics for natural language understanding systems.",
  58. title: "Natural Language Understanding Benchmarks",
  59. url: "https://nlubenchmarks.com/latest",
  60. },
  61. ],
  62. text: "The technology continues to evolve rapidly, with new breakthroughs being announced regularly",
  63. };
  64. const Example = () => (
  65. <p className="text-sm leading-relaxed">
  66. According to recent studies, artificial intelligence has shown remarkable progress in natural
  67. language processing.{" "}
  68. <InlineCitation>
  69. <InlineCitationText>{citation.text}</InlineCitationText>
  70. <InlineCitationCard>
  71. <InlineCitationCardTrigger sources={citation.sources.map((source) => source.url)} />
  72. <InlineCitationCardBody>
  73. <InlineCitationCarousel>
  74. <InlineCitationCarouselHeader>
  75. <InlineCitationCarouselPrev />
  76. <InlineCitationCarouselNext />
  77. <InlineCitationCarouselIndex />
  78. </InlineCitationCarouselHeader>
  79. <InlineCitationCarouselContent>
  80. {citation.sources.map((source) => (
  81. <InlineCitationCarouselItem key={source.url}>
  82. <InlineCitationSource
  83. description={source.description}
  84. title={source.title}
  85. url={source.url}
  86. />
  87. </InlineCitationCarouselItem>
  88. ))}
  89. </InlineCitationCarouselContent>
  90. </InlineCitationCarousel>
  91. </InlineCitationCardBody>
  92. </InlineCitationCard>
  93. </InlineCitation>
  94. .
  95. </p>
  96. );
  97. export default Example;