mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
- Refactored the new fine-tuned system prompt to heavily reduce token usage by removing redundent snippets and duplicate instructions while keeping the same strict rules in place. - Default prompt now uses this system prompt to reduce token usage by default
66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
import { getSystemPrompt } from './prompts/prompts';
|
|
import optimized from './prompts/optimized';
|
|
import { getFineTunedPrompt } from './prompts/new-prompt';
|
|
import type { DesignScheme } from '~/types/design-scheme';
|
|
|
|
export interface PromptOptions {
|
|
cwd: string;
|
|
allowedHtmlElements: string[];
|
|
modificationTagName: string;
|
|
designScheme?: DesignScheme;
|
|
supabase?: {
|
|
isConnected: boolean;
|
|
hasSelectedProject: boolean;
|
|
credentials?: {
|
|
anonKey?: string;
|
|
supabaseUrl?: string;
|
|
};
|
|
};
|
|
}
|
|
|
|
export class PromptLibrary {
|
|
static library: Record<
|
|
string,
|
|
{
|
|
label: string;
|
|
description: string;
|
|
get: (options: PromptOptions) => string;
|
|
}
|
|
> = {
|
|
default: {
|
|
label: 'Default Prompt',
|
|
description: 'An fine tuned prompt for better results and less token usage',
|
|
get: (options) => getFineTunedPrompt(options.cwd, options.supabase, options.designScheme),
|
|
},
|
|
original: {
|
|
label: 'Old Default Prompt',
|
|
description: 'The OG battle tested default system Prompt',
|
|
get: (options) => getSystemPrompt(options.cwd, options.supabase, options.designScheme),
|
|
},
|
|
optimized: {
|
|
label: 'Optimized Prompt (experimental)',
|
|
description: 'An Experimental version of the prompt for lower token usage',
|
|
get: (options) => optimized(options),
|
|
},
|
|
};
|
|
static getList() {
|
|
return Object.entries(this.library).map(([key, value]) => {
|
|
const { label, description } = value;
|
|
return {
|
|
id: key,
|
|
label,
|
|
description,
|
|
};
|
|
});
|
|
}
|
|
static getPropmtFromLibrary(promptId: string, options: PromptOptions) {
|
|
const prompt = this.library[promptId];
|
|
|
|
if (!prompt) {
|
|
throw 'Prompt Now Found';
|
|
}
|
|
|
|
return this.library[promptId]?.get(options);
|
|
}
|
|
}
|