v1.1.0: AI分析历史记录 + 数据源详情页(/analysis/<id>),展示大模型参考的RAG新闻/概况/指标/评级/持仓/提示词
This commit is contained in:
@@ -61,6 +61,12 @@ def page_stock(code):
|
||||
service=SERVICE_NAME, is_mock=IS_MOCK)
|
||||
|
||||
|
||||
@app.route("/analysis/<int:aid>")
|
||||
def page_analysis(aid):
|
||||
return render_template("analysis_detail.html", aid=aid,
|
||||
service=SERVICE_NAME, is_mock=IS_MOCK)
|
||||
|
||||
|
||||
# ===================================================================== 公共
|
||||
def _indicators(code):
|
||||
rows = query("SELECT date,open,high,low,close,volume FROM stock_daily "
|
||||
@@ -365,13 +371,32 @@ def api_analyze(code):
|
||||
def api_analyze_status(code):
|
||||
from engine import analyst
|
||||
st = analyst.report_status(code)
|
||||
if not st:
|
||||
cached = analyst.get_cached_report(code)
|
||||
if cached:
|
||||
return jsonify({"status": "done", "report": cached["report"],
|
||||
"cached": True, "created_at": cached["created_at"]})
|
||||
return jsonify({"status": "idle"})
|
||||
return jsonify(st)
|
||||
if st:
|
||||
return jsonify(st)
|
||||
# 无运行中任务:返回最近一次历史分析
|
||||
hist = analyst.list_history(code, limit=1)
|
||||
if hist:
|
||||
detail = analyst.get_history(hist[0]["id"])
|
||||
return jsonify({"status": "done", "report": detail["report"],
|
||||
"history_id": detail["id"], "created_at": detail["created_at"],
|
||||
"cached": True})
|
||||
return jsonify({"status": "idle"})
|
||||
|
||||
|
||||
@app.route("/api/stock/<code>/analyses")
|
||||
def api_stock_analyses(code):
|
||||
from engine import analyst
|
||||
return jsonify({"items": analyst.list_history(code)})
|
||||
|
||||
|
||||
@app.route("/api/analyses/<int:aid>")
|
||||
def api_analysis_detail(aid):
|
||||
from engine import analyst
|
||||
d = analyst.get_history(aid)
|
||||
if not d:
|
||||
return jsonify({"error": "记录不存在"}), 404
|
||||
stock = query_one("SELECT code, name, industry, board FROM stocks WHERE code=?", (d["code"],))
|
||||
return jsonify({"analysis": d, "stock": stock})
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ 自选
|
||||
|
||||
Reference in New Issue
Block a user