Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions langfuse/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
NumericScoreV1,
Observation,
ObservationLevel,
ObservationV2,
ObservationsView,
PricingTier,
PricingTierCondition,
Expand Down Expand Up @@ -423,6 +424,7 @@
"ObservationBody": ".ingestion",
"ObservationLevel": ".commons",
"ObservationType": ".ingestion",
"ObservationV2": ".commons",
"Observations": ".observations",
"ObservationsV2Meta": ".observations_v2",
"ObservationsV2Response": ".observations_v2",
Expand Down Expand Up @@ -714,6 +716,7 @@ def __dir__():
"ObservationBody",
"ObservationLevel",
"ObservationType",
"ObservationV2",
"Observations",
"ObservationsV2Meta",
"ObservationsV2Response",
Expand Down
3 changes: 3 additions & 0 deletions langfuse/api/commons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
NumericScoreV1,
Observation,
ObservationLevel,
ObservationV2,
ObservationsView,
PricingTier,
PricingTierCondition,
Expand Down Expand Up @@ -94,6 +95,7 @@
"NumericScoreV1": ".types",
"Observation": ".types",
"ObservationLevel": ".types",
"ObservationV2": ".types",
"ObservationsView": ".types",
"PricingTier": ".types",
"PricingTierCondition": ".types",
Expand Down Expand Up @@ -179,6 +181,7 @@ def __dir__():
"NumericScoreV1",
"Observation",
"ObservationLevel",
"ObservationV2",
"ObservationsView",
"PricingTier",
"PricingTierCondition",
Expand Down
3 changes: 3 additions & 0 deletions langfuse/api/commons/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from .numeric_score_v1 import NumericScoreV1
from .observation import Observation
from .observation_level import ObservationLevel
from .observation_v2 import ObservationV2
from .observations_view import ObservationsView
from .pricing_tier import PricingTier
from .pricing_tier_condition import PricingTierCondition
Expand Down Expand Up @@ -80,6 +81,7 @@
"NumericScoreV1": ".numeric_score_v1",
"Observation": ".observation",
"ObservationLevel": ".observation_level",
"ObservationV2": ".observation_v2",
"ObservationsView": ".observations_view",
"PricingTier": ".pricing_tier",
"PricingTierCondition": ".pricing_tier_condition",
Expand Down Expand Up @@ -160,6 +162,7 @@ def __dir__():
"NumericScoreV1",
"Observation",
"ObservationLevel",
"ObservationV2",
"ObservationsView",
"PricingTier",
"PricingTierCondition",
Expand Down
235 changes: 235 additions & 0 deletions langfuse/api/commons/types/observation_v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

import pydantic
import typing_extensions
from ...core.pydantic_utilities import UniversalBaseModel
from ...core.serialization import FieldMetadata
from .observation_level import ObservationLevel


class ObservationV2(UniversalBaseModel):
"""
An observation from the v2 API with field-group-based selection.
Core fields are always present. Other fields are included only when their field group is requested.
"""

id: str = pydantic.Field()
"""
The unique identifier of the observation
"""

trace_id: typing_extensions.Annotated[
typing.Optional[str], FieldMetadata(alias="traceId")
] = pydantic.Field(default=None)
"""
The trace ID associated with the observation
"""

start_time: typing_extensions.Annotated[
dt.datetime, FieldMetadata(alias="startTime")
] = pydantic.Field()
"""
The start time of the observation
"""

end_time: typing_extensions.Annotated[
typing.Optional[dt.datetime], FieldMetadata(alias="endTime")
] = pydantic.Field(default=None)
"""
The end time of the observation
"""

project_id: typing_extensions.Annotated[str, FieldMetadata(alias="projectId")] = (
pydantic.Field()
)
"""
The project ID this observation belongs to
"""

parent_observation_id: typing_extensions.Annotated[
typing.Optional[str], FieldMetadata(alias="parentObservationId")
] = pydantic.Field(default=None)
"""
The parent observation ID
"""

type: str = pydantic.Field()
"""
The type of the observation (e.g. GENERATION, SPAN, EVENT)
"""

name: typing.Optional[str] = pydantic.Field(default=None)
"""
The name of the observation
"""

level: typing.Optional[ObservationLevel] = pydantic.Field(default=None)
"""
The level of the observation
"""

status_message: typing_extensions.Annotated[
typing.Optional[str], FieldMetadata(alias="statusMessage")
] = pydantic.Field(default=None)
"""
The status message of the observation
"""

version: typing.Optional[str] = pydantic.Field(default=None)
"""
The version of the observation
"""

environment: typing.Optional[str] = pydantic.Field(default=None)
"""
The environment from which this observation originated
"""

bookmarked: typing.Optional[bool] = pydantic.Field(default=None)
"""
Whether the observation is bookmarked
"""

public: typing.Optional[bool] = pydantic.Field(default=None)
"""
Whether the observation is public
"""

user_id: typing_extensions.Annotated[
typing.Optional[str], FieldMetadata(alias="userId")
] = pydantic.Field(default=None)
"""
The user ID associated with the observation
"""

session_id: typing_extensions.Annotated[
typing.Optional[str], FieldMetadata(alias="sessionId")
] = pydantic.Field(default=None)
"""
The session ID associated with the observation
"""

completion_start_time: typing_extensions.Annotated[
typing.Optional[dt.datetime], FieldMetadata(alias="completionStartTime")
] = pydantic.Field(default=None)
"""
The completion start time of the observation
"""

created_at: typing_extensions.Annotated[
typing.Optional[dt.datetime], FieldMetadata(alias="createdAt")
] = pydantic.Field(default=None)
"""
The creation timestamp of the observation
"""

updated_at: typing_extensions.Annotated[
typing.Optional[dt.datetime], FieldMetadata(alias="updatedAt")
] = pydantic.Field(default=None)
"""
The last update timestamp of the observation
"""

input: typing.Optional[typing.Any] = pydantic.Field(default=None)
"""
The input data of the observation
"""

output: typing.Optional[typing.Any] = pydantic.Field(default=None)
"""
The output data of the observation
"""

metadata: typing.Optional[typing.Any] = pydantic.Field(default=None)
"""
Additional metadata of the observation
"""

provided_model_name: typing_extensions.Annotated[
typing.Optional[str], FieldMetadata(alias="providedModelName")
] = pydantic.Field(default=None)
"""
The model name as provided by the user
"""

internal_model_id: typing_extensions.Annotated[
typing.Optional[str], FieldMetadata(alias="internalModelId")
] = pydantic.Field(default=None)
"""
The internal model ID matched by Langfuse
"""

model_parameters: typing_extensions.Annotated[
typing.Optional[typing.Any], FieldMetadata(alias="modelParameters")
] = pydantic.Field(default=None)
"""
The parameters of the model used for the observation
"""

usage_details: typing_extensions.Annotated[
typing.Optional[typing.Dict[str, int]], FieldMetadata(alias="usageDetails")
] = pydantic.Field(default=None)
"""
The usage details of the observation. Key is the usage metric name, value is the number of units consumed.
"""

cost_details: typing_extensions.Annotated[
typing.Optional[typing.Dict[str, float]], FieldMetadata(alias="costDetails")
] = pydantic.Field(default=None)
"""
The cost details of the observation. Key is the cost metric name, value is the cost in USD.
"""

total_cost: typing_extensions.Annotated[
typing.Optional[float], FieldMetadata(alias="totalCost")
] = pydantic.Field(default=None)
"""
The total cost of the observation in USD
"""

prompt_id: typing_extensions.Annotated[
typing.Optional[str], FieldMetadata(alias="promptId")
] = pydantic.Field(default=None)
"""
The prompt ID associated with the observation
"""

prompt_name: typing_extensions.Annotated[
typing.Optional[str], FieldMetadata(alias="promptName")
] = pydantic.Field(default=None)
"""
The prompt name associated with the observation
"""

prompt_version: typing_extensions.Annotated[
typing.Optional[int], FieldMetadata(alias="promptVersion")
] = pydantic.Field(default=None)
"""
The prompt version associated with the observation
"""

latency: typing.Optional[float] = pydantic.Field(default=None)
"""
The latency in seconds
"""

time_to_first_token: typing_extensions.Annotated[
typing.Optional[float], FieldMetadata(alias="timeToFirstToken")
] = pydantic.Field(default=None)
"""
The time to first token in seconds
"""

model_id: typing_extensions.Annotated[
typing.Optional[str], FieldMetadata(alias="modelId")
] = pydantic.Field(default=None)
"""
The matched model ID
"""

model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
extra="allow", frozen=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import typing

import pydantic
from ...commons.types.observation_v2 import ObservationV2
from ...core.pydantic_utilities import UniversalBaseModel
from .observations_v2meta import ObservationsV2Meta

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

data: typing.List[typing.Dict[str, typing.Any]] = pydantic.Field()
data: typing.List[ObservationV2] = pydantic.Field()
"""
Array of observation objects. Fields included depend on the `fields` parameter in the request.
"""
Expand Down
Loading