增加大模型
This commit is contained in:
+27
-8
@@ -14,7 +14,7 @@ from .exceptions import BinanceRateLimitedError
|
||||
from .period_api import get_period_top30
|
||||
from .periods import get_daybefore_period, get_today_period, get_yesterday_period
|
||||
from .chart_image import render_daily_chart_png_async
|
||||
from .llm_service import get_interpret_state, run_interpretation_batch
|
||||
from .llm_service import get_interpret_state, init_interpret_batch, run_interpretation_batch
|
||||
from .scheduler import job_finalize_yesterday, job_push_wecom, job_refresh_today, start_scheduler, startup_tasks, stop_scheduler
|
||||
from .stats import compute_three_day_stats
|
||||
from .aggregator import aggregate_period
|
||||
@@ -207,19 +207,38 @@ async def api_llm_status():
|
||||
|
||||
|
||||
@app.get("/api/llm/interpretations")
|
||||
async def api_llm_interpretations(batch_id: str | None = None, limit: int = 50):
|
||||
return {"items": get_llm_interpretations(batch_id, limit)}
|
||||
async def api_llm_interpretations(batch_id: str | None = None, limit: int = 100):
|
||||
"""返回解读列表;进行中时优先当前批次(即使尚无记录)。"""
|
||||
st = get_interpret_state()
|
||||
bid = batch_id or (st.get("batch_id") if st.get("running") else None)
|
||||
items = get_llm_interpretations(bid, limit) if bid else get_llm_interpretations(None, limit)
|
||||
if not bid and items:
|
||||
bid = items[0].get("batch_id", "")
|
||||
return {
|
||||
"items": items,
|
||||
"batch_id": bid or st.get("batch_id", ""),
|
||||
"running": st.get("running", False),
|
||||
"done": st.get("done", 0),
|
||||
"total": st.get("total", 0),
|
||||
"current_symbol": st.get("current_symbol", ""),
|
||||
}
|
||||
|
||||
|
||||
@app.post("/api/llm/interpret/run")
|
||||
async def api_llm_interpret_run(background_tasks: BackgroundTasks):
|
||||
if not settings.llm_api_key.strip():
|
||||
raise HTTPException(400, "LLM_API_KEY 未配置")
|
||||
state = get_interpret_state()
|
||||
if state.get("running"):
|
||||
return {"ok": False, "message": "解读任务进行中", **state}
|
||||
background_tasks.add_task(run_interpretation_batch)
|
||||
return {"ok": True, "message": "已启动三日交集解读队列", **get_interpret_state()}
|
||||
info = init_interpret_batch()
|
||||
if not info.get("ok"):
|
||||
return info
|
||||
bid = info.get("batch_id")
|
||||
background_tasks.add_task(run_interpretation_batch, batch_id=bid)
|
||||
return {
|
||||
"ok": True,
|
||||
"message": "已启动三日交集解读队列",
|
||||
"batch_id": bid,
|
||||
**get_interpret_state(),
|
||||
}
|
||||
|
||||
|
||||
@app.post("/api/chart/{symbol}/daily/refresh")
|
||||
|
||||
Reference in New Issue
Block a user