🪢 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
feat(api): promote score creation from legacy (#15528)
Hassieb Pakzadfb0fe5368c05
diff --git a/.github/workflows/sdk-api-spec.yml b/.github/workflows/sdk-api-spec.ymlindex bab7b2ddc6..7c53ac4187 100644--- a/.github/workflows/sdk-api-spec.yml+++ b/.github/workflows/sdk-api-spec.yml@@ -75,8 +75,9 @@ jobs:# (could not find the right option to prevent this in generation step)rm -rf langfuse/api/tests- # Install dependencies and format+ # Install dependencies, preserve backwards-compatible score creation aliases, and formatuv sync --all-extras --frozen+ uv run python scripts/patch_generated_score_compat.pyuv run ruff format langfuse/api# Check for changes and show diff for debugging@@ -122,6 +123,9 @@ jobs:# Copy generated TypeScript SDK filescp -r ../langfuse/generated/typescript/* packages/core/src/api/+ # Preserve backwards-compatible score creation aliases+ node scripts/patch-generated-score-create-alias.mjs+# Patch compilation error inducing output# Without this patch, the JS SDK will not build due to# "Error: packages/core build: src/api/core/auth/index.ts(1,10): error TS1205: Re-exporting a type when 'isolatedModules' is enabled requires using 'export type'."diff --git a/fern/apis/server/definition/legacy/score-v1.yml b/fern/apis/server/definition/legacy/score-v1.ymlindex 1154735814..54560bd070 100644--- a/fern/apis/server/definition/legacy/score-v1.yml+++ b/fern/apis/server/definition/legacy/score-v1.yml@@ -1,17 +1,8 @@# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json-imports:- pagination: ../utils/pagination.yml- commons: ../commons.ymlservice:auth: truebase-path: /api/publicendpoints:- create:- docs: Create a score (supports both trace and session scores)- method: POST- path: /scores- request: CreateScoreRequest- response: CreateScoreResponsedelete:docs: Delete a score (supports both trace and session scores)method: DELETE@@ -20,97 +11,3 @@ service:scoreId:type: stringdocs: The unique langfuse identifier of a score-types:- CreateScoreRequest:- properties:- id: optional<string>- traceId: optional<string>- sessionId: optional<string>- observationId: optional<string>- datasetRunId: optional<string>- name: string- value:- type: commons.CreateScoreValue- docs: The value of the score. Must be passed as string for categorical and text scores, and numeric for boolean and numeric scores. Boolean score values must equal either 1 or 0 (true or false). Text score values must be between 1 and 500 characters.- comment: optional<string>- metadata: optional<map<string, unknown>>- environment:- type: optional<string>- docs: The environment of the score. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.- queueId:- type: optional<string>- docs: The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.- dataType:- type: optional<commons.ScoreDataType>- docs: The data type of the score. When passing a configId this field is inferred. Otherwise, this field must be passed or will default to numeric.- configId:- type: optional<string>- docs: Reference a score config on a score. The unique langfuse identifier of a score config. When passing this field, the dataType and stringValue fields are automatically populated.- source:- type: optional<CreateScoreSource>- docs: The source of the score. Defaults to API. Set to ANNOTATION to prefill scores (e.g. from an LLM) for a human reviewer to verify in an annotation queue. When source is ANNOTATION, a configId is required unless dataType is CORRECTION. EVAL is reserved for internal evaluator outputs and is not accepted on this endpoint.- examples:- - value:- name: "novelty"- value: 0.9- traceId: "cdef-1234-5678-90ab"- - value:- name: "consistency"- value: 1.2- dataType: "NUMERIC"- traceId: "cdef-1234-5678-90ab"- - value:- name: "accuracy"- value: 0.9- dataType: "NUMERIC"- configId: "9203-4567-89ab-cdef"- traceId: "cdef-1234-5678-90ab"- environment: "test"- - value:- name: "toxicity"- value: "not toxic"- traceId: "cdef-1234-5678-90ab"- environment: "production"- - value:- name: "correctness"- value: "partially correct"- dataType: "CATEGORICAL"- configId: "1234-5678-90ab-cdef"- traceId: "cdef-1234-5678-90ab"- - value:- name: "hallucination"- value: 0- dataType: "BOOLEAN"- traceId: "cdef-1234-5678-90ab"- - value:- name: "helpfulness"- value: 1- dataType: "BOOLEAN"- configId: "1234-5678-90ab-cdef"- traceId: "cdef-1234-5678-90ab"- - value:- name: "feedback"- value: "Great explanation of the concept"- dataType: "TEXT"- traceId: "cdef-1234-5678-90ab"- - value:- name: "accuracy"- value: 0.9- dataType: "NUMERIC"- configId: "9203-4567-89ab-cdef"- traceId: "cdef-1234-5678-90ab"- source: "ANNOTATION"- queueId: "aq-1234-5678-90ab-cdef"- CreateScoreSource:- docs: |- Source values accepted when creating a score via the public REST API.- EVAL is reserved for internal evaluator outputs and is intentionally not- exposed here — use commons.ScoreSource when reading scores.- enum:- - API- - ANNOTATION- CreateScoreResponse:- properties:- id:- type: string- docs: The id of the created object in Langfusediff --git a/fern/apis/server/definition/scores.yml b/fern/apis/server/definition/scores.ymlindex f70b12c2e0..300a7cddd9 100644--- a/fern/apis/server/definition/scores.yml+++ b/fern/apis/server/definition/scores.yml@@ -4,8 +4,14 @@ imports:commons: ./commons.ymlservice:auth: true- base-path: /api/public/v2+ base-path: /api/publicendpoints:+ create:+ docs: Create a score (supports trace, observation, session, and dataset run scores)+ method: POST+ path: /scores+ request: CreateScoreRequest+ response: CreateScoreResponseget-many:availability:status: deprecated@@ -16,7 +22,7 @@ service:Get a list of scores (supports both trace and session scores)method: GET- path: /scores+ path: /v2/scoresrequest:name: GetScoresRequestquery-parameters:@@ -101,7 +107,7 @@ service:Get a score (supports both trace and session scores)method: GET- path: /scores/{scoreId}+ path: /v2/scores/{scoreId}path-parameters:scoreId:type: string@@ -109,6 +115,100 @@ service:response: commons.Scoretypes:+ CreateScoreRequest:+ properties:+ id: optional<string>+ traceId: optional<string>+ sessionId: optional<string>+ observationId: optional<string>+ datasetRunId: optional<string>+ name: string+ value:+ type: commons.CreateScoreValue+ docs: The value of the score. Must be passed as string for categorical and text scores, and numeric for boolean and numeric scores. Boolean score values must equal either 1 or 0 (true or false). Text score values must be between 1 and 500 characters.+ comment: optional<string>+ metadata: optional<map<string, unknown>>+ environment:+ type: optional<string>+ docs: The environment of the score. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.+ queueId:+ type: optional<string>+ docs: The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.+ dataType:+ type: optional<commons.ScoreDataType>+ docs: The data type of the score. When passing a configId this field is inferred. Otherwise, this field must be passed or will default to numeric.+ configId:+ type: optional<string>+ docs: Reference a score config on a score. The unique langfuse identifier of a score config. When passing this field, the dataType and stringValue fields are automatically populated.+ source:+ type: optional<CreateScoreSource>+ docs: The source of the score. Defaults to API. Set to ANNOTATION to prefill scores (e.g. from an LLM) for a human reviewer to verify in an annotation queue. When source is ANNOTATION, a configId is required unless dataType is CORRECTION. EVAL is reserved for internal evaluator outputs and is not accepted on this endpoint.+ examples:+ - value:+ name: "novelty"+ value: 0.9+ traceId: "cdef-1234-5678-90ab"+ - value:+ name: "consistency"+ value: 1.2+ dataType: "NUMERIC"+ traceId: "cdef-1234-5678-90ab"+ - value:+ name: "accuracy"+ value: 0.9+ dataType: "NUMERIC"+ configId: "9203-4567-89ab-cdef"+ traceId: "cdef-1234-5678-90ab"+ environment: "test"+ - value:+ name: "toxicity"+ value: "not toxic"+ traceId: "cdef-1234-5678-90ab"+ environment: "production"+ - value:+ name: "correctness"+ value: "partially correct"+ dataType: "CATEGORICAL"+ configId: "1234-5678-90ab-cdef"+ traceId: "cdef-1234-5678-90ab"+ - value:+ name: "hallucination"+ value: 0+ dataType: "BOOLEAN"+ traceId: "cdef-1234-5678-90ab"+ - value:+ name: "helpfulness"+ value: 1+ dataType: "BOOLEAN"+ configId: "1234-5678-90ab-cdef"+ traceId: "cdef-1234-5678-90ab"+ - value:+ name: "feedback"+ value: "Great explanation of the concept"+ dataType: "TEXT"+ traceId: "cdef-1234-5678-90ab"+ - value:+ name: "accuracy"+ value: 0.9+ dataType: "NUMERIC"+ configId: "9203-4567-89ab-cdef"+ traceId: "cdef-1234-5678-90ab"+ source: "ANNOTATION"+ queueId: "aq-1234-5678-90ab-cdef"+ CreateScoreSource:+ docs: |+ Source values accepted when creating a score via the public REST API.+ EVAL is reserved for internal evaluator outputs and is intentionally not+ exposed here — use commons.ScoreSource when reading scores.+ enum:+ - API+ - ANNOTATION+ CreateScoreResponse:+ properties:+ id:+ type: string+ docs: The id of the created object in Langfuse+GetScoresResponseTraceData:properties:userId:diff --git a/web/public/generated/api/openapi.yml b/web/public/generated/api/openapi.ymlindex c10e689fc9..d99eec119d 100644--- a/web/public/generated/api/openapi.yml+++ b/web/public/generated/api/openapi.yml@@ -2422,52 +2422,6 @@ paths:application/json:schema: {}security: *ref_0- /api/public/scores:- post:- description: Create a score (supports both trace and session scores)- operationId: legacy_scoreV1_create- tags:- - LegacyScoreV1- parameters: []- responses:- '200':- description: ''- content:- application/json:- schema:- $ref: '#/components/schemas/legacyCreateScoreResponse'- '400':- description: ''- content:- application/json:- schema: {}- '401':- description: ''- content:- application/json:- schema: {}- '403':- description: ''- content:- application/json:- schema: {}- '404':- description: ''- content:- application/json:- schema: {}- '405':- description: ''- content:- application/json:- schema: {}- security: *ref_0- requestBody:- required: true- content:- application/json:- schema:- $ref: '#/components/schemas/legacyCreateScoreRequest'/api/public/scores/{scoreId}:delete:description: Delete a score (supports both trace and session scores)@@ -5686,6 +5640,54 @@ paths:application/json:schema: {}security: *ref_0+ /api/public/scores:+ post:+ description: >-+ Create a score (supports trace, observation, session, and dataset run+ scores)+ operationId: scores_create+ tags:+ - Scores+ parameters: []+ responses:+ '200':+ description: ''+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/CreateScoreResponse'+ '400':+ description: ''+ content:+ application/json:+ schema: {}+ '401':+ description: ''+ content:+ application/json:+ schema: {}+ '403':+ description: ''+ content:+ application/json:+ schema: {}+ '404':+ description: ''+ content:+ application/json:+ schema: {}+ '405':+ description: ''+ content:+ application/json:+ schema: {}+ security: *ref_0+ requestBody:+ required: true+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/CreateScoreRequest'/api/public/v2/scores:get:description: |-@@ -11950,99 +11952,6 @@ components:required:- data- meta- legacyCreateScoreRequest:- title: legacyCreateScoreRequest- type: object- properties:- id:- type: string- nullable: true- traceId:- type: string- nullable: true- sessionId:- type: string- nullable: true- observationId:- type: string- nullable: true- datasetRunId:- type: string- nullable: true- name:- type: string- value:- $ref: '#/components/schemas/CreateScoreValue'- description: >-- The value of the score. Must be passed as string for categorical and- text scores, and numeric for boolean and numeric scores. Boolean- score values must equal either 1 or 0 (true or false). Text score- values must be between 1 and 500 characters.- comment:- type: string- nullable: true- metadata:- type: object- additionalProperties: true- nullable: true- environment:- type: string- nullable: true- description: >-- The environment of the score. Can be any lowercase alphanumeric- string with hyphens and underscores that does not start with- 'langfuse'.- queueId:- type: string- nullable: true- description: >-- The annotation queue referenced by the score. Indicates if score was- initially created while processing annotation queue.- dataType:- $ref: '#/components/schemas/ScoreDataType'- nullable: true- description: >-- The data type of the score. When passing a configId this field is- inferred. Otherwise, this field must be passed or will default to- numeric.- configId:- type: string- nullable: true- description: >-- Reference a score config on a score. The unique langfuse identifier- of a score config. When passing this field, the dataType and- stringValue fields are automatically populated.- source:- $ref: '#/components/schemas/legacyCreateScoreSource'- nullable: true- description: >-- The source of the score. Defaults to API. Set to ANNOTATION to- prefill scores (e.g. from an LLM) for a human reviewer to verify in- an annotation queue. When source is ANNOTATION, a configId is- required unless dataType is CORRECTION. EVAL is reserved for- internal evaluator outputs and is not accepted on this endpoint.- required:- - name- - value- legacyCreateScoreSource:- title: legacyCreateScoreSource- type: string- enum:- - API- - ANNOTATION- description: |-- Source values accepted when creating a score via the public REST API.- EVAL is reserved for internal evaluator outputs and is intentionally not- exposed here — use commons.ScoreSource when reading scores.- legacyCreateScoreResponse:- title: legacyCreateScoreResponse- type: object- properties:- id:- type: string- description: The id of the created object in Langfuse- required:- - idLlmConnection:title: LlmConnectiontype: object@@ -13905,6 +13814,99 @@ components:required:- data- meta+ CreateScoreRequest:+ title: CreateScoreRequest+ type: object+ properties:+ id:+ type: string+ nullable: true+ traceId:+ type: string+ nullable: true+ sessionId:+ type: string+ nullable: true+ observationId:+ type: string+ nullable: true+ datasetRunId:+ type: string+ nullable: true+ name:+ type: string+ value:+ $ref: '#/components/schemas/CreateScoreValue'+ description: >-+ The value of the score. Must be passed as string for categorical and+ text scores, and numeric for boolean and numeric scores. Boolean+ score values must equal either 1 or 0 (true or false). Text score+ values must be between 1 and 500 characters.+ comment:+ type: string+ nullable: true+ metadata:+ type: object+ additionalProperties: true+ nullable: true+ environment:+ type: string+ nullable: true+ description: >-+ The environment of the score. Can be any lowercase alphanumeric+ string with hyphens and underscores that does not start with+ 'langfuse'.+ queueId:+ type: string+ nullable: true+ description: >-+ The annotation queue referenced by the score. Indicates if score was+ initially created while processing annotation queue.+ dataType:+ $ref: '#/components/schemas/ScoreDataType'+ nullable: true+ description: >-+ The data type of the score. When passing a configId this field is+ inferred. Otherwise, this field must be passed or will default to+ numeric.+ configId:+ type: string+ nullable: true+ description: >-+ Reference a score config on a score. The unique langfuse identifier+ of a score config. When passing this field, the dataType and+ stringValue fields are automatically populated.+ source:+ $ref: '#/components/schemas/CreateScoreSource'+ nullable: true+ description: >-+ The source of the score. Defaults to API. Set to ANNOTATION to+ prefill scores (e.g. from an LLM) for a human reviewer to verify in+ an annotation queue. When source is ANNOTATION, a configId is+ required unless dataType is CORRECTION. EVAL is reserved for+ internal evaluator outputs and is not accepted on this endpoint.+ required:+ - name+ - value+ CreateScoreSource:+ title: CreateScoreSource+ type: string+ enum:+ - API+ - ANNOTATION+ description: |-+ Source values accepted when creating a score via the public REST API.+ EVAL is reserved for internal evaluator outputs and is intentionally not+ exposed here — use commons.ScoreSource when reading scores.+ CreateScoreResponse:+ title: CreateScoreResponse+ type: object+ properties:+ id:+ type: string+ description: The id of the created object in Langfuse+ required:+ - idGetScoresResponseTraceData:title: GetScoresResponseTraceDatatype: object