272 lines
7.5 KiB
Plaintext
272 lines
7.5 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
|
|
constructFn String
|
|
constructFnVersion 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 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[]
|
|
}
|
|
|
|
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 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)
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
name String?
|
|
email String? @unique
|
|
emailVerified DateTime?
|
|
image String?
|
|
accounts Account[]
|
|
sessions Session[]
|
|
organizationUsers OrganizationUser[]
|
|
organizations Organization[]
|
|
worldChampEntrant WorldChampEntrant?
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String
|
|
token String @unique
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
}
|