Skip to content

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

fix: fix empty score names (#1299)

Max Deichmann0538f27caf18
diff --git a/web/next.config.mjs b/web/next.config.mjs
index 3cc2afe290..afd9a691d4 100644
--- a/web/next.config.mjs
+++ b/web/next.config.mjs
@@ -34,26 +34,26 @@ const nextConfig = {
],
},
// Required to check authentication status from langfuse.com
- ...(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined ?
- [
- {
- source: "/api/auth/session",
- headers: [
- {
- key: "Access-Control-Allow-Origin",
- value: "https://langfuse.com",
- },
- { key: "Access-Control-Allow-Credentials", value: "true" },
- { key: "Access-Control-Allow-Methods", value: "GET,POST" },
- {
- key: "Access-Control-Allow-Headers",
- value: "Content-Type, Authorization",
- },
- ]
- },
- ] : []
- )
- ]
+ ...(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined
+ ? [
+ {
+ source: "/api/auth/session",
+ headers: [
+ {
+ key: "Access-Control-Allow-Origin",
+ value: "https://langfuse.com",
+ },
+ { key: "Access-Control-Allow-Credentials", value: "true" },
+ { key: "Access-Control-Allow-Methods", value: "GET,POST" },
+ {
+ key: "Access-Control-Allow-Headers",
+ value: "Content-Type, Authorization",
+ },
+ ],
+ },
+ ]
+ : []),
+ ];
},
// webassembly support for @dqbd/tiktoken
diff --git a/web/sentry.server.config.ts b/web/sentry.server.config.ts
index 33c7f69149..6dbf9ed242 100644
--- a/web/sentry.server.config.ts
+++ b/web/sentry.server.config.ts
@@ -22,7 +22,7 @@ if (process.env.NEXT_PUBLIC_SENTRY_DSN)
) {
return 1.0;
}
- return 0.3;
+ return 1.0;
},
profilesSampleRate: 0.3, // Profiling sample rate is relative to tracesSampleRate
diff --git a/web/src/__tests__/ingestion.servertest.ts b/web/src/__tests__/ingestion.servertest.ts
index 7d476ca7b0..308fff56f0 100644
--- a/web/src/__tests__/ingestion.servertest.ts
+++ b/web/src/__tests__/ingestion.servertest.ts
@@ -768,6 +768,7 @@ describe("/api/public/ingestion API Endpoint", () => {
it("should fail for wrong event formats", async () => {
const traceId = v4();
+ const scoreId = v4();
const responseOne = await makeAPICall("POST", "/api/public/ingestion", {
batch: [
@@ -787,13 +788,23 @@ describe("/api/public/ingestion API Endpoint", () => {
version: "2.0.0",
},
},
+ {
+ id: v4(),
+ type: "score-create",
+ timestamp: new Date().toISOString(),
+ body: {
+ id: scoreId,
+ name: "",
+ traceId: traceId,
+ },
+ },
],
});
expect(responseOne.status).toBe(207);
expect("errors" in responseOne.body).toBe(true);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
- expect(responseOne.body.errors.length).toBe(1);
+ expect(responseOne.body.errors.length).toBe(2);
expect("successes" in responseOne.body).toBe(true);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expect(responseOne.body.successes.length).toBe(1);
diff --git a/web/src/features/filters/components/filter-builder.tsx b/web/src/features/filters/components/filter-builder.tsx
index 964f8c702d..e646109727 100644
--- a/web/src/features/filters/components/filter-builder.tsx
+++ b/web/src/features/filters/components/filter-builder.tsx
@@ -26,6 +26,7 @@ import {
filterOperators,
singleFilter,
} from "@/src/server/api/interfaces/filters";
+import { NonEmptyString } from "@/src/utils/zod";
// Has WipFilterState, passes all valid filters to parent onChange
export function FilterBuilder({
@@ -185,6 +186,7 @@ function FilterBuilderForm({
<tr key={i}>
<td className="p-1 text-sm">{i === 0 ? "Where" : "And"}</td>
<td className="flex gap-2 p-1">
+ {/* selector of the column to be filtered */}
<Select
value={filter.column ?? ""}
onValueChange={(value) =>
@@ -217,6 +219,7 @@ function FilterBuilderForm({
(column?.type === "numberObject" ||
column?.type === "stringObject") ? (
column.keyOptions ? (
+ // selector of the key of the object to be filtered
<Select
disabled={!filter.column}
onValueChange={(value) => {
@@ -228,11 +231,13 @@ function FilterBuilderForm({
<SelectValue placeholder="" />
</SelectTrigger>
<SelectContent>
- {column.keyOptions.map((option) => (
- <SelectItem key={option} value={option}>
- {option}
- </SelectItem>
- ))}
+ {column.keyOptions
+ .filter((o) => NonEmptyString.safeParse(o).success)
+ .map((option) => (
+ <SelectItem key={option} value={option}>
+ {option}
+ </SelectItem>
+ ))}
</SelectContent>
</Select>
) : (
diff --git a/web/src/features/public-api/server/ingestion-api-schema.ts b/web/src/features/public-api/server/ingestion-api-schema.ts
index 4c35f36288..f4aecf5d83 100644
--- a/web/src/features/public-api/server/ingestion-api-schema.ts
+++ b/web/src/features/public-api/server/ingestion-api-schema.ts
@@ -2,7 +2,7 @@ import lodash from "lodash";
import { z } from "zod";
import { ModelUsageUnit } from "@/src/constants";
-import { jsonSchema } from "@/src/utils/zod";
+import { NonEmptyString, jsonSchema } from "@/src/utils/zod";
import { ObservationLevel } from "@prisma/client";
export const Usage = z.object({
@@ -86,11 +86,11 @@ export const OptionalObservationBody = z.object({
});
export const CreateEventEvent = OptionalObservationBody.extend({
- id: z.string().nullish(),
+ id: NonEmptyString,
});
export const UpdateEventEvent = OptionalObservationBody.extend({
- id: z.string(),
+ id: NonEmptyString,
});
export const CreateSpanBody = CreateEventEvent.extend({
@@ -147,7 +147,7 @@ export const UpdateGenerationBody = UpdateSpanBody.extend({
export const ScoreBody = z.object({
id: z.string().nullish(),
- name: z.string(),
+ name: NonEmptyString,
value: z.number(),
traceId: z.string(),
observationId: z.string().nullish(),
diff --git a/web/src/server/api/routers/generations/filterOptionsQuery.ts b/web/src/server/api/routers/generations/filterOptionsQuery.ts
index 3baadfe689..616ed129ac 100644
--- a/web/src/server/api/routers/generations/filterOptionsQuery.ts
+++ b/web/src/server/api/routers/generations/filterOptionsQuery.ts
@@ -52,6 +52,7 @@ export const filterOptionsQuery = protectedProjectProcedure
const res: ObservationOptions = {
model: model
.filter((i) => i.model !== null)
+
.map((i) => ({
value: i.model as string,
count: i._count._all,
diff --git a/web/src/server/api/routers/traces.ts b/web/src/server/api/routers/traces.ts
index 8f2423ef87..26e1f3611b 100644
--- a/web/src/server/api/routers/traces.ts
+++ b/web/src/server/api/routers/traces.ts
@@ -201,6 +201,7 @@ export const traceRouter = createTRPCRouter({
byId: protectedGetTraceProcedure
.input(z.object({ traceId: z.string() }))
.query(async ({ input, ctx }) => {
+ console.log("input", input);
const trace = await ctx.prisma.trace.findFirstOrThrow({
where: {
id: input.traceId,
diff --git a/web/src/utils/zod.ts b/web/src/utils/zod.ts
index fe5330b718..eae55d84ff 100644
--- a/web/src/utils/zod.ts
+++ b/web/src/utils/zod.ts
@@ -51,3 +51,5 @@ export const paginationZod = {
export const noHtmlRegex = /<[^>]*>/;
export const noHtmlCheck = (value: string) => !noHtmlRegex.test(value);
+
+export const NonEmptyString = z.string().min(1);