Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 79 additions & 14 deletions frontend/src/api/knowledge-base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,17 @@ export function listKnowledgeFolders(kbId: string) {
* are derived from the stored paths, so a path that does not exist yet is
* created by this call. Only the grouping changes; documents are not re-parsed.
*/
export function moveKnowledgeToFolder(kbId: string, ids: string[], folderPath: string) {
export function moveKnowledgeToFolder(
kbId: string,
ids: string[],
folderPath: string,
selection?: KnowledgeBatchSelectionPayload,
) {
return post('/api/v1/knowledge/folder', {
kb_id: kbId,
knowledge_ids: ids,
knowledge_ids: selection?.select_all ? undefined : ids,
folder_path: folderPath,
...selection,
});
}

Expand Down Expand Up @@ -357,7 +363,25 @@ export function reparseKnowledge(id: string, data?: { process_config?: Knowledge
}

export function cancelKnowledgeParse(id: string) {
return post(`/api/v1/knowledge/${id}/cancel-parse`);
// Cancel may scan large asynq queues; keep above the default 30s axios timeout.
return post(`/api/v1/knowledge/${id}/cancel-parse`, {}, { timeout: 120000 });
}

/** Batch cancel-parse. Supports explicit ids or select_all + filter. */
export function batchCancelKnowledgeParse(
kbId: string,
ids: string[],
selection?: KnowledgeBatchSelectionPayload,
) {
return post(
`/api/v1/knowledge/batch-cancel-parse`,
{
kb_id: kbId,
ids: selection?.select_all ? undefined : ids,
...selection,
},
{ timeout: 120000 },
);
}

export function getKnowledgeSpans(id: string, attempt?: number) {
Expand All @@ -369,9 +393,51 @@ export function delKnowledgeDetails(id: string) {
return del(`/api/v1/knowledge/${id}`);
}

/** Shared select_all payload for batch knowledge mutations. */
export type KnowledgeBatchFilterPayload = {
tag_ids?: string[];
keyword?: string;
file_type?: string;
parse_status?: string;
source?: string;
start_time?: string;
end_time?: string;
folder_path?: string;
folder_recursive?: boolean;
};

export type KnowledgeBatchSelectionPayload = {
select_all?: boolean;
exclude_ids?: string[];
filter?: KnowledgeBatchFilterPayload;
};

// 批量删除(同一知识库内)。后端会校验所有 id 隶属于 kb_id 且具有编辑权限。
export function batchDeleteKnowledge(kbId: string, ids: string[]) {
return post(`/api/v1/knowledge/batch-delete`, { kb_id: kbId, ids });
export function batchDeleteKnowledge(
kbId: string,
ids: string[],
selection?: KnowledgeBatchSelectionPayload,
) {
return post(`/api/v1/knowledge/batch-delete`, {
kb_id: kbId,
ids: selection?.select_all ? undefined : ids,
...selection,
});
}

// 批量重建(同一知识库内)。后端会校验归属与权限,跳过解析中/删除中的条目。
export function batchReparseKnowledge(
kbId: string,
ids: string[],
processConfig?: KnowledgeProcessOverrides,
selection?: KnowledgeBatchSelectionPayload,
) {
return post(`/api/v1/knowledge/batch-reparse`, {
kb_id: kbId,
ids: selection?.select_all ? undefined : ids,
process_config: processConfig,
...selection,
});
}

export function downKnowledgeDetails(id: string) {
Expand Down Expand Up @@ -475,7 +541,14 @@ export function deleteKnowledgeBaseTag(kbId: string, tagSeqId: number, params?:
return del(`/api/v1/knowledge-bases/${kbId}/tags/${tagSeqId}${forceQuery}`);
}

export function updateKnowledgeTagBatch(data: { updates: Record<string, string[]> }) {
export function updateKnowledgeTagBatch(data: {
updates?: Record<string, string[]>;
kb_id?: string;
tag_ids?: string[];
select_all?: boolean;
exclude_ids?: string[];
filter?: KnowledgeBatchFilterPayload;
}) {
return put(`/api/v1/knowledge/tags`, data);
}

Expand Down Expand Up @@ -627,11 +700,3 @@ export function knowledgeSemanticSearch(data: {
}) {
return post('/api/v1/knowledge-search', data);
}

export function batchReparseKnowledge(kbId: string, ids: string[], processConfig?: KnowledgeProcessOverrides) {
return post(`/api/v1/knowledge/batch-reparse`, {
kb_id: kbId,
ids,
process_config: processConfig,
});
}
10 changes: 10 additions & 0 deletions frontend/src/i18n/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ export default {
newFolderHintRoot: 'Will be created under root',
newFolderHintUnder: 'Will be created under “{folder}”',
success: 'Moved {count} documents',
partial: 'Moved {succeeded} documents, {failed} failed',
failed: 'Could not move the documents',
duplicate: 'That folder already exists',
},
Expand Down Expand Up @@ -594,6 +595,7 @@ export default {
confirmBatchDeleteDocument: 'Delete {count} selected documents? This action cannot be undone.',
batchDeleteSuccess: 'Deleted {count} documents',
batchDeleteFailed: 'Batch delete failed',
batchDeletePartial: 'Deleted {succeeded} documents, {failed} failed',
batchTag: 'Batch Tag',
batchTagDialogHeading: 'Batch Tag',
batchTagSubtitle: 'Set tags for {count} selected documents (will replace existing tags)',
Expand All @@ -606,7 +608,15 @@ export default {
confirmBatchReparse: 'Confirm and reparse',
batchReparseSuccess: 'Submitted {count} rebuild tasks',
batchReparseFailed: 'Batch rebuild failed',
batchReparsePartial: 'Submitted {succeeded} rebuild tasks, {failed} failed',
batchReparseSkippedInFlight: 'Skipped {count} document(s) still being parsed',
confirmBatchCancelParseDocument: 'Stop parsing for {count} selected documents? Existing parsed content will be kept and can be rebuilt later.',
batchCancelParseNoInFlight: 'No selected documents are currently being parsed',
batchCancelParseSkippedNotInFlight: 'Skipped {count} document(s) not in parsing state',
batchCancelParseSubmitting: 'Stopping parsing for {count} document(s), please wait…',
batchCancelParseSuccess: 'Stopped parsing for {count} document(s)',
batchCancelParsePartial: 'Stopped {succeeded} task(s), {failed} failed to stop',
batchCancelParseFailed: 'Batch stop parsing failed',
statusCompleted: 'Completed',
statusProcessing: 'Processing',
statusFinalizing: 'Optimizing',
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/i18n/locales/ko-KR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5549,6 +5549,7 @@ export default {
newFolderHintRoot: '루트 아래에 생성됩니다',
newFolderHintUnder: '「{folder}」 아래에 생성됩니다',
success: '문서 {count}개를 이동했습니다',
partial: '문서 {succeeded}개를 이동했고, {failed}개 이동에 실패했습니다',
failed: '문서를 이동할 수 없습니다',
duplicate: '이미 존재하는 폴더입니다',
},
Expand Down Expand Up @@ -5745,6 +5746,7 @@ export default {
confirmBatchDeleteDocument: '선택한 {count}개 문서를 삭제하시겠습니까? 삭제 후 복구할 수 없습니다.',
batchDeleteSuccess: '{count}개 문서가 삭제되었습니다',
batchDeleteFailed: '일괄 삭제 실패',
batchDeletePartial: '{succeeded}개 문서 삭제됨, {failed}개 실패',
batchTag: '일괄 태그',
batchTagDialogHeading: '일괄 태그 지정',
batchTagSubtitle: '선택한 {count}개 문서에 태그를 일괄 설정합니다 (기존 태그는 대체됩니다)',
Expand All @@ -5757,7 +5759,15 @@ export default {
confirmBatchReparse: '확인 후 재파싱',
batchReparseSuccess: '재구축 작업 {count}개가 제출되었습니다',
batchReparseFailed: '일괄 재구축 실패',
batchReparsePartial: '재구축 작업 {succeeded}개 제출됨, {failed}개 실패',
batchReparseSkippedInFlight: '파싱 중인 문서 {count}개를 건너뛰었습니다',
confirmBatchCancelParseDocument: '선택한 {count}개 문서의 파싱을 중지하시겠습니까? 이미 저장된 내용은 유지되며 이후 재구축할 수 있습니다.',
batchCancelParseNoInFlight: '선택한 문서 중 파싱 중인 작업이 없습니다',
batchCancelParseSkippedNotInFlight: '파싱 중이 아닌 문서 {count}개를 건너뛰었습니다',
batchCancelParseSubmitting: '{count}개 문서의 파싱을 중지하는 중…',
batchCancelParseSuccess: '{count}개 문서의 파싱을 중지했습니다',
batchCancelParsePartial: '{succeeded}개 파싱 작업을 중지했고, {failed}개 중지에 실패했습니다',
batchCancelParseFailed: '일괄 파싱 중지 실패',
statusCompleted: '완료',
statusProcessing: '처리 중',
statusFinalizing: '최적화 중',
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/i18n/locales/ru-RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5549,6 +5549,7 @@ export default {
newFolderHintRoot: 'Будет создана в корне',
newFolderHintUnder: 'Будет создана внутри «{folder}»',
success: 'Перемещено документов: {count}',
partial: 'Перемещено документов: {succeeded}, не удалось: {failed}',
failed: 'Не удалось переместить документы',
duplicate: 'Такая папка уже существует',
},
Expand Down Expand Up @@ -5745,6 +5746,7 @@ export default {
confirmBatchDeleteDocument: 'Удалить {count} выбранных документов? Это действие нельзя отменить.',
batchDeleteSuccess: 'Удалено документов: {count}',
batchDeleteFailed: 'Ошибка пакетного удаления',
batchDeletePartial: 'Удалено документов: {succeeded}, не удалось: {failed}',
batchTag: 'Пакетная метка',
batchTagDialogHeading: 'Пакетное назначение меток',
batchTagSubtitle: 'Установить метки для {count} выбранных документов (заменит существующие метки)',
Expand All @@ -5757,7 +5759,15 @@ export default {
confirmBatchReparse: 'Подтвердить и обработать заново',
batchReparseSuccess: 'Отправлено задач пересборки: {count}',
batchReparseFailed: 'Ошибка пакетной пересборки',
batchReparsePartial: 'Отправлено задач пересборки: {succeeded}, не удалось: {failed}',
batchReparseSkippedInFlight: 'Пропущено документов, которые ещё обрабатываются: {count}',
confirmBatchCancelParseDocument: 'Остановить разбор для {count} выбранных документов? Уже записанное содержимое сохранится и его можно будет пересобрать позже.',
batchCancelParseNoInFlight: 'Среди выбранных документов нет задач в процессе разбора',
batchCancelParseSkippedNotInFlight: 'Пропущено документов не в состоянии разбора: {count}',
batchCancelParseSubmitting: 'Остановка разбора для {count} документ(ов), подождите…',
batchCancelParseSuccess: 'Остановлен разбор для {count} документ(ов)',
batchCancelParsePartial: 'Остановлено задач: {succeeded}, не удалось остановить: {failed}',
batchCancelParseFailed: 'Ошибка пакетной остановки разбора',
statusCompleted: 'Завершено',
statusProcessing: 'Обработка',
statusFinalizing: 'Оптимизация',
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/i18n/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5551,6 +5551,7 @@ export default {
newFolderHintRoot: '将在根目录下创建',
newFolderHintUnder: '将在「{folder}」下创建',
success: '已移动 {count} 个文档',
partial: '已移动 {succeeded} 个文档,{failed} 个移动失败',
failed: '移动失败',
duplicate: '该目录已存在',
},
Expand Down Expand Up @@ -5747,6 +5748,7 @@ export default {
confirmBatchDeleteDocument: '确认删除选中的 {count} 个文档?删除后将无法恢复。',
batchDeleteSuccess: '成功删除 {count} 个文档',
batchDeleteFailed: '批量删除失败',
batchDeletePartial: '已删除 {succeeded} 个文档,{failed} 个删除失败',
batchTag: '批量打标签',
batchTagDialogHeading: '批量打标签',
batchTagSubtitle: '为选中的 {count} 个文档统一设置标签(将替换文档原有标签)',
Expand All @@ -5759,7 +5761,15 @@ export default {
confirmBatchReparse: '确认并重新解析',
batchReparseSuccess: '已提交 {count} 个重建任务',
batchReparseFailed: '批量重建失败',
batchReparsePartial: '已提交 {succeeded} 个重建任务,{failed} 个提交失败',
batchReparseSkippedInFlight: '已跳过 {count} 个正在解析中的文档',
confirmBatchCancelParseDocument: '确认停止解析选中的 {count} 个文档?已写入内容会保留,后续可重新重建。',
batchCancelParseNoInFlight: '选中文档中没有正在解析的任务',
batchCancelParseSkippedNotInFlight: '已跳过 {count} 个非解析中的文档',
batchCancelParseSubmitting: '正在停止 {count} 个文档的解析,请稍候…',
batchCancelParseSuccess: '已停止 {count} 个文档的解析任务',
batchCancelParsePartial: '已停止 {succeeded} 个解析任务,{failed} 个停止失败',
batchCancelParseFailed: '批量停止解析失败',
statusCompleted: '已完成',
statusProcessing: '解析中',
statusFinalizing: '优化中',
Expand Down
Loading