186 lines
4.0 KiB
TypeScript
186 lines
4.0 KiB
TypeScript
import request from '@/utils/request';
|
|
|
|
type ApiResult<T> = {
|
|
code: number;
|
|
msg: string;
|
|
data: T;
|
|
};
|
|
|
|
export type SopDoc = {
|
|
title: string;
|
|
desc: string;
|
|
hit: string;
|
|
type: string;
|
|
};
|
|
|
|
export type SopSnippet = {
|
|
title: string;
|
|
text: string;
|
|
};
|
|
|
|
export type SopRecord = {
|
|
title: string;
|
|
category: string;
|
|
version: string;
|
|
status: string;
|
|
owner: string;
|
|
summary: string;
|
|
};
|
|
|
|
export type SopSearchResponse = {
|
|
queryText: string;
|
|
category: string;
|
|
answer: string;
|
|
reference: string;
|
|
docs: SopDoc[];
|
|
snippets: SopSnippet[];
|
|
training: string[];
|
|
records: SopRecord[];
|
|
keyPoints?: string[];
|
|
cautions?: string[];
|
|
promptVersion?: string | null;
|
|
reviewId?: number;
|
|
};
|
|
|
|
export type SopReviewResponse = {
|
|
id: number;
|
|
usable: boolean | null;
|
|
status: string;
|
|
reviewedAt: string;
|
|
promptVersion?: string | null;
|
|
};
|
|
|
|
export type AnswerFeedbackItem = {
|
|
id: number;
|
|
queryText: string;
|
|
queryNorm: string;
|
|
fragmentId: number;
|
|
verdict: string;
|
|
category: string;
|
|
position: string;
|
|
source: string;
|
|
reviewId?: number | null;
|
|
reviewStatus: string;
|
|
reviewer?: string | null;
|
|
reviewedTime?: string | null;
|
|
createTime: string;
|
|
updateTime: string;
|
|
};
|
|
|
|
export type AnswerFeedbackReviewResponse = {
|
|
id: number;
|
|
reviewStatus: string;
|
|
reviewer?: string | null;
|
|
reviewedTime?: string | null;
|
|
};
|
|
|
|
export type SopUploadResponse = {
|
|
docId: string;
|
|
ossId: number;
|
|
fileName: string;
|
|
category: string;
|
|
fragments: number;
|
|
summary: string;
|
|
tags: string[];
|
|
snippets: SopSnippet[];
|
|
};
|
|
|
|
export function searchKnowledgeSop(data: {
|
|
queryText: string;
|
|
category: string;
|
|
position?: string;
|
|
source?: string;
|
|
limit: number;
|
|
}): Promise<ApiResult<SopSearchResponse>> {
|
|
return request({
|
|
url: '/api/knowledge/search',
|
|
method: 'post',
|
|
data,
|
|
headers: { repeatSubmit: false }
|
|
});
|
|
}
|
|
|
|
export function uploadKnowledgeDoc(data: FormData): Promise<ApiResult<SopUploadResponse>> {
|
|
return request({
|
|
url: '/api/knowledge/doc/upload',
|
|
method: 'post',
|
|
data,
|
|
timeout: 180000,
|
|
headers: { repeatSubmit: false }
|
|
});
|
|
}
|
|
|
|
export function reviewKnowledgeSop(id: number, data: { usable: boolean; reviewer?: string; note?: string }): Promise<ApiResult<SopReviewResponse>> {
|
|
return request({
|
|
url: `/api/knowledge/reviews/${id}`,
|
|
method: 'post',
|
|
data,
|
|
headers: { repeatSubmit: false }
|
|
});
|
|
}
|
|
|
|
export function listAnswerFeedback(status = '待复核', limit = 50): Promise<ApiResult<AnswerFeedbackItem[]>> {
|
|
return request({
|
|
url: '/api/knowledge/answer-feedback',
|
|
method: 'get',
|
|
params: { status, limit },
|
|
headers: { repeatSubmit: false }
|
|
});
|
|
}
|
|
|
|
export function reviewAnswerFeedback(id: number): Promise<ApiResult<AnswerFeedbackReviewResponse>> {
|
|
return request({
|
|
url: `/api/knowledge/answer-feedback/${id}/review`,
|
|
method: 'post',
|
|
headers: { repeatSubmit: false }
|
|
});
|
|
}
|
|
|
|
export type UploadEnqueueResponse = {
|
|
itemId: number;
|
|
batchId: string;
|
|
fileName: string;
|
|
status: string;
|
|
};
|
|
|
|
export type UploadItem = {
|
|
id: number;
|
|
batchId: string;
|
|
fileName: string;
|
|
category: string;
|
|
status: number;
|
|
statusLabel: string;
|
|
error: string | null;
|
|
docId: string | null;
|
|
fragmentCount: number | null;
|
|
updatedAt: string;
|
|
};
|
|
|
|
/** 批量上传走异步队列:接口只暂存+入队即返回,解析/归类/向量化由后台 worker 处理。 */
|
|
export function uploadKnowledgeDocAsync(data: FormData): Promise<ApiResult<UploadEnqueueResponse>> {
|
|
return request({
|
|
url: '/api/knowledge/doc/upload-async',
|
|
method: 'post',
|
|
data,
|
|
timeout: 60000,
|
|
headers: { repeatSubmit: false }
|
|
});
|
|
}
|
|
|
|
export function listUploadItems(batchId: string): Promise<ApiResult<UploadItem[]>> {
|
|
return request({
|
|
url: '/api/knowledge/doc/upload-items',
|
|
method: 'get',
|
|
params: { batchId },
|
|
headers: { repeatSubmit: false }
|
|
});
|
|
}
|
|
|
|
export function retryUploadItem(id: number): Promise<ApiResult<UploadItem>> {
|
|
return request({
|
|
url: `/api/knowledge/doc/upload-items/${id}/retry`,
|
|
method: 'post',
|
|
headers: { repeatSubmit: false }
|
|
});
|
|
}
|