mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-05-04 04:11:20 +00:00
This commit introduces the ability to fetch and store Supabase API keys and URL credentials when a project is selected. This enables the application to dynamically configure the Supabase connection environment variables, improving the integration with Supabase services. The changes include updates to the Supabase connection logic, new API endpoints, and modifications to the chat and prompt components to utilize the new credentials.
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import { getSystemPrompt } from './prompts/prompts';
|
|
import optimized from './prompts/optimized';
|
|
|
|
export interface PromptOptions {
|
|
cwd: string;
|
|
allowedHtmlElements: string[];
|
|
modificationTagName: string;
|
|
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: 'This is the battle tested default system Prompt',
|
|
get: (options) => getSystemPrompt(options.cwd, options.supabase),
|
|
},
|
|
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);
|
|
}
|
|
}
|