diff --git a/embd_res/kcpp_musicui.embd b/embd_res/kcpp_musicui.embd index c78fcf329..4ac2f5d9d 100644 --- a/embd_res/kcpp_musicui.embd +++ b/embd_res/kcpp_musicui.embd @@ -890,7 +890,7 @@ function loadTrack(id, callback) { showMessage("No JSON data found."); return; } - callback(item.params); + callback(item.params, item); }; req.onerror = function(){ @@ -899,7 +899,14 @@ function loadTrack(id, callback) { } function loadTrackJSON(id){ - loadTrack(id, updateForm); + loadTrack(id, function(data, item) { + // Empty values are omitted from saved params, so clear audio codes before + // applying the loaded song to avoid reusing codes from another track. + if(item.type !== "tts") { + document.getElementById("audio_codes").value = ""; + } + updateForm(data); + }); } function exportTrackJSON(id, title) { diff --git a/koboldcpp.py b/koboldcpp.py index 1478adb0a..f2d71c976 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -7999,6 +7999,17 @@ Change Mode
"choices": [{"index": 0, "finish_reason": "tool_calls" if (len(toolsdata_res) > 0) else currfinishreason, "delta": {}}] }) self.wfile.write(f"data: {chunk_final}\n\n".encode()) + strop = genparams.get("stream_options", None) + if strop and strop.get("include_usage", False): + chunk_usage = json.dumps({ + "id": "koboldcpp", + "object": "chat.completion.chunk", + "created": int(time.time()), + "model": modelNameToReturn, + "choices": [], + "usage": gendat["usage"] + }) + self.wfile.write(f"data: {chunk_usage}\n\n".encode()) self.wfile.write("data: [DONE]\n\n".encode()) self.wfile.flush() self.close_connection = True