mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-05-07 13:44:40 +00:00
update local models
This commit is contained in:
parent
10af7c9835
commit
ca7f5ad26b
@ -238,7 +238,7 @@ export default function DebugTab() {
|
|||||||
performance: false,
|
performance: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { isLocalModel, providers } = useSettings();
|
const { providers } = useSettings();
|
||||||
|
|
||||||
// Subscribe to logStore updates
|
// Subscribe to logStore updates
|
||||||
const logs = useStore(logStore.logs);
|
const logs = useStore(logStore.logs);
|
||||||
@ -1135,16 +1135,22 @@ export default function DebugTab() {
|
|||||||
}
|
}
|
||||||
}, [providers]);
|
}, [providers]);
|
||||||
|
|
||||||
// Monitor isLocalModel changes and check status periodically
|
// Monitor Ollama provider status and check periodically
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Check immediately when isLocalModel changes
|
const ollamaProvider = providers?.Ollama;
|
||||||
checkOllamaStatus();
|
|
||||||
|
|
||||||
// Set up periodic checks every 10 seconds
|
if (ollamaProvider?.settings?.enabled) {
|
||||||
const intervalId = setInterval(checkOllamaStatus, 10000);
|
// Check immediately when provider is enabled
|
||||||
|
checkOllamaStatus();
|
||||||
|
|
||||||
return () => clearInterval(intervalId);
|
// Set up periodic checks every 10 seconds
|
||||||
}, [isLocalModel, checkOllamaStatus]);
|
const intervalId = setInterval(checkOllamaStatus, 10000);
|
||||||
|
|
||||||
|
return () => clearInterval(intervalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}, [providers, checkOllamaStatus]);
|
||||||
|
|
||||||
// Replace the existing export button with this new component
|
// Replace the existing export button with this new component
|
||||||
const ExportButton = () => {
|
const ExportButton = () => {
|
||||||
@ -1222,15 +1228,6 @@ export default function DebugTab() {
|
|||||||
const ollamaProvider = providers?.Ollama;
|
const ollamaProvider = providers?.Ollama;
|
||||||
const isOllamaEnabled = ollamaProvider?.settings?.enabled;
|
const isOllamaEnabled = ollamaProvider?.settings?.enabled;
|
||||||
|
|
||||||
if (!isLocalModel) {
|
|
||||||
return {
|
|
||||||
status: 'Disabled',
|
|
||||||
color: 'text-red-500',
|
|
||||||
bgColor: 'bg-red-500',
|
|
||||||
message: 'Local models are disabled in settings',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isOllamaEnabled) {
|
if (!isOllamaEnabled) {
|
||||||
return {
|
return {
|
||||||
status: 'Disabled',
|
status: 'Disabled',
|
||||||
|
@ -2,8 +2,6 @@ import { useStore } from '@nanostores/react';
|
|||||||
import {
|
import {
|
||||||
isDebugMode,
|
isDebugMode,
|
||||||
isEventLogsEnabled,
|
isEventLogsEnabled,
|
||||||
isLocalModelsEnabled,
|
|
||||||
LOCAL_PROVIDERS,
|
|
||||||
promptStore,
|
promptStore,
|
||||||
providersStore,
|
providersStore,
|
||||||
latestBranchStore,
|
latestBranchStore,
|
||||||
@ -17,7 +15,6 @@ import {
|
|||||||
updateAutoSelectTemplate,
|
updateAutoSelectTemplate,
|
||||||
updateContextOptimization,
|
updateContextOptimization,
|
||||||
updateEventLogs,
|
updateEventLogs,
|
||||||
updateLocalModels,
|
|
||||||
updatePromptId,
|
updatePromptId,
|
||||||
} from '~/lib/stores/settings';
|
} from '~/lib/stores/settings';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
@ -49,8 +46,6 @@ export interface UseSettingsReturn {
|
|||||||
providers: Record<string, IProviderConfig>;
|
providers: Record<string, IProviderConfig>;
|
||||||
activeProviders: ProviderInfo[];
|
activeProviders: ProviderInfo[];
|
||||||
updateProviderSettings: (provider: string, config: IProviderSetting) => void;
|
updateProviderSettings: (provider: string, config: IProviderSetting) => void;
|
||||||
isLocalModel: boolean;
|
|
||||||
enableLocalModels: (enabled: boolean) => void;
|
|
||||||
|
|
||||||
// Debug and development settings
|
// Debug and development settings
|
||||||
debug: boolean;
|
debug: boolean;
|
||||||
@ -81,7 +76,6 @@ export function useSettings(): UseSettingsReturn {
|
|||||||
const debug = useStore(isDebugMode);
|
const debug = useStore(isDebugMode);
|
||||||
const eventLogs = useStore(isEventLogsEnabled);
|
const eventLogs = useStore(isEventLogsEnabled);
|
||||||
const promptId = useStore(promptStore);
|
const promptId = useStore(promptStore);
|
||||||
const isLocalModel = useStore(isLocalModelsEnabled);
|
|
||||||
const isLatestBranch = useStore(latestBranchStore);
|
const isLatestBranch = useStore(latestBranchStore);
|
||||||
const autoSelectTemplate = useStore(autoSelectStarterTemplate);
|
const autoSelectTemplate = useStore(autoSelectStarterTemplate);
|
||||||
const [activeProviders, setActiveProviders] = useState<ProviderInfo[]>([]);
|
const [activeProviders, setActiveProviders] = useState<ProviderInfo[]>([]);
|
||||||
@ -100,16 +94,12 @@ export function useSettings(): UseSettingsReturn {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let active = Object.entries(providers)
|
const active = Object.entries(providers)
|
||||||
.filter(([_key, provider]) => provider.settings.enabled)
|
.filter(([_key, provider]) => provider.settings.enabled)
|
||||||
.map(([_k, p]) => p);
|
.map(([_k, p]) => p);
|
||||||
|
|
||||||
if (!isLocalModel) {
|
|
||||||
active = active.filter((p) => !LOCAL_PROVIDERS.includes(p.name));
|
|
||||||
}
|
|
||||||
|
|
||||||
setActiveProviders(active);
|
setActiveProviders(active);
|
||||||
}, [providers, isLocalModel]);
|
}, [providers]);
|
||||||
|
|
||||||
const saveSettings = useCallback((newSettings: Partial<Settings>) => {
|
const saveSettings = useCallback((newSettings: Partial<Settings>) => {
|
||||||
setSettings((prev) => {
|
setSettings((prev) => {
|
||||||
@ -135,11 +125,6 @@ export function useSettings(): UseSettingsReturn {
|
|||||||
logStore.logSystem(`Event logs ${enabled ? 'enabled' : 'disabled'}`);
|
logStore.logSystem(`Event logs ${enabled ? 'enabled' : 'disabled'}`);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const enableLocalModels = useCallback((enabled: boolean) => {
|
|
||||||
updateLocalModels(enabled);
|
|
||||||
logStore.logSystem(`Local models ${enabled ? 'enabled' : 'disabled'}`);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const setPromptId = useCallback((id: string) => {
|
const setPromptId = useCallback((id: string) => {
|
||||||
updatePromptId(id);
|
updatePromptId(id);
|
||||||
logStore.logSystem(`Prompt template updated to ${id}`);
|
logStore.logSystem(`Prompt template updated to ${id}`);
|
||||||
@ -205,8 +190,6 @@ export function useSettings(): UseSettingsReturn {
|
|||||||
providers,
|
providers,
|
||||||
activeProviders,
|
activeProviders,
|
||||||
updateProviderSettings,
|
updateProviderSettings,
|
||||||
isLocalModel,
|
|
||||||
enableLocalModels,
|
|
||||||
debug,
|
debug,
|
||||||
enableDebugMode,
|
enableDebugMode,
|
||||||
eventLogs,
|
eventLogs,
|
||||||
|
@ -129,7 +129,6 @@ const SETTINGS_KEYS = {
|
|||||||
AUTO_SELECT_TEMPLATE: 'autoSelectTemplate',
|
AUTO_SELECT_TEMPLATE: 'autoSelectTemplate',
|
||||||
CONTEXT_OPTIMIZATION: 'contextOptimizationEnabled',
|
CONTEXT_OPTIMIZATION: 'contextOptimizationEnabled',
|
||||||
EVENT_LOGS: 'isEventLogsEnabled',
|
EVENT_LOGS: 'isEventLogsEnabled',
|
||||||
LOCAL_MODELS: 'isLocalModelsEnabled',
|
|
||||||
PROMPT_ID: 'promptId',
|
PROMPT_ID: 'promptId',
|
||||||
DEVELOPER_MODE: 'isDeveloperMode',
|
DEVELOPER_MODE: 'isDeveloperMode',
|
||||||
} as const;
|
} as const;
|
||||||
@ -159,7 +158,6 @@ const getInitialSettings = () => {
|
|||||||
autoSelectTemplate: getStoredBoolean(SETTINGS_KEYS.AUTO_SELECT_TEMPLATE, true),
|
autoSelectTemplate: getStoredBoolean(SETTINGS_KEYS.AUTO_SELECT_TEMPLATE, true),
|
||||||
contextOptimization: getStoredBoolean(SETTINGS_KEYS.CONTEXT_OPTIMIZATION, true),
|
contextOptimization: getStoredBoolean(SETTINGS_KEYS.CONTEXT_OPTIMIZATION, true),
|
||||||
eventLogs: getStoredBoolean(SETTINGS_KEYS.EVENT_LOGS, true),
|
eventLogs: getStoredBoolean(SETTINGS_KEYS.EVENT_LOGS, true),
|
||||||
localModels: getStoredBoolean(SETTINGS_KEYS.LOCAL_MODELS, false),
|
|
||||||
promptId: isBrowser ? localStorage.getItem(SETTINGS_KEYS.PROMPT_ID) || 'default' : 'default',
|
promptId: isBrowser ? localStorage.getItem(SETTINGS_KEYS.PROMPT_ID) || 'default' : 'default',
|
||||||
developerMode: getStoredBoolean(SETTINGS_KEYS.DEVELOPER_MODE, false),
|
developerMode: getStoredBoolean(SETTINGS_KEYS.DEVELOPER_MODE, false),
|
||||||
};
|
};
|
||||||
@ -172,7 +170,6 @@ export const latestBranchStore = atom<boolean>(initialSettings.latestBranch);
|
|||||||
export const autoSelectStarterTemplate = atom<boolean>(initialSettings.autoSelectTemplate);
|
export const autoSelectStarterTemplate = atom<boolean>(initialSettings.autoSelectTemplate);
|
||||||
export const enableContextOptimizationStore = atom<boolean>(initialSettings.contextOptimization);
|
export const enableContextOptimizationStore = atom<boolean>(initialSettings.contextOptimization);
|
||||||
export const isEventLogsEnabled = atom<boolean>(initialSettings.eventLogs);
|
export const isEventLogsEnabled = atom<boolean>(initialSettings.eventLogs);
|
||||||
export const isLocalModelsEnabled = atom<boolean>(initialSettings.localModels);
|
|
||||||
export const promptStore = atom<string>(initialSettings.promptId);
|
export const promptStore = atom<string>(initialSettings.promptId);
|
||||||
|
|
||||||
// Helper functions to update settings with persistence
|
// Helper functions to update settings with persistence
|
||||||
@ -196,11 +193,6 @@ export const updateEventLogs = (enabled: boolean) => {
|
|||||||
localStorage.setItem(SETTINGS_KEYS.EVENT_LOGS, JSON.stringify(enabled));
|
localStorage.setItem(SETTINGS_KEYS.EVENT_LOGS, JSON.stringify(enabled));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateLocalModels = (enabled: boolean) => {
|
|
||||||
isLocalModelsEnabled.set(enabled);
|
|
||||||
localStorage.setItem(SETTINGS_KEYS.LOCAL_MODELS, JSON.stringify(enabled));
|
|
||||||
};
|
|
||||||
|
|
||||||
export const updatePromptId = (id: string) => {
|
export const updatePromptId = (id: string) => {
|
||||||
promptStore.set(id);
|
promptStore.set(id);
|
||||||
localStorage.setItem(SETTINGS_KEYS.PROMPT_ID, id);
|
localStorage.setItem(SETTINGS_KEYS.PROMPT_ID, id);
|
||||||
|
Loading…
Reference in New Issue
Block a user