记录 4-48 实测失败与耗时复盘,修复前台输入及 Jev 配置

Browse Source
This commit is contained in:
Codex
2026-10-03 10:56:19 +08:00
parent 030527f5de
commit 2131f89e62
18 changed files with 859 additions and 38 deletions
+5 -29
View File
@@ -10,6 +10,7 @@ import urllib.request
from pathlib import Path from pathlib import Path
from mcp_session import Session as Bridge from mcp_session import Session as Bridge
from jev_client import request_decision
REPO_ROOT = Path(__file__).resolve().parents[1] REPO_ROOT = Path(__file__).resolve().parents[1]
MIRROR_ASSETS = REPO_ROOT / 'vendor' / 'aalc' / 'assets' / 'images' / 'default' / 'share' / 'mirror' MIRROR_ASSETS = REPO_ROOT / 'vendor' / 'aalc' / 'assets' / 'images' / 'default' / 'share' / 'mirror'
@@ -572,39 +573,14 @@ def candidates(state, previous_battle=False, refresh_used=0):
def decide(cfg, state, options, recent): def decide(cfg, state, options, recent):
body = {'model': 'jev-1.13-free', description = ('目标:按用户已配置的队伍和速通规则推进当前镜牢。当前楼层:%s\n当前游戏 OCR(坐标仅供辨识):\n' % state.get('floor', '尚未识别') +
'state': '目标:按用户已配置的队伍和速通规则推进当前镜牢。当前楼层:%s\n当前游戏 OCR(坐标仅供辨识):\n' % state.get('floor', '尚未识别') +
'\n'.join('%s @%d,%d' % (i['text'], i['x'], i['y']) for i in text_items(state) '\n'.join('%s @%d,%d' % (i['text'], i['x'], i['y']) for i in text_items(state)
if not i['text'].upper().startswith('STEAM')) + if not i['text'].upper().startswith('STEAM')) +
'\n截图视觉与可用控件观察(不是预先做出的决定):\n' + '\n截图视觉与可用控件观察(不是预先做出的决定):\n' +
'\n'.join(val['description'] for key,val in options.items() if key != 'requires_analysis') + '\n'.join(val['description'] for key,val in options.items() if key != 'requires_analysis') +
'\n最近动作和执行结果:' + json.dumps(recent[-4:], ensure_ascii=False), '\n最近动作和执行结果:' + json.dumps(recent[-4:], ensure_ascii=False))
'questions': {'action': {'type': 'choice', 'instructions': SYSTEM_RULES, return request_decision(cfg, description,
'criteria': {key: val['description'] for key, val in options.items()}}}} {key: val['description'] for key, val in options.items()}, SYSTEM_RULES)
request = urllib.request.Request(
'https://opencode.ai/zen/v1/systemone',
data=json.dumps(body, ensure_ascii=False).encode('utf-8'),
headers={'Authorization': 'Bearer ' + cfg['apiKey'], 'Content-Type': 'application/json',
'User-Agent': 'Mozilla/5.0'}, method='POST')
start = time.monotonic()
for attempt in range(2):
try:
with urllib.request.urlopen(request, timeout=7) as response:
result = json.load(response)
break
except urllib.error.HTTPError as error:
if error.code in (401,403,429) or attempt:
raise
time.sleep(.3)
except (OSError, TimeoutError):
if attempt:
raise
time.sleep(.3)
answer = result.get('answers', {}).get('action', {})
choice = answer.get('choice')
if answer.get('type') != 'choice' or choice not in options:
raise ValueError('Jev returned an unsupported candidate')
return choice, round((time.monotonic() - start) * 1000)
def fixed_fallback(options): def fixed_fallback(options):