@@ -1221,6 +1221,7 @@ def create_score(
12211221 data_type : Optional [Literal ["NUMERIC" , "BOOLEAN" ]] = None ,
12221222 comment : Optional [str ] = None ,
12231223 config_id : Optional [str ] = None ,
1224+ metadata : Optional [Any ] = None ,
12241225 ) -> None : ...
12251226
12261227 @overload
@@ -1235,19 +1236,23 @@ def create_score(
12351236 data_type : Optional [Literal ["CATEGORICAL" ]] = "CATEGORICAL" ,
12361237 comment : Optional [str ] = None ,
12371238 config_id : Optional [str ] = None ,
1239+ metadata : Optional [Any ] = None ,
12381240 ) -> None : ...
12391241
12401242 def create_score (
12411243 self ,
12421244 * ,
12431245 name : str ,
12441246 value : Union [float , str ],
1245- trace_id : str ,
1247+ session_id : Optional [str ] = None ,
1248+ dataset_run_id : Optional [str ] = None ,
1249+ trace_id : Optional [str ] = None ,
12461250 observation_id : Optional [str ] = None ,
12471251 score_id : Optional [str ] = None ,
12481252 data_type : Optional [ScoreDataType ] = None ,
12491253 comment : Optional [str ] = None ,
12501254 config_id : Optional [str ] = None ,
1255+ metadata : Optional [Any ] = None ,
12511256 ) -> None :
12521257 """Create a score for a specific trace or observation.
12531258
@@ -1257,12 +1262,15 @@ def create_score(
12571262 Args:
12581263 name: Name of the score (e.g., "relevance", "accuracy")
12591264 value: Score value (can be numeric for NUMERIC/BOOLEAN types or string for CATEGORICAL)
1265+ session_id: ID of the Langfuse session to associate the score with
1266+ dataset_run_id: ID of the Langfuse dataset run to associate the score with
12601267 trace_id: ID of the Langfuse trace to associate the score with
1261- observation_id: Optional ID of the specific observation to score
1268+ observation_id: Optional ID of the specific observation to score. Trace ID must be provided too.
12621269 score_id: Optional custom ID for the score (auto-generated if not provided)
12631270 data_type: Type of score (NUMERIC, BOOLEAN, or CATEGORICAL)
12641271 comment: Optional comment or explanation for the score
12651272 config_id: Optional ID of a score config defined in Langfuse
1273+ metadata: Optional metadata to be attached to the score
12661274
12671275 Example:
12681276 ```python
@@ -1293,6 +1301,8 @@ def create_score(
12931301 try :
12941302 score_event = {
12951303 "id" : score_id ,
1304+ "session_id" : session_id ,
1305+ "dataset_run_id" : dataset_run_id ,
12961306 "trace_id" : trace_id ,
12971307 "observation_id" : observation_id ,
12981308 "name" : name ,
@@ -1301,6 +1311,7 @@ def create_score(
13011311 "comment" : comment ,
13021312 "config_id" : config_id ,
13031313 "environment" : self ._environment ,
1314+ "metadata" : metadata ,
13041315 }
13051316
13061317 new_body = ScoreBody (** score_event )
0 commit comments