bolt.diy/app/lib/stores/settings.ts

53 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-12-10 13:07:23 +00:00
import { atom, map } from 'nanostores';
import { workbenchStore } from './workbench';
2024-12-10 13:07:23 +00:00
import { PROVIDER_LIST } from '~/utils/constants';
2024-12-11 08:32:21 +00:00
import type { IProviderConfig } from '~/types/model';
export interface Shortcut {
key: string;
ctrlKey?: boolean;
shiftKey?: boolean;
altKey?: boolean;
metaKey?: boolean;
ctrlOrMetaKey?: boolean;
action: () => void;
}
export interface Shortcuts {
toggleTerminal: Shortcut;
}
2024-12-10 13:07:23 +00:00
export const URL_CONFIGURABLE_PROVIDERS = ['Ollama', 'LMStudio', 'OpenAILike'];
export const LOCAL_PROVIDERS = ['OpenAILike', 'LMStudio', 'Ollama'];
2024-12-10 13:07:23 +00:00
export type ProviderSetting = Record<string, IProviderConfig>;
2024-12-07 15:27:50 +00:00
export const shortcutsStore = map<Shortcuts>({
toggleTerminal: {
key: 'j',
ctrlOrMetaKey: true,
action: () => workbenchStore.toggleTerminal(),
},
});
2024-12-10 13:07:23 +00:00
const initialProviderSettings: ProviderSetting = {};
PROVIDER_LIST.forEach((provider) => {
initialProviderSettings[provider.name] = {
...provider,
settings: {
2024-12-13 05:49:57 +00:00
enabled: true,
2024-12-10 13:07:23 +00:00
},
};
});
2024-12-10 13:07:23 +00:00
export const providersStore = map<ProviderSetting>(initialProviderSettings);
2024-12-10 13:07:23 +00:00
export const isDebugMode = atom(false);
export const isEventLogsEnabled = atom(false);
2024-12-10 13:07:23 +00:00
export const isLocalModelsEnabled = atom(true);
export const promptStore = atom<string>('default');
export const latestBranchStore = atom(false);