去掉大模型
This commit is contained in:
+3
-67
@@ -2,19 +2,17 @@ import logging
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import BackgroundTasks, FastAPI, HTTPException
|
||||
from fastapi.responses import FileResponse, Response
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.responses import FileResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from .config import ROOT_DIR, settings
|
||||
from .funding_store import get_funding_bundle
|
||||
from .kline_store import get_daily_candles, sync_daily_klines
|
||||
from .db import get_latest_snapshot, get_llm_interpretations, init_db, log_push, save_snapshot
|
||||
from .db import get_latest_snapshot, init_db, log_push, save_snapshot
|
||||
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, 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
|
||||
@@ -179,68 +177,6 @@ async def api_funding_history(symbol: str, limit: int | None = None, refresh: bo
|
||||
raise HTTPException(502, "资金费率获取失败") from e
|
||||
|
||||
|
||||
@app.get("/api/chart/{symbol}/daily.png")
|
||||
async def api_chart_daily_png(symbol: str, limit: int | None = None):
|
||||
sym = symbol.upper().strip()
|
||||
if not sym.endswith("USDT"):
|
||||
raise HTTPException(400, "invalid symbol")
|
||||
try:
|
||||
png = await render_daily_chart_png_async(sym, limit or settings.chart_kline_limit)
|
||||
return Response(content=png, media_type="image/png")
|
||||
except ValueError as e:
|
||||
raise HTTPException(404, str(e)) from e
|
||||
except Exception as e:
|
||||
logger.error("chart png %s failed: %s", sym, e)
|
||||
raise HTTPException(502, "图表生成失败") from e
|
||||
|
||||
|
||||
@app.get("/api/llm/status")
|
||||
async def api_llm_status():
|
||||
state = get_interpret_state()
|
||||
return {
|
||||
**state,
|
||||
"enabled": bool(settings.llm_api_key.strip()),
|
||||
"model": settings.llm_model,
|
||||
"base_url": settings.llm_base_url,
|
||||
"interval_sec": settings.llm_symbol_interval_sec,
|
||||
}
|
||||
|
||||
|
||||
@app.get("/api/llm/interpretations")
|
||||
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 未配置")
|
||||
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")
|
||||
async def api_chart_daily_refresh(symbol: str, limit: int | None = None):
|
||||
"""强制从币安同步日 K 到本地库。"""
|
||||
|
||||
Reference in New Issue
Block a user