Skip to content

Commit

Permalink
Add function calls to chat history for loop bug
Browse files Browse the repository at this point in the history
  • Loading branch information
heatherlogan-scottlogic committed Aug 1, 2023
1 parent 437a79b commit 160414d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 1 addition & 4 deletions backend/src/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 4 additions & 2 deletions backend/src/openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ 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: {}
}
},
{
name: "askQuestion",
description: "Ask a question about the documents",
description: "Ask a question about the documents with company information. ",
parameters: {
type: "object",
properties: {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 160414d

Please sign in to comment.