fix: 1.接入ai_suggestion.

2. 接入合同起草功能。
This commit is contained in:
2025-12-05 00:04:45 +08:00
parent eca98fc540
commit 33f10896a0
29 changed files with 3184 additions and 981 deletions
+2 -2
View File
@@ -71,13 +71,13 @@ export function FileInfo({ fileInfo, onConfirmResults }: FileInfoProps) {
{/* 操作按钮区域 */}
<div className="flex items-center gap-3">
{/* 下载文件按钮 */}
{/* 下载文件按钮 */}
<button
onClick={handleDownloadFile}
className="inline-flex items-center px-3 py-1.5 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
<i className="fas fa-download mr-1.5"></i>
</button>
{/* 导出评查报告按钮 */}
@@ -527,7 +527,7 @@ export function FilePreview({ fileContent, activeReviewPointResultId, targetPage
<span className="ml-2 text-xs text-gray-500 hidden sm:hidden md:hidden lg:hidden xl:inline whitespace-nowrap flex-shrink-0">
{zoomLevel}%
</span>
<button
{/* <button
className={`ant-btn ant-btn-sm ant-btn-default py-0 px-1 text-xs max-h-6 leading-5 ml-2 flex-shrink-0 ${dragMode ? 'active bg-green-300' : ''}`}
title="切换拖拽模式"
aria-pressed={dragMode}
@@ -537,7 +537,7 @@ export function FilePreview({ fileContent, activeReviewPointResultId, targetPage
<span className="ml-1 hidden sm:hidden md:hidden lg:hidden xl:inline truncate max-w-[80px]">
拖拽模式{dragMode ? '(已激活)' : ''}
</span>
</button>
</button> */}
</div>
</div>
<div
@@ -1809,6 +1809,26 @@ export function ReviewPointsList({
value: string;
char_positions?: CharPosition[];
}>;
ai_suggestion?: {
summary?: string;
analysis?: {
failure_reason?: string;
solution_approach?: string;
rule_understanding?: string;
};
suggestions?: Record<string, {
reason: string;
source: {
page: number | null;
type: string;
field: string | null;
};
priority: string;
confidence: number;
suggested_value: string | null;
}>;
generated_at?: string;
};
message?: string;
res?: boolean;
} | undefined;
@@ -1934,10 +1954,10 @@ export function ReviewPointsList({
// 渲染AI模型返回的评估消息
if (config.message) {
// 检查message是否为对象,如果是则转换为字符串
const messageContent = typeof config.message === 'object'
? JSON.stringify(config.message)
const messageContent = typeof config.message === 'object'
? JSON.stringify(config.message)
: String(config.message);
// 添加模型评估消息区域,使用蓝色背景突出显示
fieldElements.push(
<div key="message" className="p-2 bg-blue-50 rounded border border-blue-200 text-xs mb-3 select-text">
@@ -1949,6 +1969,57 @@ export function ReviewPointsList({
);
}
// 渲染AI建议(ai_suggestion
if (config.ai_suggestion?.suggestions && Object.keys(config.ai_suggestion.suggestions).length > 0) {
// 遍历suggestions对象的key-value对
Object.entries(config.ai_suggestion.suggestions).forEach(([key, suggestionValue], index) => {
// 检查建议值是否存在(null 或有值都要渲染)
const hasSuggestedValue = suggestionValue.suggested_value !== null && suggestionValue.suggested_value.trim() !== '';
fieldElements.push(
<div key={`ai-suggestion-${index}`} className="mb-3">
{/* 字段名称标签 */}
<div className="text-xs text-gray-600 mb-2 font-medium">
<i className="ri-lightbulb-line text-yellow-500 mr-1"></i>
AI建议修改 - {key}
</div>
{/* 原因说明 */}
<div className="mb-2 p-2 bg-amber-50 rounded border border-amber-200 text-xs text-gray-700">
<div className="flex items-start">
<i className="ri-information-line text-amber-600 mr-1 mt-0.5"></i>
<div>
<span>{suggestionValue.reason}</span>
{suggestionValue.source.page !== null && (
<span className="ml-2 text-gray-500">
(: {suggestionValue.source.page})
</span>
)}
</div>
</div>
</div>
{/* 建议内容显示 */}
<div className="flex gap-2 items-center">
{/* 文本输入框 */}
<textarea
value={suggestionValue.suggested_value || ''}
readOnly
disabled={!hasSuggestedValue}
className={`flex-1 p-2 border rounded text-xs resize-none overflow-y-auto ${
hasSuggestedValue
? 'border-gray-200 bg-gray-50 text-gray-700 cursor-not-allowed'
: 'border-gray-200 bg-gray-100 text-gray-400 cursor-not-allowed'
}`}
aria-label={`${key}的AI建议内容`}
placeholder={!hasSuggestedValue ? '暂无建议值' : ''}
/>
</div>
</div>
);
});
}
// 返回包含所有元素的React片段
return <>{fieldElements}</>;
};