Skip to content

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

Add typing of observations

Marc Klingende646ecbbe52
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index f059194d62..e252d5c6d1 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -83,7 +83,7 @@ model Observation {
type ObservationType
name String
startTime DateTime @map("start_time")
- endTime DateTime @map("end_time")
+ endTime DateTime? @map("end_time")
attributes Json
parentObservationId String? @map("parent_observation_id")
parent Observation? @relation("ParentChilds", fields: [parentObservationId], references: [id])
diff --git a/src/utils/types.ts b/src/utils/types.ts
index eee42dfd42..73af94dc09 100644
--- a/src/utils/types.ts
+++ b/src/utils/types.ts
@@ -6,7 +6,19 @@ export type NestedObservation = Observation & {
// TODO: Marc add types for span and event
+export type TypedObservation = Event | Span | LlmCall;
+
+export type Event = Observation & {
+ type: "EVENT";
+};
+
+export type Span = Observation & {
+ type: "SPAN";
+ endTime: Date; // not null
+};
+
export type LlmCall = Observation & {
+ type: "LLMCALL";
attributes: {
prompt?: string;
completion?: string;