|
| 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 | + ) |
0 commit comments