mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Merge pull request #237 from one-some/UI2
Convert WI upload to post request
This commit is contained in:
@@ -8534,10 +8534,10 @@ def UI_2_upload_world_info_folder(data):
|
||||
logger.debug("Calcing AI Text from WI Upload")
|
||||
koboldai_vars.calc_ai_text()
|
||||
|
||||
@socketio.on('import_world_info')
|
||||
@app.route("/upload_wi", methods=["POST"])
|
||||
@logger.catch
|
||||
def UI_2_import_world_info(data):
|
||||
wi_data = data["data"]
|
||||
def UI_2_import_world_info():
|
||||
wi_data = request.get_json()
|
||||
uids = {}
|
||||
|
||||
for folder_name, children in wi_data["folders"].items():
|
||||
@@ -8558,6 +8558,7 @@ def UI_2_import_world_info(data):
|
||||
wpp=entry_data["wpp"],
|
||||
)
|
||||
koboldai_vars.worldinfo_v2.add_item_to_folder(uids[child], folder_name)
|
||||
return ":)"
|
||||
|
||||
@socketio.on("search_wi")
|
||||
@logger.catch
|
||||
|
@@ -4001,7 +4001,7 @@ function sendPromptConfiguration() {
|
||||
$(".prompt-config-ph").remove();
|
||||
}
|
||||
|
||||
function loadNAILorebook(data, filename) {
|
||||
async function loadNAILorebook(data, filename) {
|
||||
let lorebookVersion = data.lorebookVersion;
|
||||
let wi_data = {folders: {[filename]: []}, entries: {}};
|
||||
console.log(`Loading NAI lorebook version ${lorebookVersion}`);
|
||||
@@ -4036,7 +4036,16 @@ function loadNAILorebook(data, filename) {
|
||||
|
||||
i++;
|
||||
}
|
||||
socket.emit("import_world_info", {data: wi_data});
|
||||
|
||||
let r = await fetch("/upload_wi", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(wi_data)
|
||||
});
|
||||
|
||||
if (!r.ok) alert("WI upload errored! Please report this.");
|
||||
}
|
||||
|
||||
async function loadKoboldData(data, filename) {
|
||||
@@ -4046,7 +4055,15 @@ async function loadKoboldData(data, filename) {
|
||||
socket.emit("load_story_list", "");
|
||||
} else if (data.folders !== undefined && data.entries !== undefined) {
|
||||
// World Info Folder
|
||||
socket.emit("import_world_info", {data: data});
|
||||
let r = await fetch("/upload_wi", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
|
||||
if (!r.ok) alert("WI upload errored! Please report this.");
|
||||
} else {
|
||||
// Bad data
|
||||
console.error("Bad data!");
|
||||
|
Reference in New Issue
Block a user