[fix] stringlize ain and revert cha
This commit is contained in:
@@ -3,7 +3,7 @@ import type { OpenAIChat, OpenAIChatFull } from ".";
|
||||
import { DataBase, setDatabase, type character } from "../storage/database";
|
||||
import { pluginProcess } from "../plugins/plugins";
|
||||
import { language } from "../../lang";
|
||||
import { stringlizeChat, unstringlizeChat } from "./stringlize";
|
||||
import { stringlizeAINChat, stringlizeChat, unstringlizeChat } from "./stringlize";
|
||||
import { globalFetch, isNodeServer, isTauri } from "../storage/globalApi";
|
||||
import { sleep } from "../util";
|
||||
import { createDeep } from "./deepai";
|
||||
@@ -565,12 +565,12 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
};
|
||||
|
||||
const send_body = {
|
||||
text: stringlizeChat(formated, currentChar?.name ?? ''),
|
||||
text: stringlizeAINChat(formated, currentChar?.name ?? ''),
|
||||
length: maxTokens,
|
||||
temperature: temperature,
|
||||
top_p: 0.7,
|
||||
tailfree: 1.0,
|
||||
rep_pen: arg.frequencyPenalty ?? (db.frequencyPenalty / 100),
|
||||
rep_pen: arg.frequencyPenalty ?? (db.frequencyPenalty / 100) + 1,
|
||||
};
|
||||
|
||||
const response = await globalFetch(api_server_url + '/api', {
|
||||
|
||||
@@ -24,17 +24,16 @@ 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:", "system:"]
|
||||
let chunks:string[] = ["system note:", "system:","system note:", "system:"]
|
||||
if(char){
|
||||
chunks.push(`${char}:`)
|
||||
}
|
||||
|
||||
for(const form of formated){
|
||||
if(form.name){
|
||||
const chunk = `${form.name}:`
|
||||
if(!chunks.includes(chunk)){
|
||||
chunks.push(chunk)
|
||||
}
|
||||
chunks.push(`${form.name}:`)
|
||||
chunks.push(`${form.name}:`)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,4 +52,20 @@ export function unstringlizeChat(text:string, formated:OpenAIChat[], char:string
|
||||
}
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
export function stringlizeAINChat(formated:OpenAIChat[], char:string = ''){
|
||||
let resultString:string[] = []
|
||||
for(const form of formated){
|
||||
if(form.role === 'system'){
|
||||
resultString.push(form.content)
|
||||
}
|
||||
else if(form.name){
|
||||
resultString.push(form.name + ": " + form.content)
|
||||
}
|
||||
else{
|
||||
resultString.push(form.content)
|
||||
}
|
||||
}
|
||||
return resultString.join('\n\n') + `\n\n${char}:`
|
||||
}
|
||||
Reference in New Issue
Block a user