🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore: add TraceView to prisma schema (#1504)
Marc Klingendbc90662a2d4
diff --git a/packages/shared/prisma/generated/types.ts b/packages/shared/prisma/generated/types.tsindex e8a56430aa..b780d82b8f 100644--- a/packages/shared/prisma/generated/types.ts+++ b/packages/shared/prisma/generated/types.ts@@ -296,6 +296,24 @@ export type TraceSession = {bookmarked: Generated<boolean>;public: Generated<boolean>;};+export type TraceView = {+ id: string;+ external_id: string | null;+ timestamp: Generated<Timestamp>;+ name: string | null;+ user_id: string | null;+ metadata: unknown | null;+ release: string | null;+ version: string | null;+ project_id: string;+ public: Generated<boolean>;+ bookmarked: Generated<boolean>;+ tags: Generated<string[]>;+ input: unknown | null;+ output: unknown | null;+ session_id: string | null;+ duration: number | null;+};export type User = {id: string;name: string | null;@@ -335,6 +353,7 @@ export type DB = {Session: Session;trace_sessions: TraceSession;traces: Trace;+ traces_view: TraceView;users: User;verification_tokens: VerificationToken;};diff --git a/packages/shared/prisma/schema.prisma b/packages/shared/prisma/schema.prismaindex 0d8e2020a3..90ed5ed677 100644--- a/packages/shared/prisma/schema.prisma+++ b/packages/shared/prisma/schema.prisma@@ -185,6 +185,8 @@ model TraceSession {@@map("trace_sessions")}+// Update TraceView below when making changes to this model!+model Trace {id String @id @default(cuid())externalId String? @map("external_id")@@ -218,6 +220,33 @@ model Trace {@@map("traces")}+// This view is based on the trace table. Once prisma supports+// inheritance, we should remove code duplication here.+view TraceView {+ // trace fields+ id String @id @default(cuid())+ externalId String? @map("external_id")+ timestamp DateTime @default(now())+ name String?+ userId String? @map("user_id")+ metadata Json?+ release String?+ version String?+ projectId String @map("project_id")+ public Boolean @default(false)+ bookmarked Boolean @default(false)+ tags String[] @default([])+ input Json?+ output Json?+ sessionId String? @map("session_id")++ // calculated fields+ duration Float? @map("duration") // can be null if no observations in trace++ @@map("traces_view")+}++// Update ObservationView below when making changes to this model!model Observation {id String @id @default(cuid())traceId String? @map("trace_id")@@ -272,6 +301,51 @@ model Observation {@@map("observations")}+// This view is a mix of the observation and model. Once prisma supports+// inheritance, we should remove code duplication here.+view ObservationView {+ id String @id @default(cuid())+ traceId String? @map("trace_id")+ projectId String @map("project_id")+ type ObservationType+ startTime DateTime @default(now()) @map("start_time")+ endTime DateTime? @map("end_time")+ name String?+ metadata Json?+ parentObservationId String? @map("parent_observation_id")+ level ObservationLevel @default(DEFAULT)+ statusMessage String? @map("status_message")+ version String?+ createdAt DateTime @default(now()) @map("created_at")++ // GENERATION ONLY+ model String?+ modelParameters Json?+ input Json?+ output Json?+ promptTokens Int @default(0) @map("prompt_tokens")+ completionTokens Int @default(0) @map("completion_tokens")+ totalTokens Int @default(0) @map("total_tokens")+ unit String?+ completionStartTime DateTime? @map("completion_start_time")++ promptId String? @map("prompt_id")++ // model fields+ modelId String? @map("model_id")+ inputPrice Decimal? @map("input_price")+ outputPrice Decimal? @map("output_price")+ totalPrice Decimal? @map("total_price")++ // calculated fields+ calculatedInputCost Decimal? @map("calculated_input_cost")+ calculatedOutputCost Decimal? @map("calculated_output_cost")+ calculatedTotalCost Decimal? @map("calculated_total_cost")+ latency Float? @map("latency")++ @@map("observations_view")+}+enum ObservationType {SPANEVENT@@ -452,6 +526,7 @@ model Prompt {@@map("prompts")}+// Update ObservationView below when making changes to this model!model Model {id String @id @default(cuid())createdAt DateTime @default(now()) @map("created_at")@@ -476,51 +551,6 @@ model Model {@@map("models")}-// This view is a mix of the observation and model. Once prisma supports-// inheritance, we should remove code duplication here.-view ObservationView {- id String @id @default(cuid())- traceId String? @map("trace_id")- projectId String @map("project_id")- type ObservationType- startTime DateTime @default(now()) @map("start_time")- endTime DateTime? @map("end_time")- name String?- metadata Json?- parentObservationId String? @map("parent_observation_id")- level ObservationLevel @default(DEFAULT)- statusMessage String? @map("status_message")- version String?- createdAt DateTime @default(now()) @map("created_at")-- // GENERATION ONLY- model String?- modelParameters Json?- input Json?- output Json?- promptTokens Int @default(0) @map("prompt_tokens")- completionTokens Int @default(0) @map("completion_tokens")- totalTokens Int @default(0) @map("total_tokens")- unit String?- completionStartTime DateTime? @map("completion_start_time")-- promptId String? @map("prompt_id")-- // model fields- modelId String? @map("model_id")- inputPrice Decimal? @map("input_price")- outputPrice Decimal? @map("output_price")- totalPrice Decimal? @map("total_price")-- // calculated fields- calculatedInputCost Decimal? @map("calculated_input_cost")- calculatedOutputCost Decimal? @map("calculated_output_cost")- calculatedTotalCost Decimal? @map("calculated_total_cost")- latency Float? @map("latency")-- @@map("observations_view")-}-model AuditLog {id String @id @default(cuid())createdAt DateTime @default(now()) @map("created_at")