feat(knowledgeBase): Refactor document list API and improve polling logic
- Update getDocumentList API to accept kb_id as separate parameter instead of extracting from query object - Fix parameter name from auto_question to auto_questions in parser config - Add progress field initialization in document update params - Improve polling logic to handle both auto-return and manual stay scenarios with proper loading state management - Add console logging for debugging polling status and document processing - Reduce polling interval from 5000ms to 3000ms for faster status updates - Enhance cleanup logic with route change detection to prevent memory leaks - Add record parameter to progress render function for better data access - Refactor confirm dialog callbacks to properly manage loading state timing - Ensure loading indicator displays correctly when user chooses to stay on page
This commit is contained in:
@@ -22,6 +22,7 @@ const CreateFolderModal = forwardRef<CreateFolderModalRef,CreateFolderModalRefPr
|
||||
};
|
||||
|
||||
const handleOpen = (folder?: FolderFormData | null) => {
|
||||
debugger
|
||||
if (folder) {
|
||||
setFolder(folder);
|
||||
// 设置表单值
|
||||
|
||||
@@ -24,6 +24,7 @@ interface RecallTestResultProps {
|
||||
scrollableTarget?: string;
|
||||
editable?: boolean; // 是否可编辑
|
||||
onItemClick?: (item: RecallTestData, index: number) => void; // 点击项的回调
|
||||
parserMode?: number; // 解析模式,1 表示 QA 格式
|
||||
}
|
||||
|
||||
const RecallTestResult = ({
|
||||
@@ -35,9 +36,31 @@ const RecallTestResult = ({
|
||||
scrollableTarget,
|
||||
editable = false,
|
||||
onItemClick,
|
||||
parserMode = 0,
|
||||
}: RecallTestResultProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// 解析 QA 格式内容
|
||||
const parseQAContent = (content: string) => {
|
||||
if (!content || parserMode !== 1) return null;
|
||||
|
||||
const qaRegex = /question:\s*(.*?)\s*answer:\s*(.*?)$/s;
|
||||
const match = content.match(qaRegex);
|
||||
|
||||
if (match) {
|
||||
const question = match[1]?.trim() || '';
|
||||
const answer = match[2]?.trim() || '';
|
||||
return { question, answer };
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
// 格式化 QA 内容为显示格式
|
||||
const formatQAContent = (question: string, answer: string) => {
|
||||
return `**问题:** ${question}\n\n**答案:** ${answer}`;
|
||||
};
|
||||
|
||||
const handleItemClick = (e: React.MouseEvent, item: RecallTestData, index: number) => {
|
||||
// 检查点击的是否是图片或图片相关元素
|
||||
const target = e.target as HTMLElement;
|
||||
@@ -126,7 +149,14 @@ const RecallTestResult = ({
|
||||
</div>
|
||||
<div className='rb:flex rb:text-left rb:px-4 rb:py-3 rb:bg-[#F0F3F8] rb:rounded-lg rb:mt-2'>
|
||||
<div className='rb:text-gray-800 rb:text-sm rb:whitespace-pre-wrap rb:break-words rb:w-full'>
|
||||
<RbMarkdown content={item.page_content} showHtmlComments={true} />
|
||||
{(() => {
|
||||
const qaContent = parseQAContent(item.page_content);
|
||||
if (qaContent) {
|
||||
const formattedContent = formatQAContent(qaContent.question, qaContent.answer);
|
||||
return <RbMarkdown content={formattedContent} showHtmlComments={true} />;
|
||||
}
|
||||
return <RbMarkdown content={item.page_content} showHtmlComments={true} />;
|
||||
})()}
|
||||
</div>
|
||||
</div>
|
||||
{item.metadata?.file_created_at && (
|
||||
|
||||
Reference in New Issue
Block a user