Skip to content

Commit c735ef7

Browse files
authored
Merge pull request elizaOS#1371 from proteanx/fixImageGen
fix: image generation using imageSettings
2 parents 7b19dd0 + 4bd5c7e commit c735ef7

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

packages/core/src/types.ts

+12
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,18 @@ export type Character = {
707707
settings?: {
708708
secrets?: { [key: string]: string };
709709
intiface?: boolean;
710+
imageSettings?: {
711+
steps?: number;
712+
width?: number;
713+
height?: number;
714+
negativePrompt?: string;
715+
numIterations?: number;
716+
guidanceScale?: number;
717+
seed?: number;
718+
modelId?: string;
719+
jobId?: string;
720+
count?: number;
721+
};
710722
voice?: {
711723
model?: string; // For VITS
712724
url?: string; // Legacy VITS support

packages/plugin-image-generation/src/index.ts

+12-17
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ const imageGeneration: Action = {
120120
const imagePrompt = message.content.text;
121121
elizaLogger.log("Image prompt received:", imagePrompt);
122122

123+
const imageSettings = runtime.character?.settings?.imageSettings || {};
124+
elizaLogger.log("Image settings:", imageSettings);
125+
123126
// TODO: Generate a prompt for the image
124127

125128
const res: { image: string; caption: string }[] = [];
@@ -128,23 +131,15 @@ const imageGeneration: Action = {
128131
const images = await generateImage(
129132
{
130133
prompt: imagePrompt,
131-
width: options.width || 1024,
132-
height: options.height || 1024,
133-
...(options.count != null ? { count: options.count || 1 } : {}),
134-
...(options.negativePrompt != null
135-
? { negativePrompt: options.negativePrompt }
136-
: {}),
137-
...(options.numIterations != null
138-
? { numIterations: options.numIterations }
139-
: {}),
140-
...(options.guidanceScale != null
141-
? { guidanceScale: options.guidanceScale }
142-
: {}),
143-
...(options.seed != null ? { seed: options.seed } : {}),
144-
...(options.modelId != null
145-
? { modelId: options.modelId }
146-
: {}),
147-
...(options.jobId != null ? { jobId: options.jobId } : {}),
134+
width: options.width || imageSettings.width || 1024,
135+
height: options.height || imageSettings.height || 1024,
136+
...(options.count != null || imageSettings.count != null ? { count: options.count || imageSettings.count || 1 } : {}),
137+
...(options.negativePrompt != null || imageSettings.negativePrompt != null ? { negativePrompt: options.negativePrompt || imageSettings.negativePrompt } : {}),
138+
...(options.numIterations != null || imageSettings.numIterations != null ? { numIterations: options.numIterations || imageSettings.numIterations } : {}),
139+
...(options.guidanceScale != null || imageSettings.guidanceScale != null ? { guidanceScale: options.guidanceScale || imageSettings.guidanceScale } : {}),
140+
...(options.seed != null || imageSettings.seed != null ? { seed: options.seed || imageSettings.seed } : {}),
141+
...(options.modelId != null || imageSettings.modelId != null ? { modelId: options.modelId || imageSettings.modelId } : {}),
142+
...(options.jobId != null || imageSettings.jobId != null ? { jobId: options.jobId || imageSettings.jobId } : {}),
148143
},
149144
runtime
150145
);

0 commit comments

Comments
 (0)