Add batch image jobs runtime
This commit is contained in:
33
src/index.ts
33
src/index.ts
@@ -1,27 +1,32 @@
|
||||
import { streamPrompt } from "@/ai";
|
||||
import { loadConfig } from "@/config";
|
||||
import { saveImage } from "@/image";
|
||||
|
||||
const DEFAULT_PROMPT =
|
||||
"A cute nano banano mascot in a clean sci-fi lab, bright colors, polished illustration";
|
||||
|
||||
function buildPrompt(): string {
|
||||
const cliPrompt = Bun.argv.slice(2).join(" ").trim();
|
||||
return cliPrompt || DEFAULT_PROMPT;
|
||||
}
|
||||
import { jobs } from "@/jobs";
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const config = loadConfig();
|
||||
const prompt = buildPrompt();
|
||||
const enabledJobs = jobs.filter((job) => job.enabled !== false);
|
||||
|
||||
console.log(`Prompt: ${prompt}`);
|
||||
if (enabledJobs.length === 0) {
|
||||
throw new Error("No enabled jobs found.");
|
||||
}
|
||||
|
||||
const image = await streamPrompt(config, prompt);
|
||||
for (const job of enabledJobs) {
|
||||
console.log(`\n=== ${job.name} ===`);
|
||||
console.log(`Prompt: ${job.prompt}`);
|
||||
console.log(`Input images: ${job.images?.length ?? 0}`);
|
||||
|
||||
const savedImagePath = await saveImage(image.bytes, image.mediaType);
|
||||
const image = await streamPrompt(config, job);
|
||||
|
||||
console.log(`\nSaved image: ${savedImagePath}`);
|
||||
console.log(`Image media type: ${image.mediaType}`);
|
||||
const savedImagePath = await saveImage(
|
||||
image.bytes,
|
||||
image.mediaType,
|
||||
job.name,
|
||||
);
|
||||
|
||||
console.log(`\nSaved image: ${savedImagePath}`);
|
||||
console.log(`Image media type: ${image.mediaType}`);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error: unknown) => {
|
||||
|
||||
Reference in New Issue
Block a user