Expose imageModel to system prompt

This commit is contained in:
Alex Gleason committed 2025-12-09 00:33:54 -06:00
1 parent d8bf0d0432
commit 62b1a19f2d
2 files changed
+11 -3

No files matched your search

+6 -2
View File
@@ -63,7 +63,7 @@ export class SessionManager {
private listeners: Partial<Record<keyof SessionManagerEvents, Set<(...args: unknown[]) => void>>> = {};
private fs: JSRuntimeFS;
private nostr: NPool;
private getSettings: () => { providers: AIProvider[] };
private getSettings: () => { providers: AIProvider[]; imageModel?: string };
private getConfig: () => AppConfig;
private getDefaultConfig: () => AppConfig;
private getProviderModels?: () => Array<{ id: string; provider: string; contextLength?: number; pricing?: { prompt: import('decimal.js').Decimal; completion: import('decimal.js').Decimal } }>;
@@ -72,7 +72,7 @@ export class SessionManager {
constructor(
fs: JSRuntimeFS,
nostr: NPool,
getSettings: () => { providers: AIProvider[] },
getSettings: () => { providers: AIProvider[]; imageModel?: string },
getConfig: () => AppConfig,
getDefaultConfig: () => AppConfig,
getProviderModels?: () => Array<{ id: string; provider: string; contextLength?: number; pricing?: { prompt: import('decimal.js').Decimal; completion: import('decimal.js').Decimal } }>,
@@ -289,6 +289,9 @@ export class SessionManager {
baseURL: provider.baseURL,
};
// Get imageModel from settings
const settings = this.getSettings();
const systemPrompt = await makeSystemPrompt({
cwd: `${config.fsPathProjects}/${projectId}`,
fs: this.fs,
@@ -303,6 +306,7 @@ export class SessionManager {
projectTemplate,
model: modelInfo,
provider: providerInfo,
imageModel: settings.imageModel,
});
// Helper function to filter out unsupported image formats (keep only JPG/JPEG/PNG)
+5 -1
View File
@@ -33,6 +33,7 @@ export interface MakeSystemPromptOpts {
projectTemplate?: { name: string; description: string; url: string };
model: ModelInfo;
provider: ProviderInfo;
imageModel?: string;
}
/**
@@ -183,6 +184,8 @@ When a project is first created, you (the AI) choose an appropriate template fro
Shakespeare supports AI-powered image generation. Users can configure an image model in **Settings > AI** under the "Advanced" section.
{% if imageModel %}- **Configured Image Model**: {{ imageModel }}{% else %}- **Image Model Status**: Not configured{% endif %}
**Important Notes:**
- Not all models support image generation
- If users experience issues with image generation, they should try selecting a different image model in Settings > AI
@@ -250,7 +253,7 @@ Note: the badge should be displayed at its natural size. It is recommended to om
{{ AGENTS }}{% endif %}`;
export async function makeSystemPrompt(opts: MakeSystemPromptOpts): Promise<string> {
const { tools, mode, fs, cwd, config, defaultConfig, user, metadata, repositoryUrl, template, projectTemplate, model, provider } = opts;
const { tools, mode, fs, cwd, config, defaultConfig, user, metadata, repositoryUrl, template, projectTemplate, model, provider, imageModel } = opts;
// Add current date
const date = new Date().toLocaleDateString("en-US", {
@@ -334,6 +337,7 @@ export async function makeSystemPrompt(opts: MakeSystemPromptOpts): Promise<stri
projectTemplate,
model,
provider,
imageModel,
};
// Render the template with the context