:boom: [Fix] Revert default_model set from Dexie back to localStorage
Browse files- components/buttons_binder.js +2 -2
- networks/endpoint_storage.js +16 -23
components/buttons_binder.js
CHANGED
@@ -246,8 +246,8 @@ class AvailableModelsSelectBinder {
|
|
246 |
bind() {
|
247 |
const select = $("#available-models-select");
|
248 |
select.change(() => {
|
249 |
-
|
250 |
-
|
251 |
});
|
252 |
}
|
253 |
}
|
|
|
246 |
bind() {
|
247 |
const select = $("#available-models-select");
|
248 |
select.change(() => {
|
249 |
+
localStorage.setItem("default_model", select.val());
|
250 |
+
console.log("set default_model:", select.val());
|
251 |
});
|
252 |
}
|
253 |
}
|
networks/endpoint_storage.js
CHANGED
@@ -15,7 +15,6 @@ class EndpointStorage {
|
|
15 |
this.db = new Dexie("endpoints");
|
16 |
this.db.version(1).stores({
|
17 |
endpoints: "index, endpoint, api_key",
|
18 |
-
data: "",
|
19 |
});
|
20 |
this.db.endpoints.count((count) => {
|
21 |
console.log(`${count} endpoints loaded.`);
|
@@ -127,30 +126,24 @@ class EndpointStorage {
|
|
127 |
|
128 |
// set default model
|
129 |
let default_model = "";
|
130 |
-
let
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
} else {
|
146 |
-
default_model = "";
|
147 |
-
}
|
148 |
-
|
149 |
-
select.val(default_model);
|
150 |
-
console.log(`default_model: ${select.val()}`);
|
151 |
-
});
|
152 |
});
|
153 |
}
|
|
|
154 |
render_endpoint_and_api_key_items() {
|
155 |
this.create_endpoint_and_api_key_items();
|
156 |
this.bind_endpoint_and_api_key_buttons();
|
|
|
15 |
this.db = new Dexie("endpoints");
|
16 |
this.db.version(1).stores({
|
17 |
endpoints: "index, endpoint, api_key",
|
|
|
18 |
});
|
19 |
this.db.endpoints.count((count) => {
|
20 |
console.log(`${count} endpoints loaded.`);
|
|
|
126 |
|
127 |
// set default model
|
128 |
let default_model = "";
|
129 |
+
let storage_default_model = localStorage.getItem("default_model");
|
130 |
+
console.log("storage_default_model:", storage_default_model);
|
131 |
+
if (
|
132 |
+
storage_default_model &&
|
133 |
+
available_models.includes(storage_default_model)
|
134 |
+
) {
|
135 |
+
default_model = storage_default_model;
|
136 |
+
} else if (available_models) {
|
137 |
+
default_model = available_models[0];
|
138 |
+
localStorage.setItem("default_model", default_model);
|
139 |
+
} else {
|
140 |
+
default_model = "";
|
141 |
+
}
|
142 |
+
select.val(default_model);
|
143 |
+
console.log(`default_model: ${select.val()}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
});
|
145 |
}
|
146 |
+
|
147 |
render_endpoint_and_api_key_items() {
|
148 |
this.create_endpoint_and_api_key_items();
|
149 |
this.bind_endpoint_and_api_key_buttons();
|