feat: new file
This commit is contained in:
24
backend/app/routes/ai.py
Normal file
24
backend/app/routes/ai.py
Normal 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)
|
||||
|
||||
Reference in New Issue
Block a user