diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 8bb331e897..6fafa4ede8 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -707,6 +707,18 @@ export type Character = { settings?: { secrets?: { [key: string]: string }; intiface?: boolean; + imageSettings?: { + steps?: number; + width?: number; + height?: number; + negativePrompt?: string; + numIterations?: number; + guidanceScale?: number; + seed?: number; + modelId?: string; + jobId?: string; + count?: number; + }; voice?: { model?: string; // For VITS url?: string; // Legacy VITS support diff --git a/packages/plugin-image-generation/src/index.ts b/packages/plugin-image-generation/src/index.ts index 1c9d0305ae..4600fb3a3d 100644 --- a/packages/plugin-image-generation/src/index.ts +++ b/packages/plugin-image-generation/src/index.ts @@ -120,6 +120,9 @@ const imageGeneration: Action = { const imagePrompt = message.content.text; elizaLogger.log("Image prompt received:", imagePrompt); + const imageSettings = runtime.character?.settings?.imageSettings || {}; + elizaLogger.log("Image settings:", imageSettings); + // TODO: Generate a prompt for the image const res: { image: string; caption: string }[] = []; @@ -128,23 +131,15 @@ const imageGeneration: Action = { const images = await generateImage( { prompt: imagePrompt, - width: options.width || 1024, - height: options.height || 1024, - ...(options.count != null ? { count: options.count || 1 } : {}), - ...(options.negativePrompt != null - ? { negativePrompt: options.negativePrompt } - : {}), - ...(options.numIterations != null - ? { numIterations: options.numIterations } - : {}), - ...(options.guidanceScale != null - ? { guidanceScale: options.guidanceScale } - : {}), - ...(options.seed != null ? { seed: options.seed } : {}), - ...(options.modelId != null - ? { modelId: options.modelId } - : {}), - ...(options.jobId != null ? { jobId: options.jobId } : {}), + width: options.width || imageSettings.width || 1024, + height: options.height || imageSettings.height || 1024, + ...(options.count != null || imageSettings.count != null ? { count: options.count || imageSettings.count || 1 } : {}), + ...(options.negativePrompt != null || imageSettings.negativePrompt != null ? { negativePrompt: options.negativePrompt || imageSettings.negativePrompt } : {}), + ...(options.numIterations != null || imageSettings.numIterations != null ? { numIterations: options.numIterations || imageSettings.numIterations } : {}), + ...(options.guidanceScale != null || imageSettings.guidanceScale != null ? { guidanceScale: options.guidanceScale || imageSettings.guidanceScale } : {}), + ...(options.seed != null || imageSettings.seed != null ? { seed: options.seed || imageSettings.seed } : {}), + ...(options.modelId != null || imageSettings.modelId != null ? { modelId: options.modelId || imageSettings.modelId } : {}), + ...(options.jobId != null || imageSettings.jobId != null ? { jobId: options.jobId || imageSettings.jobId } : {}), }, runtime );