diff --git a/backend/src/openai.js b/backend/src/openai.js index d570dc861..59790f7af 100644 --- a/backend/src/openai.js +++ b/backend/src/openai.js @@ -37,21 +37,21 @@ const chatGptFunctions = [ parameters: { type: "object", properties: {} - } - }, - { - name: "askQuestion", - description: "Ask a question about the documents with company information. ", - parameters: { - type: "object", - properties: { - question: { - type: "string", - description: "The question asked about the documents", - } + } + }, + { + name: "askQuestion", + description: "Ask a question about the documents with company information. ", + parameters: { + type: "object", + properties: { + question: { + type: "string", + description: "The question asked about the documents", } } - }, + } + }, ]; function initOpenAi() { @@ -104,12 +104,12 @@ async function chatGptCallFunction(functionCall, defenceInfo, session) { session ); } - + } else if (functionName == "getEmailWhitelist") { response = getEmailWhitelist(isDefenceActive("EMAIL_WHITELIST", session.activeDefences)); } - if (functionName === "askQuestion"){ + if (functionName === "askQuestion") { console.debug("Asking question: " + params.question); // if asking a question, call the queryDocuments response = await queryDocuments(params.question); diff --git a/backend/test/unit/email.test.js b/backend/test/unit/email.test.js index e85065101..c1cab6867 100644 --- a/backend/test/unit/email.test.js +++ b/backend/test/unit/email.test.js @@ -13,12 +13,13 @@ test("GIVEN email is ready to be sent WHEN email is sent THEN session list is up }; const response = sendEmail(address, subject, body, session); // check the response - expect(response).toBe(JSON.stringify({ isEmailSent: true })); - // check the sent email has been added to the session - expect(session.sentEmails.length).toBe(1); - expect(session.sentEmails[0].address).toBe(address); - expect(session.sentEmails[0].subject).toBe(subject); - expect(session.sentEmails[0].content).toBe(body); + expect(response).toBe("Email sent to " + address + " with subject " + + subject + " and body " + body); +// check the sent email has been added to the session +expect(session.sentEmails.length).toBe(1); +expect(session.sentEmails[0].address).toBe(address); +expect(session.sentEmails[0].subject).toBe(subject); +expect(session.sentEmails[0].content).toBe(body); }); test("GIVEN EMAIL_WHITELIST envionrment variable is set WHEN getting whitelist AND whitelist defense on THEN list is returned", () => {