🪢 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
perf: do not load observation i/o from db on traces.byId (#1053)
Max Deichmann0a99988e6e20
diff --git a/src/features/ingest/lib/usage.ts b/src/features/ingest/lib/usage.tsindex 33937c4dde..4d458b4c3a 100644--- a/src/features/ingest/lib/usage.ts+++ b/src/features/ingest/lib/usage.ts@@ -197,6 +197,7 @@ function unicodeToBytesInString(input: string): string {}return result;}+function unicodeToBytes(input: string): Uint8Array {const encoder = new TextEncoder();return encoder.encode(input);diff --git a/src/server/api/routers/traces.ts b/src/server/api/routers/traces.tsindex 1b1222e8ae..80211844e1 100644--- a/src/server/api/routers/traces.ts+++ b/src/server/api/routers/traces.ts@@ -208,6 +208,36 @@ export const traceRouter = createTRPCRouter({},});const observations = await ctx.prisma.observationView.findMany({+ select: {+ id: true,+ traceId: true,+ projectId: true,+ type: true,+ startTime: true,+ endTime: true,+ name: true,+ metadata: true,+ parentObservationId: true,+ level: true,+ statusMessage: true,+ version: true,+ createdAt: true,+ model: true,+ modelParameters: true,+ promptTokens: true,+ completionTokens: true,+ totalTokens: true,+ unit: true,+ completionStartTime: true,+ promptId: true,+ modelId: true,+ inputPrice: true,+ outputPrice: true,+ totalPrice: true,+ calculatedInputCost: true,+ calculatedOutputCost: true,+ calculatedTotalCost: true,+ },where: {traceId: {equals: input.traceId,@@ -237,11 +267,7 @@ export const traceRouter = createTRPCRouter({return {...trace,latency: latencyMs !== undefined ? latencyMs / 1000 : undefined,- observations: observations.map(- ({ input: _input, output: _output, ...rest }) => {- return { ...rest };- },- ) as ObservationReturnType[],+ observations: observations as ObservationReturnType[],};}),deleteMany: protectedProjectProcedure