修复:纠正证据不足误判并同步产品下钻顶部指标
This commit is contained in:
@@ -251,7 +251,8 @@ def synthesize(*, base_url: str, api_key: str, model: str, question: str,
|
||||
'VCM亮片只录合计是既有业务口径,不视为零缺陷、漏导入或系统故障;其他小额差额不作为关注重点。'
|
||||
'用户问普通统计变化时,已有指标、分组、规格和缺陷事实通常足以回答,不要求现场生产原因或全部原始行。'
|
||||
'只返回JSON:groupFactIds、productFactIds、defectFactIds、otherFactIds分别为对应候选中的id数组。每类候选非空时至少选1项、最多2项,空候选返回空数组;总共最多6项,禁止编造。evidenceSufficient为布尔值,'
|
||||
'missingEvidence为仅与用户明确问题相关的缺失证据字符串数组。证据确实不足时填写缺项并设false。')
|
||||
'missingEvidence为仅与用户明确问题相关的缺失证据字符串数组。证据确实不足时填写具体缺项并设false;'
|
||||
'没有具体缺项时必须返回空数组并设true,不能仅因返回Top排名、未查询全部原始行或未查现场原因而设false。')
|
||||
body={'model':model,'stream':False,'max_completion_tokens':4096,
|
||||
'thinking':{'type':'disabled'},'response_format':{'type':'json_object'},
|
||||
'messages':[{'role':'system','content':system},{'role':'user','content':selector_text}]}
|
||||
@@ -283,8 +284,12 @@ def synthesize(*, base_url: str, api_key: str, model: str, question: str,
|
||||
sufficient=parsed.get('evidenceSufficient');missing=parsed.get('missingEvidence')
|
||||
if (not isinstance(sufficient,bool) or not isinstance(missing,list)
|
||||
or any(not isinstance(x,str) for x in missing)):raise ValueError('invalid evidence completion')
|
||||
missing=list(dict.fromkeys(item.strip() for item in missing if item.strip()))[:10]
|
||||
# 模型的孤立 false 不能证明数据缺失;具体缺项仍阻止完成,调用方另行检查服务端覆盖。
|
||||
completion_adjusted = not sufficient and not missing
|
||||
text=render_report(report,selected,missing[:10])
|
||||
return {'answer':text,'evidenceSufficient':sufficient and not missing,'missingEvidence':missing[:10],
|
||||
return {'answer':text,'evidenceSufficient':not missing,'missingEvidence':missing,
|
||||
'modelDeclaredEvidenceSufficient':sufficient,'completionAdjusted':completion_adjusted,
|
||||
'model':document.get('model',model),'usage':document.get('usage') if isinstance(document.get('usage'),dict) else {},
|
||||
'finishReason':'stop','selectedFactIds':selected,'factCount':len(report['facts']),
|
||||
'selectionAdjusted':selection_adjusted}
|
||||
|
||||
Reference in New Issue
Block a user