Spaces:
Runtime error
Runtime error
Download src/server/chat/service.ts from Ali-Developments/COURTRIX: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/Ali-Developments/COURTRIX/resolve/main/src/server/chat/service.ts
- Command line
-
hf download hf://spaces/Ali-Developments/COURTRIX/src/server/chat/service.ts
-
curl -L -o service.ts https://huggingface.co/spaces/Ali-Developments/COURTRIX/resolve/main/src/server/chat/service.ts
1.4 kB
| import type { Prisma } from "@prisma/client"; | |
| import { requireCaseByIdForOwner } from "@/server/cases/service"; | |
| import { db } from "@/server/db"; | |
| import type { CaseChatQuestionInput } from "@/server/validation/case"; | |
| export async function listCaseChatTurnsForOwner( | |
| ownerId: string, | |
| customerId: string, | |
| caseId: string, | |
| ) { | |
| await requireCaseByIdForOwner(ownerId, customerId, caseId); | |
| return db.caseChatTurn.findMany({ | |
| where: { | |
| ownerId, | |
| customerId, | |
| caseId, | |
| }, | |
| orderBy: { | |
| createdAt: "asc", | |
| }, | |
| }); | |
| } | |
| export async function listRecentCaseChatTurnsForOwner( | |
| ownerId: string, | |
| customerId: string, | |
| caseId: string, | |
| take = 8, | |
| ) { | |
| await requireCaseByIdForOwner(ownerId, customerId, caseId); | |
| return db.caseChatTurn.findMany({ | |
| where: { | |
| ownerId, | |
| customerId, | |
| caseId, | |
| }, | |
| orderBy: { | |
| createdAt: "desc", | |
| }, | |
| take, | |
| }); | |
| } | |
| export async function createCaseChatTurnForOwner( | |
| ownerId: string, | |
| customerId: string, | |
| caseId: string, | |
| input: CaseChatQuestionInput & { | |
| answer: string; | |
| sources: unknown; | |
| }, | |
| ) { | |
| await requireCaseByIdForOwner(ownerId, customerId, caseId); | |
| return db.caseChatTurn.create({ | |
| data: { | |
| ownerId, | |
| customerId, | |
| caseId, | |
| question: input.question.trim(), | |
| answer: input.answer, | |
| sources: input.sources as Prisma.InputJsonValue, | |
| }, | |
| }); | |
| } | |