Skip to content

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

chore: correct number parsing from postgres in clickhouse merge (#3987)

Steffen Schmitzf14c611aaca8
diff --git a/packages/shared/src/server/definitions.ts b/packages/shared/src/server/definitions.ts
index 85bbdbeb95..c8b6ee84ef 100644
--- a/packages/shared/src/server/definitions.ts
+++ b/packages/shared/src/server/definitions.ts
@@ -252,16 +252,16 @@ export const convertPostgresObservationToInsert = (
total: observation.total_tokens,
},
provided_cost_details: {
- input: observation.input_cost,
- output: observation.output_cost,
- total: observation.total_cost,
+ input: observation.input_cost?.toNumber() ?? null,
+ output: observation.output_cost?.toNumber() ?? null,
+ total: observation.total_cost?.toNumber() ?? null,
},
cost_details: {
- input: observation.calculated_input_cost,
- output: observation.calculated_output_cost,
- total: observation.calculated_total_cost,
+ input: observation.calculated_input_cost?.toNumber() ?? null,
+ output: observation.calculated_output_cost?.toNumber() ?? null,
+ total: observation.calculated_total_cost?.toNumber() ?? null,
},
- total_cost: observation.calculated_total_cost,
+ total_cost: observation.calculated_total_cost?.toNumber() ?? null,
completion_start_time: observation.completion_start_time?.getTime(),
prompt_id: observation.prompt_id,
prompt_name: observation.prompt_name,
diff --git a/worker/src/services/IngestionService/tests/IngestionService.integration.test.ts b/worker/src/services/IngestionService/tests/IngestionService.integration.test.ts
index f628735456..72d625a4d5 100644
--- a/worker/src/services/IngestionService/tests/IngestionService.integration.test.ts
+++ b/worker/src/services/IngestionService/tests/IngestionService.integration.test.ts
@@ -1069,6 +1069,8 @@ describe("Ingestion end-to-end tests", () => {
model: "gpt-3.5",
projectId,
startTime: new Date(oldEvent),
+ // Validates that numbers are parsed correctly. Since there is no usage, no effect on result
+ calculatedTotalCost: "0.273330000000000000000000000000",
},
});
@@ -1082,6 +1084,7 @@ describe("Ingestion end-to-end tests", () => {
traceId: traceId,
modelParameters: { someKey: ["user-1", "user-2"] },
output: "overwritten",
+ usage: null,
},
},
];