-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_personas_sqlite.py
More file actions
78 lines (62 loc) · 2.69 KB
/
Copy pathupdate_personas_sqlite.py
File metadata and controls
78 lines (62 loc) · 2.69 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
72
73
74
75
76
77
78
"""
直接使用SQLite更新内置人设
"""
import sqlite3
import os
# 数据库路径
db_path = os.path.join(os.path.dirname(__file__), "data", "quantagent.db")
# 新的人设内容
NEW_PERSONA_CONTENT = """你是 QuantAgent 的内置 AI 助手,这是一款专业的 A 股量化分析软件。
【软件功能模块】
1. 📊 今日行情:实时A股行情数据、五档盘口、大盘指数
2. 📈 策略回测:内置5种经典策略(均线交叉、MACD、RSI超买超卖、KDJ、布林带),支持自定义策略,提供资金曲线图可视化
3. 🔍 智能选股:技术指标条件筛选、AI智能推荐
4. 🧠 AI预测:Alpha模式(A股逻辑因子)和经典模式(技术指标),基于XGBoost机器学习
5. 📚 知识库:记录投资经验、教训、策略、复盘
【你可以帮助用户】
- 分析股票行情数据,解读技术指标
- 推荐适合的交易策略
- 执行回测:你可以进入软件的📊回测模块,输入股票代码,选择策略,查看交易流水和资金曲线图
- 解释预测结果和特征重要性
- 管理投资知识库
【回复要求】
用中文回复,保持专业简洁。对于量化问题,优先使用数据和指标说话。"""
def update_personas():
"""更新所有内置人设"""
if not os.path.exists(db_path):
print(f"❌ 数据库文件不存在: {db_path}")
return
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
try:
# 查找所有内置人设
cursor.execute("SELECT id, user_id, name, content FROM personas WHERE is_builtin = 1")
personas = cursor.fetchall()
if not personas:
print("❌ 未找到任何内置人设")
return
print(f"📝 找到 {len(personas)} 个内置人设")
# 更新每个人设
for persona_id, user_id, name, old_content in personas:
cursor.execute(
"UPDATE personas SET content = ? WHERE id = ?",
(NEW_PERSONA_CONTENT, persona_id)
)
print(f"✅ 已更新用户 {user_id} 的内置人设 [{name}]")
print(f" 旧内容前50字: {old_content[:50]}...")
print(f" 新内容前50字: {NEW_PERSONA_CONTENT[:50]}...")
print()
# 提交更改
conn.commit()
print(f"✨ 成功更新 {len(personas)} 个内置人设!")
except Exception as e:
print(f"❌ 更新失败: {e}")
conn.rollback()
finally:
conn.close()
if __name__ == "__main__":
print("=" * 60)
print("🔄 开始更新所有用户的内置人设...")
print("=" * 60)
update_personas()
print("=" * 60)