Compare commits

..
Author SHA1 Message Date
architect dc802ae289 [PRISM] DeepSeek fallback on malformed JSON
lint / hygiene (pull_request) Failing after 1m9s
standard / check (pull_request) Successful in 12s
lint / hygiene (push) Failing after 33s
standard / check (push) Successful in 14s
2026-11-27 10:04:46 +03:00
+12 -7
View File
@@ -90,13 +90,13 @@ while True:
note_kind = "scenario" if kind == "model_scenario" else ("review" if kind == "model_review" else "positioning")
prompt = MODEL_PROMPT % (name, vendor, role or "unknown", domain or "unknown", specs[:800])
r = L.ask(prompt, max_tokens=250, temperature=0.2,
chain=[{"name": "qwen2.5:3b-32k", "kind": "ollama", "timeout": 300}])
chain=[{"name": "qwen2.5:3b", "kind": "ollama", "timeout": 300}])
text = r["text"].strip()[:2000]
cur.execute("""insert into prism.model_notes(model_id,kind,text,model)
values (%s,%s,%s,'qwen2.5:7b')""", (mid, note_kind, text))
cur.execute("""insert into prism.runs(model_id,kind,status,worker,model,stats,started_at,finished_at)
values (%s,'model_note7b','ok','229',%s,%s,now(),now())""",
(mid, "qwen2.5:3b-32k", json.dumps({"task_id": task_id, "chars": len(text)})))
(mid, "qwen2.5:3b", json.dumps({"task_id": task_id, "chars": len(text)})))
else:
cur.execute("select url,title from prism.sources where id=%s", (sid,))
s = cur.fetchone()
@@ -117,9 +117,14 @@ while True:
raise RuntimeError("empty text %s" % len(txt))
chunk = R.pick_excerpt(txt, 3500)
conn.commit()
r = L.ask(SUPPORT_PROMPT + chunk, max_tokens=3000, temperature=0.0,
chain=[{"name": "qwen2.5:3b-32k", "kind": "ollama", "timeout": 300}])
d = parse_loose(r["text"])
r = L.ask(SUPPORT_PROMPT + chunk, max_tokens=1200, temperature=0.0,
chain=[{"name": "qwen2.5:3b", "kind": "ollama", "timeout": 300}])
try:
d = parse_loose(r["text"])
except Exception:
r = L.ask(SUPPORT_PROMPT + chunk, max_tokens=1200, temperature=0.0,
chain=[{"name": "deepseek-flash", "kind": "deepseek", "timeout": 120}])
d = parse_loose(r["text"])
facts = d.get("facts") or []
for f in facts:
key = re.sub(r"[^a-zA-Z0-9_.-]+", "_", str(f.get("key") or "fact")).strip("_").lower()
@@ -136,7 +141,7 @@ while True:
(mid, sid, key, vtext, f.get("unit"), f.get("quote")))
cur.execute("""insert into prism.runs(model_id,kind,status,worker,model,stats,started_at,finished_at)
values (%s,'enrich_support7b','ok','229',%s,%s,now(),now())""",
(mid, "qwen2.5:3b-32k", json.dumps({"source_id": sid, "facts": len(facts)})))
(mid, "qwen2.5:3b", json.dumps({"source_id": sid, "facts": len(facts)})))
cur.execute("update prism.tasks set status='done', finished_at=now() where id=%s", (task_id,))
print("done", task_id, kind, flush=True)
except Exception as e:
@@ -144,7 +149,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,'worker7b','error','229',%s,%s,now(),now())""",
(mid, "qwen2.5:3b-32k", str(e)[:300]))
(mid, "qwen2.5:3b", str(e)[:300]))
print("error", task_id, kind, str(e)[:150], flush=True)
conn.commit()
time.sleep(1)