Skip to content

Commit 3008a53

Browse files
langfuse-botlangfuse-bot
andauthored
feat(api): update API spec from langfuse/langfuse d59b6a3 (#1489)
Co-authored-by: langfuse-bot <langfuse-bot@langfuse.com>
1 parent 179374a commit 3008a53

File tree

18 files changed

+149
-14
lines changed

18 files changed

+149
-14
lines changed

langfuse/api/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
OpenAiResponseUsageSchema,
138138
OpenAiUsage,
139139
OptionalObservationBody,
140+
Organization,
140141
OrganizationApiKey,
141142
OrganizationApiKeysResponse,
142143
OrganizationProject,
@@ -187,6 +188,7 @@
187188
Score,
188189
ScoreBody,
189190
ScoreConfig,
191+
ScoreConfigDataType,
190192
ScoreConfigs,
191193
ScoreDataType,
192194
ScoreEvent,
@@ -392,6 +394,7 @@
392394
"OpenAiResponseUsageSchema",
393395
"OpenAiUsage",
394396
"OptionalObservationBody",
397+
"Organization",
395398
"OrganizationApiKey",
396399
"OrganizationApiKeysResponse",
397400
"OrganizationProject",
@@ -442,6 +445,7 @@
442445
"Score",
443446
"ScoreBody",
444447
"ScoreConfig",
448+
"ScoreConfigDataType",
445449
"ScoreConfigs",
446450
"ScoreDataType",
447451
"ScoreEvent",

langfuse/api/reference.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3191,6 +3191,8 @@ JSON string containing the query parameters with the following structure:
31913191

31923192
Get metrics from the Langfuse project using a query object.
31933193

3194+
Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance.
3195+
31943196
For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
31953197
</dd>
31963198
</dl>
@@ -4007,7 +4009,9 @@ client.observations.get(
40074009
<dl>
40084010
<dd>
40094011

4010-
Get a list of observations
4012+
Get a list of observations.
4013+
4014+
Consider using the [v2 observations endpoint](/api-reference#tag/observationsv2/GET/api/public/v2/observations) for cursor-based pagination and field selection.
40114015
</dd>
40124016
</dl>
40134017
</dd>
@@ -6666,7 +6670,7 @@ Create a score configuration (config). Score configs are used to define the stru
66666670
<dd>
66676671

66686672
```python
6669-
from langfuse import CreateScoreConfigRequest, ScoreDataType
6673+
from langfuse import CreateScoreConfigRequest, ScoreConfigDataType
66706674
from langfuse.client import FernLangfuse
66716675

66726676
client = FernLangfuse(
@@ -6680,7 +6684,7 @@ client = FernLangfuse(
66806684
client.score_configs.create(
66816685
request=CreateScoreConfigRequest(
66826686
name="name",
6683-
data_type=ScoreDataType.NUMERIC,
6687+
data_type=ScoreConfigDataType.NUMERIC,
66846688
),
66856689
)
66866690

@@ -7157,6 +7161,14 @@ client.score_v_2.get()
71577161
<dl>
71587162
<dd>
71597163

7164+
**fields:** `typing.Optional[str]` — Comma-separated list of field groups to include in the response. Available field groups: 'score' (core score fields), 'trace' (trace properties: userId, tags, environment). If not specified, both 'score' and 'trace' are returned by default. Example: 'score' to exclude trace data, 'score,trace' to include both. Note: When filtering by trace properties (using userId or traceTags parameters), the 'trace' field group must be included, otherwise a 400 error will be returned.
7165+
7166+
</dd>
7167+
</dl>
7168+
7169+
<dl>
7170+
<dd>
7171+
71607172
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
71617173

71627174
</dd>

langfuse/api/resources/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
PricingTierOperator,
9393
Score,
9494
ScoreConfig,
95+
ScoreConfigDataType,
9596
ScoreDataType,
9697
ScoreSource,
9798
ScoreV1,
@@ -211,6 +212,7 @@
211212
ApiKeyList,
212213
ApiKeyResponse,
213214
ApiKeySummary,
215+
Organization,
214216
Project,
215217
ProjectDeletionResponse,
216218
Projects,
@@ -412,6 +414,7 @@
412414
"OpenAiResponseUsageSchema",
413415
"OpenAiUsage",
414416
"OptionalObservationBody",
417+
"Organization",
415418
"OrganizationApiKey",
416419
"OrganizationApiKeysResponse",
417420
"OrganizationProject",
@@ -462,6 +465,7 @@
462465
"Score",
463466
"ScoreBody",
464467
"ScoreConfig",
468+
"ScoreConfigDataType",
465469
"ScoreConfigs",
466470
"ScoreDataType",
467471
"ScoreEvent",

langfuse/api/resources/commons/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
PricingTierOperator,
3333
Score,
3434
ScoreConfig,
35+
ScoreConfigDataType,
3536
ScoreDataType,
3637
ScoreSource,
3738
ScoreV1,
@@ -92,6 +93,7 @@
9293
"PricingTierOperator",
9394
"Score",
9495
"ScoreConfig",
96+
"ScoreConfigDataType",
9597
"ScoreDataType",
9698
"ScoreSource",
9799
"ScoreV1",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .pricing_tier_operator import PricingTierOperator
3232
from .score import Score, Score_Boolean, Score_Categorical, Score_Numeric
3333
from .score_config import ScoreConfig
34+
from .score_config_data_type import ScoreConfigDataType
3435
from .score_data_type import ScoreDataType
3536
from .score_source import ScoreSource
3637
from .score_v_1 import ScoreV1, ScoreV1_Boolean, ScoreV1_Categorical, ScoreV1_Numeric
@@ -73,6 +74,7 @@
7374
"PricingTierOperator",
7475
"Score",
7576
"ScoreConfig",
77+
"ScoreConfigDataType",
7678
"ScoreDataType",
7779
"ScoreSource",
7880
"ScoreV1",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ....core.datetime_utils import serialize_datetime
77
from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
88
from .config_category import ConfigCategory
9-
from .score_data_type import ScoreDataType
9+
from .score_config_data_type import ScoreConfigDataType
1010

1111

1212
class ScoreConfig(pydantic_v1.BaseModel):
@@ -19,7 +19,7 @@ class ScoreConfig(pydantic_v1.BaseModel):
1919
created_at: dt.datetime = pydantic_v1.Field(alias="createdAt")
2020
updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt")
2121
project_id: str = pydantic_v1.Field(alias="projectId")
22-
data_type: ScoreDataType = pydantic_v1.Field(alias="dataType")
22+
data_type: ScoreConfigDataType = pydantic_v1.Field(alias="dataType")
2323
is_archived: bool = pydantic_v1.Field(alias="isArchived")
2424
"""
2525
Whether the score config is archived. Defaults to false
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import enum
4+
import typing
5+
6+
T_Result = typing.TypeVar("T_Result")
7+
8+
9+
class ScoreConfigDataType(str, enum.Enum):
10+
NUMERIC = "NUMERIC"
11+
BOOLEAN = "BOOLEAN"
12+
CATEGORICAL = "CATEGORICAL"
13+
14+
def visit(
15+
self,
16+
numeric: typing.Callable[[], T_Result],
17+
boolean: typing.Callable[[], T_Result],
18+
categorical: typing.Callable[[], T_Result],
19+
) -> T_Result:
20+
if self is ScoreConfigDataType.NUMERIC:
21+
return numeric()
22+
if self is ScoreConfigDataType.BOOLEAN:
23+
return boolean()
24+
if self is ScoreConfigDataType.CATEGORICAL:
25+
return categorical()

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@ class ScoreDataType(str, enum.Enum):
1010
NUMERIC = "NUMERIC"
1111
BOOLEAN = "BOOLEAN"
1212
CATEGORICAL = "CATEGORICAL"
13+
CORRECTION = "CORRECTION"
1314

1415
def visit(
1516
self,
1617
numeric: typing.Callable[[], T_Result],
1718
boolean: typing.Callable[[], T_Result],
1819
categorical: typing.Callable[[], T_Result],
20+
correction: typing.Callable[[], T_Result],
1921
) -> T_Result:
2022
if self is ScoreDataType.NUMERIC:
2123
return numeric()
2224
if self is ScoreDataType.BOOLEAN:
2325
return boolean()
2426
if self is ScoreDataType.CATEGORICAL:
2527
return categorical()
28+
if self is ScoreDataType.CORRECTION:
29+
return correction()

langfuse/api/resources/ingestion/types/score_body.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ class ScoreBody(pydantic_v1.BaseModel):
3333
dataset_run_id: typing.Optional[str] = pydantic_v1.Field(
3434
alias="datasetRunId", default=None
3535
)
36-
name: str
36+
name: str = pydantic_v1.Field()
37+
"""
38+
The name of the score. Always overrides "output" for correction scores.
39+
"""
40+
3741
environment: typing.Optional[str] = None
3842
queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None)
3943
"""

langfuse/api/resources/metrics/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def metrics(
2525
"""
2626
Get metrics from the Langfuse project using a query object.
2727
28+
Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance.
29+
2830
For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
2931
3032
Parameters
@@ -138,6 +140,8 @@ async def metrics(
138140
"""
139141
Get metrics from the Langfuse project using a query object.
140142
143+
Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance.
144+
141145
For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
142146
143147
Parameters

0 commit comments

Comments
 (0)