Fix SupaMemory error handling in supaMemory.ts

This commit is contained in:
kwaroran
2024-04-09 03:55:16 +09:00
parent def1b5f788
commit 86c0e366cc

View File

@@ -224,15 +224,31 @@ export async function supaMemory(
}
})
console.log(da)
try {
if(!da.ok){
return {
currentTokens: currentTokens,
chats: chats,
error: "SupaMemory: HTTP: " + await da.data
}
}
result = (await da.data)?.choices[0]?.text?.trim()
result = (await da.data)?.choices[0]?.text?.trim()
if(!result){
return {
currentTokens: currentTokens,
chats: chats,
error: "SupaMemory: HTTP: " + await da.data
}
}
if(!result){
return result
} catch (error) {
return {
currentTokens: currentTokens,
chats: chats,
error: "SupaMemory: HTTP: " + await da.data
error: "SupaMemory: HTTP: " + error
}
}
}