zju 0614 v2 with background
This commit is contained in:
77
analyzers/zju_0614.py
Normal file
77
analyzers/zju_0614.py
Normal file
@ -0,0 +1,77 @@
|
||||
import sys, os, json
|
||||
sys.path.insert(0, '/home/ubuntu/inspiration-collector')
|
||||
from tools.config import load_secrets, get_output_dir
|
||||
from tools.llm import DeepSeekClient
|
||||
from tools.memos_client import MemosClient
|
||||
from datetime import datetime, timezone, timedelta
|
||||
import subprocess
|
||||
|
||||
secrets = load_secrets()
|
||||
mc = MemosClient(secrets.get('memos_url','http://localhost:5230'), secrets['memos_token'])
|
||||
llm = DeepSeekClient(secrets['deepseek_api_key'], secrets.get('deepseek_model','deepseek-chat'), temperature=0.5)
|
||||
TZ_BJ = timezone(timedelta(hours=8))
|
||||
PROJ = '/home/ubuntu/inspiration-collector'
|
||||
|
||||
memos = mc.list_memos(days=1)
|
||||
target = [m for m in memos if '厉敏' in m['content'] or '数字浙江' in m['content'] or '数字经济' in m['content'] or '一号工程' in m['content']]
|
||||
|
||||
lines = []
|
||||
for m in target:
|
||||
ct = m['created_at']
|
||||
try:
|
||||
dt = datetime.fromisoformat(ct.replace('Z','+00:00')) + timedelta(hours=8)
|
||||
ts = dt.strftime('%m/%d %H:%M')
|
||||
except:
|
||||
ts = ct[:16]
|
||||
lines.append('- **[' + ts + ']** ' + m['content'].strip())
|
||||
|
||||
text = '\n\n'.join(lines)
|
||||
|
||||
sp = '''将以下课程学习记录整理成个人学习笔记。
|
||||
|
||||
要求:
|
||||
1. 逻辑层次清晰,用自然分段和小标题体现结构,不要教科书式条目,也不要大段无层次文字
|
||||
2. 对关键概念补充必要的背景信息(如技术革命的简要说明、人物背景等),让笔记有信息厚度
|
||||
3. 开头记录客观信息:时间、地点、课程名称、授课老师(如有背景简介也写上)
|
||||
4. 文风克制客观,不用第一人称和抒情,这是给自己看的笔记
|
||||
5. 篇幅适中(约1500-2000字)
|
||||
|
||||
输出纯Markdown。'''
|
||||
|
||||
teacher_bio = """
|
||||
【授课老师背景】
|
||||
厉敏,曾任浙江省经济和信息化厅副厅长、党组成员,长期分管浙江省信息化、数字经济及产业发展工作,是浙江数字经济的主要谋划者和实践者,主持浙江数字化改革和数字经济"一号工程"相关政策体系的制定与落地。
|
||||
"""
|
||||
|
||||
prompt = '以下是在浙江大学学习的记录:\n\n' + text + '\n\n【授课老师背景】\n' + teacher_bio.strip()
|
||||
result = llm.ask(system_prompt=sp, user_prompt=prompt)
|
||||
|
||||
cc = len(result.replace(' ','').replace('\n',''))
|
||||
rm = max(1, round(cc/300))
|
||||
|
||||
content = '---\ndate: 2026-06-14\ntype: zju-analysis\ntags: [浙大, 学习分析]\n---\n\n'
|
||||
content += '> 本文共 **' + str(cc) + '** 字 · 预计阅读 **' + str(rm) + '** 分钟\n\n'
|
||||
content += result
|
||||
|
||||
daily_dir = os.path.join(get_output_dir('daily'), '2026-06-14')
|
||||
os.makedirs(daily_dir, exist_ok=True)
|
||||
|
||||
# Delete old version
|
||||
for old in os.listdir(daily_dir):
|
||||
if '浙大' in old or 'zju' in old.lower():
|
||||
try:
|
||||
os.remove(os.path.join(daily_dir, old))
|
||||
except:
|
||||
pass
|
||||
|
||||
now_str = datetime.now(TZ_BJ).strftime('%H%M%S')
|
||||
fname = '01_浙大学习分析.md'
|
||||
fpath = os.path.join(daily_dir, fname)
|
||||
with open(fpath, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
print('Done: ' + fpath + ' (' + str(cc) + ' chars)')
|
||||
subprocess.run(['git','add','-A'], cwd=PROJ, capture_output=True, timeout=15)
|
||||
subprocess.run(['git','commit','-m','zju 0614 v2 with background'], cwd=PROJ, capture_output=True, timeout=15)
|
||||
subprocess.run(['git','push','origin','main'], cwd=PROJ, capture_output=True, timeout=30)
|
||||
print('Pushed')
|
||||
Reference in New Issue
Block a user