[PRISM] Use qwen2.5:3b for note audit, finalize 44 draft cards
lint / hygiene (push) Failing after 23s
standard / check (push) Successful in 12s
lint / hygiene (pull_request) Failing after 21s
standard / check (pull_request) Successful in 10s

This commit is contained in:
architect committed 2026-11-29 22:39:50 +03:00
1 parent 9efcbfb490
commit 52787de1da
5 files changed
+129 -18

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
-- Prism: rebuild draft final cards from audited models.
-- Only quality_status=product, specs>=5, notes>=3, latest note_audit.ok=true.
-- State is draft_ready: nothing is auto-published.
begin;
insert into prism.final_cards(model_id,state,card,prepared_at)
select m.id,'draft_ready',
jsonb_build_object(
'name',m.name,'vendor',m.vendor,'role',m.role,'domain',m.domain,
'specs',coalesce((select jsonb_agg(jsonb_build_object('key',sp.key,'value',sp.value_text,'unit',sp.unit) order by sp.key)
from prism.specs sp where sp.model_id=m.id),'[]'::jsonb),
'notes',coalesce((select jsonb_agg(jsonb_build_object('kind',n.kind,'text',n.text) order by n.kind)
from prism.model_notes n where n.model_id=m.id),'[]'::jsonb),
'audit',coalesce((select jsonb_build_object('ok',a.ok,'issues',a.issues) from prism.note_audits a
where a.model_id=m.id order by a.id desc limit 1),'{"ok":false,"issues":[]}'::jsonb)
),now()
from prism.models m
where m.quality_status='product'
and (select count(*) from prism.specs sp where sp.model_id=m.id)>=5
and (select count(*) from prism.model_notes n where n.model_id=m.id)>=3
and (select a.ok from prism.note_audits a where a.model_id=m.id order by a.id desc limit 1) is true
and not exists (select 1 from prism.final_cards f where f.model_id=m.id);
commit;
+5 -4
View File
@@ -49,17 +49,18 @@ while True:
{specs[:1500]}
"""
r = L.ask(prompt, max_tokens=350, temperature=0.0,
chain=[{"name": "qwen2.5:7b", "kind": "ollama", "timeout": 300}])
chain=[{"name": "qwen2.5:3b", "kind": "ollama", "timeout": 300},
{"name": "deepseek-flash", "kind": "deepseek", "timeout": 120}])
mm = re.search(r"\{.*\}", r["text"], re.S)
d = json.loads(mm.group(0)) if mm else {}
good = bool(d.get("ok"))
issues = d.get("issues") or []
cur.execute("""insert into prism.note_audits(model_id,ok,issues,model)
values (%s,%s,%s::jsonb,'qwen2.5:7b')""",
values (%s,%s,%s::jsonb,'qwen2.5:3b')""",
(mid, good, json.dumps(issues, ensure_ascii=False)))
cur.execute("""insert into prism.runs(model_id,kind,status,worker,model,stats,started_at,finished_at)
values (%s,'note_audit7b','ok','229',%s,%s,now(),now())""",
(mid, "qwen2.5:7b", json.dumps({"issues": len(issues), "ok": good})))
(mid, "qwen2.5:3b", json.dumps({"issues": len(issues), "ok": good})))
cur.execute("update prism.tasks set status='done', finished_at=now() where id=%s", (task_id,))
print("done", task_id, "ok", good, "issues", len(issues), flush=True)
except Exception as e:
@@ -67,7 +68,7 @@ while True:
(str(e)[:300], task_id))
cur.execute("""insert into prism.runs(model_id,kind,status,worker,model,error,started_at,finished_at)
values (%s,'note_audit7b','error','229',%s,%s,now(),now())""",
(mid, "qwen2.5:7b", str(e)[:300]))
(mid, "qwen2.5:3b", str(e)[:300]))
print("error", task_id, str(e)[:150], flush=True)
conn.commit()
time.sleep(1)