"""JEV Dashboard — zero-dependency web panel (Python stdlib only). python dashboard.py # -> http://localhost:8590 Paste your sk_jev-ai_... token in the browser (kept in process memory only), list models, run test decisions, bench latency, manage a key pool. AlStack: https://t.me/AlStack """ import json, time, threading from http.server import HTTPServer, BaseHTTPRequestHandler from urllib.parse import urlparse import urllib.request PORT = 8590 BASE = 'https://jev-ai.pro/api/v1' POOL = [] # keys added via dashboard (memory only) POOL_LOCK = threading.Lock() PAGE = """ JEV Decision Hub

JEV Decision Hub

decision-layer API: state + typed questions → calibrated answers in ~0.3s  |  free credits: jev-ai.pro magic-link login

1. Токен

2. Модели

3. Бенч

4. Тест решения

ответ появится здесь
👻 иишко — каталоги халявы, AI-тулзов и абюза
""" def jev_call(path, key, body=None): h = {'Content-Type': 'application/json', 'Authorization': 'Bea' + 'rer ' + key} req = urllib.request.Request(BASE + path, data=json.dumps(body).encode() if body is not None else None, headers=h, method='POST' if body is not None else 'GET') try: r = urllib.request.urlopen(req, timeout=60) return r.status, json.loads(r.read().decode()) except urllib.error.HTTPError as ex: return ex.code, {'error': ex.read().decode('utf-8', 'ignore')[:200]} except Exception as ex: return 0, {'error': str(ex)[:200]} def pick_key(token): if token: return [token] with POOL_LOCK: return list(POOL) class H(BaseHTTPRequestHandler): def log_message(self, *a): pass def _send(self, obj, code=200, html=False): b = obj.encode() if isinstance(obj, str) else json.dumps(obj).encode() self.send_response(code) self.send_header('Content-Type', 'text/html; charset=utf-8' if html else 'application/json') self.send_header('Content-Length', str(len(b))) self.end_headers() self.wfile.write(b) def _body(self): n = int(self.headers.get('Content-Length', 0)) return json.loads(self.rfile.read(n) or b'{}') def do_GET(self): p = urlparse(self.path).path if p == '/': self._send(PAGE, html=True) elif p == '/pool_info': with POOL_LOCK: n = len(POOL) self._send({'info': f'ключей в пуле: {n}' + (f' ({", ".join(k[:12] + "..." for k in POOL)})' if n else ' — добавь токен выше')}) else: self._send({'error': 'not found'}, 404) def do_POST(self): p = urlparse(self.path).path b = self._body() tok = (b.get('token') or '').strip() if p == '/test': keys = pick_key(tok) if not keys: return self._send({'ok': False, 'error': 'нет токена'}) s, d = jev_call('/models/', keys[0]) return self._send({'ok': s == 200, 'models': len(d.get('models', [])) if s == 200 else 0, 'error': '' if s == 200 else f'{s}: {d}'}) if p == '/pool_add': if not tok.startswith('sk_'): return self._send({'ok': False, 'info': 'ключ должен начинаться с sk_'}) with POOL_LOCK: if tok not in POOL: POOL.append(tok) info = f'ключей в пуле: {len(POOL)}' return self._send({'ok': True, 'info': info}) if p == '/models': keys = pick_key(tok) if not keys: return self._send({'ok': False, 'error': 'нет токена'}) s, d = jev_call('/models/', keys[0]) return self._send({'ok': s == 200, 'models': d.get('models', []), 'error': '' if s == 200 else f'{s}'}) if p == '/bench': keys = pick_key(tok) if not keys: return self._send({'ok': False, 'error': 'нет токена'}) body = {'model': 'jev-latest', 'state': 'bench ping', 'questions': {'ok': {'type': 'noul', 'instructions': 'Is this a bench call?'}}} ts, i = [], 0 for _ in range(5): key = keys[i % len(keys)] i += 1 t0 = time.time() s, d = jev_call('/systemone', key, body) if s == 200: ts.append(time.time() - t0) if not ts: return self._send({'ok': False, 'error': f'все вызовы упали: {s} {d}'}) return self._send({'ok': True, 'avg': f'{sum(ts)/len(ts):.2f}', 'min': f'{min(ts):.2f}', 'max': f'{max(ts):.2f}', 'pool': len(keys)}) if p == '/decide': keys = pick_key(tok) if not keys: return self._send({'ok': False, 'error': 'нет токена'}) body = {'model': b.get('model', 'jev-latest'), 'state': b.get('state', ''), 'questions': b.get('questions', {})} last = None for key in keys: s, d = jev_call('/systemone', key, body) if s == 200: d['_key'] = key[:12] + '...' return self._send(d) last = f'{s}: {d}' if s not in (401, 402, 403): break return self._send({'ok': False, 'error': last or 'нет ключей'}) self._send({'error': 'not found'}, 404) if __name__ == '__main__': print(f'JEV Dashboard -> http://localhost:{PORT} (AlStack: https://t.me/AlStack)') HTTPServer(('127.0.0.1', PORT), H).serve_forever()