mirror of
https://github.com/vitalityAI/therapist.git
synced 2025-04-08 05:40:17 -04:00
chore: prettier
This commit is contained in:
parent
c6219e6e6e
commit
488cfb722c
31
src/chat.js
31
src/chat.js
|
@ -1,7 +1,7 @@
|
||||||
import { Configuration, OpenAIApi } from "openai";
|
import { Configuration, OpenAIApi } from "openai";
|
||||||
import * as dotenv from 'dotenv'
|
import * as dotenv from "dotenv";
|
||||||
import { getMessages } from "./session";
|
import { getMessages } from "./session";
|
||||||
dotenv.config()
|
dotenv.config();
|
||||||
|
|
||||||
const configuration = new Configuration({
|
const configuration = new Configuration({
|
||||||
apiKey: process.env.OPENAI_API_KEY,
|
apiKey: process.env.OPENAI_API_KEY,
|
||||||
|
@ -10,23 +10,24 @@ const configuration = new Configuration({
|
||||||
const openai = new OpenAIApi(configuration);
|
const openai = new OpenAIApi(configuration);
|
||||||
|
|
||||||
export const chat = async (callId) => {
|
export const chat = async (callId) => {
|
||||||
const msgs = await getMessages(callId)
|
const msgs = await getMessages(callId);
|
||||||
const messages = [
|
const messages = [
|
||||||
{
|
{
|
||||||
"role": "system",
|
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."
|
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){
|
|
||||||
|
for (let msg of msgs) {
|
||||||
messages.push({
|
messages.push({
|
||||||
"role": msg.role,
|
role: msg.role,
|
||||||
"content": msg.content
|
content: msg.content,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await openai.createChatCompletion({
|
await openai.createChatCompletion({
|
||||||
model: "gpt-3.5-turbo",
|
model: "gpt-3.5-turbo",
|
||||||
messages: messages
|
messages: messages,
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user