GUI: upload, live progress + ETA, delete; report thinking; docs twg fix
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
edb8ee3731
commit
cbe111bc34
+41
-10
@@ -12,7 +12,9 @@ SYS_A = ('Dividi la trascrizione in argomenti discussi. Rispondi SOLO JSON: {"to
|
||||
'Le righe [SCHERMO] riportano cosa era visibile sullo schermo condiviso (tipo, titolo, testo letto): usale come fonte di fatti complementare al parlato. '
|
||||
'In "shown" metti i fatti concreti visti a schermo e rilevanti per l\'argomento (valori, nomi di sistemi, ticket, errori, URL), ognuno iniziando con il timestamp "mm:ss" della riga [SCHERMO] da cui proviene. '
|
||||
'Se parlato e schermo divergono, riportalo nel summary. Usa solo fatti presenti nel testo. '
|
||||
'Usa i nomi dei partecipanti solo se compaiono nel testo come nomi propri; non citare mai le etichette "Speaker N": usa forme impersonali ("si conferma", "viene proposto"). Ogni argomento copre almeno 3 minuti di discussione: non creare un argomento per ogni schermata. Scrivi tutto in italiano. Se non sei sicuro, ometti. '
|
||||
'Usa i nomi dei partecipanti solo se compaiono nel testo come nomi propri; non citare mai le etichette "Speaker N": usa forme impersonali ("si conferma", "viene proposto"). Ogni argomento copre almeno 3 minuti di discussione: non creare un argomento per ogni schermata. '
|
||||
'Nel summary riporta ciò che è stato detto, spiegato e deciso, non la navigazione tra le schermate (es. «si apre la console»): al massimo 6 punti per argomento. '
|
||||
'Non scrivere voci vuote come «nessuna domanda aperta»: lascia la lista vuota. Scrivi tutto in italiano. Se non sei sicuro, ometti. '
|
||||
'Glossario dei termini corretti letti dallo schermo (la trascrizione può storpiarli, usa la grafia del glossario): ')
|
||||
SYS_B = 'Dato l\'elenco degli argomenti, rispondi SOLO JSON: {"title":str,"tldr":[str]}. title: titolo breve della riunione (max 8 parole). Massimo 5 punti in tldr, in italiano, forma impersonale, senza etichette "Speaker N". Usa solo fatti presenti.'
|
||||
SYS_D = ('Hai un argomento di una riunione e alcuni estratti di documentazione aziendale numerati. Rispondi SOLO JSON: {"summary":[{"text":str,"doc":int|null}],"from_docs":[{"text":str,"doc":int}]}. '
|
||||
@@ -28,9 +30,20 @@ def secs(s):
|
||||
return int(m[1]) * 60 + int(m[2]) if m else 0
|
||||
|
||||
|
||||
def chat(system, user, max_tokens, retries=2):
|
||||
body = {"model": llama.current(False), "temperature": 0.2, "max_tokens": max_tokens,
|
||||
"chat_template_kwargs": {"enable_thinking": False}, "response_format": {"type": "json_object"},
|
||||
PROG = None # [name, calls done, calls expected] while report.run() is active
|
||||
|
||||
|
||||
def _tick(note):
|
||||
if PROG: PROG[1] += 1; db.tick(PROG[0], PROG[1], max(PROG[2], PROG[1] + 1) if note != "fine" else PROG[1], note)
|
||||
|
||||
|
||||
THINK = 1024 # reasoning budget per report call (server: --reasoning-budget); added to max_tokens so the answer keeps its room
|
||||
|
||||
|
||||
def chat(system, user, max_tokens, retries=2, think=False):
|
||||
"""think=True only for the report passes (topics, docs merge, overview); docs queries and memory stay fast."""
|
||||
body = {"model": llama.current(False), "temperature": 0.2, "max_tokens": max_tokens + (THINK if think else 0),
|
||||
"chat_template_kwargs": {"enable_thinking": think}, "response_format": {"type": "json_object"},
|
||||
"messages": [{"role": "system", "content": system}, {"role": "user", "content": user}]}
|
||||
for _ in range(retries):
|
||||
try:
|
||||
@@ -151,6 +164,7 @@ def _tidy(topics, dur, min_s=TIDY_MIN):
|
||||
m = dict(a)
|
||||
m["title"] = (a if ln(a) >= ln(b) else b)["title"]
|
||||
for k in ("summary", "shown", "decisions", "actions", "open_questions"): m[k] = a[k] + b[k]
|
||||
for k in ("decisions", "open_questions"): m[k] = _clean(m[k])
|
||||
m["start_s"], m["end_s"] = min(a["start_s"], b["start_s"]), max(a["end_s"], b["end_s"])
|
||||
topics[lo:hi + 1] = [m]
|
||||
for t in topics:
|
||||
@@ -158,6 +172,18 @@ def _tidy(topics, dur, min_s=TIDY_MIN):
|
||||
return topics
|
||||
|
||||
|
||||
FILLER = re.compile(r"(?i)^\s*(nessun[aoe]?|non (sono|è) (emers|stat)|n/?a\b|-+$)")
|
||||
|
||||
|
||||
def _clean(xs):
|
||||
"""Drop model filler ("Nessuna domanda aperta emersa…") and duplicates; merged topics repeated them."""
|
||||
out = []
|
||||
for x in xs:
|
||||
x = str(x).strip()
|
||||
if x and not FILLER.match(x) and x.lower() not in {o.lower() for o in out}: out.append(x)
|
||||
return out
|
||||
|
||||
|
||||
def _words(s): return {w for w in re.findall(r"\w+", s.lower()) if len(w) >= 5}
|
||||
|
||||
|
||||
@@ -169,7 +195,7 @@ def _pass_d(t, docs):
|
||||
if not top: return
|
||||
user = f"ARGOMENTO: {t['title']}\nSINTESI:\n" + "\n".join(f"- {x['text']}" for x in t["summary"]) + "\n\nDOCUMENTI:\n" + "\n\n".join(
|
||||
f"[{n}] {d['title']} ({d['source']})\n{d['body'][:2500]}" for n, d in enumerate(top, 1))
|
||||
r = chat(SYS_D, user, 2500) or {}
|
||||
r = chat(SYS_D, user, 2500, think=True) or {}
|
||||
ref = lambda n: top[n - 1]["i"] if isinstance(n, int) and 1 <= n <= len(top) else None
|
||||
fix = lambda l: [{"text": str(x["text"]), "doc": ref(x.get("doc"))} for x in l if isinstance(x, dict) and x.get("text")]
|
||||
s = fix(r.get("summary") or [])
|
||||
@@ -219,19 +245,23 @@ def run(name, window_words=3000):
|
||||
items += [(e["t"], f"[{mmss(e['t'])}] [MANO ALZATA] {e['who']}", 0) for e in evs if e["kind"] == "hand"]
|
||||
items.sort(key=lambda x: x[0])
|
||||
|
||||
global PROG
|
||||
n_chunks = max(1, -(-sum(w for _, _, w in items) // window_words))
|
||||
PROG = [name, 0, n_chunks + 3 * n_chunks + 1] # chunks + ~3 topics per chunk (docs pass) + overview
|
||||
db.tick(name, 0, PROG[2], f"argomenti: blocco 1 di {n_chunks}")
|
||||
system = SYS_A + (", ".join(glossary) or "nessuno")
|
||||
topics, buf, words, wstart = [], [], 0, 0
|
||||
def flush(end):
|
||||
nonlocal buf, words
|
||||
if not buf: return
|
||||
d = chat(system, "\n".join(buf), 4000)
|
||||
d = chat(system, "\n".join(buf), 4000, think=True); _tick(f"argomenti: blocco {PROG[1] + 1} di {n_chunks} fatto")
|
||||
ts = d.get("topics") if d else None
|
||||
if not ts:
|
||||
ts = [{"title": f"Parte {mmss(wstart)}–{mmss(end)}", "start": mmss(wstart), "end": mmss(end), "summary": ["(riassunto non disponibile)"]}]
|
||||
for t in ts:
|
||||
t = {"title": str(t.get("title") or "Argomento"), "summary": list(t.get("summary") or []), "shown": list(t.get("shown") or []),
|
||||
"decisions": list(t.get("decisions") or []), "actions": [a for a in (t.get("actions") or []) if isinstance(a, dict)],
|
||||
"open_questions": list(t.get("open_questions") or []),
|
||||
"decisions": _clean(t.get("decisions") or []), "actions": [a for a in (t.get("actions") or []) if isinstance(a, dict)],
|
||||
"open_questions": _clean(t.get("open_questions") or []),
|
||||
"start_s": secs(t.get("start")), "end_s": secs(t.get("end"))}
|
||||
t["end_s"] = min(max(t["end_s"], t["start_s"] + 1), max(dur, t["start_s"] + 1))
|
||||
topics.append(t)
|
||||
@@ -246,12 +276,13 @@ def run(name, window_words=3000):
|
||||
for a in t["actions"]:
|
||||
if re.fullmatch(r"Speaker \d+", str(a.get("who", ""))) and a["who"] not in names: a["who"] = ""
|
||||
docs = _load(name, "docs.json", {"items": [], "people": []})["items"]
|
||||
PROG[2] = PROG[1] + (len(topics) if docs else 0) + 1
|
||||
for t in topics:
|
||||
t["summary"] = [{"text": str(s), "doc": None} for s in t["summary"]]
|
||||
t["from_docs"] = []
|
||||
if docs: _pass_d(t, docs)
|
||||
if docs: _pass_d(t, docs); _tick(f"documentazione per «{t['title'][:50]}»")
|
||||
|
||||
ov = chat(SYS_B, json.dumps([{"title": t["title"], "summary": [x["text"] for x in t["summary"]], "shown": t["shown"], "decisions": t["decisions"], "actions": t["actions"]} for t in topics], ensure_ascii=False), 800) or {}
|
||||
ov = chat(SYS_B, json.dumps([{"title": t["title"], "summary": [x["text"] for x in t["summary"]], "shown": t["shown"], "decisions": t["decisions"], "actions": t["actions"]} for t in topics], ensure_ascii=False), 800, think=True) or {}; _tick("fine")
|
||||
tldr = [str(x) for x in (ov.get("tldr") or [])][:5]
|
||||
title = title or str(ov.get("title") or "").strip()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user