fix(journaling): optimize serper video search queries to prevent MDX hallucination
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧪 Test (push) Successful in 59s
Monorepo Pipeline / 🧹 Lint (push) Failing after 2m0s
Monorepo Pipeline / 🏗️ Build (push) Successful in 5m9s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧪 Test (push) Successful in 59s
Monorepo Pipeline / 🧹 Lint (push) Failing after 2m0s
Monorepo Pipeline / 🏗️ Build (push) Successful in 5m9s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
This commit is contained in:
@@ -6,6 +6,12 @@ export interface ThumbnailGeneratorConfig {
|
||||
replicateApiKey: string;
|
||||
}
|
||||
|
||||
export interface ThumbnailGenerateOptions {
|
||||
model?: string;
|
||||
systemPrompt?: string;
|
||||
imagePrompt?: string; // Path to local reference image
|
||||
}
|
||||
|
||||
export class ThumbnailGenerator {
|
||||
private replicate: Replicate;
|
||||
|
||||
@@ -18,21 +24,43 @@ export class ThumbnailGenerator {
|
||||
public async generateImage(
|
||||
topic: string,
|
||||
outputPath: string,
|
||||
options?: ThumbnailGenerateOptions,
|
||||
): Promise<string> {
|
||||
const systemPrompt = `Technical blueprint / architectural illustration — clean lines, monochrome base with one highlighter accent color (yellow, pink, or green). Abstract, geometric, or diagrammatic illustrations only. 'Engineering notebook sketch' — precise, minimal, professional. No text in images. No people or realistic photos.`;
|
||||
const defaultSystemPrompt = `A highly polished, ultra-minimalist conceptual illustration. Style: high-end tech agency, clean modern 3D or flat vector art, extensive use of negative space, elegant monochrome palette (whites, light grays) with a single vibrant accent color (neon green or electric blue). Extremely clean and precise geometry. Absolutely no text, no photorealism, no chaotic lines, no messy sketches, no people.`;
|
||||
|
||||
const systemPrompt = options?.systemPrompt || defaultSystemPrompt;
|
||||
const prompt = `${systemPrompt}\n\nTopic to illustrate abstractly: ${topic}`;
|
||||
|
||||
console.log(`🎨 Generating thumbnail for topic: "${topic}"...`);
|
||||
|
||||
const output = await this.replicate.run("black-forest-labs/flux-1.1-pro", {
|
||||
input: {
|
||||
prompt,
|
||||
aspect_ratio: "16:9",
|
||||
output_format: "png",
|
||||
output_quality: 90,
|
||||
prompt_upsampling: false,
|
||||
},
|
||||
let inputPayload: any = {
|
||||
prompt,
|
||||
aspect_ratio: "16:9",
|
||||
output_format: "png",
|
||||
output_quality: 90,
|
||||
prompt_upsampling: false,
|
||||
};
|
||||
|
||||
if (options?.imagePrompt) {
|
||||
console.log(`🖼️ Using image style reference: ${options.imagePrompt}`);
|
||||
try {
|
||||
const absImgPath = path.isAbsolute(options.imagePrompt)
|
||||
? options.imagePrompt
|
||||
: path.resolve(process.cwd(), options.imagePrompt);
|
||||
const imgBuffer = await fs.readFile(absImgPath);
|
||||
const base64 = imgBuffer.toString("base64");
|
||||
// Replicate models usually expect a data URI for image_prompt
|
||||
inputPayload.image_prompt = `data:image/png;base64,${base64}`;
|
||||
} catch (err) {
|
||||
console.warn(`⚠️ Could not load image prompt: ${err}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Default to the requested nano-banana-pro model unless explicitly provided
|
||||
const model = options?.model || "google/nano-banana-pro";
|
||||
|
||||
const output = await this.replicate.run(model as `${string}/${string}`, {
|
||||
input: inputPayload,
|
||||
});
|
||||
|
||||
// Replicate returns a ReadableStream for the output of flux-1.1-pro in newer Node SDKs
|
||||
|
||||
Reference in New Issue
Block a user