From 86c0e366cc2ffcfaeac0a3f6a4c1e229f078b291 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Tue, 9 Apr 2024 03:55:16 +0900 Subject: [PATCH] Fix SupaMemory error handling in supaMemory.ts --- src/ts/process/memory/supaMemory.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/ts/process/memory/supaMemory.ts b/src/ts/process/memory/supaMemory.ts index 12483d33..ed214907 100644 --- a/src/ts/process/memory/supaMemory.ts +++ b/src/ts/process/memory/supaMemory.ts @@ -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 } } }