chunk.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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-xs font-medium text-text-tertiary'>
  11. <SelectionMod className='size-[10px]' />
  12. <p className='ml-0.5 flex gap-2'>
  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='body-md-regular text-text-secondary'>
  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='shrink-0 text-[13px] font-medium leading-[20px] text-text-tertiary'>Q</label>
  43. <p className='body-md-regular text-text-secondary'>{qa.question}</p>
  44. </div>
  45. <div className='flex gap-x-1'>
  46. <label className='shrink-0 text-[13px] font-medium leading-[20px] text-text-tertiary'>A</label>
  47. <p className='body-md-regular text-text-secondary'>{qa.answer}</p>
  48. </div>
  49. </div>
  50. }