feat(frontend): integrate GraphRAG scored evaluation results
- Add getUnifiedEvaluationResults API function - Extend ReviewPointsListProps with flowType, scoredResults, scoredSummary - Add ScoredResultCard rendering for graphrag flow_type - Modify reviews.tsx loader to call unified API - Add scored evaluation component imports Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -94,6 +94,53 @@ interface StatsData {
|
||||
score: number;
|
||||
}
|
||||
|
||||
// GraphRAG Scored 评查结果类型
|
||||
interface FieldScore {
|
||||
field_path: string;
|
||||
evaluation_as: string;
|
||||
weight: number;
|
||||
scored: number;
|
||||
max_score: number;
|
||||
status: string; // 'filled' | 'placeholder'
|
||||
value: string;
|
||||
page?: string;
|
||||
ai_feedback?: string;
|
||||
}
|
||||
|
||||
interface ScoredEvaluationResult {
|
||||
evaluation_point_id: number;
|
||||
code: string;
|
||||
name: string;
|
||||
passed: boolean;
|
||||
machine_score: number;
|
||||
score: number;
|
||||
percentage: number;
|
||||
total_score: number;
|
||||
total_weight: number;
|
||||
pass_threshold: number;
|
||||
result_type: 'scored';
|
||||
field_results: FieldScore[];
|
||||
missing_fields?: string[];
|
||||
ai_suggestion?: string;
|
||||
}
|
||||
|
||||
interface EvaluationSummary {
|
||||
total_points: number;
|
||||
passed_count: number;
|
||||
failed_count: number;
|
||||
total_score: number;
|
||||
total_full_score: number;
|
||||
average_percentage: number;
|
||||
}
|
||||
|
||||
interface UnifiedEvaluationResponse {
|
||||
document_id: number;
|
||||
flow_type: 'graphrag' | 'legacy';
|
||||
results: ScoredEvaluationResult[];
|
||||
summary: EvaluationSummary;
|
||||
evaluated_at: string;
|
||||
}
|
||||
|
||||
// 在文件顶部添加的类型定义,在interface区块前添加
|
||||
interface OcrDataResult {
|
||||
pages?: number[];
|
||||
@@ -1126,3 +1173,49 @@ export async function getReviewPoints_fromApi(fileId: string, request: Request)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取统一评查结果(GraphRAG Scored 模式)
|
||||
*
|
||||
* @param fileId 文档ID
|
||||
* @param request Remix请求对象
|
||||
* @returns 统一评查结果
|
||||
*/
|
||||
export async function getUnifiedEvaluationResults(fileId: string, request: Request) {
|
||||
try {
|
||||
const { userInfo, frontendJWT } = await getUserSession(request);
|
||||
if (!userInfo?.user_id) {
|
||||
return { error: '用户身份验证失败', status: 401 };
|
||||
}
|
||||
|
||||
const response = await apiRequest<UnifiedEvaluationResponse>(
|
||||
`/api/v2/evaluation/results-unified/${fileId}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${frontendJWT}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (response.error) {
|
||||
console.error('❌ [getUnifiedEvaluationResults] API调用失败:', response.error);
|
||||
return { error: response.error, status: response.status || 500 };
|
||||
}
|
||||
|
||||
if (response.data) {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
console.error('❌ [getUnifiedEvaluationResults] API响应数据为空');
|
||||
return { error: 'API响应数据为空', status: 500 };
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ [getUnifiedEvaluationResults] 调用失败:', error);
|
||||
return {
|
||||
error: error instanceof Error ? error.message : '获取评查结果失败',
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user