-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_meeting.py
More file actions
executable file
·71 lines (64 loc) · 4.03 KB
/
Copy pathprocess_meeting.py
File metadata and controls
executable file
·71 lines (64 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
"""session_dir -> транскрипт (если нет) -> claude summary -> note.md [-> Obsidian]."""
import sys, os, subprocess, shutil, datetime
from pathlib import Path
ses = Path(sys.argv[1]); to_obs = "--obsidian" in sys.argv
here = Path(__file__).parent
title = (ses/"title.txt").read_text().strip() if (ses/"title.txt").exists() else ses.name
# транскрипт
if not (ses/"transcript.md").exists():
subprocess.run(["/usr/local/bin/python3.11", str(here/"transcribe_merge.py"), str(ses)],
stdout=subprocess.DEVNULL)
text = (ses/"transcript.md").read_text() if (ses/"transcript.md").exists() else ""
body = "\n".join(l for l in text.splitlines() if l.startswith("**["))
if len(body) < 40:
print("транскрипт пустой/короткий - саммари пропущено"); (ses/"note.md").write_text(text); sys.exit(0)
def claude_bin():
for c in [os.environ.get("ECHO_CLAUDE_BIN"), shutil.which("claude")]:
if c and os.access(c, os.X_OK): return c
return None
def load_config():
cfg = {}
p = here / "config.env"
if p.exists():
for line in p.read_text().splitlines():
line = line.strip()
if line and not line.startswith("#") and "=" in line:
k, v = line.split("=", 1); cfg[k] = v
return cfg
CB = claude_bin()
if not CB: print("claude CLI не найден"); sys.exit(1)
sysp = ("Ты обработчик заметок встреч. Вход - транскрипт с метками спикеров (Я / Собеседник). "
"Верни markdown-заметку на языке транскрипта со секциями: ## Кратко (3-5 буллетов), "
"## Решения, ## Задачи (сгруппировать по владельцу, конкретно и actionable), "
"## Договорённости / следующий шаг, ## Ключевой инсайт (если есть). "
"Короткое тире, без воды. Ничего не выдумывай - только из транскрипта.")
env = {**os.environ, "PATH": "/opt/homebrew/bin:" + os.environ.get("PATH", "")}
env.pop("CLAUDECODE", None); env.pop("CLAUDE_CODE", None)
# claude здесь работает по подписке (ANTHROPIC_API_KEY не задан), денег вызов не стоит.
# Был --max-budget-usd 0.30: он считает расчётную цену по прайсу API и рубит вызов -
# 2-часовой воркшоп (157 КБ ≈ 52К токенов) в потолок не влез и падал с
# «Error: Exceeded USD budget» в stdout. Ограничитель убран, страховка - таймаут.
timeout = min(1800, max(300, int(len(body) / 300)))
r = subprocess.run([CB,"-p","--model","sonnet","--setting-sources","","--system-prompt",sysp,
"--no-session-persistence"],
input=f"Транскрипт встречи «{title}»:\n\n{body}", capture_output=True, text=True, timeout=timeout, env=env)
if r.returncode != 0:
print(f"claude failed rc={r.returncode} (~{len(body)//3} токенов, timeout={timeout}с)\n"
f"stderr: {r.stderr[:300]}\nstdout: {r.stdout[:300]}"); sys.exit(1)
summary = r.stdout.strip()
date = datetime.date.today().isoformat()
note = f"# {title}\n\n> {date} · echo\n\n{summary}\n\n---\n\n## Полный транскрипт\n\n{text}\n"
(ses/"note.md").write_text(note)
print(f"note -> {ses}/note.md ({len(summary)} chars summary)")
if to_obs:
# OBSIDIAN_VAULT_PATH задаётся в config.env (см. config.env.example) или env-переменной.
d = os.environ.get("ECHO_OBSIDIAN_PATH") or load_config().get("OBSIDIAN_VAULT_PATH")
if not d:
print("OBSIDIAN_VAULT_PATH не задан - заметка осталась в папке сессии")
else:
vault = Path(os.path.expanduser(d))
vault.mkdir(parents=True, exist_ok=True)
dest = vault / f"{date} {title}.md".replace("/", "_")
shutil.copy(ses/"note.md", dest)
print(f"Obsidian -> {dest}")