fix: 1.接入ai_suggestion.
2. 接入合同起草功能。
This commit is contained in:
@@ -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}</>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user