Add initial image CLI runtime
This commit is contained in:
31
src/index.ts
Normal file
31
src/index.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const config = loadConfig();
|
||||
const prompt = buildPrompt();
|
||||
|
||||
console.log(`Prompt: ${prompt}`);
|
||||
|
||||
const image = await streamPrompt(config, prompt);
|
||||
|
||||
const savedImagePath = await saveImage(image.bytes, image.mediaType);
|
||||
|
||||
console.log(`\nSaved image: ${savedImagePath}`);
|
||||
console.log(`Image media type: ${image.mediaType}`);
|
||||
}
|
||||
|
||||
main().catch((error: unknown) => {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
console.error(`\nRequest failed: ${message}`);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in New Issue
Block a user