Files
2026-03-18 18:57:58 +08:00

25 lines
622 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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)