Skip to content

Commit ca4f36f

Browse files
authored
Merge pull request #75 from LlamaEnjoyer/model_search_and_add_tweaks
feat: Improve model search and add debouncing
2 parents 6906b14 + 531c688 commit ca4f36f

File tree

5 files changed

+51
-10
lines changed

5 files changed

+51
-10
lines changed

server.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@ def api_reset_to_app_defaults():
498498
sampling_params = [
499499
"temperature", "top_k", "top_p", "min_p", "tfs",
500500
"mirostat", "mirostat_tau", "mirostat_eta", "typical",
501-
"repp", "repr", "repd", "quad_sampling", "temperature_last", "skew"
501+
"repp", "repr", "repd", "quad_sampling", "temperature_last", "skew",
502+
"dry_base", "dry_multiplier", "dry_range"
502503
]
503504

504505
# Reset only sampling parameters to defaults

static/chatsettings.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ export class SessionSettings {
138138
mirostat: this.sss_i_mirostat.element,
139139
mirostat_tau: this.sss_i_mirostat_tau.element.querySelector(".sss-item-left"),
140140
mirostat_eta: this.sss_i_mirostat_eta.element.querySelector(".sss-item-left"),
141-
temperature_last: this.sss_i_temperature_last.element
141+
temperature_last: this.sss_i_temperature_last.element,
142+
dry_base: this.sss_i_dry_base.element.querySelector(".sss-item-left"),
143+
dry_multiplier: this.sss_i_dry_multiplier.element.querySelector(".sss-item-left"),
144+
dry_range: this.sss_i_dry_range.element.querySelector(".sss-item-left")
142145
};
143146

144147
// Helper function to toggle label highlights
@@ -193,7 +196,8 @@ export class SessionSettings {
193196
const samplingParams = [
194197
"temperature", "top_k", "top_p", "min_p", "tfs",
195198
"mirostat", "mirostat_tau", "mirostat_eta", "typical",
196-
"repp", "repr", "quad_sampling", "temperature_last", "skew"
199+
"repp", "repr", "quad_sampling", "temperature_last", "skew",
200+
"dry_base", "dry_multiplier", "dry_range"
197201
];
198202

199203
const diffParams = {};
@@ -255,7 +259,8 @@ export class SessionSettings {
255259
this.sss_i_minP, this.sss_i_quadSampling, this.sss_i_tfs,
256260
this.sss_i_typical, this.sss_i_skew, this.sss_i_repPenalty,
257261
this.sss_i_repRange, this.sss_i_mirostat, this.sss_i_mirostat_tau,
258-
this.sss_i_mirostat_eta, this.sss_i_temperature_last
262+
this.sss_i_mirostat_eta, this.sss_i_temperature_last,
263+
this.sss_i_dry_base, this.sss_i_dry_multiplier, this.sss_i_dry_range
259264
];
260265

261266
// Helper function to update button states

static/models.css

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111
}
1212

1313
.model-search-box {
14-
flex-grow: 1;
14+
width: 215px;
15+
min-width: 215px;
1516
background-color: var(--textbox-background);
1617
color: var(--textcolor-text);
1718
border-radius: 5px;
1819
border: 1px solid var(--textbox-border);
19-
padding: 5px;
20+
padding-top: 5px;
21+
padding-bottom: 5px;
22+
padding-left: 5px;
23+
padding-right: 25px; /* Space for clear button */
2024
font-size: var(--font-size-medium);
2125
}
2226

static/models.js

+25-3
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ export class Models {
5252
this.searchBox.tb.value = "";
5353
this.populateModelList();
5454
});
55-
this.searchBox.tb.addEventListener("input", () => {
55+
this.searchBox.tb.addEventListener("input", util.debounce(() => {
5656
this.searchState = this.searchBox.tb.value;
5757
this.populateModelList();
58-
});
58+
}, 400)); // delay in ms
5959
this.searchBox.tb.addEventListener("keydown", () => {
6060
if (event.key === 'Escape' || event.keyCode === 27) {
6161
this.searchState = this.textbox_initial;
@@ -191,6 +191,14 @@ export class ModelView {
191191
this.error_message = "";
192192
}
193193

194+
getFolderName(path) {
195+
if (!path) return null;
196+
// Remove trailing slash if present
197+
path = path.replace(/[/\\]$/, '');
198+
// Get the last part of the path (the folder name)
199+
return path.split(/[/\\]/).pop();
200+
}
201+
194202
updateView() {
195203
if (!this.modelID || this.modelID == "new") {
196204
let model_info = {};
@@ -218,6 +226,12 @@ export class ModelView {
218226
send(post = null) {
219227
let packet = {};
220228
packet.model_info = this.modelInfo;
229+
if (this.modelID == "new") {
230+
let folderName = this.getFolderName(this.modelInfo.model_directory);
231+
if (folderName) {
232+
this.modelInfo.name = folderName;
233+
}
234+
}
221235
fetch("/api/update_model", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(packet) })
222236
.then(response => response.json())
223237
.then(response => {
@@ -346,7 +360,15 @@ export class ModelView {
346360
this.element.appendChild(util.newDiv(null, "model-view-text divider", ""));
347361
this.element.appendChild(util.newDiv(null, "model-view-text spacer", ""));
348362

349-
this.tb_model_directory = new controls.LabelTextbox("model-view-item-left", "Model directory", "model-view-item-textbox wide", "~/models/my_model/", this.modelInfo, "model_directory", null, () => { this.send() } );
363+
this.tb_model_directory = new controls.LabelTextbox("model-view-item-left", "Model directory", "model-view-item-textbox wide", "~/models/my_model/", this.modelInfo, "model_directory", null, () => {
364+
if (this.modelID == "new") {
365+
let folderName = this.getFolderName(this.modelInfo.model_directory);
366+
if (folderName) {
367+
this.modelInfo.name = folderName;
368+
}
369+
}
370+
this.send();
371+
});
350372
this.element.appendChild(this.tb_model_directory.element);
351373

352374
this.element_model = util.newHFlex();

static/util.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
export function assert(condition, message) {
32
if (!condition) {
43
throw new Error(message || "Assertion failed");
@@ -209,3 +208,13 @@ export function saveStringDialog(textString, filename) {
209208
document.body.removeChild(downloadLink);
210209
URL.revokeObjectURL(textUrl);
211210
}
211+
212+
export function debounce(func, delay) {
213+
let timeoutId;
214+
return function(...args) {
215+
clearTimeout(timeoutId);
216+
timeoutId = setTimeout(() => {
217+
func.apply(this, args);
218+
}, delay);
219+
};
220+
}

0 commit comments

Comments
 (0)