mirror of
https://github.com/vitalityAI/therapist.git
synced 2025-04-08 05:40:17 -04:00
Merge branch 'main' of https://github.com/vitalityAI/therapist into main
This commit is contained in:
commit
73fc637426
|
@ -39,7 +39,7 @@ model Message {
|
||||||
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
role Role
|
role Role
|
||||||
content String
|
content String @default("")
|
||||||
|
|
||||||
session Session @relation(fields: [sessionId], references: [id])
|
session Session @relation(fields: [sessionId], references: [id])
|
||||||
sessionId String @db.ObjectId
|
sessionId String @db.ObjectId
|
||||||
|
|
|
@ -69,10 +69,6 @@ app.post("/respond", async (req, res) => {
|
||||||
transferSession(req.body.CallSid, operatorPhone);
|
transferSession(req.body.CallSid, operatorPhone);
|
||||||
twiml.say("We're connecting you to a counselor now.");
|
twiml.say("We're connecting you to a counselor now.");
|
||||||
|
|
||||||
await addMessage(callId, Role.BOT, "");
|
|
||||||
let summary = await summarize(callId);
|
|
||||||
console.log(summary);
|
|
||||||
|
|
||||||
const dial = twiml.dial({});
|
const dial = twiml.dial({});
|
||||||
dial.number(operatorPhone);
|
dial.number(operatorPhone);
|
||||||
res.type("text/xml");
|
res.type("text/xml");
|
||||||
|
|
|
@ -36,7 +36,10 @@ 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),
|
||||||
content: msg.content,
|
content:
|
||||||
|
msg.content.length > 0
|
||||||
|
? msg.content
|
||||||
|
: "This message was not recorded correctly.",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@ import { Role } from "@prisma/client";
|
||||||
import { db } from "./db.js";
|
import { db } from "./db.js";
|
||||||
|
|
||||||
export const createSession = async (callId, callerPhone) => {
|
export const createSession = async (callId, callerPhone) => {
|
||||||
|
let session = await findSessionByCallId(callId);
|
||||||
|
if (session) return session;
|
||||||
|
|
||||||
return await db.session.create({
|
return await db.session.create({
|
||||||
data: {
|
data: {
|
||||||
callId: callId,
|
callId: callId,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user