From 390e3bcb622e917f1acb387e75c2bd005122daf3 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Sun, 3 Dec 2023 19:15:09 +0900 Subject: [PATCH] [feat] add new ooba --- src/lib/Setting/Pages/BotSettings.svelte | 10 ++- src/lib/Setting/Pages/OobaSettings.svelte | 76 +++++++++++++---------- src/lib/UI/GUI/CheckInput.svelte | 3 +- src/lib/UI/ModelList.svelte | 63 +++++++++++-------- src/ts/process/request.ts | 50 +++++++++++++++ 5 files changed, 140 insertions(+), 62 deletions(-) diff --git a/src/lib/Setting/Pages/BotSettings.svelte b/src/lib/Setting/Pages/BotSettings.svelte index 6969cbeb..88486e6a 100644 --- a/src/lib/Setting/Pages/BotSettings.svelte +++ b/src/lib/Setting/Pages/BotSettings.svelte @@ -254,7 +254,11 @@ {#if !isTauri} You are using web version. you must use ngrok or other tunnels to use your local webui. {/if} - Warning: For Ooba version over 1.7, use "Reverse Proxy" as model, and use url like http://127.0.0.1:5000/v1/chat/completions + Warning: For Ooba version over 1.7, use "Ooba" as model, and use url like http://127.0.0.1:5000/v1/chat/completions +{/if} +{#if $DataBase.aiModel === 'ooba' || $DataBase.subModel === 'ooba'} + Ooba {language.providerURL} + {/if} {#if advancedBotSettings} {#if !$DataBase.promptTemplate} @@ -465,8 +469,8 @@ {/if} {/if} -{#if ($DataBase.reverseProxyOobaMode && $DataBase.aiModel === 'reverse_proxy')} - +{#if ($DataBase.reverseProxyOobaMode && $DataBase.aiModel === 'reverse_proxy') || ($DataBase.aiModel === 'ooba')} + {/if} diff --git a/src/lib/Setting/Pages/OobaSettings.svelte b/src/lib/Setting/Pages/OobaSettings.svelte index 7a1cffa6..a26edb16 100644 --- a/src/lib/Setting/Pages/OobaSettings.svelte +++ b/src/lib/Setting/Pages/OobaSettings.svelte @@ -1,6 +1,5 @@
@@ -25,37 +25,49 @@
- Ooba Mode - - Instruct - Chat - Chat-Instruct - - + {#if instructionMode} + System Prefix + + User Prefix + + Assistant Prefix + + Seperator + - {#if $DataBase.reverseProxyOobaArgs.mode === 'instruct'} - user prefix - - bot prefix - - system prefix - - system message - - {/if} - {#if $DataBase.reverseProxyOobaArgs.mode === 'chat' || $DataBase.reverseProxyOobaArgs.mode === 'chat-instruct'} - user prefix - - bot prefix - - system prefix - - start message - - {/if} - {#if $DataBase.reverseProxyOobaArgs.mode === 'chat-instruct'} - chat_instruct_command - + {:else} + Ooba Mode + + Instruct + Chat + Chat-Instruct + + + + {#if $DataBase.reverseProxyOobaArgs.mode === 'instruct'} + user prefix + + bot prefix + + system prefix + + system message + + {/if} + {#if $DataBase.reverseProxyOobaArgs.mode === 'chat' || $DataBase.reverseProxyOobaArgs.mode === 'chat-instruct'} + user prefix + + bot prefix + + system prefix + + start message + + {/if} + {#if $DataBase.reverseProxyOobaArgs.mode === 'chat-instruct'} + chat_instruct_command + + {/if} {/if} min_p diff --git a/src/lib/UI/GUI/CheckInput.svelte b/src/lib/UI/GUI/CheckInput.svelte index f09ab198..cc600820 100644 --- a/src/lib/UI/GUI/CheckInput.svelte +++ b/src/lib/UI/GUI/CheckInput.svelte @@ -7,10 +7,11 @@ export let name = '' export let hiddenName = false export let className = "" + export let grayText = false
diff --git a/src/ts/process/request.ts b/src/ts/process/request.ts index 83cb0264..8e955b55 100644 --- a/src/ts/process/request.ts +++ b/src/ts/process/request.ts @@ -758,6 +758,56 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model' } } + case 'ooba': { + const suggesting = model === "submodel" + const proompt = stringlizeChatOba(formated, currentChar.name, suggesting, arg.continue) + let stopStrings = getStopStrings(suggesting) + if(db.localStopStrings){ + stopStrings = db.localStopStrings.map((v) => { + return risuChatParser(v.replace(/\\n/g, "\n")) + }) + } + let bodyTemplate:Record = { + 'prompt': proompt, + presence_penalty: arg.PresensePenalty || (db.PresensePenalty / 100), + frequency_penalty: arg.frequencyPenalty || (db.frequencyPenalty / 100), + logit_bias: bias, + max_tokens: maxTokens, + stop: stopStrings, + temperature: temperature, + top_p: db.topP + } + + const url = new URL(db.textgenWebUIBlockingURL) + url.pathname = "/v1/chat/completions" + const urlStr = url.toString() + + const OobaBodyTemplate = db.reverseProxyOobaArgs + const keys = Object.keys(OobaBodyTemplate) + for(const key of keys){ + if(OobaBodyTemplate[key] !== undefined && OobaBodyTemplate[key] !== null){ + bodyTemplate[key] = OobaBodyTemplate[key] + } + } + + const response = await globalFetch(urlStr, { + body: bodyTemplate, + }) + + if(!response.ok){ + return { + type: 'fail', + result: (language.errors.httpError + `${JSON.stringify(response.data)}`) + } + } + const text:string = response.data.choices[0].text + return { + type: 'success', + result: text.replace(/##\n/g, '') + } + + } + case 'custom':{ const d = await pluginProcess({ bias: bias,