update local models

This commit is contained in:
Stijnus 2025-02-18 21:51:02 +01:00
parent 10af7c9835
commit ca7f5ad26b
3 changed files with 16 additions and 44 deletions

View File

@ -238,7 +238,7 @@ export default function DebugTab() {
performance: false,
});
const { isLocalModel, providers } = useSettings();
const { providers } = useSettings();
// Subscribe to logStore updates
const logs = useStore(logStore.logs);
@ -1135,16 +1135,22 @@ export default function DebugTab() {
}
}, [providers]);
// Monitor isLocalModel changes and check status periodically
// Monitor Ollama provider status and check periodically
useEffect(() => {
// Check immediately when isLocalModel changes
checkOllamaStatus();
const ollamaProvider = providers?.Ollama;
// Set up periodic checks every 10 seconds
const intervalId = setInterval(checkOllamaStatus, 10000);
if (ollamaProvider?.settings?.enabled) {
// Check immediately when provider is enabled
checkOllamaStatus();
return () => clearInterval(intervalId);
}, [isLocalModel, checkOllamaStatus]);
// Set up periodic checks every 10 seconds
const intervalId = setInterval(checkOllamaStatus, 10000);
return () => clearInterval(intervalId);
}
return undefined;
}, [providers, checkOllamaStatus]);
// Replace the existing export button with this new component
const ExportButton = () => {
@ -1222,15 +1228,6 @@ export default function DebugTab() {
const ollamaProvider = providers?.Ollama;
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) {
return {
status: 'Disabled',

View File

@ -2,8 +2,6 @@ import { useStore } from '@nanostores/react';
import {
isDebugMode,
isEventLogsEnabled,
isLocalModelsEnabled,
LOCAL_PROVIDERS,
promptStore,
providersStore,
latestBranchStore,
@ -17,7 +15,6 @@ import {
updateAutoSelectTemplate,
updateContextOptimization,
updateEventLogs,
updateLocalModels,
updatePromptId,
} from '~/lib/stores/settings';
import { useCallback, useEffect, useState } from 'react';
@ -49,8 +46,6 @@ export interface UseSettingsReturn {
providers: Record<string, IProviderConfig>;
activeProviders: ProviderInfo[];
updateProviderSettings: (provider: string, config: IProviderSetting) => void;
isLocalModel: boolean;
enableLocalModels: (enabled: boolean) => void;
// Debug and development settings
debug: boolean;
@ -81,7 +76,6 @@ export function useSettings(): UseSettingsReturn {
const debug = useStore(isDebugMode);
const eventLogs = useStore(isEventLogsEnabled);
const promptId = useStore(promptStore);
const isLocalModel = useStore(isLocalModelsEnabled);
const isLatestBranch = useStore(latestBranchStore);
const autoSelectTemplate = useStore(autoSelectStarterTemplate);
const [activeProviders, setActiveProviders] = useState<ProviderInfo[]>([]);
@ -100,16 +94,12 @@ export function useSettings(): UseSettingsReturn {
});
useEffect(() => {
let active = Object.entries(providers)
const active = Object.entries(providers)
.filter(([_key, provider]) => provider.settings.enabled)
.map(([_k, p]) => p);
if (!isLocalModel) {
active = active.filter((p) => !LOCAL_PROVIDERS.includes(p.name));
}
setActiveProviders(active);
}, [providers, isLocalModel]);
}, [providers]);
const saveSettings = useCallback((newSettings: Partial<Settings>) => {
setSettings((prev) => {
@ -135,11 +125,6 @@ export function useSettings(): UseSettingsReturn {
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) => {
updatePromptId(id);
logStore.logSystem(`Prompt template updated to ${id}`);
@ -205,8 +190,6 @@ export function useSettings(): UseSettingsReturn {
providers,
activeProviders,
updateProviderSettings,
isLocalModel,
enableLocalModels,
debug,
enableDebugMode,
eventLogs,

View File

@ -129,7 +129,6 @@ const SETTINGS_KEYS = {
AUTO_SELECT_TEMPLATE: 'autoSelectTemplate',
CONTEXT_OPTIMIZATION: 'contextOptimizationEnabled',
EVENT_LOGS: 'isEventLogsEnabled',
LOCAL_MODELS: 'isLocalModelsEnabled',
PROMPT_ID: 'promptId',
DEVELOPER_MODE: 'isDeveloperMode',
} as const;
@ -159,7 +158,6 @@ const getInitialSettings = () => {
autoSelectTemplate: getStoredBoolean(SETTINGS_KEYS.AUTO_SELECT_TEMPLATE, true),
contextOptimization: getStoredBoolean(SETTINGS_KEYS.CONTEXT_OPTIMIZATION, 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',
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 enableContextOptimizationStore = atom<boolean>(initialSettings.contextOptimization);
export const isEventLogsEnabled = atom<boolean>(initialSettings.eventLogs);
export const isLocalModelsEnabled = atom<boolean>(initialSettings.localModels);
export const promptStore = atom<string>(initialSettings.promptId);
// 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));
};
export const updateLocalModels = (enabled: boolean) => {
isLocalModelsEnabled.set(enabled);
localStorage.setItem(SETTINGS_KEYS.LOCAL_MODELS, JSON.stringify(enabled));
};
export const updatePromptId = (id: string) => {
promptStore.set(id);
localStorage.setItem(SETTINGS_KEYS.PROMPT_ID, id);