From fd625036093e4fe383b8be78a880ead945531284 Mon Sep 17 00:00:00 2001 From: Jack Italiano Date: Thu, 7 Mar 2024 15:56:54 -0500 Subject: [PATCH] remove condition in error to return to assistant - SS api seems to not return errors properly, so can't check for 429 - now just catch all errors from SS and tell assistant (bidara) that ss is not working --- src/assistant/bidaraFunctions.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/assistant/bidaraFunctions.js b/src/assistant/bidaraFunctions.js index e59b58b..305a828 100644 --- a/src/assistant/bidaraFunctions.js +++ b/src/assistant/bidaraFunctions.js @@ -40,17 +40,14 @@ export async function ssSearch(params) { try { const response = await fetch("https://api.semanticscholar.org/graph/v1/paper/search?" + searchParams); - if (response.status === 429) { + if (response.status === 429 || response.code === 429 || response.statusCode === 429) { return "Semantic Scholar is currently having issues with their servers. So, for now, searching for academic papers will not work." } const papers = await response.json(); return JSON.stringify(papers); } catch (e) { - if (e instanceof TypeError && e.message === 'Failed to fetch') { - return "Semantic Scholar is currently having issues with their servers. So, for now, searching for academic papers will not work." - } - - throw e; + console.error('error: ' + e); + return "Semantic Scholar is currently having issues with their servers. So, for now, searching for academic papers will not work." } }