v1.1.0: AI分析历史记录 + 数据源详情页(/analysis/<id>),展示大模型参考的RAG新闻/概况/指标/评级/持仓/提示词

This commit is contained in:
2026-08-19 21:00:20 +08:00
parent b0fece63ff
commit 4a9ea9ddd7
8 changed files with 273 additions and 10 deletions
+13 -1
View File
@@ -100,6 +100,17 @@ CREATE TABLE IF NOT EXISTS analysis_cache (
created_at TEXT DEFAULT (datetime('now','localtime'))
);
CREATE TABLE IF NOT EXISTS analysis_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
code TEXT NOT NULL,
stock_name TEXT DEFAULT '',
focus TEXT DEFAULT '',
report TEXT,
sources TEXT DEFAULT '{}', -- JSON:大模型参考的数据源(RAG新闻/概况/指标/评级/持仓/提示词)
created_at TEXT DEFAULT (datetime('now','localtime'))
);
CREATE INDEX IF NOT EXISTS idx_history_code ON analysis_history(code);
CREATE TABLE IF NOT EXISTS market_index (
date TEXT PRIMARY KEY,
sh REAL DEFAULT 0, -- 上证指数(点)
@@ -165,7 +176,8 @@ def table_count(name):
def wipe_all():
"""清空业务表(保留结构)+ 重置自增序列,用于重灌数据"""
for t in ("stock_daily", "inst_ratings", "fund_holdings", "news",
"institutions", "stocks", "watchlist", "analysis_cache", "market_index"):
"institutions", "stocks", "watchlist", "analysis_cache", "analysis_history",
"market_index"):
with db() as conn:
conn.execute(f'DELETE FROM "{t}"')
with db() as conn: