Skip to content

Commit f2494f0

Browse files
author
langfuse-bot
committed
feat(api): update API spec from langfuse/langfuse a93f65a
1 parent bb139f2 commit f2494f0

5 files changed

Lines changed: 246 additions & 1 deletion

File tree

langfuse/api/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
NumericScoreV1,
9898
Observation,
9999
ObservationLevel,
100+
ObservationV2,
100101
ObservationsView,
101102
PricingTier,
102103
PricingTierCondition,
@@ -423,6 +424,7 @@
423424
"ObservationBody": ".ingestion",
424425
"ObservationLevel": ".commons",
425426
"ObservationType": ".ingestion",
427+
"ObservationV2": ".commons",
426428
"Observations": ".observations",
427429
"ObservationsV2Meta": ".observations_v2",
428430
"ObservationsV2Response": ".observations_v2",
@@ -714,6 +716,7 @@ def __dir__():
714716
"ObservationBody",
715717
"ObservationLevel",
716718
"ObservationType",
719+
"ObservationV2",
717720
"Observations",
718721
"ObservationsV2Meta",
719722
"ObservationsV2Response",

langfuse/api/commons/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
NumericScoreV1,
3333
Observation,
3434
ObservationLevel,
35+
ObservationV2,
3536
ObservationsView,
3637
PricingTier,
3738
PricingTierCondition,
@@ -94,6 +95,7 @@
9495
"NumericScoreV1": ".types",
9596
"Observation": ".types",
9697
"ObservationLevel": ".types",
98+
"ObservationV2": ".types",
9799
"ObservationsView": ".types",
98100
"PricingTier": ".types",
99101
"PricingTierCondition": ".types",
@@ -179,6 +181,7 @@ def __dir__():
179181
"NumericScoreV1",
180182
"Observation",
181183
"ObservationLevel",
184+
"ObservationV2",
182185
"ObservationsView",
183186
"PricingTier",
184187
"PricingTierCondition",

langfuse/api/commons/types/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .numeric_score_v1 import NumericScoreV1
3232
from .observation import Observation
3333
from .observation_level import ObservationLevel
34+
from .observation_v2 import ObservationV2
3435
from .observations_view import ObservationsView
3536
from .pricing_tier import PricingTier
3637
from .pricing_tier_condition import PricingTierCondition
@@ -80,6 +81,7 @@
8081
"NumericScoreV1": ".numeric_score_v1",
8182
"Observation": ".observation",
8283
"ObservationLevel": ".observation_level",
84+
"ObservationV2": ".observation_v2",
8385
"ObservationsView": ".observations_view",
8486
"PricingTier": ".pricing_tier",
8587
"PricingTierCondition": ".pricing_tier_condition",
@@ -160,6 +162,7 @@ def __dir__():
160162
"NumericScoreV1",
161163
"Observation",
162164
"ObservationLevel",
165+
"ObservationV2",
163166
"ObservationsView",
164167
"PricingTier",
165168
"PricingTierCondition",
Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import datetime as dt
4+
import typing
5+
6+
import pydantic
7+
import typing_extensions
8+
from ...core.pydantic_utilities import UniversalBaseModel
9+
from ...core.serialization import FieldMetadata
10+
from .observation_level import ObservationLevel
11+
12+
13+
class ObservationV2(UniversalBaseModel):
14+
"""
15+
An observation from the v2 API with field-group-based selection.
16+
Core fields are always present. Other fields are included only when their field group is requested.
17+
"""
18+
19+
id: str = pydantic.Field()
20+
"""
21+
The unique identifier of the observation
22+
"""
23+
24+
trace_id: typing_extensions.Annotated[
25+
typing.Optional[str], FieldMetadata(alias="traceId")
26+
] = pydantic.Field(default=None)
27+
"""
28+
The trace ID associated with the observation
29+
"""
30+
31+
start_time: typing_extensions.Annotated[
32+
dt.datetime, FieldMetadata(alias="startTime")
33+
] = pydantic.Field()
34+
"""
35+
The start time of the observation
36+
"""
37+
38+
end_time: typing_extensions.Annotated[
39+
typing.Optional[dt.datetime], FieldMetadata(alias="endTime")
40+
] = pydantic.Field(default=None)
41+
"""
42+
The end time of the observation
43+
"""
44+
45+
project_id: typing_extensions.Annotated[str, FieldMetadata(alias="projectId")] = (
46+
pydantic.Field()
47+
)
48+
"""
49+
The project ID this observation belongs to
50+
"""
51+
52+
parent_observation_id: typing_extensions.Annotated[
53+
typing.Optional[str], FieldMetadata(alias="parentObservationId")
54+
] = pydantic.Field(default=None)
55+
"""
56+
The parent observation ID
57+
"""
58+
59+
type: str = pydantic.Field()
60+
"""
61+
The type of the observation (e.g. GENERATION, SPAN, EVENT)
62+
"""
63+
64+
name: typing.Optional[str] = pydantic.Field(default=None)
65+
"""
66+
The name of the observation
67+
"""
68+
69+
level: typing.Optional[ObservationLevel] = pydantic.Field(default=None)
70+
"""
71+
The level of the observation
72+
"""
73+
74+
status_message: typing_extensions.Annotated[
75+
typing.Optional[str], FieldMetadata(alias="statusMessage")
76+
] = pydantic.Field(default=None)
77+
"""
78+
The status message of the observation
79+
"""
80+
81+
version: typing.Optional[str] = pydantic.Field(default=None)
82+
"""
83+
The version of the observation
84+
"""
85+
86+
environment: typing.Optional[str] = pydantic.Field(default=None)
87+
"""
88+
The environment from which this observation originated
89+
"""
90+
91+
bookmarked: typing.Optional[bool] = pydantic.Field(default=None)
92+
"""
93+
Whether the observation is bookmarked
94+
"""
95+
96+
public: typing.Optional[bool] = pydantic.Field(default=None)
97+
"""
98+
Whether the observation is public
99+
"""
100+
101+
user_id: typing_extensions.Annotated[
102+
typing.Optional[str], FieldMetadata(alias="userId")
103+
] = pydantic.Field(default=None)
104+
"""
105+
The user ID associated with the observation
106+
"""
107+
108+
session_id: typing_extensions.Annotated[
109+
typing.Optional[str], FieldMetadata(alias="sessionId")
110+
] = pydantic.Field(default=None)
111+
"""
112+
The session ID associated with the observation
113+
"""
114+
115+
completion_start_time: typing_extensions.Annotated[
116+
typing.Optional[dt.datetime], FieldMetadata(alias="completionStartTime")
117+
] = pydantic.Field(default=None)
118+
"""
119+
The completion start time of the observation
120+
"""
121+
122+
created_at: typing_extensions.Annotated[
123+
typing.Optional[dt.datetime], FieldMetadata(alias="createdAt")
124+
] = pydantic.Field(default=None)
125+
"""
126+
The creation timestamp of the observation
127+
"""
128+
129+
updated_at: typing_extensions.Annotated[
130+
typing.Optional[dt.datetime], FieldMetadata(alias="updatedAt")
131+
] = pydantic.Field(default=None)
132+
"""
133+
The last update timestamp of the observation
134+
"""
135+
136+
input: typing.Optional[typing.Any] = pydantic.Field(default=None)
137+
"""
138+
The input data of the observation
139+
"""
140+
141+
output: typing.Optional[typing.Any] = pydantic.Field(default=None)
142+
"""
143+
The output data of the observation
144+
"""
145+
146+
metadata: typing.Optional[typing.Any] = pydantic.Field(default=None)
147+
"""
148+
Additional metadata of the observation
149+
"""
150+
151+
provided_model_name: typing_extensions.Annotated[
152+
typing.Optional[str], FieldMetadata(alias="providedModelName")
153+
] = pydantic.Field(default=None)
154+
"""
155+
The model name as provided by the user
156+
"""
157+
158+
internal_model_id: typing_extensions.Annotated[
159+
typing.Optional[str], FieldMetadata(alias="internalModelId")
160+
] = pydantic.Field(default=None)
161+
"""
162+
The internal model ID matched by Langfuse
163+
"""
164+
165+
model_parameters: typing_extensions.Annotated[
166+
typing.Optional[typing.Any], FieldMetadata(alias="modelParameters")
167+
] = pydantic.Field(default=None)
168+
"""
169+
The parameters of the model used for the observation
170+
"""
171+
172+
usage_details: typing_extensions.Annotated[
173+
typing.Optional[typing.Dict[str, int]], FieldMetadata(alias="usageDetails")
174+
] = pydantic.Field(default=None)
175+
"""
176+
The usage details of the observation. Key is the usage metric name, value is the number of units consumed.
177+
"""
178+
179+
cost_details: typing_extensions.Annotated[
180+
typing.Optional[typing.Dict[str, float]], FieldMetadata(alias="costDetails")
181+
] = pydantic.Field(default=None)
182+
"""
183+
The cost details of the observation. Key is the cost metric name, value is the cost in USD.
184+
"""
185+
186+
total_cost: typing_extensions.Annotated[
187+
typing.Optional[float], FieldMetadata(alias="totalCost")
188+
] = pydantic.Field(default=None)
189+
"""
190+
The total cost of the observation in USD
191+
"""
192+
193+
prompt_id: typing_extensions.Annotated[
194+
typing.Optional[str], FieldMetadata(alias="promptId")
195+
] = pydantic.Field(default=None)
196+
"""
197+
The prompt ID associated with the observation
198+
"""
199+
200+
prompt_name: typing_extensions.Annotated[
201+
typing.Optional[str], FieldMetadata(alias="promptName")
202+
] = pydantic.Field(default=None)
203+
"""
204+
The prompt name associated with the observation
205+
"""
206+
207+
prompt_version: typing_extensions.Annotated[
208+
typing.Optional[int], FieldMetadata(alias="promptVersion")
209+
] = pydantic.Field(default=None)
210+
"""
211+
The prompt version associated with the observation
212+
"""
213+
214+
latency: typing.Optional[float] = pydantic.Field(default=None)
215+
"""
216+
The latency in seconds
217+
"""
218+
219+
time_to_first_token: typing_extensions.Annotated[
220+
typing.Optional[float], FieldMetadata(alias="timeToFirstToken")
221+
] = pydantic.Field(default=None)
222+
"""
223+
The time to first token in seconds
224+
"""
225+
226+
model_id: typing_extensions.Annotated[
227+
typing.Optional[str], FieldMetadata(alias="modelId")
228+
] = pydantic.Field(default=None)
229+
"""
230+
The matched model ID
231+
"""
232+
233+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
234+
extra="allow", frozen=True
235+
)

langfuse/api/observations_v2/types/observations_v2response.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import typing
44

55
import pydantic
6+
from ...commons.types.observation_v2 import ObservationV2
67
from ...core.pydantic_utilities import UniversalBaseModel
78
from .observations_v2meta import ObservationsV2Meta
89

@@ -15,7 +16,7 @@ class ObservationsV2Response(UniversalBaseModel):
1516
Use the `cursor` in `meta` to retrieve the next page of results.
1617
"""
1718

18-
data: typing.List[typing.Dict[str, typing.Any]] = pydantic.Field()
19+
data: typing.List[ObservationV2] = pydantic.Field()
1920
"""
2021
Array of observation objects. Fields included depend on the `fields` parameter in the request.
2122
"""

0 commit comments

Comments
 (0)