save changes
This commit is contained in:
@ -18,10 +18,13 @@ const servers = [
|
|||||||
baseUrl: process.env.SERVER1_COMFY_BASE_URL,
|
baseUrl: process.env.SERVER1_COMFY_BASE_URL,
|
||||||
outputDir: process.env.SERVER1_COMFY_OUTPUT_DIR,
|
outputDir: process.env.SERVER1_COMFY_OUTPUT_DIR,
|
||||||
},
|
},
|
||||||
//{
|
|
||||||
// baseUrl: process.env.SERVER2_COMFY_BASE_URL,
|
/*
|
||||||
// outputDir: process.env.SERVER2_COMFY_OUTPUT_DIR,
|
{
|
||||||
//},
|
baseUrl: process.env.SERVER2_COMFY_BASE_URL,
|
||||||
|
outputDir: process.env.SERVER2_COMFY_OUTPUT_DIR,
|
||||||
|
},
|
||||||
|
*/
|
||||||
];
|
];
|
||||||
|
|
||||||
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
|
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
|||||||
@ -146,20 +146,30 @@ async function processItem(genre: string, item: any) {
|
|||||||
} = item;
|
} = item;
|
||||||
|
|
||||||
// Determine final scene text
|
// Determine final scene text
|
||||||
const finalScene =
|
const finalScene = scene;
|
||||||
(typeof scene === 'string' && scene.trim().length > 0)
|
|
||||||
|
/*(typeof scene === 'string' && scene.trim().length > 0)
|
||||||
? scene
|
? scene
|
||||||
: Array.isArray(sceneVariants) && sceneVariants.length > 0
|
: Array.isArray(sceneVariants) && sceneVariants.length > 0
|
||||||
? sceneVariants[0]
|
? sceneVariants[0]
|
||||||
: '';
|
: '';
|
||||||
|
*/
|
||||||
|
|
||||||
// Choose one random action (fall back to legacy 'action' if needed)
|
// Choose one random action (fall back to legacy 'action' if needed)
|
||||||
let chosenAction = '';
|
let chosenAction = '';
|
||||||
|
if (Array.isArray(actions) && actions.length > 0) {
|
||||||
|
chosenAction = actions[0];
|
||||||
|
} else if (typeof action === 'string') {
|
||||||
|
chosenAction = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (Array.isArray(actions) && actions.length > 0) {
|
if (Array.isArray(actions) && actions.length > 0) {
|
||||||
chosenAction = actions[Math.floor(Math.random() * actions.length)];
|
chosenAction = actions[Math.floor(Math.random() * actions.length)];
|
||||||
} else if (typeof action === 'string') {
|
} else if (typeof action === 'string') {
|
||||||
chosenAction = action;
|
chosenAction = action;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Choose random accents (pick 1 or 2 if available)
|
// Choose random accents (pick 1 or 2 if available)
|
||||||
let chosenAccents = '';
|
let chosenAccents = '';
|
||||||
@ -179,11 +189,24 @@ async function processItem(genre: string, item: any) {
|
|||||||
|
|
||||||
// Compose the action text that will be stored in the DB (so later prompt generation can use it)
|
// Compose the action text that will be stored in the DB (so later prompt generation can use it)
|
||||||
const actionText = [chosenAction, meta].filter(Boolean).join(' ').trim();
|
const actionText = [chosenAction, meta].filter(Boolean).join(' ').trim();
|
||||||
|
//const actionText = [chosenAction, meta].filter(Boolean).join(' ').trim();
|
||||||
|
|
||||||
// Generate image_prompt and video_prompt using LM Studio (with retries)
|
// Generate image_prompt and video_prompt using LM Studio (with retries)
|
||||||
let imagePrompt: string | null = null;
|
let imagePrompt: string | null = null;
|
||||||
let videoPrompt: string | null = null;
|
let videoPrompt: string | null = null;
|
||||||
|
|
||||||
|
|
||||||
|
// Check if the item already exists (compare stored action text so duplicates are avoided)
|
||||||
|
const existing = await query(
|
||||||
|
'SELECT id FROM video WHERE genre = ? AND sub_genre = ? AND scene = ? AND action = ? AND camera = ?',
|
||||||
|
[genre, subGenre, finalScene, chosenAction, camera]
|
||||||
|
) as any[];
|
||||||
|
|
||||||
|
if (existing.length > 0) {
|
||||||
|
logger.info(`Skipped (exists): ${genre} - ${subGenre} - ${finalScene}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const lmInput = `
|
const lmInput = `
|
||||||
Generate two prompts in JSON: { "imagePrompt": "...", "videoPrompt": "..." }.
|
Generate two prompts in JSON: { "imagePrompt": "...", "videoPrompt": "..." }.
|
||||||
Image prompt: ~125 words describing a still image representing the scene. Include lighting, mood, style and any accents provided.
|
Image prompt: ~125 words describing a still image representing the scene. Include lighting, mood, style and any accents provided.
|
||||||
@ -220,25 +243,15 @@ async function processItem(genre: string, item: any) {
|
|||||||
if (!imagePrompt || !videoPrompt) {
|
if (!imagePrompt || !videoPrompt) {
|
||||||
logger.warn(`LMStudio did not return both prompts for ${genre} - ${subGenre} - ${finalScene}. Inserting without prompts.`);
|
logger.warn(`LMStudio did not return both prompts for ${genre} - ${subGenre} - ${finalScene}. Inserting without prompts.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the item already exists (compare stored action text so duplicates are avoided)
|
|
||||||
const existing = await query(
|
|
||||||
'SELECT id FROM video WHERE genre = ? AND sub_genre = ? AND scene = ? AND action = ? AND camera = ?',
|
|
||||||
[genre, subGenre, finalScene, actionText, camera]
|
|
||||||
) as any[];
|
|
||||||
|
|
||||||
if (existing.length === 0) {
|
|
||||||
// Insert the new item with generated prompts
|
// Insert the new item with generated prompts
|
||||||
await query(
|
await query(
|
||||||
'INSERT INTO video (genre, sub_genre, scene, action, camera, image_prompt, video_prompt) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
'INSERT INTO video (genre, sub_genre, scene, action, camera, image_prompt, video_prompt) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
||||||
[genre, subGenre, finalScene, actionText, camera, imagePrompt, videoPrompt]
|
[genre, subGenre, finalScene, chosenAction, camera, imagePrompt, videoPrompt]
|
||||||
);
|
);
|
||||||
logger.info(`Inserted: ${genre} - ${subGenre} - ${finalScene}`);
|
logger.info(`Inserted: ${genre} - ${subGenre} - ${finalScene}`);
|
||||||
logger.info(`Image prompt: ${imagePrompt}`);
|
logger.info(`Image prompt: ${imagePrompt}`);
|
||||||
logger.info(`Video prompt: ${videoPrompt}`);
|
logger.info(`Video prompt: ${videoPrompt}`);
|
||||||
} else {
|
|
||||||
logger.info(`Skipped (exists): ${genre} - ${subGenre} - ${finalScene}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,10 +16,10 @@ interface VideoRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const servers = [
|
const servers = [
|
||||||
{
|
/*{
|
||||||
baseUrl: process.env.SERVER1_COMFY_BASE_URL,
|
baseUrl: process.env.SERVER1_COMFY_BASE_URL,
|
||||||
outputDir: process.env.SERVER1_COMFY_OUTPUT_DIR,
|
outputDir: process.env.SERVER1_COMFY_OUTPUT_DIR,
|
||||||
},
|
},*/
|
||||||
{
|
{
|
||||||
baseUrl: process.env.SERVER2_COMFY_BASE_URL,
|
baseUrl: process.env.SERVER2_COMFY_BASE_URL,
|
||||||
outputDir: process.env.SERVER2_COMFY_OUTPUT_DIR,
|
outputDir: process.env.SERVER2_COMFY_OUTPUT_DIR,
|
||||||
|
|||||||
Reference in New Issue
Block a user