Use frontend-selected characters instead of fetching recent ones
This commit is contained in:
@@ -10,7 +10,6 @@ import {
|
||||
getNextPageNumber,
|
||||
getStoryWithPagesBySlug,
|
||||
getLastPageImage,
|
||||
getStoryCharacterImages,
|
||||
} from "@/lib/db-actions";
|
||||
import { freeTierRateLimit } from "@/lib/rate-limit";
|
||||
import { uploadImageToS3 } from "@/lib/s3-upload";
|
||||
@@ -134,11 +133,8 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
// Get story character images (up to 2 most recent)
|
||||
const storyCharacterImages = await getStoryCharacterImages(story.id);
|
||||
referenceImages.push(...storyCharacterImages.slice(-2)); // Take last 2
|
||||
|
||||
// Add current character images to references
|
||||
// Use only the character images sent from the frontend (user's selection)
|
||||
// These are already the most recent/relevant characters the user wants to use
|
||||
referenceImages.push(...characterImages);
|
||||
|
||||
// Build the prompt with continuation context
|
||||
|
||||
@@ -119,9 +119,8 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
// Get story character images (up to 2 most recent)
|
||||
const storyCharacterImages = await getStoryCharacterImages(storyId);
|
||||
referenceImages.push(...storyCharacterImages.slice(-2)); // Take last 2
|
||||
// For continuation pages, character images are sent from frontend
|
||||
// No need to fetch separately - frontend handles selection
|
||||
} else {
|
||||
// New story: no previous page reference
|
||||
// Create story with temporary title, will update with generated title
|
||||
@@ -140,7 +139,7 @@ export async function POST(request: NextRequest) {
|
||||
});
|
||||
}
|
||||
|
||||
// Add current character images to references
|
||||
// Use only the character images sent from the frontend
|
||||
referenceImages.push(...characterImages);
|
||||
|
||||
const dimensions = FIXED_DIMENSIONS;
|
||||
|
||||
@@ -21,6 +21,7 @@ export async function GET() {
|
||||
id: stories.id,
|
||||
title: stories.title,
|
||||
slug: stories.slug,
|
||||
style: stories.style,
|
||||
createdAt: stories.createdAt,
|
||||
pageCount: pages.pageNumber,
|
||||
coverImage: pages.generatedImageUrl,
|
||||
@@ -41,6 +42,7 @@ export async function GET() {
|
||||
id: row.id,
|
||||
title: row.title,
|
||||
slug: row.slug,
|
||||
style: row.style,
|
||||
createdAt: row.createdAt,
|
||||
pageCount: 0,
|
||||
coverImage: null,
|
||||
|
||||
Reference in New Issue
Block a user