Auto speaker count from roster, one-to-one speaker map, clean LLM junk, merge recordings, Teams caption scraping
This commit is contained in:
+8
-1
@@ -40,6 +40,13 @@ def _tick(note):
|
||||
|
||||
THINK = 1024 # reasoning budget per report call (server: --reasoning-budget); added to max_tokens so the answer keeps its room
|
||||
|
||||
def _clean(o):
|
||||
"""Small models sometimes append '<closing braces> + a self-check' inside the last string value: cut it."""
|
||||
if isinstance(o, str): return re.split(r"[\]}]{2,}|[\u2705\u2714\u274c]", o)[0].strip()
|
||||
if isinstance(o, list): return [_clean(x) for x in o]
|
||||
if isinstance(o, dict): return {k: _clean(v) for k, v in o.items()}
|
||||
return o
|
||||
|
||||
|
||||
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."""
|
||||
@@ -56,7 +63,7 @@ def chat(system, user, max_tokens, retries=2, think=False):
|
||||
r = _open(urllib.request.Request(API, json.dumps(body).encode(), {"Content-Type": "application/json"}), timeout=1800)
|
||||
t = llama.content(json.load(r), f"report ({max_tokens} max)")
|
||||
t = re.sub(r"<think>.*?</think>", "", t, flags=re.S)
|
||||
d = json.loads(t[t.find("{"):t.rfind("}") + 1])
|
||||
d = _clean(json.loads(t[t.find("{"):t.rfind("}") + 1]))
|
||||
if isinstance(d, dict): return d
|
||||
except (ValueError, KeyError): pass
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user