feat: govern knowledge assets and source citations

This commit is contained in:
key
2026-08-02 01:43:43 +08:00
parent cafb836cda
commit 699cc08050
144 changed files with 17205 additions and 453 deletions
+31 -2
View File
@@ -6,7 +6,8 @@ import type {
UnifiedKnowledgeResponse,
KnowledgeSnippet,
PositionSopSummary,
SummaryCardResponse
SummaryCardResponse,
KnowledgeCitationDetail
} from '@/types/api';
import { apiRequest, apiUrl, authHeaders, readTextPayload } from './api';
import { getSelectedPosition } from './auth';
@@ -243,6 +244,29 @@ export const requestKnowledgeResourceDownloadLink = async (attachmentId: number)
return apiUrl(response.url);
};
export const loadKnowledgeCitationDetail = (detailRef: string) => {
const safeRef = String(detailRef || '').trim();
if (!/^[A-Za-z0-9_-]{43}$/.test(safeRef)) return Promise.reject(new Error('引用地址无效'));
return apiRequest<KnowledgeCitationDetail>({
url: `/api/knowledge/citations/${encodeURIComponent(safeRef)}`,
method: 'GET',
timeout: 15000,
clearAuthOnUnauthorized: false
});
};
export const loadKnowledgeCitationMediaUrl = async (detailRef: string) => {
const safeRef = String(detailRef || '').trim();
if (!/^[A-Za-z0-9_-]{43}$/.test(safeRef)) throw new Error('引用地址无效');
const response = await apiRequest<{ url: string }>({
url: `/api/knowledge/citations/${encodeURIComponent(safeRef)}/media-link`,
method: 'POST',
clearAuthOnUnauthorized: false
});
if (!response.url?.startsWith('/api/knowledge/resources/')) throw new Error('视频地址无效');
return apiUrl(response.url);
};
const normalizeUnifiedResponse = (response: UnifiedKnowledgeResponse): KnowledgeSearchResponse => {
const legacy = response.legacy || ({} as KnowledgeSearchResponse);
const citationSnippets = (response.citations || []).map((item) => normalizeSnippet({
@@ -255,7 +279,10 @@ const normalizeUnifiedResponse = (response: UnifiedKnowledgeResponse): Knowledge
domain: item.domain,
status: item.status,
occurredAt: item.occurredAt,
updatedAt: item.updatedAt
updatedAt: item.updatedAt,
mediaType: item.mediaType,
detailRef: item.detailRef,
locatorSummary: item.locatorSummary
}));
return {
...legacy,
@@ -292,6 +319,7 @@ export const getPositionSopSummary = (position = getSelectedPosition()) =>
export const submitAnswerFeedback = (params: {
queryText: string;
requestId?: string;
fragmentIds: number[];
verdict: AnswerFeedbackVerdict;
reviewId?: number | null;
@@ -303,6 +331,7 @@ export const submitAnswerFeedback = (params: {
method: 'POST',
data: {
queryText: params.queryText,
requestId: params.requestId || '',
fragmentIds: params.fragmentIds,
verdict: params.verdict,
category: 'sop',