mirror of
https://github.com/vitalityAI/therapist.git
synced 2025-04-08 05:40:17 -04:00
chore: chatjs formatting
This commit is contained in:
parent
07fbc1ab29
commit
ecdd45b638
14
src/chat.js
14
src/chat.js
|
@ -11,15 +11,15 @@ const configuration = new Configuration({
|
||||||
const openai = new OpenAIApi(configuration);
|
const openai = new OpenAIApi(configuration);
|
||||||
|
|
||||||
const convertRole = (role) => {
|
const convertRole = (role) => {
|
||||||
switch(role){
|
switch (role) {
|
||||||
case Role.BOT:
|
case Role.BOT:
|
||||||
return "assistant"
|
return "assistant";
|
||||||
case Role.USER:
|
case Role.USER:
|
||||||
return "user"
|
return "user";
|
||||||
default:
|
default:
|
||||||
return "user"
|
return "user";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
export const chat = async (callId) => {
|
export const chat = async (callId) => {
|
||||||
const msgs = await getMessages(callId);
|
const msgs = await getMessages(callId);
|
||||||
|
@ -38,12 +38,12 @@ export const chat = async (callId) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(messages)
|
console.log(messages);
|
||||||
|
|
||||||
const res = await openai.createChatCompletion({
|
const res = await openai.createChatCompletion({
|
||||||
model: "gpt-3.5-turbo",
|
model: "gpt-3.5-turbo",
|
||||||
messages: messages,
|
messages: messages,
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.data.choices[0].message.content
|
return res.data.choices[0].message.content;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user