chunk.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import type { FC, PropsWithChildren } from 'react'
  2. import { SelectionMod } from '../base/icons/src/public/knowledge'
  3. import type { QA } from '@/models/datasets'
  4. export type ChunkLabelProps = {
  5. label: string
  6. characterCount: number
  7. }
  8. export const ChunkLabel: FC<ChunkLabelProps> = (props) => {
  9. const { label, characterCount } = props
  10. return <div className='flex items-center text-text-tertiary text-xs font-medium'>
  11. <SelectionMod className='size-[10px]' />
  12. <p className='flex gap-2 ml-0.5'>
  13. <span>
  14. {label}
  15. </span>
  16. <span>
  17. ·
  18. </span>
  19. <span>
  20. {`${characterCount} characters`}
  21. </span>
  22. </p>
  23. </div>
  24. }
  25. export type ChunkContainerProps = ChunkLabelProps & PropsWithChildren
  26. export const ChunkContainer: FC<ChunkContainerProps> = (props) => {
  27. const { label, characterCount, children } = props
  28. return <div className='space-y-2'>
  29. <ChunkLabel label={label} characterCount={characterCount} />
  30. <div className='text-text-secondary body-md-regular'>
  31. {children}
  32. </div>
  33. </div>
  34. }
  35. export type QAPreviewProps = {
  36. qa: QA
  37. }
  38. export const QAPreview: FC<QAPreviewProps> = (props) => {
  39. const { qa } = props
  40. return <div className='flex flex-col gap-y-2'>
  41. <div className='flex gap-x-1'>
  42. <label className='text-text-tertiary text-[13px] font-medium leading-[20px] shrink-0'>Q</label>
  43. <p className='text-text-secondary body-md-regular'>{qa.question}</p>
  44. </div>
  45. <div className='flex gap-x-1'>
  46. <label className='text-text-tertiary text-[13px] font-medium leading-[20px] shrink-0'>A</label>
  47. <p className='text-text-secondary body-md-regular'>{qa.answer}</p>
  48. </div>
  49. </div>
  50. }