[feat] new model selection screen

This commit is contained in:
kwaroran
2023-05-26 20:23:45 +09:00
parent cf9ae31a26
commit 4903a88131
7 changed files with 123 additions and 32 deletions

View File

@@ -4,6 +4,7 @@ import { changeLanguage } from '../lang';
import type { RisuPlugin } from './process/plugins';
import { saveAsset as saveImageGlobal } from './globalApi';
import { cloneDeep } from 'lodash';
import type { S } from '@tauri-apps/api/dialog-20ff401c';
export const DataBase = writable({} as any as Database)
export const loadedStore = writable(false)
@@ -386,6 +387,7 @@ export interface botPreset{
forceReplaceUrl2:string
promptPreprocess: boolean,
bias: [string, number][]
koboldURL?: string
}
export interface Database{
@@ -486,6 +488,7 @@ export interface Database{
globalscript: customscript[]
sendWithEnter:boolean
clickToEdit: boolean
koboldURL:string
}
@@ -627,7 +630,9 @@ export function saveCurrentPreset(){
forceReplaceUrl: db.forceReplaceUrl,
forceReplaceUrl2: db.forceReplaceUrl2,
promptPreprocess: db.promptPreprocess,
bias: db.bias
bias: db.bias,
koboldURL: db.koboldURL
}
db.botPresets = pres
DataBase.set(db)
@@ -668,5 +673,6 @@ export function changeToPreset(id =0){
db.promptPreprocess = newPres.promptPreprocess ?? db.promptPreprocess
db.forceReplaceUrl2 = newPres.forceReplaceUrl2 ?? db.forceReplaceUrl2
db.bias = newPres.bias ?? db.bias
db.koboldURL = newPres.koboldURL ?? db.koboldURL
DataBase.set(db)
}

View File

@@ -241,7 +241,7 @@ export async function sendChat(chatProcessIndex = -1):Promise<boolean> {
else{
while(currentTokens > maxContextTokens){
if(chats.length <= 1){
alertError(language.errors.toomuchtoken)
alertError(language.errors.toomuchtoken + "\n\nRequired Tokens: " + currentTokens)
return false
}

View File

@@ -418,6 +418,34 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
}
}
}
case "kobold":{
const proompt = stringlizeChat(formated, currentChar?.name ?? '')
const url = new URL(db.koboldURL)
url.pathname = '/generate'
const da = await fetch(url, {
method: "POST",
body: JSON.stringify({
"prompt": proompt,
"temperature": db.temperature,
"top_p": 0.9
}),
headers: {
"content-type": "application/json",
}
})
if(da.status !== 200){
return {
type: "fail",
result: await da.text(),
noRetry: da.status >= 500
}
}
const data = await da.json()
return data.results[0].text
}
default:{
if(aiModel.startsWith("horde:::")){
const proompt = stringlizeChat(formated, currentChar?.name ?? '')
@@ -432,8 +460,8 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
"frmtrmblln": false,
"frmtrmspch": false,
"frmttriminc": false,
"max_context_length": 200,
"max_length": 20,
"max_context_length": db.maxContext + 100,
"max_length": db.maxResponse,
"rep_pen": 3,
"rep_pen_range": 0,
"rep_pen_slope": 10,

View File

@@ -8,7 +8,7 @@ export function stringlizeChat(formated:OpenAIChat[], char:string = ''){
let resultString:string[] = []
for(const form of formated){
if(form.role === 'system'){
resultString.push("system note: " + form.content)
resultString.push("system: " + form.content)
}
else if(form.name){
resultString.push(form.name + ": " + form.content)
@@ -23,7 +23,7 @@ export function stringlizeChat(formated:OpenAIChat[], char:string = ''){
export function unstringlizeChat(text:string, formated:OpenAIChat[], char:string = ''){
console.log(text)
let minIndex = -1
let chunks:string[] = ["system note:"]
let chunks:string[] = ["system note:", "system:"]
if(char){
chunks.push(`${char}:`)
}