Skip to content

Commit c7b6e12

Browse files
langfuse-botlangfuse-bothassiebp
authored
feat(api): update API spec from langfuse/langfuse 41f064c (#1492)
Co-authored-by: langfuse-bot <[email protected]> Co-authored-by: Hassieb Pakzad <[email protected]>
1 parent 280b831 commit c7b6e12

20 files changed

+177
-70
lines changed

langfuse/api/reference.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3635,7 +3635,7 @@ Use the `fields` parameter to control which observation fields are returned:
36353635
- `basic` - name, level, statusMessage, version, environment, bookmarked, public, userId, sessionId
36363636
- `time` - completionStartTime, createdAt, updatedAt
36373637
- `io` - input, output
3638-
- `metadata` - metadata
3638+
- `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
36393639
- `model` - providedModelName, internalModelId, modelParameters
36403640
- `usage` - usageDetails, costDetails, totalCost
36413641
- `prompt` - promptId, promptName, promptVersion
@@ -3699,6 +3699,19 @@ Example: "basic,usage,model"
36993699
<dl>
37003700
<dd>
37013701

3702+
**expand_metadata:** `typing.Optional[str]`
3703+
3704+
Comma-separated list of metadata keys to return non-truncated.
3705+
By default, metadata values over 200 characters are truncated.
3706+
Use this parameter to retrieve full values for specific keys.
3707+
Example: "key1,key2"
3708+
3709+
</dd>
3710+
</dl>
3711+
3712+
<dl>
3713+
<dd>
3714+
37023715
**limit:** `typing.Optional[int]` — Number of items to return per page. Maximum 1000, default 50.
37033716

37043717
</dd>

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,31 @@
1111
class BaseScore(pydantic_v1.BaseModel):
1212
id: str
1313
trace_id: typing.Optional[str] = pydantic_v1.Field(alias="traceId", default=None)
14+
"""
15+
The trace ID associated with the score
16+
"""
17+
1418
session_id: typing.Optional[str] = pydantic_v1.Field(
1519
alias="sessionId", default=None
1620
)
21+
"""
22+
The session ID associated with the score
23+
"""
24+
1725
observation_id: typing.Optional[str] = pydantic_v1.Field(
1826
alias="observationId", default=None
1927
)
28+
"""
29+
The observation ID associated with the score
30+
"""
31+
2032
dataset_run_id: typing.Optional[str] = pydantic_v1.Field(
2133
alias="datasetRunId", default=None
2234
)
35+
"""
36+
The dataset run ID associated with the score
37+
"""
38+
2339
name: str
2440
source: ScoreSource
2541
timestamp: dt.datetime
@@ -28,8 +44,20 @@ class BaseScore(pydantic_v1.BaseModel):
2844
author_user_id: typing.Optional[str] = pydantic_v1.Field(
2945
alias="authorUserId", default=None
3046
)
31-
comment: typing.Optional[str] = None
32-
metadata: typing.Optional[typing.Any] = None
47+
"""
48+
The user ID of the author
49+
"""
50+
51+
comment: typing.Optional[str] = pydantic_v1.Field(default=None)
52+
"""
53+
Comment on the score
54+
"""
55+
56+
metadata: typing.Any = pydantic_v1.Field()
57+
"""
58+
Metadata associated with the score
59+
"""
60+
3361
config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None)
3462
"""
3563
Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range
@@ -40,7 +68,7 @@ class BaseScore(pydantic_v1.BaseModel):
4068
The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
4169
"""
4270

43-
environment: typing.Optional[str] = pydantic_v1.Field(default=None)
71+
environment: str = pydantic_v1.Field()
4472
"""
4573
The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
4674
"""

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,30 @@ class BaseScoreV1(pydantic_v1.BaseModel):
1616
observation_id: typing.Optional[str] = pydantic_v1.Field(
1717
alias="observationId", default=None
1818
)
19+
"""
20+
The observation ID associated with the score
21+
"""
22+
1923
timestamp: dt.datetime
2024
created_at: dt.datetime = pydantic_v1.Field(alias="createdAt")
2125
updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt")
2226
author_user_id: typing.Optional[str] = pydantic_v1.Field(
2327
alias="authorUserId", default=None
2428
)
25-
comment: typing.Optional[str] = None
26-
metadata: typing.Optional[typing.Any] = None
29+
"""
30+
The user ID of the author
31+
"""
32+
33+
comment: typing.Optional[str] = pydantic_v1.Field(default=None)
34+
"""
35+
Comment on the score
36+
"""
37+
38+
metadata: typing.Any = pydantic_v1.Field()
39+
"""
40+
Metadata associated with the score
41+
"""
42+
2743
config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None)
2844
"""
2945
Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range
@@ -34,7 +50,7 @@ class BaseScoreV1(pydantic_v1.BaseModel):
3450
The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
3551
"""
3652

37-
environment: typing.Optional[str] = pydantic_v1.Field(default=None)
53+
environment: str = pydantic_v1.Field()
3854
"""
3955
The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
4056
"""

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class Comment(pydantic_v1.BaseModel):
1919
author_user_id: typing.Optional[str] = pydantic_v1.Field(
2020
alias="authorUserId", default=None
2121
)
22+
"""
23+
The user ID of the comment author
24+
"""
2225

2326
def json(self, **kwargs: typing.Any) -> str:
2427
kwargs_with_defaults: typing.Any = {

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@
1010
class Dataset(pydantic_v1.BaseModel):
1111
id: str
1212
name: str
13-
description: typing.Optional[str] = None
14-
metadata: typing.Optional[typing.Any] = None
13+
description: typing.Optional[str] = pydantic_v1.Field(default=None)
14+
"""
15+
Description of the dataset
16+
"""
17+
18+
metadata: typing.Any = pydantic_v1.Field()
19+
"""
20+
Metadata associated with the dataset
21+
"""
22+
1523
input_schema: typing.Optional[typing.Any] = pydantic_v1.Field(
1624
alias="inputSchema", default=None
1725
)

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,35 @@
1111
class DatasetItem(pydantic_v1.BaseModel):
1212
id: str
1313
status: DatasetStatus
14-
input: typing.Optional[typing.Any] = None
15-
expected_output: typing.Optional[typing.Any] = pydantic_v1.Field(
16-
alias="expectedOutput", default=None
17-
)
18-
metadata: typing.Optional[typing.Any] = None
14+
input: typing.Any = pydantic_v1.Field()
15+
"""
16+
Input data for the dataset item
17+
"""
18+
19+
expected_output: typing.Any = pydantic_v1.Field(alias="expectedOutput")
20+
"""
21+
Expected output for the dataset item
22+
"""
23+
24+
metadata: typing.Any = pydantic_v1.Field()
25+
"""
26+
Metadata associated with the dataset item
27+
"""
28+
1929
source_trace_id: typing.Optional[str] = pydantic_v1.Field(
2030
alias="sourceTraceId", default=None
2131
)
32+
"""
33+
The trace ID that sourced this dataset item
34+
"""
35+
2236
source_observation_id: typing.Optional[str] = pydantic_v1.Field(
2337
alias="sourceObservationId", default=None
2438
)
39+
"""
40+
The observation ID that sourced this dataset item
41+
"""
42+
2543
dataset_id: str = pydantic_v1.Field(alias="datasetId")
2644
dataset_name: str = pydantic_v1.Field(alias="datasetName")
2745
created_at: dt.datetime = pydantic_v1.Field(alias="createdAt")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DatasetRun(pydantic_v1.BaseModel):
2323
Description of the run
2424
"""
2525

26-
metadata: typing.Optional[typing.Any] = pydantic_v1.Field(default=None)
26+
metadata: typing.Any = pydantic_v1.Field()
2727
"""
2828
Metadata of the dataset run
2929
"""

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class DatasetRunItem(pydantic_v1.BaseModel):
1616
observation_id: typing.Optional[str] = pydantic_v1.Field(
1717
alias="observationId", default=None
1818
)
19+
"""
20+
The observation ID associated with this run item
21+
"""
22+
1923
created_at: dt.datetime = pydantic_v1.Field(alias="createdAt")
2024
updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt")
2125

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ class Model(pydantic_v1.BaseModel):
7474
Optional. Tokenizer to be applied to observations which match to this model. See docs for more details.
7575
"""
7676

77-
tokenizer_config: typing.Optional[typing.Any] = pydantic_v1.Field(
78-
alias="tokenizerConfig", default=None
79-
)
77+
tokenizer_config: typing.Any = pydantic_v1.Field(alias="tokenizerConfig")
8078
"""
8179
Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details.
8280
"""

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from ....core.datetime_utils import serialize_datetime
77
from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
8-
from .map_value import MapValue
98
from .observation_level import ObservationLevel
109
from .usage import Usage
1110

@@ -55,14 +54,12 @@ class Observation(pydantic_v1.BaseModel):
5554
The model used for the observation
5655
"""
5756

58-
model_parameters: typing.Optional[typing.Dict[str, MapValue]] = pydantic_v1.Field(
59-
alias="modelParameters", default=None
60-
)
57+
model_parameters: typing.Any = pydantic_v1.Field(alias="modelParameters")
6158
"""
6259
The parameters of the model used for the observation
6360
"""
6461

65-
input: typing.Optional[typing.Any] = pydantic_v1.Field(default=None)
62+
input: typing.Any = pydantic_v1.Field()
6663
"""
6764
The input data of the observation
6865
"""
@@ -72,17 +69,17 @@ class Observation(pydantic_v1.BaseModel):
7269
The version of the observation
7370
"""
7471

75-
metadata: typing.Optional[typing.Any] = pydantic_v1.Field(default=None)
72+
metadata: typing.Any = pydantic_v1.Field()
7673
"""
7774
Additional metadata of the observation
7875
"""
7976

80-
output: typing.Optional[typing.Any] = pydantic_v1.Field(default=None)
77+
output: typing.Any = pydantic_v1.Field()
8178
"""
8279
The output data of the observation
8380
"""
8481

85-
usage: typing.Optional[Usage] = pydantic_v1.Field(default=None)
82+
usage: Usage = pydantic_v1.Field()
8683
"""
8784
(Deprecated. Use usageDetails and costDetails instead.) The usage data of the observation
8885
"""
@@ -111,21 +108,17 @@ class Observation(pydantic_v1.BaseModel):
111108
The prompt ID associated with the observation
112109
"""
113110

114-
usage_details: typing.Optional[typing.Dict[str, int]] = pydantic_v1.Field(
115-
alias="usageDetails", default=None
116-
)
111+
usage_details: typing.Dict[str, int] = pydantic_v1.Field(alias="usageDetails")
117112
"""
118113
The usage details of the observation. Key is the name of the usage metric, value is the number of units consumed. The total key is the sum of all (non-total) usage metrics or the total value ingested.
119114
"""
120115

121-
cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field(
122-
alias="costDetails", default=None
123-
)
116+
cost_details: typing.Dict[str, float] = pydantic_v1.Field(alias="costDetails")
124117
"""
125118
The cost details of the observation. Key is the name of the cost metric, value is the cost in USD. The total key is the sum of all (non-total) cost metrics or the total value ingested.
126119
"""
127120

128-
environment: typing.Optional[str] = pydantic_v1.Field(default=None)
121+
environment: str = pydantic_v1.Field()
129122
"""
130123
The environment from which this observation originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
131124
"""

0 commit comments

Comments
 (0)