Stijnus
commited on
Commit
·
ca7f5ad
1
Parent(s):
10af7c9
update local models
Browse files
app/components/@settings/tabs/debug/DebugTab.tsx
CHANGED
@@ -238,7 +238,7 @@ export default function DebugTab() {
|
|
238 |
performance: false,
|
239 |
});
|
240 |
|
241 |
-
const {
|
242 |
|
243 |
// Subscribe to logStore updates
|
244 |
const logs = useStore(logStore.logs);
|
@@ -1135,16 +1135,22 @@ export default function DebugTab() {
|
|
1135 |
}
|
1136 |
}, [providers]);
|
1137 |
|
1138 |
-
// Monitor
|
1139 |
useEffect(() => {
|
1140 |
-
|
1141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1142 |
|
1143 |
-
|
1144 |
-
|
1145 |
|
1146 |
-
return
|
1147 |
-
}, [
|
1148 |
|
1149 |
// Replace the existing export button with this new component
|
1150 |
const ExportButton = () => {
|
@@ -1222,15 +1228,6 @@ export default function DebugTab() {
|
|
1222 |
const ollamaProvider = providers?.Ollama;
|
1223 |
const isOllamaEnabled = ollamaProvider?.settings?.enabled;
|
1224 |
|
1225 |
-
if (!isLocalModel) {
|
1226 |
-
return {
|
1227 |
-
status: 'Disabled',
|
1228 |
-
color: 'text-red-500',
|
1229 |
-
bgColor: 'bg-red-500',
|
1230 |
-
message: 'Local models are disabled in settings',
|
1231 |
-
};
|
1232 |
-
}
|
1233 |
-
|
1234 |
if (!isOllamaEnabled) {
|
1235 |
return {
|
1236 |
status: 'Disabled',
|
|
|
238 |
performance: false,
|
239 |
});
|
240 |
|
241 |
+
const { providers } = useSettings();
|
242 |
|
243 |
// Subscribe to logStore updates
|
244 |
const logs = useStore(logStore.logs);
|
|
|
1135 |
}
|
1136 |
}, [providers]);
|
1137 |
|
1138 |
+
// Monitor Ollama provider status and check periodically
|
1139 |
useEffect(() => {
|
1140 |
+
const ollamaProvider = providers?.Ollama;
|
1141 |
+
|
1142 |
+
if (ollamaProvider?.settings?.enabled) {
|
1143 |
+
// Check immediately when provider is enabled
|
1144 |
+
checkOllamaStatus();
|
1145 |
+
|
1146 |
+
// Set up periodic checks every 10 seconds
|
1147 |
+
const intervalId = setInterval(checkOllamaStatus, 10000);
|
1148 |
|
1149 |
+
return () => clearInterval(intervalId);
|
1150 |
+
}
|
1151 |
|
1152 |
+
return undefined;
|
1153 |
+
}, [providers, checkOllamaStatus]);
|
1154 |
|
1155 |
// Replace the existing export button with this new component
|
1156 |
const ExportButton = () => {
|
|
|
1228 |
const ollamaProvider = providers?.Ollama;
|
1229 |
const isOllamaEnabled = ollamaProvider?.settings?.enabled;
|
1230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1231 |
if (!isOllamaEnabled) {
|
1232 |
return {
|
1233 |
status: 'Disabled',
|
app/lib/hooks/useSettings.ts
CHANGED
@@ -2,8 +2,6 @@ import { useStore } from '@nanostores/react';
|
|
2 |
import {
|
3 |
isDebugMode,
|
4 |
isEventLogsEnabled,
|
5 |
-
isLocalModelsEnabled,
|
6 |
-
LOCAL_PROVIDERS,
|
7 |
promptStore,
|
8 |
providersStore,
|
9 |
latestBranchStore,
|
@@ -17,7 +15,6 @@ import {
|
|
17 |
updateAutoSelectTemplate,
|
18 |
updateContextOptimization,
|
19 |
updateEventLogs,
|
20 |
-
updateLocalModels,
|
21 |
updatePromptId,
|
22 |
} from '~/lib/stores/settings';
|
23 |
import { useCallback, useEffect, useState } from 'react';
|
@@ -49,8 +46,6 @@ export interface UseSettingsReturn {
|
|
49 |
providers: Record<string, IProviderConfig>;
|
50 |
activeProviders: ProviderInfo[];
|
51 |
updateProviderSettings: (provider: string, config: IProviderSetting) => void;
|
52 |
-
isLocalModel: boolean;
|
53 |
-
enableLocalModels: (enabled: boolean) => void;
|
54 |
|
55 |
// Debug and development settings
|
56 |
debug: boolean;
|
@@ -81,7 +76,6 @@ export function useSettings(): UseSettingsReturn {
|
|
81 |
const debug = useStore(isDebugMode);
|
82 |
const eventLogs = useStore(isEventLogsEnabled);
|
83 |
const promptId = useStore(promptStore);
|
84 |
-
const isLocalModel = useStore(isLocalModelsEnabled);
|
85 |
const isLatestBranch = useStore(latestBranchStore);
|
86 |
const autoSelectTemplate = useStore(autoSelectStarterTemplate);
|
87 |
const [activeProviders, setActiveProviders] = useState<ProviderInfo[]>([]);
|
@@ -100,16 +94,12 @@ export function useSettings(): UseSettingsReturn {
|
|
100 |
});
|
101 |
|
102 |
useEffect(() => {
|
103 |
-
|
104 |
.filter(([_key, provider]) => provider.settings.enabled)
|
105 |
.map(([_k, p]) => p);
|
106 |
|
107 |
-
if (!isLocalModel) {
|
108 |
-
active = active.filter((p) => !LOCAL_PROVIDERS.includes(p.name));
|
109 |
-
}
|
110 |
-
|
111 |
setActiveProviders(active);
|
112 |
-
}, [providers
|
113 |
|
114 |
const saveSettings = useCallback((newSettings: Partial<Settings>) => {
|
115 |
setSettings((prev) => {
|
@@ -135,11 +125,6 @@ export function useSettings(): UseSettingsReturn {
|
|
135 |
logStore.logSystem(`Event logs ${enabled ? 'enabled' : 'disabled'}`);
|
136 |
}, []);
|
137 |
|
138 |
-
const enableLocalModels = useCallback((enabled: boolean) => {
|
139 |
-
updateLocalModels(enabled);
|
140 |
-
logStore.logSystem(`Local models ${enabled ? 'enabled' : 'disabled'}`);
|
141 |
-
}, []);
|
142 |
-
|
143 |
const setPromptId = useCallback((id: string) => {
|
144 |
updatePromptId(id);
|
145 |
logStore.logSystem(`Prompt template updated to ${id}`);
|
@@ -205,8 +190,6 @@ export function useSettings(): UseSettingsReturn {
|
|
205 |
providers,
|
206 |
activeProviders,
|
207 |
updateProviderSettings,
|
208 |
-
isLocalModel,
|
209 |
-
enableLocalModels,
|
210 |
debug,
|
211 |
enableDebugMode,
|
212 |
eventLogs,
|
|
|
2 |
import {
|
3 |
isDebugMode,
|
4 |
isEventLogsEnabled,
|
|
|
|
|
5 |
promptStore,
|
6 |
providersStore,
|
7 |
latestBranchStore,
|
|
|
15 |
updateAutoSelectTemplate,
|
16 |
updateContextOptimization,
|
17 |
updateEventLogs,
|
|
|
18 |
updatePromptId,
|
19 |
} from '~/lib/stores/settings';
|
20 |
import { useCallback, useEffect, useState } from 'react';
|
|
|
46 |
providers: Record<string, IProviderConfig>;
|
47 |
activeProviders: ProviderInfo[];
|
48 |
updateProviderSettings: (provider: string, config: IProviderSetting) => void;
|
|
|
|
|
49 |
|
50 |
// Debug and development settings
|
51 |
debug: boolean;
|
|
|
76 |
const debug = useStore(isDebugMode);
|
77 |
const eventLogs = useStore(isEventLogsEnabled);
|
78 |
const promptId = useStore(promptStore);
|
|
|
79 |
const isLatestBranch = useStore(latestBranchStore);
|
80 |
const autoSelectTemplate = useStore(autoSelectStarterTemplate);
|
81 |
const [activeProviders, setActiveProviders] = useState<ProviderInfo[]>([]);
|
|
|
94 |
});
|
95 |
|
96 |
useEffect(() => {
|
97 |
+
const active = Object.entries(providers)
|
98 |
.filter(([_key, provider]) => provider.settings.enabled)
|
99 |
.map(([_k, p]) => p);
|
100 |
|
|
|
|
|
|
|
|
|
101 |
setActiveProviders(active);
|
102 |
+
}, [providers]);
|
103 |
|
104 |
const saveSettings = useCallback((newSettings: Partial<Settings>) => {
|
105 |
setSettings((prev) => {
|
|
|
125 |
logStore.logSystem(`Event logs ${enabled ? 'enabled' : 'disabled'}`);
|
126 |
}, []);
|
127 |
|
|
|
|
|
|
|
|
|
|
|
128 |
const setPromptId = useCallback((id: string) => {
|
129 |
updatePromptId(id);
|
130 |
logStore.logSystem(`Prompt template updated to ${id}`);
|
|
|
190 |
providers,
|
191 |
activeProviders,
|
192 |
updateProviderSettings,
|
|
|
|
|
193 |
debug,
|
194 |
enableDebugMode,
|
195 |
eventLogs,
|
app/lib/stores/settings.ts
CHANGED
@@ -129,7 +129,6 @@ const SETTINGS_KEYS = {
|
|
129 |
AUTO_SELECT_TEMPLATE: 'autoSelectTemplate',
|
130 |
CONTEXT_OPTIMIZATION: 'contextOptimizationEnabled',
|
131 |
EVENT_LOGS: 'isEventLogsEnabled',
|
132 |
-
LOCAL_MODELS: 'isLocalModelsEnabled',
|
133 |
PROMPT_ID: 'promptId',
|
134 |
DEVELOPER_MODE: 'isDeveloperMode',
|
135 |
} as const;
|
@@ -159,7 +158,6 @@ const getInitialSettings = () => {
|
|
159 |
autoSelectTemplate: getStoredBoolean(SETTINGS_KEYS.AUTO_SELECT_TEMPLATE, true),
|
160 |
contextOptimization: getStoredBoolean(SETTINGS_KEYS.CONTEXT_OPTIMIZATION, true),
|
161 |
eventLogs: getStoredBoolean(SETTINGS_KEYS.EVENT_LOGS, true),
|
162 |
-
localModels: getStoredBoolean(SETTINGS_KEYS.LOCAL_MODELS, false),
|
163 |
promptId: isBrowser ? localStorage.getItem(SETTINGS_KEYS.PROMPT_ID) || 'default' : 'default',
|
164 |
developerMode: getStoredBoolean(SETTINGS_KEYS.DEVELOPER_MODE, false),
|
165 |
};
|
@@ -172,7 +170,6 @@ export const latestBranchStore = atom<boolean>(initialSettings.latestBranch);
|
|
172 |
export const autoSelectStarterTemplate = atom<boolean>(initialSettings.autoSelectTemplate);
|
173 |
export const enableContextOptimizationStore = atom<boolean>(initialSettings.contextOptimization);
|
174 |
export const isEventLogsEnabled = atom<boolean>(initialSettings.eventLogs);
|
175 |
-
export const isLocalModelsEnabled = atom<boolean>(initialSettings.localModels);
|
176 |
export const promptStore = atom<string>(initialSettings.promptId);
|
177 |
|
178 |
// Helper functions to update settings with persistence
|
@@ -196,11 +193,6 @@ export const updateEventLogs = (enabled: boolean) => {
|
|
196 |
localStorage.setItem(SETTINGS_KEYS.EVENT_LOGS, JSON.stringify(enabled));
|
197 |
};
|
198 |
|
199 |
-
export const updateLocalModels = (enabled: boolean) => {
|
200 |
-
isLocalModelsEnabled.set(enabled);
|
201 |
-
localStorage.setItem(SETTINGS_KEYS.LOCAL_MODELS, JSON.stringify(enabled));
|
202 |
-
};
|
203 |
-
|
204 |
export const updatePromptId = (id: string) => {
|
205 |
promptStore.set(id);
|
206 |
localStorage.setItem(SETTINGS_KEYS.PROMPT_ID, id);
|
|
|
129 |
AUTO_SELECT_TEMPLATE: 'autoSelectTemplate',
|
130 |
CONTEXT_OPTIMIZATION: 'contextOptimizationEnabled',
|
131 |
EVENT_LOGS: 'isEventLogsEnabled',
|
|
|
132 |
PROMPT_ID: 'promptId',
|
133 |
DEVELOPER_MODE: 'isDeveloperMode',
|
134 |
} as const;
|
|
|
158 |
autoSelectTemplate: getStoredBoolean(SETTINGS_KEYS.AUTO_SELECT_TEMPLATE, true),
|
159 |
contextOptimization: getStoredBoolean(SETTINGS_KEYS.CONTEXT_OPTIMIZATION, true),
|
160 |
eventLogs: getStoredBoolean(SETTINGS_KEYS.EVENT_LOGS, true),
|
|
|
161 |
promptId: isBrowser ? localStorage.getItem(SETTINGS_KEYS.PROMPT_ID) || 'default' : 'default',
|
162 |
developerMode: getStoredBoolean(SETTINGS_KEYS.DEVELOPER_MODE, false),
|
163 |
};
|
|
|
170 |
export const autoSelectStarterTemplate = atom<boolean>(initialSettings.autoSelectTemplate);
|
171 |
export const enableContextOptimizationStore = atom<boolean>(initialSettings.contextOptimization);
|
172 |
export const isEventLogsEnabled = atom<boolean>(initialSettings.eventLogs);
|
|
|
173 |
export const promptStore = atom<string>(initialSettings.promptId);
|
174 |
|
175 |
// Helper functions to update settings with persistence
|
|
|
193 |
localStorage.setItem(SETTINGS_KEYS.EVENT_LOGS, JSON.stringify(enabled));
|
194 |
};
|
195 |
|
|
|
|
|
|
|
|
|
|
|
196 |
export const updatePromptId = (id: string) => {
|
197 |
promptStore.set(id);
|
198 |
localStorage.setItem(SETTINGS_KEYS.PROMPT_ID, id);
|