Every /api/xmpp/health fetch ran a real LLM call (22k token system prompt each). Dashboard refreshes every 10s -> thousands of paid LLM calls/day, plus 38s latency hanging the health tab on '加载中...'. LLM health is now derived from the gateway's own agent.log (zero cost, more accurate than synthetic ping — real traffic results): - last 'API call #N latency=Xs' -> ok - last 'API call failed ... HTTP 429...' -> error with summary - health() runtime 38s -> 0.1s; endpoint 38s -> 0.097s
20 lines
597 B
Python
20 lines
597 B
Python
import ast, sys
|
|
for p in ['/home/hmo/MoFin/xmpp_logger.py']:
|
|
try:
|
|
ast.parse(open(p).read())
|
|
print('SYNTAX OK:', p)
|
|
except SyntaxError as e:
|
|
print('SYNTAX ERROR:', p, e)
|
|
sys.exit(1)
|
|
sys.path.insert(0, '/home/hmo/MoFin')
|
|
import xmpp_logger as x
|
|
import time, json
|
|
print('== _scan_agent_log ==')
|
|
print(json.dumps(x._scan_agent_log(time.time()), ensure_ascii=False))
|
|
print('== health (no LLM ping) ==')
|
|
import time as t
|
|
t0 = t.time()
|
|
h = x.health()
|
|
print(f'took {t.time()-t0:.1f}s')
|
|
print('llm_provider:', h.get('llm_provider'))
|
|
print('status:', h.get('status')) |