Change Reverse proxy name to Custom and add additionalParams

This commit is contained in:
kwaroran
2024-03-20 21:02:34 +09:00
parent ef811b5b57
commit 5bede2b90a
14 changed files with 136 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@@ -299,7 +299,7 @@ export const languageChinese = {
"loadDataFromAccount": "从帐户加载数据", "loadDataFromAccount": "从帐户加载数据",
"saveCurrentDataToAccount": "将当前数据保存到帐户", "saveCurrentDataToAccount": "将当前数据保存到帐户",
"chatAssumed": "", "chatAssumed": "",
"proxyAPIKey": "代理API密钥/密码", "proxyAPIKey": "API密钥/密码",
"proxyRequestModel": "代理请求模型", "proxyRequestModel": "代理请求模型",
"officialWiki": "官方Wiki", "officialWiki": "官方Wiki",
"officialWikiDesc": "RisuAI的官方Wiki随意查看。", "officialWikiDesc": "RisuAI的官方Wiki随意查看。",

View File

@@ -329,8 +329,8 @@ export const languageGerman = {
loadDataFromAccount: "Daten aus dem Konto laden", loadDataFromAccount: "Daten aus dem Konto laden",
saveCurrentDataToAccount: "Aktuelle Daten im Konto speichern", saveCurrentDataToAccount: "Aktuelle Daten im Konto speichern",
chatAssumed: "", chatAssumed: "",
proxyAPIKey: "Proxy-Schlüssel/Passwort", proxyAPIKey: "Schlüssel/Passwort",
proxyRequestModel: "Proxy-Anforderungsmodell", proxyRequestModel: "Anforderungsmodell",
officialWiki: "Offizielles Wiki", officialWiki: "Offizielles Wiki",
officialWikiDesc: "Offizielles Wiki für RisuAI. Schauen Sie doch gerne bei uns vorbei", officialWikiDesc: "Offizielles Wiki für RisuAI. Schauen Sie doch gerne bei uns vorbei",
officialDiscord: "Offizieller Discord", officialDiscord: "Offizieller Discord",

View File

@@ -117,6 +117,7 @@ export const languageEnglish = {
requestretrys: "This option is used to set the number of request retrys when request fails.", requestretrys: "This option is used to set the number of request retrys when request fails.",
emotionPrompt: "This option is used to set the prompt that is used to detect emotion. if it is blank, it will use the default prompt.", emotionPrompt: "This option is used to set the prompt that is used to detect emotion. if it is blank, it will use the default prompt.",
removePunctuationHypa: "If enabled, it will remove punctuation before executing HypaMemory.", removePunctuationHypa: "If enabled, it will remove punctuation before executing HypaMemory.",
additionalParams: "Additional parameters that would be added to the request body. if you want to exclude some parameters, you can put `{{none}}` to the value. if you want to add a header instead of body, you can put `header::` in front of the key like `header::Authorization`.",
}, },
setup: { setup: {
chooseProvider: "Choose AI Provider", chooseProvider: "Choose AI Provider",
@@ -364,7 +365,7 @@ export const languageEnglish = {
saveCurrentDataToAccount: "Save Current Data to Account", saveCurrentDataToAccount: "Save Current Data to Account",
chatAssumed: "", chatAssumed: "",
proxyAPIKey: "Proxy Key/Password", proxyAPIKey: "Proxy Key/Password",
proxyRequestModel: "Proxy Request Model", proxyRequestModel: "Request Model",
officialWiki: "Official Wiki", officialWiki: "Official Wiki",
officialWikiDesc: "Official Wiki for RisuAI. feel free to see.", officialWikiDesc: "Official Wiki for RisuAI. feel free to see.",
officialDiscord: "Official Discord", officialDiscord: "Official Discord",
@@ -473,7 +474,7 @@ export const languageEnglish = {
depthPrompt: "Depth Prompt", depthPrompt: "Depth Prompt",
largePortrait: "Portrait", largePortrait: "Portrait",
lorePlus: "LoreBook+", lorePlus: "LoreBook+",
reverseProxyOobaMode: "Reverse Proxy Ooba Mode", reverseProxyOobaMode: "Ooba Mode",
joinMultiUserRoom: "Join MultiUser Room", joinMultiUserRoom: "Join MultiUser Room",
exactTokens: "Exact Tokens", exactTokens: "Exact Tokens",
fixedTokens: "Approximate Tokens", fixedTokens: "Approximate Tokens",
@@ -547,4 +548,6 @@ export const languageEnglish = {
outputTokens: "Output Tokens", outputTokens: "Output Tokens",
tokenWarning: "Token caculation can be inaccurate. it is recommended to use it as a reference.", tokenWarning: "Token caculation can be inaccurate. it is recommended to use it as a reference.",
log: "Log", log: "Log",
popularityLevelDesc: "Popularity increases with downloads, etc. to estimate, 3.7 popularity is about 1 downloads.",
additionalParams: "Additional Parameters",
} }

View File

@@ -300,8 +300,8 @@ export const languageKorean = {
loadDataFromAccount: "계정에서 데이터 불러오기", loadDataFromAccount: "계정에서 데이터 불러오기",
saveCurrentDataToAccount: "계정에 데이터 현재 덮어쓰기", saveCurrentDataToAccount: "계정에 데이터 현재 덮어쓰기",
chatAssumed: "", chatAssumed: "",
proxyAPIKey: "프록시 키/패스워드", proxyAPIKey: "키/패스워드",
proxyRequestModel: "프록시 요청 모델", proxyRequestModel: "요청 모델",
officialWiki: "공식 위키", officialWiki: "공식 위키",
officialWikiDesc: "리스AI의 공식 위키. 자유롭게 보세요.", officialWikiDesc: "리스AI의 공식 위키. 자유롭게 보세요.",
officialDiscord: "공식 디스코드", officialDiscord: "공식 디스코드",

View File

@@ -300,7 +300,7 @@ export const LanguageVietnamese = {
"loadDataFromAccount": "Tải dữ liệu từ tài khoản", "loadDataFromAccount": "Tải dữ liệu từ tài khoản",
"saveCurrentDataToAccount": "Lưu dữ liệu hiện tại vào tài khoản", "saveCurrentDataToAccount": "Lưu dữ liệu hiện tại vào tài khoản",
"chatAssumed": "--", "chatAssumed": "--",
"proxyAPIKey": "Khóa proxy/Mật khẩu", "proxyAPIKey": "Khóa/Mật khẩu",
"proxyRequestModel": "Mô hình yêu cầu proxy", "proxyRequestModel": "Mô hình yêu cầu proxy",
"officialWiki": "Wiki chính thức", "officialWiki": "Wiki chính thức",
"officialWikiDesc": "Wiki chính thức của RisuAI. cứ thoải mái xem nhé.", "officialWikiDesc": "Wiki chính thức của RisuAI. cứ thoải mái xem nhé.",

View File

@@ -159,7 +159,7 @@
<TextInput marginBottom={true} size={"sm"} placeholder="..." bind:value={$DataBase.mistralKey}/> <TextInput marginBottom={true} size={"sm"} placeholder="..." bind:value={$DataBase.mistralKey}/>
{/if} {/if}
{#if $DataBase.aiModel === 'reverse_proxy' || $DataBase.subModel === 'reverse_proxy'} {#if $DataBase.aiModel === 'reverse_proxy' || $DataBase.subModel === 'reverse_proxy'}
<span class="text-textcolor mt-2">{language.forceReplaceUrl} URL <Help key="forceUrl"/></span> <span class="text-textcolor mt-2">URL <Help key="forceUrl"/></span>
<TextInput marginBottom={false} size={"sm"} bind:value={$DataBase.forceReplaceUrl} placeholder="https//..." /> <TextInput marginBottom={false} size={"sm"} bind:value={$DataBase.forceReplaceUrl} placeholder="https//..." />
<span class="text-textcolor mt-4"> {language.proxyAPIKey}</span> <span class="text-textcolor mt-4"> {language.proxyAPIKey}</span>
<TextInput marginBottom={false} size={"sm"} placeholder="leave it blank if it hasn't password" bind:value={$DataBase.proxyKey} /> <TextInput marginBottom={false} size={"sm"} placeholder="leave it blank if it hasn't password" bind:value={$DataBase.proxyKey} />
@@ -577,6 +577,46 @@
</table> </table>
</Arcodion> </Arcodion>
{#if $DataBase.aiModel === 'reverse_proxy'}
<Arcodion styled name="{language.additionalParams} " help="additionalParams">
<table class="contain w-full max-w-full tabler">
<tr>
<th class="font-medium">{language.key}</th>
<th class="font-medium">{language.value}</th>
<th>
<button class="font-medium cursor-pointer hover:text-green-500 w-full flex justify-center items-center" on:click={() => {
let additionalParams = $DataBase.additionalParams
additionalParams.push(['', ''])
$DataBase.additionalParams = additionalParams
}}><PlusIcon /></button>
</th>
</tr>
{#if $DataBase.bias.length === 0}
<tr>
<div class="text-textcolor2">{language.noData}</div>
</tr>
{/if}
{#each $DataBase.additionalParams as additionalParams, i}
<tr>
<td class="font-medium truncate">
<TextInput bind:value={$DataBase.additionalParams[i][0]} size="lg" fullwidth/>
</td>
<td class="font-medium truncate">
<TextInput bind:value={$DataBase.additionalParams[i][1]} size="lg" fullwidth/>
</td>
<td>
<button class="font-medium flex justify-center items-center h-full cursor-pointer hover:text-green-500 w-full" on:click={() => {
let additionalParams = $DataBase.additionalParams
additionalParams.splice(i, 1)
$DataBase.additionalParams = additionalParams
}}><TrashIcon /></button>
</td>
</tr>
{/each}
</table>
</Arcodion>
{/if}
{#if !$DataBase.promptTemplate} {#if !$DataBase.promptTemplate}
<div class="flex items-center mt-4"> <div class="flex items-center mt-4">

View File

@@ -67,7 +67,7 @@
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('claude-1.0')}}>claude-v1.0</button> <button class="p-2 hover:text-green-500" on:click={() => {changeModel('claude-1.0')}}>claude-v1.0</button>
{/if} {/if}
</Arcodion> </Arcodion>
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('reverse_proxy')}}>Reverse Proxy</button> <button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('reverse_proxy')}}>Custom (OpenAI-compatible)</button>
{#if $DataBase.tpo && isTauri} {#if $DataBase.tpo && isTauri}
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={async () => { <button class="hover:bg-selected px-6 py-2 text-lg" on:click={async () => {
const selected = await open({ const selected = await open({
@@ -129,6 +129,7 @@
{/each} {/each}
{/await} {/await}
</Arcodion> </Arcodion>
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('oaicomp')}}>Custom (OpenAI-compatible)</button>
{#if showUnrec} {#if showUnrec}
<Arcodion name="WebLLM Local"> <Arcodion name="WebLLM Local">
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('hf:::Xenova/opt-350m')}}>opt-350m</button> <button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('hf:::Xenova/opt-350m')}}>opt-350m</button>

View File

@@ -7,6 +7,7 @@
import { DataBase } from "src/ts/storage/database"; import { DataBase } from "src/ts/storage/database";
import RealmLicense from "./RealmLicense.svelte"; import RealmLicense from "./RealmLicense.svelte";
import MultiLangDisplay from "../GUI/MultiLangDisplay.svelte"; import MultiLangDisplay from "../GUI/MultiLangDisplay.svelte";
import { tooltip } from "src/ts/gui/tooltip";
export let openedData:hubType export let openedData:hubType
@@ -35,7 +36,7 @@
{/each} {/each}
</div> </div>
<div class="flex flex-wrap w-full flex-row gap-1 mt-2"> <div class="flex flex-wrap w-full flex-row gap-1 mt-2">
<span class="text-textcolor2"> <span class="text-textcolor2" use:tooltip={language.popularityLevelDesc}>
{language.popularityLevel.replace('{}', openedData.download.toString())} {language.popularityLevel.replace('{}', openedData.download.toString())}
</span> </span>
<div class="border-l-selected border-l ml-1 mr-1"></div> <div class="border-l-selected border-l ml-1 mr-1"></div>

View File

@@ -15,6 +15,12 @@
if( today.getMonth() === 3 && today.getDate() === 1){ if( today.getMonth() === 3 && today.getDate() === 1){
specialDay = 'aprilFool' specialDay = 'aprilFool'
} }
if( today.getMonth() === 3 && today.getDate() === 14){
specialDay = 'anniversary'
}
if( today.getMonth() === 9 && today.getDate() === 31){
specialDay = 'halloween'
}
let iconAnimation = 0 let iconAnimation = 0
let clicks = 0 let clicks = 0
let score = 0 let score = 0

View File

@@ -52,7 +52,7 @@ export function getModelName(name:string){
case "novellist damsel": case "novellist damsel":
return "NovelList Damsel" return "NovelList Damsel"
case 'reverse_proxy': case 'reverse_proxy':
return "Reverse Proxy" return "Custom (OpenAI-compatible)"
case 'openrouter': case 'openrouter':
return "OpenRouter" return "OpenRouter"
case 'gptvi4_1106': case 'gptvi4_1106':
@@ -144,6 +144,12 @@ export function getModelShortName(model:string){
return split[split.length-1] return split[split.length-1]
} }
} }
if(model.startsWith('reverse_proxy')){
return 'Custom'
}
if(model.startsWith('oaicomp')){
return 'Custom'
}
return getModelName(model) return getModelName(model)
} }

View File

@@ -0,0 +1,28 @@
import type { OpenAIChat } from "..";
import { HypaProcesser } from "./hypamemory";
export async function termMemory(chats:OpenAIChat[]){
const processer = new HypaProcesser('MiniLM')
processer.addText(chats.map(chat=>chat.content))
let scoredResults:{[key:string]:number}
for(let i=1;i<5;i++){
const chat = chats[chats.length-i]
if(!chat?.content){
continue
}
const scoredArray = (await processer.similaritySearchScored(chat.content)).map((result) => {
return [result[0],result[1]/i] as [string,number]
})
for(const scored of scoredArray){
if(scoredResults[scored[0]]){
scoredResults[scored[0]] += scored[1]
}else{
scoredResults[scored[0]] = scored[1]
}
}
}
const result = Object.entries(scoredResults).sort((a,b)=>a[1]-b[1])
return result.map(([content,score])=>(content)).join('\n\n')
}

View File

@@ -606,6 +606,43 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
} }
} }
if(raiModel === 'reverse_proxy'){
const additionalParams = db.additionalParams
for(let i=0;i<additionalParams.length;i++){
let key = additionalParams[i][0]
let value = additionalParams[i][1]
if(!key || !value){
continue
}
if(value === '{{none}}'){
if(key.startsWith('header::')){
key = key.replace('header::', '')
delete headers[key]
}
else{
delete body[key]
}
continue
}
if(key.startsWith('header::')){
key = key.replace('header::', '')
headers[key] = value
}
else if(isNaN(parseFloat(value))){
if(value.startsWith('"') && value.endsWith('"')){
value = value.slice(1, -1)
}
body[key] = value
}
else{
body[key] = parseFloat(value)
}
}
}
const res = await globalFetch(replacerURL, { const res = await globalFetch(replacerURL, {
body: body, body: body,
headers: headers, headers: headers,

View File

@@ -375,6 +375,7 @@ export function setDatabase(data:Database){
data.memoryLimitThickness ??= 1 data.memoryLimitThickness ??= 1
data.modules ??= [] data.modules ??= []
data.enabledModules ??= [] data.enabledModules ??= []
data.additionalParams ??= []
changeLanguage(data.language) changeLanguage(data.language)
DataBase.set(data) DataBase.set(data)
@@ -600,6 +601,7 @@ export interface Database{
enabledModules: string[] enabledModules: string[]
sideMenuRerollButton?:boolean sideMenuRerollButton?:boolean
requestInfoInsideChat?:boolean requestInfoInsideChat?:boolean
additionalParams:[string, string][]
} }
export interface customscript{ export interface customscript{