Skip to content

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

fix: override score name when config is set (#4445)

Marc Klingencb7230ac41d7
diff --git a/packages/shared/src/server/ingestion/validateAndInflateScore.ts b/packages/shared/src/server/ingestion/validateAndInflateScore.ts
index f78ae28fd2..71e0c87a13 100644
--- a/packages/shared/src/server/ingestion/validateAndInflateScore.ts
+++ b/packages/shared/src/server/ingestion/validateAndInflateScore.ts
@@ -17,7 +17,7 @@ type ValidateAndInflateScoreParams = {
export async function validateAndInflateScore(
params: ValidateAndInflateScoreParams,
): Promise<Score> {
- const { body, projectId } = params;
+ const { body, projectId, scoreId } = params;
if (body.configId) {
const config = await prisma.scoreConfig.findFirst({
@@ -32,10 +32,22 @@ export async function validateAndInflateScore(
"The configId you provided does not match a valid config in this project",
);
- validateConfigAgainstBody(body, config as ValidatedScoreConfig);
+ // Override some fields in the score body with config fields
+ // We ignore the set fields in the body
+ const bodyWithConfigOverrides = {
+ ...body,
+ name: config.name,
+ };
+
+ validateConfigAgainstBody(
+ bodyWithConfigOverrides,
+ config as ValidatedScoreConfig,
+ );
return inflateScoreBody({
- ...params,
+ projectId,
+ scoreId,
+ body: bodyWithConfigOverrides,
config: config as ValidatedScoreConfig,
});
}