chunk.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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'><span>
  13. {label}
  14. </span>
  15. <span>
  16. ·
  17. </span>
  18. <span>
  19. {`${characterCount} characters`}
  20. </span></p>
  21. </div>
  22. }
  23. export type ChunkContainerProps = ChunkLabelProps & PropsWithChildren
  24. export const ChunkContainer: FC<ChunkContainerProps> = (props) => {
  25. const { label, characterCount, children } = props
  26. return <div className='space-y-2'>
  27. <ChunkLabel label={label} characterCount={characterCount} />
  28. <div className='text-text-secondary body-md-regular'>
  29. {children}
  30. </div>
  31. </div>
  32. }
  33. export type QAPreviewProps = {
  34. qa: QA
  35. }
  36. export const QAPreview: FC<QAPreviewProps> = (props) => {
  37. const { qa } = props
  38. return <div className='flex flex-col gap-y-2'>
  39. <div className='flex gap-x-1'>
  40. <label className='text-text-tertiary text-[13px] font-medium leading-[20px] shrink-0'>Q</label>
  41. <p className='text-text-secondary body-md-regular'>{qa.question}</p>
  42. </div>
  43. <div className='flex gap-x-1'>
  44. <label className='text-text-tertiary text-[13px] font-medium leading-[20px] shrink-0'>A</label>
  45. <p className='text-text-secondary body-md-regular'>{qa.answer}</p>
  46. </div>
  47. </div>
  48. }