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,7 +224,14 @@ 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()
@@ -235,6 +242,15 @@ export async function supaMemory(
error: "SupaMemory: HTTP: " + await da.data error: "SupaMemory: HTTP: " + await da.data
} }
} }
return result
} catch (error) {
return {
currentTokens: currentTokens,
chats: chats,
error: "SupaMemory: HTTP: " + error
}
}
} }
else { else {
const promptbody:OpenAIChat[] = [ const promptbody:OpenAIChat[] = [