[STAGE5] Model Registry v0 + health
This commit is contained in:
1 parent
ae5ab904fd
commit
457f95d3b1
3 files changed
+100
-1
No files matched your search
@@ -0,0 +1,21 @@
|
||||
version: 1
|
||||
source: "stage5 model registry v0"
|
||||
models:
|
||||
- id: deepseek-chat
|
||||
provider: deepseek
|
||||
role: primary-reasoning
|
||||
endpoint: "https://api.deepseek.com"
|
||||
health: external
|
||||
note: "ключ только на сервере"
|
||||
- id: qwen2.5:3b
|
||||
provider: ollama-pc
|
||||
role: local-fast
|
||||
endpoint: "http://192.168.1.194:11434"
|
||||
health: ollama
|
||||
note: "ПК, модель может быть выгружена"
|
||||
- id: qwen2.5:3b
|
||||
provider: ollama-host
|
||||
role: local-fallback
|
||||
endpoint: "http://192.168.1.10:11434"
|
||||
health: ollama
|
||||
note: "host fallback"
|
||||
@@ -0,0 +1,35 @@
|
||||
# Stage 5 — AI Factory & Agents
|
||||
|
||||
Статус: начат 2026-11-27.
|
||||
Gate G5: агент не имеет production-доступа вне Tool Gateway.
|
||||
|
||||
## Сделано
|
||||
|
||||
Model Registry v0:
|
||||
|
||||
```text
|
||||
http://192.168.1.10:9161/alpha/models
|
||||
GET /v1/models
|
||||
```
|
||||
|
||||
- реестр моделей/провайдеров;
|
||||
- external/Ollama health;
|
||||
- PC-Ollama offline показывается как down;
|
||||
- без выдачи агентам production-доступа.
|
||||
|
||||
## Задачи
|
||||
|
||||
| Код | Задача | Статус |
|
||||
|---|---|---|
|
||||
| S5-01 | Model Registry v0 | done |
|
||||
| S5-02 | GPU leases | open |
|
||||
| S5-03 | Evals / golden set | open |
|
||||
| S5-04 | Memory | open |
|
||||
| S5-05 | Night Shift | open |
|
||||
| S5-06 | Tool Gateway / agent approvals | open |
|
||||
| S5-07 | Gate G5 | open |
|
||||
|
||||
## Ограничение
|
||||
|
||||
- GPU leases, evals, memory, Tool Gateway — ещё не реализованы.
|
||||
- Model Registry read-only, не выдаёт доступ к моделям.
|
||||
@@ -236,6 +236,7 @@ def acceptance_status():
|
||||
|
||||
|
||||
SERVICES_PATH = Path("/root/buryan-infra/docs/architecture/REGISTRY/services.yaml")
|
||||
MODELS_PATH = Path("/root/buryan-infra/docs/architecture/REGISTRY/models.yaml")
|
||||
|
||||
|
||||
def service_health(svc):
|
||||
@@ -279,6 +280,29 @@ def mission_services():
|
||||
"down": sum(1 for x in rows if x["up"] is False), "items": rows}
|
||||
|
||||
|
||||
def model_health(m):
|
||||
if m.get("health") == "external":
|
||||
return {"up": None, "loaded": None, "error": "external provider"}
|
||||
endpoint = (m.get("endpoint") or "").rstrip("/")
|
||||
try:
|
||||
with urllib.request.urlopen(endpoint + "/api/tags", timeout=3) as r:
|
||||
body = json.loads(r.read().decode("utf-8", "replace"))
|
||||
names = [x.get("name") for x in body.get("models") or []]
|
||||
return {"up": True, "loaded": m.get("id") in names, "models": names[:10]}
|
||||
except Exception as e:
|
||||
return {"up": False, "loaded": None, "error": str(e)[:120]}
|
||||
|
||||
|
||||
def model_registry():
|
||||
import yaml
|
||||
data = yaml.safe_load(MODELS_PATH.read_text())
|
||||
rows = []
|
||||
for m in data.get("models") or []:
|
||||
h = model_health(m)
|
||||
rows.append({**{k: m.get(k) for k in ("id", "provider", "role", "endpoint", "health", "note")}, **h})
|
||||
return {"ok": all(x.get("up") is not False for x in rows), "total": len(rows), "items": rows}
|
||||
|
||||
|
||||
def request_check(q):
|
||||
qn = (q or "").strip().lower()
|
||||
if not qn:
|
||||
@@ -587,6 +611,15 @@ class H(BaseHTTPRequestHandler):
|
||||
if u.path == "/mission":
|
||||
self.out(200, PAGE_MISSION, "text/html")
|
||||
return
|
||||
if u.path == "/v1/models":
|
||||
try:
|
||||
self.out(200, model_registry())
|
||||
except Exception as e:
|
||||
self.out(502, {"ok": False, "error": str(e)[:300]})
|
||||
return
|
||||
if u.path == "/models":
|
||||
self.out(200, PAGE_MODELS, "text/html")
|
||||
return
|
||||
if u.path == "/request":
|
||||
self.out(200, PAGE_REQUEST, "text/html")
|
||||
return
|
||||
@@ -731,6 +764,16 @@ async function go(){const q=document.getElementById('q').value.trim();if(!q)retu
|
||||
document.getElementById('q').addEventListener('keydown',e=>{if(e.key==='Enter')go()});
|
||||
</script></body></html>"""
|
||||
|
||||
PAGE_MODELS = """<!doctype html><html lang=ru><head><meta charset=utf-8>
|
||||
<meta name=viewport content="width=device-width,initial-scale=1"><title>Models — Buryans</title>
|
||||
<style>body{background:#0d1117;color:#e6edf3;font:15px/1.5 system-ui,Arial;margin:0;padding:28px}h1{margin:0 0 6px}.mut{color:#8b949e}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:12px;margin-top:18px}.card{background:#161b22;border:1px solid #30363d;border-radius:10px;padding:14px}.card h3{margin:0 0 4px;font-size:17px}.tag{color:#8b949e;font-size:13px}.ok{color:#3fb950}.bad{color:#f85149}.unk{color:#d29922}a{color:#58a6ff}</style></head><body>
|
||||
<h1>Model Registry</h1><div class=mut>Read-only реестр моделей и health. Агенты не получают production-доступ через эту страницу. · <a href="/alpha/mission">Mission Control →</a></div>
|
||||
<div class=mut id=summary style="margin-top:10px">загрузка…</div><div class=grid id=rows></div>
|
||||
<script>
|
||||
const e=s=>String(s??'').replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c]));
|
||||
fetch('v1/models').then(r=>r.json()).then(d=>{document.getElementById('summary').textContent=`моделей ${d.total} · ok ${d.ok}`;document.getElementById('rows').innerHTML=(d.items||[]).map(x=>{const st=x.up===true?'<span class=ok>● up</span>':x.up===false?'<span class=bad>● down</span>':'<span class=unk>● external</span>';return `<div class=card><h3>${e(x.id)}</h3><div class=tag>${e(x.provider)} · ${e(x.role)}</div><div style="margin-top:6px">${st} ${x.loaded===true?'· loaded':x.loaded===false?'· not loaded':''}</div><div class=tag>${e(x.health)} · ${e(x.endpoint)}</div>${x.error?`<div class=tag>${e(x.error)}</div>`:''}</div>`}).join('')}).catch(()=>document.getElementById('summary').textContent='не удалось получить реестр моделей');
|
||||
</script></body></html>"""
|
||||
|
||||
PAGE_MISSION = """<!doctype html><html lang=ru><head><meta charset=utf-8>
|
||||
<meta name=viewport content="width=device-width,initial-scale=1">
|
||||
<title>Mission Control — Buryans</title>
|
||||
@@ -743,7 +786,7 @@ h1{font-size:28px;margin:0 0 6px}.mut{color:#8b949e}
|
||||
.ok{color:#3fb950}.bad{color:#f85149}.unk{color:#d29922}
|
||||
a{color:#58a6ff}
|
||||
</style></head><body>
|
||||
<h1>Mission Control</h1><div class=mut>Read-only карта сервисов. Health, tier, owner, endpoints. Без изменения сервисов.</div>
|
||||
<h1>Mission Control</h1><div class=mut>Read-only карта сервисов. Health, tier, owner, endpoints. Без изменения сервисов. · <a href="/alpha/models">Models →</a></div>
|
||||
<div class=mut id=summary style="margin-top:10px">загрузка…</div>
|
||||
<div class=grid id=rows></div>
|
||||
<script>
|
||||
|
||||
Reference in new issue
Block a user