← Back to changelog
July 11, 2024

Create Non-Numeric Scores via SDKs

Picture Marlies MayerhoferMarlies Mayerhofer

The Langfuse API, Python and JS SDKs now support creating categorical, boolean and numeric scores.

Our improved API allows you to create categorical and boolean scores, in addition to the previously supported numeric scores. If you need your scores to follow a specific format (e.g. data type, range or name), you can now define a score configuration using the API or UI and validate scores against it.

Check out our scores documentation for score ingestion examples and code snippets.

New API routes

  • GET /api/public/score-configs
  • GET /api/public/score-configs/{configId}
  • POST /api/public/score-configs

Existing API Routes with new parameters

  • GET /api/public/scores can now retrieve scores by dataType and/or configId
  • POST /api/public/scores now supports defining dataType and/or configId

SDK methods

pip install langfuse
from langfuse import Langfuse
langfuse = Langfuse()
 
# Create a single numeric, categorical or boolean score
langfuse.score(
    score_name="accuracy",
    score_value=0.95,
    data_type="NUMERIC",
    trace_id="traceId"
)

Learn more

Was this page useful?

Questions? We're here to help

Subscribe to updates