Add inlayErrorResponse
This commit is contained in:
@@ -842,4 +842,5 @@ export const languageEnglish = {
|
||||
checkCorruption: "Check Corruption",
|
||||
showPromptComparison: "Show Prompt Comparison",
|
||||
hypaV3Desc: "HypaMemory V3 is a long-term memory system that use both summarized data and vector search.",
|
||||
inlayErrorResponse: "Inlay Error Response",
|
||||
}
|
||||
@@ -50,4 +50,8 @@
|
||||
|
||||
<div class="flex items-center mt-2">
|
||||
<Check bind:check={DBState.db.requestInfoInsideChat} name={language.requestInfoInsideChat}/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center mt-2">
|
||||
<Check bind:check={DBState.db.inlayErrorResponse} name={language.inlayErrorResponse}/>
|
||||
</div>
|
||||
@@ -260,6 +260,14 @@ html, body{
|
||||
@apply rounded-lg focus:outline-none max-w-80 w-full
|
||||
}
|
||||
|
||||
.x-risu-risu-error {
|
||||
@apply border-2 border-red-700 bg-red-500 text-white rounded-md shadow-sm focus:outline-none transition-colors duration-200 px-4 py-2 min-w-0 break-words
|
||||
}
|
||||
|
||||
.x-risu-risu-error h1 {
|
||||
@apply text-xl mb-2
|
||||
}
|
||||
|
||||
.z-100{
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
@@ -255,6 +255,11 @@ async function renderHighlightableMarkdown(data:string) {
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'risuerror':{
|
||||
lang = 'error'
|
||||
shotLang = 'error'
|
||||
break
|
||||
}
|
||||
default:{
|
||||
lang = 'none'
|
||||
shotLang = 'none'
|
||||
@@ -266,6 +271,9 @@ async function renderHighlightableMarkdown(data:string) {
|
||||
if(lang === 'none'){
|
||||
rendered = rendered.replace(placeholder, `<pre><code>${md.utils.escapeHtml(code)}</code></pre>`)
|
||||
}
|
||||
else if(lang === 'error'){
|
||||
rendered = rendered.replace(placeholder, `<div class="risu-error"><h1>${language.error}</h1>${md.utils.escapeHtml(code)}</div>`)
|
||||
}
|
||||
else{
|
||||
const highlighted = hljs.highlight(code, {
|
||||
language: lang,
|
||||
@@ -285,7 +293,7 @@ async function renderHighlightableMarkdown(data:string) {
|
||||
}
|
||||
|
||||
|
||||
export const assetRegex = /{{(raw|path|img|image|video|audio|bg|emotion|asset|video-img|source)::(.+?)}}/g
|
||||
export const assetRegex = /{{(raw|path|img|image|video|audio|bg|emotion|asset|video-img|source)::(.+?)}}/gms
|
||||
|
||||
async function parseAdditionalAssets(data:string, char:simpleCharacterArgument|character, mode:'normal'|'back', mode2:'unset'|'pre'|'post' = 'unset'){
|
||||
const assetWidthString = (DBState.db.assetWidth && DBState.db.assetWidth !== -1 || DBState.db.assetWidth === 0) ? `max-width:${DBState.db.assetWidth}rem;` : ''
|
||||
|
||||
@@ -102,6 +102,24 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
return data.trim()
|
||||
}
|
||||
|
||||
function throwError(error:string){
|
||||
|
||||
if(DBState.db.inlayErrorResponse){
|
||||
DBState.db.characters[selectedChar].chats[selectedChat].message.push({
|
||||
role: 'char',
|
||||
data: `\`\`\`risuerror\n${error}\n\`\`\``,
|
||||
saying: currentChar.chaId,
|
||||
time: Date.now(),
|
||||
generationInfo,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
alertError(error)
|
||||
return
|
||||
}
|
||||
|
||||
let isDoing = get(doingChat)
|
||||
|
||||
if(isDoing){
|
||||
@@ -134,7 +152,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
if(!peerSafe){
|
||||
peerRevertChat()
|
||||
doingChat.set(false)
|
||||
alertError(language.otherUserRequesting)
|
||||
throwError(language.otherUserRequesting)
|
||||
return false
|
||||
}
|
||||
await peerSync()
|
||||
@@ -198,7 +216,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
else{
|
||||
currentChar = findCharacterbyIdwithCache(nowChatroom.characters[chatProcessIndex])
|
||||
if(!currentChar){
|
||||
alertError(`cannot find character: ${nowChatroom.characters[chatProcessIndex]}`)
|
||||
throwError(`cannot find character: ${nowChatroom.characters[chatProcessIndex]}`)
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -815,7 +833,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
const sp = await hypaMemoryV2(chats, currentTokens, maxContextTokens, currentChat, nowChatroom, tokenizer)
|
||||
if(sp.error){
|
||||
console.log(sp)
|
||||
alertError(sp.error)
|
||||
throwError(sp.error)
|
||||
return false
|
||||
}
|
||||
chats = sp.chats
|
||||
@@ -836,7 +854,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
DBState.db.characters[selectedChar].chats[selectedChat].hypaV3Data = currentChat.hypaV3Data
|
||||
}
|
||||
console.log(sp)
|
||||
alertError(sp.error)
|
||||
throwError(sp.error)
|
||||
return false
|
||||
}
|
||||
chats = sp.chats
|
||||
@@ -852,7 +870,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
asHyper: DBState.db.hypaMemory
|
||||
})
|
||||
if(sp.error){
|
||||
alertError(sp.error)
|
||||
throwError(sp.error)
|
||||
return false
|
||||
}
|
||||
chats = sp.chats
|
||||
@@ -867,7 +885,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
else{
|
||||
while(currentTokens > maxContextTokens){
|
||||
if(chats.length <= 1){
|
||||
alertError(language.errors.toomuchtoken + "\n\nRequired Tokens: " + currentTokens)
|
||||
throwError(language.errors.toomuchtoken + "\n\nRequired Tokens: " + currentTokens)
|
||||
|
||||
return false
|
||||
}
|
||||
@@ -1158,7 +1176,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
let pointer = 0
|
||||
while(inputTokens > maxContextTokens){
|
||||
if(pointer >= formated.length){
|
||||
alertError(language.errors.toomuchtoken + "\n\nAt token rechecking. Required Tokens: " + inputTokens)
|
||||
throwError(language.errors.toomuchtoken + "\n\nAt token rechecking. Required Tokens: " + inputTokens)
|
||||
return false
|
||||
}
|
||||
if(formated[pointer].removable){
|
||||
@@ -1212,7 +1230,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
return false
|
||||
}
|
||||
if(req.type === 'fail'){
|
||||
alertError(req.result)
|
||||
throwError(req.result)
|
||||
return false
|
||||
}
|
||||
else if(req.type === 'streaming'){
|
||||
@@ -1553,7 +1571,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
if(abortSignal.aborted){
|
||||
return true
|
||||
}
|
||||
alertError(`${rq.result}`)
|
||||
throwError(`${rq.result}`)
|
||||
return true
|
||||
}
|
||||
else{
|
||||
@@ -1594,7 +1612,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
emotionSelected = true
|
||||
}
|
||||
} catch (error) {
|
||||
alertError(language.errors.httpError + `${error}`)
|
||||
throwError(language.errors.httpError + `${error}`)
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1605,7 +1623,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
}
|
||||
else if(currentChar.viewScreen === 'imggen'){
|
||||
if(chatProcessIndex !== -1){
|
||||
alertError("Stable diffusion in group chat is not supported")
|
||||
throwError("Stable diffusion in group chat is not supported")
|
||||
}
|
||||
|
||||
const msgs = DBState.db.characters[selectedChar].chats[selectedChat].message
|
||||
|
||||
@@ -895,6 +895,7 @@ export interface Database{
|
||||
processRegexScript: boolean
|
||||
},
|
||||
OaiCompAPIKeys: {[key:string]:string}
|
||||
inlayErrorResponse:boolean
|
||||
}
|
||||
|
||||
interface SeparateParameters{
|
||||
|
||||
Reference in New Issue
Block a user