feat: AI 辅助修改行程(自然语言调整 + 单活动替代推荐)
- 新增 refinePlan / suggestAlternativeItems 到 ai.ts - 新增 POST /api/blindbox/plan/refine(整体行程调整) - 新增 POST /api/blindbox/plan/suggest-item(单活动 AI 替代 + POI 搜索) - BlindboxPlan 底部新增自然语言输入框(方案 A) - 编辑 modal 内新增 AI 推荐替代方案卡片(方案 B) - export searchPois 供 suggest-item 路由复用
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { apiHandler, ApiError, requireUserId } from "@/lib/api";
|
||||
import { refinePlan } from "@/lib/ai";
|
||||
|
||||
export const POST = apiHandler(async (req) => {
|
||||
const { userId, instruction, days } = await req.json();
|
||||
requireUserId(userId);
|
||||
if (!instruction?.trim()) throw new ApiError("指令不能为空", 400);
|
||||
if (!Array.isArray(days) || days.length === 0) throw new ApiError("days 无效", 400);
|
||||
|
||||
const newDays = await refinePlan(days, instruction);
|
||||
if (!newDays) throw new ApiError("AI 调整失败,请重试", 500);
|
||||
return NextResponse.json({ days: newDays });
|
||||
});
|
||||
Reference in New Issue
Block a user