27 lines
880 B
Python
27 lines
880 B
Python
"""新闻/政策催化 API。"""
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from app.catalyst.models import CatalystInput
|
|
from app.catalyst.service import build_theme_catalyst_scores, get_recent_catalysts, ingest_catalyst
|
|
from app.core.deps import get_current_admin
|
|
|
|
router = APIRouter(prefix="/api/catalysts", tags=["catalysts"])
|
|
|
|
|
|
@router.get("/recent")
|
|
async def recent(limit: int = 30, hours: int = 72):
|
|
return await get_recent_catalysts(limit=limit, hours=hours)
|
|
|
|
|
|
@router.get("/theme-scores")
|
|
async def theme_scores(hours: int = 72, limit: int = 20):
|
|
scores = await build_theme_catalyst_scores(hours=hours, limit=limit)
|
|
return [item.model_dump() for item in scores]
|
|
|
|
|
|
@router.post("/ingest")
|
|
async def ingest(item: CatalystInput, _admin: dict = Depends(get_current_admin)):
|
|
analysis = await ingest_catalyst(item, use_llm=True)
|
|
return analysis.model_dump()
|