:boom: [ToFix] Unable to get and set default_model
Browse files- networks/endpoint_storage.js +27 -19
networks/endpoint_storage.js
CHANGED
@@ -15,7 +15,7 @@ class EndpointStorage {
|
|
15 |
this.db = new Dexie("endpoints");
|
16 |
this.db.version(1).stores({
|
17 |
endpoints: "index, endpoint, api_key",
|
18 |
-
|
19 |
});
|
20 |
this.db.endpoints.count((count) => {
|
21 |
console.log(`${count} endpoints loaded.`);
|
@@ -54,9 +54,10 @@ class EndpointStorage {
|
|
54 |
}
|
55 |
add_endpoint_and_api_key_item() {
|
56 |
let endpoint_and_api_key_items = $("#endpoint-and-api-key-items");
|
57 |
-
|
58 |
this.get_endpoint_and_api_key_item_html()
|
59 |
);
|
|
|
60 |
this.bind_endpoint_and_api_key_buttons();
|
61 |
}
|
62 |
create_endpoint_and_api_key_items() {
|
@@ -123,25 +124,32 @@ class EndpointStorage {
|
|
123 |
const option = new Option(value, value);
|
124 |
select.append(option);
|
125 |
});
|
126 |
-
});
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
-
|
144 |
-
|
|
|
|
|
145 |
}
|
146 |
render_endpoint_and_api_key_items() {
|
147 |
this.create_endpoint_and_api_key_items();
|
|
|
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.`);
|
|
|
54 |
}
|
55 |
add_endpoint_and_api_key_item() {
|
56 |
let endpoint_and_api_key_items = $("#endpoint-and-api-key-items");
|
57 |
+
let endpoint_and_api_key_item = $(
|
58 |
this.get_endpoint_and_api_key_item_html()
|
59 |
);
|
60 |
+
endpoint_and_api_key_items.prepend(endpoint_and_api_key_item);
|
61 |
this.bind_endpoint_and_api_key_buttons();
|
62 |
}
|
63 |
create_endpoint_and_api_key_items() {
|
|
|
124 |
const option = new Option(value, value);
|
125 |
select.append(option);
|
126 |
});
|
|
|
127 |
|
128 |
+
// set default model
|
129 |
+
let default_model = "";
|
130 |
+
let db_default_model = "";
|
131 |
+
this.db.data.get("default_model").then((value) => {
|
132 |
+
db_default_model = value;
|
133 |
+
console.log("db_default_model:", db_default_model);
|
134 |
+
if (
|
135 |
+
db_default_model &&
|
136 |
+
available_models.includes(db_default_model)
|
137 |
+
) {
|
138 |
+
default_model = db_default_model;
|
139 |
+
} else if (available_models) {
|
140 |
+
default_model = available_models[0];
|
141 |
+
this.db.data.put({
|
142 |
+
key: "default_model",
|
143 |
+
value: default_model,
|
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();
|