This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
================================================================================
|
||||
|
||||
【已完成】
|
||||
- V10.216 修正 `/observability/ppt_audit_history` 的 AiderHeal 派工斷點:失敗簡報即使只有 `issues_found` 診斷摘要也能一鍵送修,並修正 `execute_code_fix` 參數與 dict 回傳解析,避免按鈕 400/500。
|
||||
- V10.215 強化 `/observability/ppt_audit_history` 視覺問題追蹤:將 `issues_found` 拆成投影片、問題類型、問題文字與回放入口,新增「視覺問題追蹤」面板,讓問題簡報能直接定位與預覽。
|
||||
- V10.213 補 `/observability/ppt_audit_history` 視覺 QA 診斷摘要:審核歷史與 Action Queue 直接顯示 `ppt_audit_results.issues_found` 的投影片問題,讓「有問題」可追查,不再只剩問題數或空白錯誤欄。
|
||||
- V10.212 修正 PPT 視覺 QA 的 Ollama 三主機 fallback:當 Primary/Secondary request timeout 超過 unhealthy TTL 時,第三輪仍強制打 111 final fallback;PPT 截圖送模型前轉輕量 JPEG、縮小輸出 token,降低單檔審核耗時。
|
||||
|
||||
@@ -320,7 +320,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '')
|
||||
# ==========================================
|
||||
# 系統版本與路徑
|
||||
# ==========================================
|
||||
SYSTEM_VERSION = "V10.215"
|
||||
SYSTEM_VERSION = "V10.216"
|
||||
LOG_FILE_PATH = os.path.join(BASE_DIR, 'logs/system.log')
|
||||
public_url = PUBLIC_URL # 用於模板顯示
|
||||
|
||||
|
||||
@@ -1812,25 +1812,39 @@ def ppt_audit_trigger_aider_heal():
|
||||
"""
|
||||
try:
|
||||
from services.aider_heal_executor import execute_code_fix
|
||||
data = request.json or {}
|
||||
data = request.get_json(silent=True) or {}
|
||||
error_msg = (data.get('error_msg') or '').strip()
|
||||
issue_summary = (data.get('issue_summary') or '').strip()
|
||||
pptx_filename = (data.get('pptx_filename') or '').strip()
|
||||
if not error_msg:
|
||||
return jsonify({'ok': False, 'error': '需提供 error_msg'}), 400
|
||||
diagnosis = error_msg or issue_summary
|
||||
if not diagnosis:
|
||||
return jsonify({'ok': False, 'error': '需提供 error_msg 或 issue_summary'}), 400
|
||||
|
||||
error_message = diagnosis[:500]
|
||||
if pptx_filename:
|
||||
error_message = f"PPT 視覺審核失敗:{pptx_filename}\n診斷:{error_message}"
|
||||
|
||||
# 構造 context 給 AiderHeal
|
||||
context = {
|
||||
'error_type': 'ppt_vision_audit_failure',
|
||||
'error_message': error_msg[:500],
|
||||
'error_message': error_message[:500],
|
||||
'target_file': 'services/ppt_generator.py',
|
||||
'pptx_filename': pptx_filename,
|
||||
'triggered_by': 'admin_observability',
|
||||
'issue_summary': issue_summary[:500],
|
||||
}
|
||||
result = execute_code_fix(context)
|
||||
result = execute_code_fix(
|
||||
error_type='ppt_vision_audit_failure',
|
||||
error_message=error_message,
|
||||
target_file='services/ppt_generator.py',
|
||||
context=context,
|
||||
)
|
||||
return jsonify({
|
||||
'ok': bool(getattr(result, 'success', False)),
|
||||
'action': getattr(result, 'action', None),
|
||||
'message': getattr(result, 'message', '') or '已派出 AiderHeal',
|
||||
'ok': bool(result.get('success')),
|
||||
'action': result.get('action'),
|
||||
'message': result.get('message') or '已派出 AiderHeal',
|
||||
'commit_sha': result.get('commit_sha'),
|
||||
'reverted': bool(result.get('reverted')),
|
||||
})
|
||||
except Exception as e:
|
||||
return jsonify({'ok': False, 'error': f'{type(e).__name__}: {str(e)[:200]}'}), 500
|
||||
|
||||
@@ -454,7 +454,7 @@
|
||||
type="button"
|
||||
data-ppt-aider-heal
|
||||
data-ppt-filename="{{ r.pptx_filename }}"
|
||||
data-ppt-error="{{ r.error_msg or '' }}">
|
||||
data-ppt-error="{{ r.issue_summary or r.error_msg or '' }}">
|
||||
<i class="fas fa-wrench me-1"></i>AiderHeal
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
@@ -518,6 +518,42 @@ def test_ppt_audit_run_vision_queues_background_audit(client, monkeypatch):
|
||||
assert captured['max_files'] == 1
|
||||
|
||||
|
||||
def test_ppt_audit_trigger_aider_heal_accepts_issue_summary(client, monkeypatch):
|
||||
"""視覺 QA failed 常只有 issues_found;AiderHeal 應可吃診斷摘要派工。"""
|
||||
from services import aider_heal_executor as svc
|
||||
|
||||
captured = {}
|
||||
|
||||
def fake_execute_code_fix(**kwargs):
|
||||
captured.update(kwargs)
|
||||
return {
|
||||
'success': True,
|
||||
'action': 'CODE_FIX',
|
||||
'message': '已派出 AiderHeal',
|
||||
'commit_sha': None,
|
||||
'reverted': False,
|
||||
}
|
||||
|
||||
monkeypatch.setattr(svc, 'execute_code_fix', fake_execute_code_fix)
|
||||
|
||||
r = client.post(
|
||||
'/observability/ppt_audit/trigger_aider_heal',
|
||||
json={
|
||||
'pptx_filename': 'ocbot_daily_20260517.pptx',
|
||||
'issue_summary': 'S1: 圖表被切掉:右側圖例超出邊界',
|
||||
},
|
||||
)
|
||||
data = r.get_json()
|
||||
|
||||
assert r.status_code == 200
|
||||
assert data['ok'] is True
|
||||
assert captured['error_type'] == 'ppt_vision_audit_failure'
|
||||
assert captured['target_file'] == 'services/ppt_generator.py'
|
||||
assert 'ocbot_daily_20260517.pptx' in captured['error_message']
|
||||
assert '圖表被切掉' in captured['error_message']
|
||||
assert captured['context']['issue_summary'] == 'S1: 圖表被切掉:右側圖例超出邊界'
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────────
|
||||
# /observability/host_health
|
||||
# ──────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user