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

47 lines
1.2 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: {
enabled: false,
},
};
});
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 isLocalModelsEnabled = atom(true);