From 7637b94ea77f79d7907c35df74d3a70360f8b701 Mon Sep 17 00:00:00 2001 From: Kyle Corbitt Date: Sat, 5 Aug 2023 13:49:03 -0700 Subject: [PATCH] schema changes --- app/prisma/schema.prisma | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/app/prisma/schema.prisma b/app/prisma/schema.prisma index 6b8812f..32ce994 100644 --- a/app/prisma/schema.prisma +++ b/app/prisma/schema.prisma @@ -210,6 +210,8 @@ model Organization { organizationUsers OrganizationUser[] experiments Experiment[] datasets Dataset[] + loggedCalls LoggedCall[] + apiKeys ApiKey[] } enum OrganizationUserRole { @@ -249,6 +251,64 @@ model WorldChampEntrant { @@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