修复:普通对话沿用模型原文并保留业务前态
This commit is contained in:
@@ -99,4 +99,40 @@ class ConversationTests(unittest.TestCase):
|
||||
for sanitizer in (public_progress_text,public_thinking_text):
|
||||
output=sanitizer(text);self.assertNotIn('quality-turn:',output);self.assertIn('继续答复',output)
|
||||
|
||||
|
||||
class AutonomousConversationReviewTests(unittest.TestCase):
|
||||
def test_capability_descriptions_do_not_claim_to_have_run_a_query(self):
|
||||
value=direct();value['directResponse']['answer']='我可以帮你比较不同产业部谁表现更好,并整理已核实的历史结果。'
|
||||
self.assertEqual(normalize_task(value,'你能做什么')['directResponse']['answer'],value['directResponse']['answer'])
|
||||
def test_unsupported_bare_explain_is_repaired_before_protocol_confirmation(self):
|
||||
from test_nao_agent_task import task_value
|
||||
replies=[task_value(kind='explain',freshQuery=False,fields=[],stages=[],dimensions=[],dimensionStages={}),direct(),{'aligned':True,'requiresEvidence':False}]
|
||||
calls=[]
|
||||
def opener(request,timeout):
|
||||
calls.append(json.loads(request.data));reply=replies.pop(0)
|
||||
return io.BytesIO(json.dumps({'choices':[{'finish_reason':'stop','message':{'content':json.dumps(reply)}}]}).encode())
|
||||
task=plan_task(base_url='https://offline.invalid',api_key='synthetic',model='m',question='介绍一下能做哪些事',context={'_protocol':{'version':1,'autonomousEnabled':True}},cancel_event=threading.Event(),opener=opener)
|
||||
self.assertIn('directResponse',task);self.assertEqual(len(calls),3);self.assertEqual(task['planRecovery']['errors'][0]['field'],'kind.protocol')
|
||||
def test_autonomous_greeting_still_receives_independent_semantic_review(self):
|
||||
bodies=[]
|
||||
def opener(request,timeout):
|
||||
bodies.append(json.loads(request.data));reply=direct() if len(bodies)==1 else {'aligned':True,'requiresEvidence':False}
|
||||
return io.BytesIO(json.dumps({'choices':[{'finish_reason':'stop','message':{'content':json.dumps(reply)}}]}).encode())
|
||||
task=plan_task(base_url='https://offline.invalid',api_key='synthetic',model='m',question='你好',context={'_protocol':{'version':1,'autonomousEnabled':True}},cancel_event=threading.Event(),opener=opener)
|
||||
self.assertIn('directResponse',task);self.assertEqual(len(bodies),2);self.assertIn('plannedTask',json.loads(bodies[1]['messages'][1]['content']))
|
||||
def test_autonomous_business_answer_mislabelled_as_conversation_cannot_skip_evidence_review(self):
|
||||
calls=[]
|
||||
def opener(request,timeout):
|
||||
body=json.loads(request.data);calls.append(body)
|
||||
if 'plannedTask' in json.loads(body['messages'][1]['content']):reply={'aligned':True,'requiresEvidence':True}
|
||||
else:
|
||||
reply=direct();reply['directResponse']['answer']='这批比之前差,得调整设备。'
|
||||
return io.BytesIO(json.dumps({'choices':[{'finish_reason':'stop','message':{'content':json.dumps(reply)}}]}).encode())
|
||||
with self.assertRaises(TaskUnavailable):plan_task(base_url='https://offline.invalid',api_key='synthetic',model='m',question='解释这批次质量问题',context={'_protocol':{'version':1,'autonomousEnabled':True}},cancel_event=threading.Event(),opener=opener)
|
||||
self.assertTrue(any('plannedTask' in json.loads(body['messages'][1]['content']) for body in calls))
|
||||
def test_unqueried_chinese_values_and_plain_causal_assertions_are_rejected(self):
|
||||
for text in ['黑片合格率下降了,主要原因是设备故障。','上月报废重量为一百。']:
|
||||
value=direct();value['directResponse']['answer']=text
|
||||
with self.subTest(text=text),self.assertRaises(TaskUnavailable):normalize_task(value,'你好')
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user