Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

db

Max Deichmannbc558098fbe6
diff --git a/prisma/migrations/20230518193415_add_observaionts_and_traces/migration.sql b/prisma/migrations/20230518193415_add_observaionts_and_traces/migration.sql
new file mode 100644
index 0000000000..c53bda787f
--- /dev/null
+++ b/prisma/migrations/20230518193415_add_observaionts_and_traces/migration.sql
@@ -0,0 +1,30 @@
+-- CreateTable
+CREATE TABLE "traces" (
+ "id" TEXT NOT NULL,
+ "timestamp" TIMESTAMP(3) NOT NULL,
+ "name" TEXT NOT NULL,
+ "attributes" JSONB NOT NULL,
+ "status" TEXT NOT NULL,
+ "status_message" TEXT,
+
+ CONSTRAINT "traces_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "observations" (
+ "id" TEXT NOT NULL,
+ "traceId" TEXT NOT NULL,
+ "name" TEXT NOT NULL,
+ "start_time" TIMESTAMP(3) NOT NULL,
+ "end_time" TIMESTAMP(3) NOT NULL,
+ "attributes" JSONB NOT NULL,
+ "parentObservationId" TEXT,
+
+ CONSTRAINT "observations_pkey" PRIMARY KEY ("id")
+);
+
+-- AddForeignKey
+ALTER TABLE "observations" ADD CONSTRAINT "observations_traceId_fkey" FOREIGN KEY ("traceId") REFERENCES "traces"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "observations" ADD CONSTRAINT "observations_parentObservationId_fkey" FOREIGN KEY ("parentObservationId") REFERENCES "observations"("id") ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/prisma/migrations/20230518193521_changes/migration.sql b/prisma/migrations/20230518193521_changes/migration.sql
new file mode 100644
index 0000000000..9c77542553
--- /dev/null
+++ b/prisma/migrations/20230518193521_changes/migration.sql
@@ -0,0 +1,17 @@
+/*
+ Warnings:
+
+ - You are about to drop the column `parentObservationId` on the `observations` table. All the data in the column will be lost.
+ - Added the required column `type` to the `observations` table without a default value. This is not possible if the table is not empty.
+
+*/
+-- DropForeignKey
+ALTER TABLE "observations" DROP CONSTRAINT "observations_parentObservationId_fkey";
+
+-- AlterTable
+ALTER TABLE "observations" DROP COLUMN "parentObservationId",
+ADD COLUMN "parent_observation_id" TEXT,
+ADD COLUMN "type" TEXT NOT NULL;
+
+-- AddForeignKey
+ALTER TABLE "observations" ADD CONSTRAINT "observations_parent_observation_id_fkey" FOREIGN KEY ("parent_observation_id") REFERENCES "observations"("id") ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index c8adfdf5d2..ce4fdf670f 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -62,3 +62,32 @@ model VerificationToken {
@@unique([identifier, token])
}
+
+model Trace {
+ id String @id @default(cuid())
+ timestamp DateTime
+ name String
+ attributes Json
+ status String
+ statusMessage String? @map("status_message")
+ Observations Observations[]
+
+ @@map("traces")
+}
+
+model Observations {
+ id String @id @default(cuid())
+ traceId String
+ trace Trace @relation(fields: [traceId], references: [id], onDelete: Cascade)
+
+ type String
+ name String
+ startTime DateTime @map("start_time")
+ endTime DateTime @map("end_time")
+ attributes Json
+ parentObservationId String? @map("parent_observation_id")
+ parent Observations? @relation("ParentChilds", fields: [parentObservationId], references: [id])
+ childs Observations[] @relation("ParentChilds")
+
+ @@map("observations")
+}