Add execution-model decision handoff and Jev AALC research
This commit is contained in:
@@ -93,10 +93,26 @@ class SceneRegressionTest(unittest.TestCase):
|
|||||||
error=agent.urllib.error.HTTPError('https://example.test',429,'rate limit',{},None)
|
error=agent.urllib.error.HTTPError('https://example.test',429,'rate limit',{},None)
|
||||||
with mock.patch.object(agent.urllib.request,'urlopen',side_effect=error) as request, mock.patch.object(agent.time,'sleep') as sleep:
|
with mock.patch.object(agent.urllib.request,'urlopen',side_effect=error) as request, mock.patch.object(agent.time,'sleep') as sleep:
|
||||||
with self.assertRaises(agent.urllib.error.HTTPError):
|
with self.assertRaises(agent.urllib.error.HTTPError):
|
||||||
agent.decide({'apiKey':'test'}, {'items':[]},{'wait':{'description':'wait'}},[])
|
agent.decide({'apiKey':'test','model':'jev-test'}, {'items':[]},{'wait':{'description':'wait'}},[])
|
||||||
self.assertEqual(request.call_count,1)
|
self.assertEqual(request.call_count,1)
|
||||||
sleep.assert_not_called()
|
sleep.assert_not_called()
|
||||||
|
|
||||||
|
def test_jev_uses_configured_model_and_returns_probabilities_without_images(self):
|
||||||
|
response = mock.MagicMock()
|
||||||
|
response.__enter__.return_value = response
|
||||||
|
response.read.return_value = b'{"model":"jev-test","answers":{"action":{"type":"choice","choice":"wait","confidence":0.5,"probabilities":{"wait":0.75,"inspect":0.25}}}}'
|
||||||
|
state = {'screen': {'path': 'LOCAL_SCREENSHOT_ONLY.png'},
|
||||||
|
'items': [{'text': 'EVENT', 'x': 10, 'y': 20}]}
|
||||||
|
options = {'wait': {'description': 'wait'}, 'inspect': {'description': 'inspect'}}
|
||||||
|
with mock.patch.object(agent.urllib.request, 'urlopen', return_value=response) as request:
|
||||||
|
result = agent.decide({'apiKey': 'test', 'model': 'jev-test'}, state, options, [])
|
||||||
|
payload = agent.json.loads(request.call_args.args[0].data.decode('utf-8'))
|
||||||
|
self.assertEqual(payload['model'], 'jev-test')
|
||||||
|
self.assertIsInstance(payload['state'], str)
|
||||||
|
self.assertNotIn('LOCAL_SCREENSHOT_ONLY', payload['state'])
|
||||||
|
self.assertEqual(result['confidence'], .5)
|
||||||
|
self.assertEqual(result['probabilities'], {'wait': .75, 'inspect': .25})
|
||||||
|
|
||||||
def test_single_extra_gift_decline_preserves_core_and_multi_cards(self):
|
def test_single_extra_gift_decline_preserves_core_and_multi_cards(self):
|
||||||
state = {'items': [{'text':t,'x':100,'y':100,'w':100,'h':40} for t in
|
state = {'items': [{'text':t,'x':100,'y':100,'w':100,'h':40} for t in
|
||||||
('获得E.G.O饰品','石版字符','拒绝饰品','选择')]}
|
('获得E.G.O饰品','石版字符','拒绝饰品','选择')]}
|
||||||
|
|||||||
Reference in New Issue
Block a user