feat: new file

This commit is contained in:
Daniel
2026-03-18 18:57:58 +08:00
commit d0ff049899
31 changed files with 1507 additions and 0 deletions

24
backend/app/routes/ai.py Normal file
View File

@@ -0,0 +1,24 @@
from __future__ import annotations
from fastapi import APIRouter
from pydantic import BaseModel, Field
from ..services.ai_insight import generate_insight
router = APIRouter()
class InsightRequest(BaseModel):
query: str = Field(..., min_length=1, max_length=2000)
product_id: str | None = None
top_k: int = Field(6, ge=1, le=20)
@router.post("/insight")
def insight(req: InsightRequest):
"""
基于向量检索 + LLM可选输出“爆款发现 -> 数据验证 -> 决策跟卖”的建议。
"""
return generate_insight(query=req.query, product_id=req.product_id, top_k=req.top_k)