Storing the model on promptVariant is problematic because it isn't always in sync with the actual prompt definition. I'm removing it for now to see if we can get away with that -- might have to add it back in later if this causes trouble. Added `cost` to modelOutput as well so we can cache that, which is important given that the cost calculations won't be the same between different API providers.
252 lines
6.8 KiB
Plaintext
252 lines
6.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
|
|
|
|
TemplateVariable TemplateVariable[]
|
|
PromptVariant PromptVariant[]
|
|
TestScenario TestScenario[]
|
|
Evaluation Evaluation[]
|
|
}
|
|
|
|
model PromptVariant {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
label String
|
|
constructFn String
|
|
model 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
|
|
|
|
statusCode Int?
|
|
errorMessage String?
|
|
retryTime DateTime?
|
|
streamingChannel String?
|
|
retrievalStatus CellRetrievalStatus @default(COMPLETE)
|
|
|
|
modelOutput ModelOutput?
|
|
|
|
promptVariantId String @db.Uuid
|
|
promptVariant PromptVariant @relation(fields: [promptVariantId], references: [id], onDelete: Cascade)
|
|
|
|
testScenarioId String @db.Uuid
|
|
testScenario TestScenario @relation(fields: [testScenarioId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([promptVariantId, testScenarioId])
|
|
}
|
|
|
|
model ModelOutput {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
inputHash String
|
|
output Json
|
|
timeToComplete Int @default(0)
|
|
cost Float?
|
|
promptTokens Int?
|
|
completionTokens Int?
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
scenarioVariantCellId String @db.Uuid
|
|
scenarioVariantCell ScenarioVariantCell @relation(fields: [scenarioVariantCellId], references: [id], onDelete: Cascade)
|
|
outputEvaluation OutputEvaluation[]
|
|
|
|
@@unique([scenarioVariantCellId])
|
|
@@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
|
|
OutputEvaluation OutputEvaluation[]
|
|
}
|
|
|
|
model OutputEvaluation {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
|
|
// Number between 0 (fail) and 1 (pass)
|
|
result Float
|
|
details String?
|
|
|
|
modelOutputId String @db.Uuid
|
|
modelOutput ModelOutput @relation(fields: [modelOutputId], 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([modelOutputId, 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
|
|
OrganizationUser OrganizationUser[]
|
|
Experiment 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 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[]
|
|
OrganizationUser OrganizationUser[]
|
|
Organization Organization[]
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String
|
|
token String @unique
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
}
|