[fix] name appending wrong

This commit is contained in:
kwaroran
2023-12-24 22:07:12 +09:00
parent 464fcccf6d
commit 036fc00f7b
6 changed files with 37 additions and 12 deletions

View File

@@ -32,6 +32,7 @@ export interface OpenAIChat{
memo?:string
name?:string
removable?:boolean
attr?:string[]
}
export interface OpenAIChatFull extends OpenAIChat{
@@ -566,11 +567,18 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
}
}
let attr:string[] = []
if(nowChatroom.type === 'group'){
formedChat = name + ': ' + formedChat
attr.push('nameAdded')
}
const chat:OpenAIChat = {
role: msg.role === 'user' ? 'user' : 'assistant',
content: formedChat,
memo: msg.chatId,
name: name
attr: attr
}
chats.push(chat)
currentTokens += await tokenizer.tokenizeChat(chat)
@@ -1269,8 +1277,13 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
function systemizeChat(chat:OpenAIChat[]){
for(let i=0;i<chat.length;i++){
if(chat[i].role === 'user' || chat[i].role === 'assistant'){
chat[i].content = chat[i].role + ': ' + chat[i].content
const attr = chat[i].attr ?? []
if(!attr.includes('nameAdded')){
chat[i].content = chat[i].role + ': ' + chat[i].content
}
chat[i].role = 'system'
delete chat[i].memo
delete chat[i].name
}
}
return chat

View File

@@ -110,6 +110,7 @@ export interface OpenAIChatExtra {
memo?:string
name?:string
removable?:boolean
attr?:string[]
}
@@ -133,6 +134,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
raiModel = 'reverse_proxy'
}
}
console.log(formated)
switch(raiModel){
case 'gpt35':
case 'gpt35_0613':
@@ -153,7 +155,6 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
case 'mistral-medium':
case 'reverse_proxy':{
let formatedChat:OpenAIChatExtra[] = []
console.log(formated)
if(db.inlayImage){
let pendingImages:OpenAIImageContents[] = []
for(let i=0;i<formated.length;i++){
@@ -192,10 +193,6 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
let oobaSystemPrompts:string[] = []
for(let i=0;i<formatedChat.length;i++){
if(formatedChat[i].role !== 'function'){
if(arg.isGroupChat && formatedChat[i].name){
formatedChat[i].content = formatedChat[i].name + ": " + formatedChat[i].content
formatedChat[i].name = undefined
}
if(!(formatedChat[i].name && formatedChat[i].name.startsWith('example_') && db.newOAIHandle)){
formatedChat[i].name = undefined
}
@@ -204,6 +201,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
}
delete formatedChat[i].memo
delete formatedChat[i].removable
delete formatedChat[i].attr
}
if(aiModel === 'reverse_proxy' && db.reverseProxyOobaMode && formatedChat[i].role === 'system'){
const cont = formatedChat[i].content