370 lines
9.8 KiB
Plaintext
370 lines
9.8 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Experiment {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
label String
|
|
|
|
sortIndex Int @default(0)
|
|
|
|
organizationId String @db.Uuid
|
|
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
templateVariables TemplateVariable[]
|
|
promptVariants PromptVariant[]
|
|
testScenarios TestScenario[]
|
|
evaluations Evaluation[]
|
|
}
|
|
|
|
model PromptVariant {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
label String
|
|
promptConstructor String
|
|
promptConstructorVersion Int
|
|
model String
|
|
modelProvider String
|
|
|
|
uiId String @default(uuid()) @db.Uuid
|
|
visible Boolean @default(true)
|
|
sortIndex Int @default(0)
|
|
|
|
experimentId String @db.Uuid
|
|
experiment Experiment @relation(fields: [experimentId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
scenarioVariantCells ScenarioVariantCell[]
|
|
|
|
@@index([uiId])
|
|
}
|
|
|
|
model TestScenario {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
variableValues Json
|
|
|
|
uiId String @default(uuid()) @db.Uuid
|
|
visible Boolean @default(true)
|
|
sortIndex Int @default(0)
|
|
|
|
experimentId String @db.Uuid
|
|
experiment Experiment @relation(fields: [experimentId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
scenarioVariantCells ScenarioVariantCell[]
|
|
}
|
|
|
|
model TemplateVariable {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
label String
|
|
|
|
experimentId String @db.Uuid
|
|
experiment Experiment @relation(fields: [experimentId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
enum CellRetrievalStatus {
|
|
PENDING
|
|
IN_PROGRESS
|
|
COMPLETE
|
|
ERROR
|
|
}
|
|
|
|
model ScenarioVariantCell {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
retrievalStatus CellRetrievalStatus @default(COMPLETE)
|
|
jobQueuedAt DateTime?
|
|
jobStartedAt DateTime?
|
|
modelResponses ModelResponse[]
|
|
errorMessage String? // Contains errors that occurred independently of model responses
|
|
|
|
promptVariantId String @db.Uuid
|
|
promptVariant PromptVariant @relation(fields: [promptVariantId], references: [id], onDelete: Cascade)
|
|
prompt Json?
|
|
|
|
testScenarioId String @db.Uuid
|
|
testScenario TestScenario @relation(fields: [testScenarioId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([promptVariantId, testScenarioId])
|
|
}
|
|
|
|
model ModelResponse {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
inputHash String
|
|
requestedAt DateTime?
|
|
receivedAt DateTime?
|
|
output Json?
|
|
cost Float?
|
|
promptTokens Int?
|
|
completionTokens Int?
|
|
statusCode Int?
|
|
errorMessage String?
|
|
retryTime DateTime?
|
|
outdated Boolean @default(false)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
scenarioVariantCellId String @db.Uuid
|
|
scenarioVariantCell ScenarioVariantCell @relation(fields: [scenarioVariantCellId], references: [id], onDelete: Cascade)
|
|
outputEvaluations OutputEvaluation[]
|
|
|
|
@@index([inputHash])
|
|
}
|
|
|
|
enum EvalType {
|
|
CONTAINS
|
|
DOES_NOT_CONTAIN
|
|
GPT4_EVAL
|
|
}
|
|
|
|
model Evaluation {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
label String
|
|
evalType EvalType
|
|
value String
|
|
|
|
experimentId String @db.Uuid
|
|
experiment Experiment @relation(fields: [experimentId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
outputEvaluations OutputEvaluation[]
|
|
}
|
|
|
|
model OutputEvaluation {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
// Number between 0 (fail) and 1 (pass)
|
|
result Float
|
|
details String?
|
|
|
|
modelResponseId String @db.Uuid
|
|
modelResponse ModelResponse @relation(fields: [modelResponseId], references: [id], onDelete: Cascade)
|
|
|
|
evaluationId String @db.Uuid
|
|
evaluation Evaluation @relation(fields: [evaluationId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([modelResponseId, evaluationId])
|
|
}
|
|
|
|
model Dataset {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
name String
|
|
datasetEntries DatasetEntry[]
|
|
|
|
organizationId String @db.Uuid
|
|
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model DatasetEntry {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
input String
|
|
output String?
|
|
|
|
datasetId String @db.Uuid
|
|
dataset Dataset? @relation(fields: [datasetId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model Organization {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
personalOrgUserId String? @unique @db.Uuid
|
|
PersonalOrgUser User? @relation(fields: [personalOrgUserId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
organizationUsers OrganizationUser[]
|
|
experiments Experiment[]
|
|
datasets Dataset[]
|
|
loggedCalls LoggedCall[]
|
|
apiKeys ApiKey[]
|
|
}
|
|
|
|
enum OrganizationUserRole {
|
|
ADMIN
|
|
MEMBER
|
|
VIEWER
|
|
}
|
|
|
|
model OrganizationUser {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
role OrganizationUserRole
|
|
|
|
organizationId String @db.Uuid
|
|
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
|
|
userId String @db.Uuid
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([organizationId, userId])
|
|
}
|
|
|
|
model WorldChampEntrant {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
userId String @db.Uuid
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
approved Boolean @default(false)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([userId])
|
|
}
|
|
|
|
model LoggedCall {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
startTime DateTime
|
|
endTime DateTime
|
|
|
|
reqPayload Json
|
|
respPayload Json?
|
|
respStatus Int?
|
|
error String?
|
|
|
|
durationMs Int?
|
|
inputTokens Int?
|
|
outputTokens Int?
|
|
finishReason String?
|
|
completionId String?
|
|
totalCost Decimal? @db.Decimal(18, 12)
|
|
|
|
cacheParentId String? @db.Uuid
|
|
cacheParent LoggedCall? @relation(name: "CacheParentChild", fields: [cacheParentId], references: [id], onDelete: Cascade)
|
|
|
|
organizationId String @db.Uuid
|
|
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
|
|
tags LoggedCallTag[]
|
|
cacheChildren LoggedCall[] @relation(name: "CacheParentChild")
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([startTime])
|
|
}
|
|
|
|
model LoggedCallTag {
|
|
id String @id @default(cuid())
|
|
name String
|
|
value String?
|
|
|
|
loggedCallId String
|
|
loggedCall LoggedCall @relation(fields: [loggedCallId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([name])
|
|
@@index([name, value])
|
|
}
|
|
|
|
model ApiKey {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
name String
|
|
apiKey String @unique
|
|
|
|
organizationId String @db.Uuid
|
|
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model Account {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
userId String @db.Uuid
|
|
type String
|
|
provider String
|
|
providerAccountId String
|
|
refresh_token String? @db.Text
|
|
refresh_token_expires_in Int?
|
|
access_token String? @db.Text
|
|
expires_at Int?
|
|
token_type String?
|
|
scope String?
|
|
id_token String? @db.Text
|
|
session_state String?
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([provider, providerAccountId])
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
sessionToken String @unique
|
|
userId String @db.Uuid
|
|
expires DateTime
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
enum UserRole {
|
|
ADMIN
|
|
USER
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
name String?
|
|
email String? @unique
|
|
emailVerified DateTime?
|
|
image String?
|
|
|
|
role UserRole @default(USER)
|
|
|
|
accounts Account[]
|
|
sessions Session[]
|
|
organizationUsers OrganizationUser[]
|
|
organizations Organization[]
|
|
worldChampEntrant WorldChampEntrant?
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @default(now()) @updatedAt
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String
|
|
token String @unique
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
}
|