Skip to content

Commit

Permalink
Merge pull request #1371 from proteanx/fixImageGen
Browse files Browse the repository at this point in the history
fix: image generation using imageSettings
  • Loading branch information
monilpat authored Dec 23, 2024
2 parents 7b19dd0 + 4bd5c7e commit c735ef7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
12 changes: 12 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 12 additions & 17 deletions packages/plugin-image-generation/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }[] = [];
Expand All @@ -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
);
Expand Down

0 comments on commit c735ef7

Please sign in to comment.