2024-12-26 12:01:51 +08:00
|
|
|
import type { FC, PropsWithChildren } from 'react'
|
|
|
|
import { SelectionMod } from '../base/icons/src/public/knowledge'
|
|
|
|
import type { QA } from '@/models/datasets'
|
|
|
|
|
|
|
|
export type ChunkLabelProps = {
|
|
|
|
label: string
|
|
|
|
characterCount: number
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ChunkLabel: FC<ChunkLabelProps> = (props) => {
|
|
|
|
const { label, characterCount } = props
|
2025-03-21 17:41:03 +08:00
|
|
|
return <div className='flex items-center text-xs font-medium text-text-tertiary'>
|
2024-12-26 12:01:51 +08:00
|
|
|
<SelectionMod className='size-[10px]' />
|
2025-03-21 17:41:03 +08:00
|
|
|
<p className='ml-0.5 flex gap-2'>
|
2025-02-17 17:05:13 +08:00
|
|
|
<span>
|
|
|
|
{label}
|
|
|
|
</span>
|
|
|
|
<span>
|
2024-12-26 12:01:51 +08:00
|
|
|
·
|
2025-02-17 17:05:13 +08:00
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
{`${characterCount} characters`}
|
|
|
|
</span>
|
|
|
|
</p>
|
2024-12-26 12:01:51 +08:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
export type ChunkContainerProps = ChunkLabelProps & PropsWithChildren
|
|
|
|
|
|
|
|
export const ChunkContainer: FC<ChunkContainerProps> = (props) => {
|
|
|
|
const { label, characterCount, children } = props
|
|
|
|
return <div className='space-y-2'>
|
|
|
|
<ChunkLabel label={label} characterCount={characterCount} />
|
2025-03-21 17:41:03 +08:00
|
|
|
<div className='body-md-regular text-text-secondary'>
|
2024-12-26 12:01:51 +08:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
export type QAPreviewProps = {
|
|
|
|
qa: QA
|
|
|
|
}
|
|
|
|
|
|
|
|
export const QAPreview: FC<QAPreviewProps> = (props) => {
|
|
|
|
const { qa } = props
|
|
|
|
return <div className='flex flex-col gap-y-2'>
|
|
|
|
<div className='flex gap-x-1'>
|
2025-03-21 17:41:03 +08:00
|
|
|
<label className='shrink-0 text-[13px] font-medium leading-[20px] text-text-tertiary'>Q</label>
|
|
|
|
<p className='body-md-regular text-text-secondary'>{qa.question}</p>
|
2024-12-26 12:01:51 +08:00
|
|
|
</div>
|
|
|
|
<div className='flex gap-x-1'>
|
2025-03-21 17:41:03 +08:00
|
|
|
<label className='shrink-0 text-[13px] font-medium leading-[20px] text-text-tertiary'>A</label>
|
|
|
|
<p className='body-md-regular text-text-secondary'>{qa.answer}</p>
|
2024-12-26 12:01:51 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|