From 916840ed3e7161a69fa75e0d8d723d91cdd62be0 Mon Sep 17 00:00:00 2001 From: Rae Fu Date: Fri, 6 Oct 2023 21:39:01 -0600 Subject: [PATCH] set correct aesthetic portrait URLs when importing from chub.ai --- index.html | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 267f373..9d10de7 100644 --- a/index.html +++ b/index.html @@ -4323,7 +4323,7 @@ function get_chubai_scenario() { inputBox("Enter chub.ai prompt URL","Import from chub.ai","","https://chub.ai/characters/Anonymous/example-character", ()=>{ - let userinput = getInputBoxValue().toLowerCase().trim(); + let userinput = getInputBoxValue().trim(); if(userinput=="") { //pass @@ -4375,6 +4375,8 @@ "memory": cdesc +"\n"+ cdef, "authorsnote": "", "worldinfo": [], + // the API returns avatar URLs that are wrong a lot of the time, but they're predictable + "image": `https://avatars.charhub.io/avatars/${encodeURI(userinput)}/avatar.webp`, }; preview_temp_scenario(); }).catch((error) => { @@ -4399,11 +4401,15 @@ function preview_temp_scenario() { let author = ""; + let image = ""; if(temp_scenario.author && temp_scenario.author!="") { author = "
Author: "+temp_scenario.author; } - document.getElementById("scenariodesc").innerHTML = `

`+escapeHtml(temp_scenario.title)+`

`+ + if (temp_scenario.image) { + image = ``; + } + document.getElementById("scenariodesc").innerHTML = `

`+escapeHtml(temp_scenario.title)+`

`+image+ `

Mode: `+(temp_scenario.opmode==1?"Story":(temp_scenario.opmode==2?"Adventure":(temp_scenario.opmode==3?"Chat":"Instruct"))) + author+`

` +`

`+(temp_scenario.desc!=""?escapeHtml(temp_scenario.desc):"[No Description Given]") +`

`; } @@ -4436,6 +4442,9 @@ current_memory = replace_placeholders_direct(current_memory); } } + if (temp_scenario.image && temp_scenario.image > "") { + aestheticInstructUISettings.AI_portrait = temp_scenario.image; + } if (temp_scenario.worldinfo && temp_scenario.worldinfo.length > 0) { current_wi = []; for (let x = 0; x < temp_scenario.worldinfo.length; ++x) { @@ -8569,7 +8578,7 @@ } fulltxt = replaceAll(fulltxt, `%SpcStg%`, `
`); - fulltxt = replaceAll(fulltxt, `%SpcEtg%`, `
`); + fulltxt = replaceAll(fulltxt, `%SpcEtg%`, `
`); }else{ fulltxt = replaceAll(fulltxt, get_instruct_starttag(true), `%SclStg%`+escapeHtml(get_instruct_starttag(true))+`%SpnEtg%`);