feat: 盲盒想法输入增加 AI 灵感推荐
输入框下方展示灵感建议标签,点击即填入,降低创作门槛: - 房间有 ≥2 条想法时调用 DeepSeek 生成贴合调性的推荐 - 想法不足或 AI 失败时 fallback 到 18 条静态灵感随机选 4 条 - 提交新想法后自动刷新推荐,支持手动换一批
This commit is contained in:
@@ -113,6 +113,44 @@ export async function tagIdea(content: string): Promise<IdeaTags | null> {
|
||||
}
|
||||
}
|
||||
|
||||
const SUGGEST_SYSTEM_PROMPT = `你是一个脑洞大开的周末活动灵感助手。根据用户房间里已有的活动想法,推荐 4 个风格相近但不重复的新想法。
|
||||
|
||||
要求:
|
||||
- 贴合已有想法的整体调性(如果偏文艺就推文艺的,偏冒险就推冒险的)
|
||||
- 适当加入一些意想不到的创意,激发灵感
|
||||
- 每条想法 5-15 个字,口语化、有画面感
|
||||
- 不要与已有想法重复或过于相似
|
||||
|
||||
只返回 JSON:{ "suggestions": ["想法1", "想法2", "想法3", "想法4"] }`;
|
||||
|
||||
export async function suggestIdeas(existingIdeas: string[]): Promise<string[]> {
|
||||
try {
|
||||
const client = getClient();
|
||||
const response = await client.chat.completions.create({
|
||||
model: "deepseek-chat",
|
||||
messages: [
|
||||
{ role: "system", content: SUGGEST_SYSTEM_PROMPT },
|
||||
{ role: "user", content: `已有想法:\n${existingIdeas.map((s, i) => `${i + 1}. ${s}`).join("\n")}` },
|
||||
],
|
||||
response_format: { type: "json_object" },
|
||||
max_tokens: 200,
|
||||
temperature: 0.9,
|
||||
});
|
||||
|
||||
const text = response.choices[0]?.message?.content;
|
||||
if (!text) return [];
|
||||
|
||||
const parsed = JSON.parse(text);
|
||||
if (!Array.isArray(parsed.suggestions)) return [];
|
||||
|
||||
return parsed.suggestions
|
||||
.filter((s: unknown) => typeof s === "string" && s.length > 0)
|
||||
.slice(0, 4);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateSchedule(
|
||||
ctx: ScheduleContext,
|
||||
): Promise<{ items: PlanItem[]; summary: string } | null> {
|
||||
|
||||
Reference in New Issue
Block a user