mirror of
https://github.com/vitalityAI/therapist.git
synced 2025-04-08 05:40:17 -04:00
fixed chat?
This commit is contained in:
parent
0b399d17c8
commit
6fb6ebcb3a
|
@ -1,6 +1,6 @@
|
||||||
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.js";
|
||||||
import { Role } from "@prisma/client";
|
import { Role } from "@prisma/client";
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
|
@ -31,8 +31,6 @@ export const chat = async (callId) => {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (let msg of msgs) {
|
for (let msg of msgs) {
|
||||||
messages.push({
|
messages.push({
|
||||||
role: convertRole(msg.role),
|
role: convertRole(msg.role),
|
||||||
|
@ -40,8 +38,10 @@ export const chat = async (callId) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
};
|
};
|
||||||
|
|
10
src/test.js
10
src/test.js
|
@ -1,11 +1,9 @@
|
||||||
import { Conversation } from "./chat.js"
|
import { chat } from "./chat.js"
|
||||||
|
import { createSession } from "./session.js"
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
let convo = new Conversation()
|
// const session = await createSession("testid", "12345")
|
||||||
let res = await convo.message("I'm just feeling sad.")
|
console.log(await chat("testid"))
|
||||||
console.log("RESPONSE", res)
|
|
||||||
res = await convo.message("Yeah. My parents got divorced last week, and I think it's my fault.")
|
|
||||||
console.log("RESPONSE", res)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user