feat: implement AI bouquet generation flow with Gemini/OpenAI
* feat: scaffold message, generating, and map pages and align header steps * feat: implement AI bouquet generation flow with Gemini/OpenAI --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
31
src/routes/api/flower-flow/mood-analysis/+server.js
Normal file
31
src/routes/api/flower-flow/mood-analysis/+server.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { createJob, updateJob } from '$lib/server/flowerFlow/jobStore.js';
|
||||
import { analyzeImageMood } from '$lib/server/gemini/vision.js';
|
||||
import { isGeminiConfigured } from '$lib/server/gemini/client.js';
|
||||
import { json, readUserInput, toErrorResponse } from '$lib/server/http.js';
|
||||
|
||||
/** @type {import('./$types').RequestHandler} */
|
||||
export async function POST({ request }) {
|
||||
try {
|
||||
const formData = await request.formData();
|
||||
const image = formData.get('image');
|
||||
|
||||
if (!(image instanceof File)) {
|
||||
return json({ error: 'image file is required' }, 400);
|
||||
}
|
||||
|
||||
const userInput = readUserInput(formData);
|
||||
const job = createJob(userInput);
|
||||
const imageBytes = new Uint8Array(await image.arrayBuffer());
|
||||
const moodAnalysis = await analyzeImageMood(imageBytes, image.type || 'image/jpeg', userInput);
|
||||
|
||||
updateJob(job.id, { moodAnalysis });
|
||||
|
||||
return json({
|
||||
jobId: job.id,
|
||||
moodAnalysis,
|
||||
mock: !isGeminiConfigured()
|
||||
});
|
||||
} catch (error) {
|
||||
return toErrorResponse(error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user