From 488cfb722cad4539e2a944bcd32785820817c21e Mon Sep 17 00:00:00 2001 From: Rushil Umaretiya Date: Sat, 4 Mar 2023 21:20:21 -0500 Subject: [PATCH] chore: prettier --- src/chat.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/chat.js b/src/chat.js index 2b14cba..2439d28 100644 --- a/src/chat.js +++ b/src/chat.js @@ -1,7 +1,7 @@ import { Configuration, OpenAIApi } from "openai"; -import * as dotenv from 'dotenv' +import * as dotenv from "dotenv"; import { getMessages } from "./session"; -dotenv.config() +dotenv.config(); const configuration = new Configuration({ apiKey: process.env.OPENAI_API_KEY, @@ -10,23 +10,24 @@ const configuration = new Configuration({ const openai = new OpenAIApi(configuration); export const chat = async (callId) => { - const msgs = await getMessages(callId) + const msgs = await getMessages(callId); const messages = [ { - "role": "system", - "content": "ChatGPT, for the following conversation, please pretend to be a therapist working at a suicide. Respond as if I've called you." - } - ] - - for(let msg of msgs){ + role: "system", + content: + "ChatGPT, for the following conversation, please pretend to be a therapist working at a suicide. Respond as if I've called you.", + }, + ]; + + for (let msg of msgs) { messages.push({ - "role": msg.role, - "content": msg.content - }) + role: msg.role, + content: msg.content, + }); } await openai.createChatCompletion({ model: "gpt-3.5-turbo", - messages: messages - }) -} + messages: messages, + }); +};