From ec052307035091123af865b4ce19e03e487ba98d Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:38:39 +0800 Subject: [PATCH] updated lite, up ver --- klite.embd | 91 ++++++++++++++++++++++++++++++++++++++++++++++++---- koboldcpp.py | 2 +- 2 files changed, 85 insertions(+), 8 deletions(-) diff --git a/klite.embd b/klite.embd index 4b246b1ed0959..69dcb289c8e7f 100644 --- a/klite.embd +++ b/klite.embd @@ -3215,6 +3215,7 @@ Current version: 100 const default_oai_base = "https://api.openai.com"; const default_claude_base = "https://api.anthropic.com"; const default_palm_base = "https://generativelanguage.googleapis.com/v1beta2/models/text-bison-001:generateText?key="; + const default_gemini_base = "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key="; const a1111_models_endpoint = "/sdapi/v1/sd-models"; const a1111_options_endpoint = "/sdapi/v1/options"; @@ -6526,6 +6527,7 @@ Current version: 100 else if(epchoice==4) //palm endpoint { let desired_palm_key = document.getElementById("custom_palm_key").value.trim(); + let mdlname = document.getElementById("custom_palm_model").value; if(desired_palm_key!="") { @@ -6535,7 +6537,7 @@ Current version: 100 custom_palm_key = desired_palm_key; localsettings.saved_palm_key = custom_palm_key; - selected_models = [{ "performance": 100.0, "queued": 0.0, "eta": 0, "name": "text-bison-001", "count": 1 }]; + selected_models = [{ "performance": 100.0, "queued": 0.0, "eta": 0, "name": mdlname, "count": 1 }]; selected_workers = []; if (perfdata == null) { //generate some fake perf data if horde is offline and using custom endpoint @@ -8912,7 +8914,7 @@ Current version: 100 } else if (custom_palm_key != "")//handle for PaLM { - let targetep = default_palm_base + custom_palm_key; + let urlbase = default_palm_base; let payload = {"prompt":{"text":submit_payload.prompt}, "temperature":submit_payload.params.temperature, "maxOutputTokens": submit_payload.params.max_length, @@ -8920,6 +8922,75 @@ Current version: 100 "topK": (submit_payload.params.top_k<1?300:submit_payload.params.top_k), "candidateCount":1}; + if(document.getElementById("custom_palm_model").value=="text-bison-001") + { + payload.safetySettings = [ + { + "category": "HARM_CATEGORY_TOXICITY", + "threshold": "BLOCK_NONE" + }, + { + "category": "HARM_CATEGORY_UNSPECIFIED", + "threshold": "BLOCK_NONE" + }, + { + "category": "HARM_CATEGORY_VIOLENCE", + "threshold": "BLOCK_NONE" + }, + { + "category": "HARM_CATEGORY_SEXUAL", + "threshold": "BLOCK_NONE" + } + ]; + } + else if(document.getElementById("custom_palm_model").value=="gemini-pro") + { + if(localsettings.opmode==1) + { + submit_payload.prompt = submit_payload.prompt + " \n ASSISTANT: Here is a continuation of the story: \nASSISTANT:"; + } + + urlbase = default_gemini_base; + payload = { + "contents": [ + { + "parts": [ + { + "text": submit_payload.prompt + } + ] + } + ], + "safetySettings": [ + { + "category": "HARM_CATEGORY_HARASSMENT", + "threshold": "BLOCK_NONE" + }, + { + "category": "HARM_CATEGORY_HATE_SPEECH", + "threshold": "BLOCK_NONE" + }, + { + "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", + "threshold": "BLOCK_NONE" + }, + { + "category": "HARM_CATEGORY_DANGEROUS_CONTENT", + "threshold": "BLOCK_NONE" + } + ], + "generationConfig": { + "temperature":submit_payload.params.temperature, + "maxOutputTokens": submit_payload.params.max_length, + "topP": submit_payload.params.top_p, + "topK": (submit_payload.params.top_k<1?300:submit_payload.params.top_k), + "candidateCount":1, + "stopSequences": [] + } + }; + } + + let targetep = urlbase + custom_palm_key; last_request_str = JSON.stringify(payload); fetch(targetep, { @@ -8933,8 +9004,10 @@ Current version: 100 .then((response) => response.json()) .then((data) => { console.log("sync finished response: " + JSON.stringify(data)); - if (custom_palm_key != "" && data.candidates != null && data.candidates.length>0 && data.candidates[0].output != "") { + if (custom_palm_key != "" && data.candidates != null && data.candidates.length>0 && data.candidates[0].output && data.candidates[0].output != "") { synchro_polled_response = data.candidates[0].output; + }else if (custom_palm_key != "" && data.candidates != null && data.candidates.length>0 && data.candidates[0].content && data.candidates[0].content.parts != null && data.candidates[0].content.parts.length>0) { + synchro_polled_response = data.candidates[0].content.parts[0].text; } else { //error occurred, maybe captcha failed @@ -11769,7 +11842,7 @@ Current version: 100 - + @@ -11898,10 +11971,14 @@ Current version: 100