From 5113da1c1729e85cc0d9be6731c0a3344026066a Mon Sep 17 00:00:00 2001 From: Concedo Date: Wed, 15 Nov 2023 18:37:57 +0800 Subject: [PATCH] support custom dalle urls --- index.html | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 30c1b8c..71a5819 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ Just copy this single static HTML file anywhere and open it in a browser, or from a webserver. Please go to https://github.com/LostRuins/lite.koboldai.net for updates on Kobold Lite. Kobold Lite is under the AGPL v3.0 License unless otherwise exempted. Please do not remove this line. -Current version: 95 +Current version: 96 -Concedo --> @@ -3187,7 +3187,7 @@ const oai_submit_endpoint = "/completions"; const oai_submit_endpoint_turbo = "/chat/completions"; - const oai_image_endpoint_full = "https://api.openai.com/v1/images/generations"; + const default_oai_image_endpoint = "/images/generations"; const scale_submit_endpoint = "https://dashboard.scale.com/spellbook/api/v2/deploy/" @@ -3282,6 +3282,7 @@ saved_oai_key: "", //do not ever share this in save files! saved_oai_addr: default_oai_base, //do not ever share this in save files! saved_dalle_key: "", + saved_dalle_url: (default_oai_base + "/v1" + default_oai_image_endpoint), saved_openrouter_key: "", saved_claude_key: "", //do not ever share this in save files! saved_claude_addr: default_claude_base, //do not ever share this in save files! @@ -3970,6 +3971,18 @@ } },false); } + function set_dalle_url() + { + inputBox("Enter DALL-E API URL.\n\nNote: DALL-E is known to rephrase and rewrite submitted image prompts before generating, for censorship purposes. There is nothing Kobold Lite can do about that. ","DALL-E API URL",localsettings.saved_dalle_url,"Input DALL-E API URL", ()=>{ + let userinput = getInputBoxValue(); + userinput = userinput.trim(); + if (userinput != null && userinput!="") { + localsettings.saved_dalle_url = userinput.trim(); + }else{ + localsettings.saved_dalle_url = (default_oai_base + "/v1" + default_oai_image_endpoint); + } + },false); + } function generate_dalle_image(req_payload, onImagesDone) { @@ -3988,7 +4001,7 @@ //remove all null fields dalle_payload = Object.fromEntries(Object.entries(dalle_payload).filter(([_, v]) => v != null)); - let gen_endpoint = oai_image_endpoint_full; + let gen_endpoint = localsettings.saved_dalle_url; console.log(dalle_payload); fetch(gen_endpoint, { @@ -4426,6 +4439,7 @@ new_save_storyobj.savedsettings.home_cluster = text_hordes[0].baseurl; new_save_storyobj.savedsettings.saved_oai_key = ""; new_save_storyobj.savedsettings.saved_dalle_key = ""; + new_save_storyobj.savedsettings.saved_dalle_url = ""; new_save_storyobj.savedsettings.saved_oai_addr = ""; new_save_storyobj.savedsettings.saved_claude_key = ""; new_save_storyobj.savedsettings.saved_claude_addr = ""; @@ -4707,6 +4721,7 @@ let tmp_oai1 = localsettings.saved_oai_key; let tmp_oai2 = localsettings.saved_oai_addr; let tmp_oai3 = localsettings.saved_dalle_key; + let tmp_oai4 = localsettings.saved_dalle_url; let tmp_or1 = localsettings.saved_openrouter_key; let tmp_claude1 = localsettings.saved_claude_key; let tmp_claude2 = localsettings.saved_claude_addr; @@ -4735,6 +4750,7 @@ localsettings.saved_oai_key = tmp_oai1; localsettings.saved_oai_addr = tmp_oai2; localsettings.saved_dalle_key = tmp_oai3; + localsettings.saved_dalle_url = tmp_oai4; localsettings.saved_openrouter_key = tmp_or1; localsettings.saved_claude_key = tmp_claude1; localsettings.saved_claude_addr = tmp_claude2; @@ -6212,6 +6228,7 @@ localsettings.saved_oai_key = custom_oai_key; localsettings.saved_oai_addr = custom_oai_endpoint; localsettings.saved_dalle_key = custom_oai_key; + localsettings.saved_dalle_url = custom_oai_endpoint + default_oai_image_endpoint; }else{ localsettings.saved_openrouter_key = custom_oai_key; } @@ -9007,9 +9024,9 @@ } else if(localsettings.generate_images_mode==3) //dalle { - if(localsettings.saved_dalle_key=="") + if(localsettings.saved_dalle_key=="" || localsettings.saved_dalle_url=="") { - msgbox("Error: A valid DALL-E Key is required to generate images with DALL-E.\nThis is usually the same as your OpenAI API key, but can be customized in settings.","Invalid DALL-E Key"); + msgbox("Error: A valid DALL-E URL and Key is required to generate images with DALL-E.\nThis is usually the same as your OpenAI API key, but can be customized in settings.","Invalid DALL-E Key"); } else { @@ -12120,7 +12137,10 @@