diff --git a/embd_res/kcpp_docs.embd b/embd_res/kcpp_docs.embd index 6bf7195e1..f2de004f4 100644 --- a/embd_res/kcpp_docs.embd +++ b/embd_res/kcpp_docs.embd @@ -2891,7 +2891,7 @@ "name": "sdapi/v1" }, { - "description": "OpenAI compatible textgen API (not recommended)", + "description": "OpenAI Compatible APIs", "name": "v1" } ] diff --git a/embd_res/klite.embd b/embd_res/klite.embd index f503116fb..297e3d2d7 100644 --- a/embd_res/klite.embd +++ b/embd_res/klite.embd @@ -4138,6 +4138,7 @@ Current version indicated by LITEVER below. const alltalk_voices_endpoint = "/api/voices"; const alltalk_rvc_voices_endpoint = "/api/rvcvoices"; + const pollinations_img_endpoint = "https://gen.pollinations.ai/image"; const pollinations_text_endpoint = "https://text.pollinations.ai/openai"; const dummy_api_key = "kobo"; @@ -9074,6 +9075,72 @@ Current version indicated by LITEVER below. },true); } + function generate_pollinations_image(req_payload, autoappend) + { + let splits = req_payload.prompt.split("###"); + let prompt = splits[0].trim(); + let negprompt = (splits.length > 1 ? splits[1] : ""); + + const pollinations_params = new URLSearchParams({ + model:req_payload.models[0], + seed:Math.floor(Math.random() * 99999999), + width: req_payload.params.width, + height: req_payload.params.height, + nologo: true, + private: true, + referrer: "koboldai", + key: localsettings.saved_dalle_key + }); + + let gen_endpoint = `${pollinations_img_endpoint}/${encodeURIComponent(prompt)}?${pollinations_params.toString()}`; + + console.log(gen_endpoint); + let imgid = "PollAIimg"+(Math.floor(10000 + Math.random() * 90000)).toString(); + let nimgtag = "[<|p|" + imgid + "|p|>]"; + if (localsettings.img_newturn) { + if(localsettings.opmode == 4) + { + nimgtag = wrap_newgen_instruct_format(nimgtag,false); + } + else if(localsettings.opmode == 3) + { + nimgtag = wrap_newgen_chat_format(nimgtag); + } + } + if(autoappend) + { + gametext_arr.push(nimgtag); + } + image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:prompt, poll_category:0 }; + image_db[imgid].aspect = (req_payload.params.width>=req_payload.params.height*2?5:(req_payload.params.height>=req_payload.params.width*2?4:(req_payload.params.width>req_payload.params.height?2:(req_payload.params.width { + return response.blob(); // Convert the response into a Blob + }) + .then((finalimg) => { + const reader = new FileReader(); + reader.onloadend = () => { + let origImg = reader.result; + let imgres = localsettings.img_allowhd?VHD_RES_PX:NO_HD_RES_PX; + compressImage(origImg, (newDataUri) => { + image_db[imgid].done = true; + image_db[imgid].result = newDataUri; + }, false, imgres); + }; + reader.readAsDataURL(finalimg); + }).catch((error) => { + console.log("Generation Error: " + error); + msgbox("Image Generation Failed!\n\nCould not generate image with Pollinations.ai, maybe you are rate limited. Try again later.\n"); + }); + return imgid; + } + function set_horde_key() { inputBox("Enter AI Horde API Key.\n\nThe same key is used for image and text generation in AI Horde.","AI Horde API Key",localsettings.my_api_key,"Input AI Horde API Key", ()=>{ @@ -20582,12 +20649,20 @@ Current version indicated by LITEVER below. oai_payload.logprobs = 5; } } - if(!targetep.toLowerCase().includes("api.x.ai") && !targetep.toLowerCase().includes("api.perplexity.ai")) + if(!targetep.toLowerCase().includes("pollinations.ai") && !targetep.toLowerCase().includes("api.x.ai") && !targetep.toLowerCase().includes("api.perplexity.ai")) { //grok has no support for stop - oai_payload.stop = get_stop_sequences().slice(0, 4); //lets try adding stop sequences, limit to first 4 + let stops = get_stop_sequences().slice(0, 4); //lets try adding stop sequences, limit to first 4 + if(stops && stops.length>0) + { + oai_payload.stop = stops; + } } - if(!targetep.toLowerCase().includes("api.mistral.ai") && !targetep.toLowerCase().includes("api.x.ai")) + if(targetep.toLowerCase().includes("pollinations.ai")) + { + delete oai_payload["top_p"]; + } + if(!targetep.toLowerCase().includes("pollinations.ai") && !targetep.toLowerCase().includes("api.mistral.ai") && !targetep.toLowerCase().includes("api.x.ai")) { //mistral api does not support presence pen oai_payload.presence_penalty = scaled_rep_pen; @@ -21541,6 +21616,12 @@ Current version indicated by LITEVER below. { msgbox("Error: A valid OpenAI Compatible Image 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 OpenAI Compatible Image Key"); } + else if(localsettings.saved_dalle_url.toLowerCase().includes("pollinations.ai")) + { + let desired_model = localsettings.saved_dalle_model; + genimg_payload.models = [desired_model]; + imgid = generate_pollinations_image(genimg_payload, autoappend); + } else { imgid = "DALLEimg"+(Math.floor(10000 + Math.random() * 90000)).toString(); diff --git a/otherarch/qwen3tts/tts_transformer.cpp b/otherarch/qwen3tts/tts_transformer.cpp index 47a0b22c5..686322807 100644 --- a/otherarch/qwen3tts/tts_transformer.cpp +++ b/otherarch/qwen3tts/tts_transformer.cpp @@ -19,6 +19,8 @@ # define ttsfseek fseeko #endif +bool qwen3tts_allowgpu = false; + namespace qwen3_tts { TTSTransformer::TTSTransformer() = default; diff --git a/otherarch/tts_adapter.cpp b/otherarch/tts_adapter.cpp index 7b0aabce2..79e52476d 100644 --- a/otherarch/tts_adapter.cpp +++ b/otherarch/tts_adapter.cpp @@ -501,7 +501,7 @@ static std::string detectedarch = ""; //qwen3tts specific static bool is_qwen3tts_file = false; static qwen3_tts::Qwen3TTS qwen3tts_runner; -bool qwen3tts_allowgpu = false; +extern bool qwen3tts_allowgpu; int total_tts_gens = 0; static std::string tts_executable_path = "";