feat: restore learning feedback and knowledge capabilities

This commit is contained in:
2026-07-18 00:50:11 +08:00
parent 876a23a123
commit 6bdc86e3fc
152 changed files with 30337 additions and 953 deletions
+66 -2
View File
@@ -16,6 +16,9 @@ export type SopDoc = {
export type SopSnippet = {
title: string;
text: string;
fragmentId?: number | null;
spaceCode?: string | null;
sourceType?: string;
};
export type SopRecord = {
@@ -29,6 +32,7 @@ export type SopRecord = {
};
export type SopSearchResponse = {
requestId?: string;
queryText: string;
category: string;
answer: string;
@@ -41,6 +45,31 @@ export type SopSearchResponse = {
cautions?: string[];
promptVersion?: string | null;
reviewId?: number;
citations?: SopCitation[];
usedSpaceCodes?: string[];
noEvidence?: boolean;
data?: unknown;
};
export type SopCitation = {
spaceCode?: string | null;
sourceType: string;
docId?: string | null;
title: string;
snippet: string;
fragmentId?: number | null;
};
type UnifiedQueryResponse = {
requestId: string;
queryText: string;
answer: string;
citations: SopCitation[];
usedSpaceCodes: string[];
noEvidence: boolean;
promptVersion?: string | null;
legacy?: SopSearchResponse | null;
data?: unknown;
};
export type SopReviewResponse = {
@@ -92,12 +121,46 @@ export function searchKnowledgeSop(data: {
position?: string;
source?: string;
limit: number;
spaceCodes?: string[];
toolCode?: 'MY_PRACTICE_SUMMARY' | 'TEAM_PRACTICE_SUMMARY';
}): Promise<ApiResult<SopSearchResponse>> {
return request({
url: '/api/knowledge/search',
return request<unknown, ApiResult<UnifiedQueryResponse>>({
url: '/api/knowledge/query',
method: 'post',
data,
headers: { repeatSubmit: false }
}).then((result) => {
const response = result.data;
const legacy = response.legacy || ({} as SopSearchResponse);
const snippets = legacy.snippets?.length
? legacy.snippets
: (response.citations || []).map((item) => ({
title: item.title,
text: item.snippet,
fragmentId: item.fragmentId,
spaceCode: item.spaceCode,
sourceType: item.sourceType
}));
return {
...result,
data: {
...legacy,
requestId: response.requestId,
queryText: response.queryText,
category: legacy.category || data.category || 'sop',
answer: response.answer,
reference: legacy.reference || response.citations.map((item) => item.title).join('、'),
docs: legacy.docs || [],
snippets,
training: legacy.training || [],
records: legacy.records || [],
citations: response.citations || [],
usedSpaceCodes: response.usedSpaceCodes || [],
noEvidence: response.noEvidence,
promptVersion: response.promptVersion,
data: response.data
}
};
});
}
@@ -149,6 +212,7 @@ export type UploadItem = {
batchId: string;
fileName: string;
category: string;
spaceCodes: string[];
status: number;
statusLabel: string;
error: string | null;