-
-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathsetProviderModelDiscoveryMode.ts
More file actions
35 lines (30 loc) · 863 Bytes
/
setProviderModelDiscoveryMode.ts
File metadata and controls
35 lines (30 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type QuickAdd from "src/main";
import { settingsStore } from "src/settingsStore";
import type { Migration } from "./Migrations";
import { deepClone } from "src/utils/deepClone";
const setProviderModelDiscoveryMode: Migration = {
description:
"Ensure every AI provider has a discovery mode so browsing works without models.dev",
migrate: async (_plugin: QuickAdd) => {
const currentSettings = settingsStore.getState();
const providers = currentSettings.ai.providers ?? [];
let updated = false;
for (const provider of providers) {
if (!provider.modelSource) {
provider.modelSource = "auto";
updated = true;
}
}
if (!updated) {
return;
}
settingsStore.setState((state) => ({
...state,
ai: {
...state.ai,
providers: deepClone(providers),
},
}));
},
};
export default setProviderModelDiscoveryMode;