From 160414db8bba7b7846435728f83feafde489c2a7 Mon Sep 17 00:00:00 2001 From: "Heather Logan (She/Her)" Date: Tue, 1 Aug 2023 10:23:06 +0100 Subject: [PATCH] Add function calls to chat history for loop bug --- backend/src/email.js | 5 +---- backend/src/openai.js | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/src/email.js b/backend/src/email.js index 4a2455db6..e85cd2497 100644 --- a/backend/src/email.js +++ b/backend/src/email.js @@ -41,10 +41,7 @@ function sendEmail(address, subject, body, session) { console.log(response); // add the sent email to the session session.sentEmails.push(email); - const result = { - isEmailSent: true, - }; - return JSON.stringify(result); + return response; } module.exports = { diff --git a/backend/src/openai.js b/backend/src/openai.js index 34a5e787c..d570dc861 100644 --- a/backend/src/openai.js +++ b/backend/src/openai.js @@ -33,7 +33,7 @@ const chatGptFunctions = [ { name: "getEmailWhitelist", description: - "user asks who is on the email whitelist and the system replies with the list of emails. if the email whitelist defence is not active then user should be able to email anyone. ", + "user asks who is on the email whitelist and the system replies with the list of emails. ", parameters: { type: "object", properties: {} @@ -41,7 +41,7 @@ const chatGptFunctions = [ }, { name: "askQuestion", - description: "Ask a question about the documents", + description: "Ask a question about the documents with company information. ", parameters: { type: "object", properties: { @@ -168,6 +168,8 @@ async function chatGptSendMessage(message, session) { let reply = await chatGptChatCompletion(session); // check if GPT wanted to call a function while (reply.function_call) { + session.chatHistory.push(reply); + // call the function and get a new reply and defence info from const functionCallReply = await chatGptCallFunction( reply.function_call,