精简订单展示并修复查单追问串入报价
This commit is contained in:
@@ -110,7 +110,7 @@ class OrderDataTests(unittest.TestCase):
|
||||
'parent_order_no':self.record['order_no'], 'data_note':'子单独立货物数据未提供'}])
|
||||
card = self.events('CHILD20260001-01')[0]['card']
|
||||
self.assertFalse(any(field['key']=='weight' for field in card['fields']))
|
||||
self.assertIn('未提供', card['notice'])
|
||||
self.assertEqual(next(field['value'] for field in card['fields'] if field['key']=='parent'), self.record['order_no'])
|
||||
|
||||
def test_followups_refresh_local_data_and_remain_within_conversation(self):
|
||||
cid = self.client.post('/api/new_chat').json['id']
|
||||
@@ -122,18 +122,38 @@ class OrderDataTests(unittest.TestCase):
|
||||
card = self.events('这票重量是多少?',cid)[0]['card']
|
||||
self.assertEqual(card['no'], self.record['order_no'])
|
||||
self.assertEqual(next(field['value'] for field in card['fields'] if field['key']=='weight'), '45.000 kg')
|
||||
self.assertIn('没有实际运费', self.events('这票运费多少钱?',cid)[0]['t'])
|
||||
self.assertIn('未记录实际运费', self.events('这票运费多少钱?',cid)[0]['t'])
|
||||
self.assertEqual(self.events('那状态呢?',cid)[0]['card']['no'], self.record['order_no'])
|
||||
self.events('查询 UNKNOWN20260001',cid)
|
||||
self.assertIn('未找到', self.events('这票重量呢?',cid)[0]['t'])
|
||||
other_cid = self.client.post('/api/new_chat').json['id']
|
||||
self.assertIsNone(order_data.answer_query('这票重量是多少?', other_cid))
|
||||
|
||||
def test_new_shipping_questions_do_not_reuse_previous_order(self):
|
||||
cid = self.client.post('/api/new_chat').json['id']
|
||||
self.events(self.record['order_no'], cid)
|
||||
for message in ('现在有30KG货物想发美国,运费多少?', '美国海运费用怎么算?', '报价30公斤到德国', '物流状态是什么意思?'):
|
||||
with self.subTest(message=message):
|
||||
self.assertIsNone(order_data.answer_query(message, cid))
|
||||
db.save_message(cid, 'user', '美国海运费用怎么算?')
|
||||
db.save_message(cid, 'assistant', '海运费用与重量及目的地有关。')
|
||||
self.assertIsNone(order_data.answer_query('那状态呢?', cid))
|
||||
|
||||
def test_short_order_followups_read_facts_without_calling_model(self):
|
||||
cid = self.client.post('/api/new_chat').json['id']
|
||||
self.events(self.record['order_no'], cid)
|
||||
with patch('logistics_chat.ai_client.post_completion') as model:
|
||||
for message in ('多少公斤?', '有几箱?', '体积呢?', '那状态呢?'):
|
||||
with self.subTest(message=message):
|
||||
self.assertEqual(self.events(message, cid)[0]['card']['no'], self.record['order_no'])
|
||||
model.assert_not_called()
|
||||
|
||||
def test_card_storage_and_model_context_contain_only_selected_facts(self):
|
||||
card = self.events(self.record['order_no'])[0]['card']
|
||||
text = card_to_text(CARD_PREFIX+json.dumps(card))
|
||||
self.assertIn('30.000', text)
|
||||
self.assertIn('US', text)
|
||||
self.assertNotIn('测试', text)
|
||||
self.assertNotIn('tenant_id', text)
|
||||
self.assertNotIn('customer_name', json.dumps(card))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user