feat: govern knowledge assets and source citations
This commit is contained in:
@@ -89,7 +89,10 @@ export const normalizeAgentResponse = (
|
||||
domain: citation.domain,
|
||||
status: citation.status,
|
||||
occurredAt: citation.occurredAt,
|
||||
updatedAt: citation.updatedAt
|
||||
updatedAt: citation.updatedAt,
|
||||
mediaType: citation.mediaType,
|
||||
detailRef: citation.detailRef,
|
||||
locatorSummary: citation.locatorSummary
|
||||
}));
|
||||
return {
|
||||
requestId: response.runId,
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user