[feat] cot

This commit is contained in:
kwaroran
2023-12-18 07:05:04 +09:00
parent 94aadc53cc
commit 8ac8e2f7ff
5 changed files with 43 additions and 1 deletions

View File

@@ -60,7 +60,7 @@
}
function displaya(message:string){
msgDisplay = risuChatParser(message, {chara: name, chatID: idx, rmVar: true})
msgDisplay = risuChatParser(message, {chara: name, chatID: idx, rmVar: true, visualize: true})
}
const setStatusMessage = (message:string, timeout:number = 0)=>{

View File

@@ -89,6 +89,11 @@
<Help key="experimental"/>
</Check>
</div>
<div class="flex items-center mt-4">
<Check bind:check={$DataBase.chainOfThought} name="Chain of Thoughts">
<Help key="experimental"/>
</Check>
</div>
<div class="flex items-center mt-4">
<Check check={$DataBase.tpo} name="Alpha DevMode" onChange={() => {
// access code is "tendo"

View File

@@ -766,10 +766,12 @@ export function risuChatParser(da:string, arg:{
var?:{[key:string]:string}
tokenizeAccurate?:boolean
consistantChar?:boolean
visualize?:boolean
} = {}):string{
const chatID = arg.chatID ?? -1
const db = arg.db ?? get(DataBase)
const aChara = arg.chara
const visualize = arg.visualize ?? false
let chara:character|string = null
if(aChara){
@@ -880,6 +882,33 @@ export function risuChatParser(da:string, arg:{
}
break
}
case 'Thoughts':{
if(!visualize){
nested[0] += `<${dat}>`
break
}
if(!commentMode){
commentMode = true
commentLatest = nested.map((f) => f)
if(commentLatest[0].endsWith('\n')){
commentLatest[0] = commentLatest[0].substring(0, commentLatest[0].length - 1)
}
commentV = new Uint8Array(v)
}
break
}
case '/Thoughts':{
if(!visualize){
nested[0] += `<${dat}>`
break
}
if(commentMode){
nested = commentLatest
v = commentV
commentMode = false
}
break
}
default:{
const mc = (pureMode) ? null : smMatcher(dat, matcherObj)
nested[0] += mc ?? `<${dat}>`

View File

@@ -259,6 +259,13 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
})
}
if(db.chainOfThought){
unformated.postEverything.push({
role: 'system',
content: `<instruction>before responding everything, Think step by step how would you respond inside <Thoughts> xml tag.</instruction>`
})
}
{
let description = risuChatParser((db.promptPreprocess ? db.descriptionPrefix: '') + currentChar.desc, {chara: currentChar})

View File

@@ -560,6 +560,7 @@ export interface Database{
projectId: string
}
mistralKey?:string
chainOfThought?:boolean
}
export interface customscript{