From 8dc6291c53208245839ddb5ea2a12f8b425f3aeb Mon Sep 17 00:00:00 2001 From: George Sproston Date: Wed, 9 Aug 2023 10:36:05 +0100 Subject: [PATCH] Bug fixes --- backend/src/openai.js | 4 ++-- backend/src/router.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/openai.js b/backend/src/openai.js index 856ec9f53..7b096c2c6 100644 --- a/backend/src/openai.js +++ b/backend/src/openai.js @@ -162,7 +162,7 @@ async function chatGptCallFunction(functionCall, defenceInfo, session) { } } else if (functionName == "getEmailWhitelist") { response = getEmailWhitelist( - isDefenceActive("EMAIL_WHITELIST", session.activeDefences) + isDefenceActive("EMAIL_WHITELIST", session.defences) ); } if (functionName === "askQuestion") { @@ -228,7 +228,7 @@ async function chatGptSendMessage(message, session) { const evalPrompt = await queryPromptEvaluationModel(message); if (evalPrompt.isMalicious) { defenceInfo.triggeredDefences.push("LLM_EVALUATION"); - if (isDefenceActive("LLM_EVALUATION", session.activeDefences)) { + if (isDefenceActive("LLM_EVALUATION", session.defences)) { console.debug("LLM evalutation defence active."); defenceInfo.blocked = true; const evalResponse = diff --git a/backend/src/router.js b/backend/src/router.js index c8457a921..a6876ac2c 100644 --- a/backend/src/router.js +++ b/backend/src/router.js @@ -106,7 +106,7 @@ router.post("/openai/chat", async (req, res, next) => { defenceInfo.blocked || openAiReply.defenceInfo.blocked; } catch (error) { console.log(error); - if (error.response.status == 401) { + if (error.response?.status == 401) { res.statusCode = 401; reply = "Please enter a valid OpenAI API key to chat to me!"; } else {