make generate_image conditionally show up

This commit is contained in:
arkml 2025-09-16 14:59:00 +05:30
parent cdfa7daf98
commit 70cbd8beea
2 changed files with 7 additions and 4 deletions

View file

@ -3,13 +3,15 @@ import { z } from 'zod';
// Provide a minimal default template to satisfy legacy code paths that // Provide a minimal default template to satisfy legacy code paths that
// still reference `templates.default`. Real templates are DB-backed. // still reference `templates.default`. Real templates are DB-backed.
const includeGeminiImageTool = !!process.env.GOOGLE_API_KEY;
const defaultTemplate: z.infer<typeof WorkflowTemplate> = { const defaultTemplate: z.infer<typeof WorkflowTemplate> = {
name: 'Blank Template', name: 'Blank Template',
description: 'A blank canvas to build your assistant.', description: 'A blank canvas to build your assistant.',
startAgent: "", startAgent: "",
agents: [], agents: [],
prompts: [], prompts: [],
tools: [ tools: includeGeminiImageTool ? [
{ {
name: "Generate Image", name: "Generate Image",
description: "Generate an image using Google Gemini given a text prompt. Returns base64-encoded image data and any text parts.", description: "Generate an image using Google Gemini given a text prompt. Returns base64-encoded image data and any text parts.",
@ -24,7 +26,7 @@ const defaultTemplate: z.infer<typeof WorkflowTemplate> = {
additionalProperties: true, additionalProperties: true,
}, },
}, },
], ] : [],
pipelines: [], pipelines: [],
}; };

View file

@ -95,9 +95,10 @@ export class CreateProjectUseCase implements ICreateProjectUseCase {
} }
} }
// Ensure the Gemini Image tool is always available by default // Conditionally include Gemini Image tool by default if GOOGLE_API_KEY is present
const hasGoogleKey = !!process.env.GOOGLE_API_KEY;
const hasImageTool = (workflow.tools || []).some(t => t.isGeminiImage || t.name === 'Generate Image'); const hasImageTool = (workflow.tools || []).some(t => t.isGeminiImage || t.name === 'Generate Image');
if (!hasImageTool) { if (hasGoogleKey && !hasImageTool) {
const imageTool = { const imageTool = {
name: 'Generate Image', name: 'Generate Image',
description: 'Generate an image using Google Gemini given a text prompt. Returns base64-encoded image data and any text parts.', description: 'Generate an image using Google Gemini given a text prompt. Returns base64-encoded image data and any text parts.',