Skip to content

Commit d55d52c

Browse files
langfuse-botlangfuse-botmarliessophie
authored
feat(api): update API spec from langfuse/langfuse 966662e (#1508)
* feat(api): update API spec from langfuse/langfuse 966662e * chore: support dataset versioning via SDK * chore: support dataset versioning via SDK --------- Co-authored-by: langfuse-bot <langfuse-bot@langfuse.com> Co-authored-by: Marlies Mayerhofer <74332854+marliessophie@users.noreply.github.com>
1 parent c8798ac commit d55d52c

File tree

15 files changed

+365
-6
lines changed

15 files changed

+365
-6
lines changed

langfuse/_client/client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2442,13 +2442,20 @@ def get_trace_url(self, *, trace_id: Optional[str] = None) -> Optional[str]:
24422442
)
24432443

24442444
def get_dataset(
2445-
self, name: str, *, fetch_items_page_size: Optional[int] = 50
2445+
self,
2446+
name: str,
2447+
*,
2448+
fetch_items_page_size: Optional[int] = 50,
2449+
version: Optional[datetime] = None,
24462450
) -> "DatasetClient":
24472451
"""Fetch a dataset by its name.
24482452
24492453
Args:
24502454
name (str): The name of the dataset to fetch.
24512455
fetch_items_page_size (Optional[int]): All items of the dataset will be fetched in chunks of this size. Defaults to 50.
2456+
version (Optional[datetime]): Retrieve dataset items as they existed at this specific point in time (UTC).
2457+
If provided, returns the state of items at the specified UTC timestamp.
2458+
If not provided, returns the latest version. Must be a timezone-aware datetime object in UTC.
24522459
24532460
Returns:
24542461
DatasetClient: The dataset with the given name.
@@ -2465,6 +2472,7 @@ def get_dataset(
24652472
dataset_name=self._url_encode(name, is_url_param=True),
24662473
page=page,
24672474
limit=fetch_items_page_size,
2475+
version=version,
24682476
)
24692477
dataset_items.extend(new_items.data)
24702478

langfuse/api/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
Comment,
3737
CommentObjectType,
3838
ConfigCategory,
39+
CorrectionScore,
3940
CreateAnnotationQueueAssignmentResponse,
4041
CreateAnnotationQueueItemRequest,
4142
CreateAnnotationQueueRequest,
@@ -85,9 +86,11 @@
8586
GetScoresResponseData,
8687
GetScoresResponseDataBoolean,
8788
GetScoresResponseDataCategorical,
89+
GetScoresResponseDataCorrection,
8890
GetScoresResponseDataNumeric,
8991
GetScoresResponseData_Boolean,
9092
GetScoresResponseData_Categorical,
93+
GetScoresResponseData_Correction,
9194
GetScoresResponseData_Numeric,
9295
GetScoresResponseTraceData,
9396
HealthResponse,
@@ -199,6 +202,7 @@
199202
ScoreV1_Numeric,
200203
Score_Boolean,
201204
Score_Categorical,
205+
Score_Correction,
202206
Score_Numeric,
203207
SdkLogBody,
204208
SdkLogEvent,
@@ -293,6 +297,7 @@
293297
"Comment",
294298
"CommentObjectType",
295299
"ConfigCategory",
300+
"CorrectionScore",
296301
"CreateAnnotationQueueAssignmentResponse",
297302
"CreateAnnotationQueueItemRequest",
298303
"CreateAnnotationQueueRequest",
@@ -342,9 +347,11 @@
342347
"GetScoresResponseData",
343348
"GetScoresResponseDataBoolean",
344349
"GetScoresResponseDataCategorical",
350+
"GetScoresResponseDataCorrection",
345351
"GetScoresResponseDataNumeric",
346352
"GetScoresResponseData_Boolean",
347353
"GetScoresResponseData_Categorical",
354+
"GetScoresResponseData_Correction",
348355
"GetScoresResponseData_Numeric",
349356
"GetScoresResponseTraceData",
350357
"HealthResponse",
@@ -456,6 +463,7 @@
456463
"ScoreV1_Numeric",
457464
"Score_Boolean",
458465
"Score_Categorical",
466+
"Score_Correction",
459467
"Score_Numeric",
460468
"SdkLogBody",
461469
"SdkLogEvent",

langfuse/api/reference.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,8 @@ client.dataset_items.get(
15191519
<dl>
15201520
<dd>
15211521

1522-
Get dataset items
1522+
Get dataset items. Optionally specify a version to get the items as they existed at that point in time.
1523+
Note: If version parameter is provided, datasetName must also be provided.
15231524
</dd>
15241525
</dl>
15251526
</dd>
@@ -1584,6 +1585,18 @@ client.dataset_items.list()
15841585
<dl>
15851586
<dd>
15861587

1588+
**version:** `typing.Optional[dt.datetime]`
1589+
1590+
ISO 8601 timestamp (RFC 3339, Section 5.6) in UTC (e.g., "2026-01-21T14:35:42Z").
1591+
If provided, returns state of dataset at this timestamp.
1592+
If not provided, returns the latest version. Requires datasetName to be specified.
1593+
1594+
</dd>
1595+
</dl>
1596+
1597+
<dl>
1598+
<dd>
1599+
15871600
**page:** `typing.Optional[int]` — page number, starts at 1
15881601

15891602
</dd>

langfuse/api/resources/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
Comment,
6868
CommentObjectType,
6969
ConfigCategory,
70+
CorrectionScore,
7071
CreateScoreValue,
7172
Dataset,
7273
DatasetItem,
@@ -101,6 +102,7 @@
101102
ScoreV1_Numeric,
102103
Score_Boolean,
103104
Score_Categorical,
105+
Score_Correction,
104106
Score_Numeric,
105107
Session,
106108
SessionWithTraces,
@@ -268,9 +270,11 @@
268270
GetScoresResponseData,
269271
GetScoresResponseDataBoolean,
270272
GetScoresResponseDataCategorical,
273+
GetScoresResponseDataCorrection,
271274
GetScoresResponseDataNumeric,
272275
GetScoresResponseData_Boolean,
273276
GetScoresResponseData_Categorical,
277+
GetScoresResponseData_Correction,
274278
GetScoresResponseData_Numeric,
275279
GetScoresResponseTraceData,
276280
)
@@ -313,6 +317,7 @@
313317
"Comment",
314318
"CommentObjectType",
315319
"ConfigCategory",
320+
"CorrectionScore",
316321
"CreateAnnotationQueueAssignmentResponse",
317322
"CreateAnnotationQueueItemRequest",
318323
"CreateAnnotationQueueRequest",
@@ -362,9 +367,11 @@
362367
"GetScoresResponseData",
363368
"GetScoresResponseDataBoolean",
364369
"GetScoresResponseDataCategorical",
370+
"GetScoresResponseDataCorrection",
365371
"GetScoresResponseDataNumeric",
366372
"GetScoresResponseData_Boolean",
367373
"GetScoresResponseData_Categorical",
374+
"GetScoresResponseData_Correction",
368375
"GetScoresResponseData_Numeric",
369376
"GetScoresResponseTraceData",
370377
"HealthResponse",
@@ -476,6 +483,7 @@
476483
"ScoreV1_Numeric",
477484
"Score_Boolean",
478485
"Score_Categorical",
486+
"Score_Correction",
479487
"Score_Numeric",
480488
"SdkLogBody",
481489
"SdkLogEvent",

langfuse/api/resources/commons/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Comment,
1111
CommentObjectType,
1212
ConfigCategory,
13+
CorrectionScore,
1314
CreateScoreValue,
1415
Dataset,
1516
DatasetItem,
@@ -41,6 +42,7 @@
4142
ScoreV1_Numeric,
4243
Score_Boolean,
4344
Score_Categorical,
45+
Score_Correction,
4446
Score_Numeric,
4547
Session,
4648
SessionWithTraces,
@@ -68,6 +70,7 @@
6870
"Comment",
6971
"CommentObjectType",
7072
"ConfigCategory",
73+
"CorrectionScore",
7174
"CreateScoreValue",
7275
"Dataset",
7376
"DatasetItem",
@@ -102,6 +105,7 @@
102105
"ScoreV1_Numeric",
103106
"Score_Boolean",
104107
"Score_Categorical",
108+
"Score_Correction",
105109
"Score_Numeric",
106110
"Session",
107111
"SessionWithTraces",

langfuse/api/resources/commons/types/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .comment import Comment
1010
from .comment_object_type import CommentObjectType
1111
from .config_category import ConfigCategory
12+
from .correction_score import CorrectionScore
1213
from .create_score_value import CreateScoreValue
1314
from .dataset import Dataset
1415
from .dataset_item import DatasetItem
@@ -29,7 +30,13 @@
2930
from .pricing_tier_condition import PricingTierCondition
3031
from .pricing_tier_input import PricingTierInput
3132
from .pricing_tier_operator import PricingTierOperator
32-
from .score import Score, Score_Boolean, Score_Categorical, Score_Numeric
33+
from .score import (
34+
Score,
35+
Score_Boolean,
36+
Score_Categorical,
37+
Score_Correction,
38+
Score_Numeric,
39+
)
3340
from .score_config import ScoreConfig
3441
from .score_config_data_type import ScoreConfigDataType
3542
from .score_data_type import ScoreDataType
@@ -52,6 +59,7 @@
5259
"Comment",
5360
"CommentObjectType",
5461
"ConfigCategory",
62+
"CorrectionScore",
5563
"CreateScoreValue",
5664
"Dataset",
5765
"DatasetItem",
@@ -83,6 +91,7 @@
8391
"ScoreV1_Numeric",
8492
"Score_Boolean",
8593
"Score_Categorical",
94+
"Score_Correction",
8695
"Score_Numeric",
8796
"Session",
8897
"SessionWithTraces",
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import datetime as dt
4+
import typing
5+
6+
from ....core.datetime_utils import serialize_datetime
7+
from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
8+
from .base_score import BaseScore
9+
10+
11+
class CorrectionScore(BaseScore):
12+
value: float = pydantic_v1.Field()
13+
"""
14+
The numeric value of the score. Always 0 for correction scores.
15+
"""
16+
17+
string_value: str = pydantic_v1.Field(alias="stringValue")
18+
"""
19+
The string representation of the correction content
20+
"""
21+
22+
def json(self, **kwargs: typing.Any) -> str:
23+
kwargs_with_defaults: typing.Any = {
24+
"by_alias": True,
25+
"exclude_unset": True,
26+
**kwargs,
27+
}
28+
return super().json(**kwargs_with_defaults)
29+
30+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
31+
kwargs_with_defaults_exclude_unset: typing.Any = {
32+
"by_alias": True,
33+
"exclude_unset": True,
34+
**kwargs,
35+
}
36+
kwargs_with_defaults_exclude_none: typing.Any = {
37+
"by_alias": True,
38+
"exclude_none": True,
39+
**kwargs,
40+
}
41+
42+
return deep_union_pydantic_dicts(
43+
super().dict(**kwargs_with_defaults_exclude_unset),
44+
super().dict(**kwargs_with_defaults_exclude_none),
45+
)
46+
47+
class Config:
48+
frozen = True
49+
smart_union = True
50+
allow_population_by_field_name = True
51+
populate_by_name = True
52+
extra = pydantic_v1.Extra.allow
53+
json_encoders = {dt.datetime: serialize_datetime}

langfuse/api/resources/commons/types/score.py

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,69 @@ class Config:
204204
json_encoders = {dt.datetime: serialize_datetime}
205205

206206

207-
Score = typing.Union[Score_Numeric, Score_Categorical, Score_Boolean]
207+
class Score_Correction(pydantic_v1.BaseModel):
208+
value: float
209+
string_value: str = pydantic_v1.Field(alias="stringValue")
210+
id: str
211+
trace_id: typing.Optional[str] = pydantic_v1.Field(alias="traceId", default=None)
212+
session_id: typing.Optional[str] = pydantic_v1.Field(
213+
alias="sessionId", default=None
214+
)
215+
observation_id: typing.Optional[str] = pydantic_v1.Field(
216+
alias="observationId", default=None
217+
)
218+
dataset_run_id: typing.Optional[str] = pydantic_v1.Field(
219+
alias="datasetRunId", default=None
220+
)
221+
name: str
222+
source: ScoreSource
223+
timestamp: dt.datetime
224+
created_at: dt.datetime = pydantic_v1.Field(alias="createdAt")
225+
updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt")
226+
author_user_id: typing.Optional[str] = pydantic_v1.Field(
227+
alias="authorUserId", default=None
228+
)
229+
comment: typing.Optional[str] = None
230+
metadata: typing.Any
231+
config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None)
232+
queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None)
233+
environment: str
234+
data_type: typing.Literal["CORRECTION"] = pydantic_v1.Field(
235+
alias="dataType", default="CORRECTION"
236+
)
237+
238+
def json(self, **kwargs: typing.Any) -> str:
239+
kwargs_with_defaults: typing.Any = {
240+
"by_alias": True,
241+
"exclude_unset": True,
242+
**kwargs,
243+
}
244+
return super().json(**kwargs_with_defaults)
245+
246+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
247+
kwargs_with_defaults_exclude_unset: typing.Any = {
248+
"by_alias": True,
249+
"exclude_unset": True,
250+
**kwargs,
251+
}
252+
kwargs_with_defaults_exclude_none: typing.Any = {
253+
"by_alias": True,
254+
"exclude_none": True,
255+
**kwargs,
256+
}
257+
258+
return deep_union_pydantic_dicts(
259+
super().dict(**kwargs_with_defaults_exclude_unset),
260+
super().dict(**kwargs_with_defaults_exclude_none),
261+
)
262+
263+
class Config:
264+
frozen = True
265+
smart_union = True
266+
allow_population_by_field_name = True
267+
populate_by_name = True
268+
extra = pydantic_v1.Extra.allow
269+
json_encoders = {dt.datetime: serialize_datetime}
270+
271+
272+
Score = typing.Union[Score_Numeric, Score_Categorical, Score_Boolean, Score_Correction]

0 commit comments

Comments
 (0)