fix audio gen ui, fix finish reason

This commit is contained in:
Concedo 2026-09-19 11:09:10 +08:00
parent a8b0069fac
commit a5ca9da631
2 changed files with 20 additions and 2 deletions

View file

@ -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) {

View file

@ -7999,6 +7999,17 @@ Change Mode<br>
"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