Skip to content

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

convert scores to doubles (#103)

Maximilian Deichmannfcadbcc8eb55
diff --git a/fern/client/definition/score.yml b/fern/client/definition/score.yml
index 8dc6902f08..6f79d89726 100644
--- a/fern/client/definition/score.yml
+++ b/fern/client/definition/score.yml
@@ -18,7 +18,7 @@ types:
traceId: string
traceIdType: optional<TraceIdType>
name: string
- value: integer
+ value: double
observationId: optional<string>
comment: optional<string>
Score:
@@ -26,7 +26,7 @@ types:
id: string
traceId: string
name: string
- value: integer
+ value: double
observationId: optional<string>
timestamp: datetime
comment: optional<string>
diff --git a/fern/client/generators.yml b/fern/client/generators.yml
index 8ce3828242..669df4668d 100644
--- a/fern/client/generators.yml
+++ b/fern/client/generators.yml
@@ -2,15 +2,15 @@ default-group: local
groups:
local:
generators:
- - name: fernapi/fern-typescript-browser-sdk
- version: 0.7.1
- output:
- location: npm
- url: npm.buildwithfern.com
- package-name: "@finto-fern/react-client"
- config:
- namespaceExport: Langfuse
- allowCustomFetcher: true
+ # - name: fernapi/fern-typescript-browser-sdk
+ # version: 0.7.1
+ # output:
+ # location: npm
+ # url: npm.buildwithfern.com
+ # package-name: "@finto-fern/react-client"
+ # config:
+ # namespaceExport: Langfuse
+ # allowCustomFetcher: true
- name: fernapi/fern-openapi
version: 0.0.26
output:
diff --git a/fern/server/definition/commons.yml b/fern/server/definition/commons.yml
index e7d3190ca6..65094b7e54 100644
--- a/fern/server/definition/commons.yml
+++ b/fern/server/definition/commons.yml
@@ -81,7 +81,7 @@ types:
id: string
traceId: string
name: string
- value: integer
+ value: double
observationId: optional<string>
timestamp: datetime
comment: optional<string>
diff --git a/fern/server/definition/score.yml b/fern/server/definition/score.yml
index 119c9377d4..b1492a97ff 100644
--- a/fern/server/definition/score.yml
+++ b/fern/server/definition/score.yml
@@ -31,7 +31,7 @@ types:
traceId: string
traceIdType: optional<commons.TraceIdTypeEnum>
name: string
- value: integer
+ value: double
observationId: optional<string>
comment: optional<string>
Scores:
diff --git a/generated/openapi-client/openapi.yml b/generated/openapi-client/openapi.yml
index 98a7a1ed1e..eede8e8306 100644
--- a/generated/openapi-client/openapi.yml
+++ b/generated/openapi-client/openapi.yml
@@ -64,7 +64,8 @@ components:
name:
type: string
value:
- type: integer
+ type: number
+ format: double
observationId:
type: string
comment:
@@ -84,7 +85,8 @@ components:
name:
type: string
value:
- type: integer
+ type: number
+ format: double
observationId:
type: string
timestamp:
diff --git a/generated/openapi-server/openapi.yml b/generated/openapi-server/openapi.yml
index 843ce1f6a7..5bdc5ee33a 100644
--- a/generated/openapi-server/openapi.yml
+++ b/generated/openapi-server/openapi.yml
@@ -815,7 +815,8 @@ components:
name:
type: string
value:
- type: integer
+ type: number
+ format: double
observationId:
type: string
nullable: true
@@ -931,7 +932,8 @@ components:
name:
type: string
value:
- type: integer
+ type: number
+ format: double
observationId:
type: string
nullable: true
diff --git a/src/__tests__/scores.servertest.ts b/src/__tests__/scores.servertest.ts
index 8fedabda12..a7124cf1fd 100644
--- a/src/__tests__/scores.servertest.ts
+++ b/src/__tests__/scores.servertest.ts
@@ -38,6 +38,52 @@ describe("/api/public/scores API Endpoint", () => {
expect(dbTrace.length).toBeGreaterThan(0);
expect(dbTrace[0]?.id).toBe(traceId);
+ const scoreId = uuidv4();
+ const createScore = await makeAPICall("POST", "/api/public/scores", {
+ id: scoreId,
+ name: "score-name",
+ value: 100.5,
+ traceId: traceId,
+ });
+
+ expect(createScore.status).toBe(200);
+ const dbScore = await prisma.score.findUnique({
+ where: {
+ id: scoreId,
+ },
+ });
+
+ expect(dbScore?.id).toBe(scoreId);
+ expect(dbScore?.traceId).toBe(traceId);
+ expect(dbScore?.name).toBe("score-name");
+ expect(dbScore?.value).toBe(100.5);
+ expect(dbScore?.observationId).toBeNull();
+ });
+
+ it("should create score for a trace with int", async () => {
+ await pruneDatabase();
+
+ const traceId = uuidv4();
+
+ await makeAPICall("POST", "/api/public/traces", {
+ id: traceId,
+ name: "trace-name",
+ userId: "user-1",
+ projectId: "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",
+ metadata: { key: "value" },
+ release: "1.0.0",
+ version: "2.0.0",
+ });
+
+ const dbTrace = await prisma.trace.findMany({
+ where: {
+ id: traceId,
+ },
+ });
+
+ expect(dbTrace.length).toBeGreaterThan(0);
+ expect(dbTrace[0]?.id).toBe(traceId);
+
const scoreId = uuidv4();
const createScore = await makeAPICall("POST", "/api/public/scores", {
id: scoreId,
diff --git a/src/pages/api/public/scores.ts b/src/pages/api/public/scores.ts
index 56c8d6e854..3559486eee 100644
--- a/src/pages/api/public/scores.ts
+++ b/src/pages/api/public/scores.ts
@@ -9,7 +9,7 @@ import { checkApiAccessScope } from "@/src/features/publicApi/server/apiScope";
const ScoreCreateSchema = z.object({
id: z.string().nullish(),
name: z.string(),
- value: z.number().int(),
+ value: z.number(),
traceId: z.string(),
traceIdType: z.enum(["LANGFUSE", "EXTERNAL"]).nullish(),
observationId: z.string().nullish(),