| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 370039d commit 87f47ab
19 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -305,6 +305,9 @@ | |||
| 305 | 305 | UpdateScoreConfigRequest, | |
| 306 | 306 | ) | |
| 307 | 307 | from .scores import ( | |
| 308 | + CreateScoreRequest, | ||
| 309 | + CreateScoreResponse, | ||
| 310 | + CreateScoreSource, | ||
| 308 | 311 | GetScoresResponse, | |
| 309 | 312 | GetScoresResponseData, | |
| 310 | 313 | GetScoresResponseDataBoolean, | |
@@ -411,6 +414,9 @@ | |||
| 411 | 414 | "CreateObservationEvent": ".ingestion", | |
| 412 | 415 | "CreatePromptRequest": ".prompts", | |
| 413 | 416 | "CreateScoreConfigRequest": ".score_configs", | |
| 417 | + "CreateScoreRequest": ".scores", | ||
| 418 | + "CreateScoreResponse": ".scores", | ||
| 419 | + "CreateScoreSource": ".scores", | ||
| 414 | 420 | "CreateScoreValue": ".commons", | |
| 415 | 421 | "CreateSpanBody": ".ingestion", | |
| 416 | 422 | "CreateSpanEvent": ".ingestion", | |
@@ -749,6 +755,9 @@ def __dir__(): | |||
| 749 | 755 | "CreateObservationEvent", | |
| 750 | 756 | "CreatePromptRequest", | |
| 751 | 757 | "CreateScoreConfigRequest", | |
| 758 | + "CreateScoreRequest", | ||
| 759 | + "CreateScoreResponse", | ||
| 760 | + "CreateScoreSource", | ||
| 752 | 761 | "CreateScoreValue", | |
| 753 | 762 | "CreateSpanBody", | |
| 754 | 763 | "CreateSpanEvent", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,14 +53,23 @@ class ObservationV2(UniversalBaseModel): | |||
| 53 | 53 | typing.Optional[str], FieldMetadata(alias="parentObservationId") | |
| 54 | 54 | ] = pydantic.Field(default=None) | |
| 55 | 55 | """ | |
| 56 | - The parent observation ID | ||
| 56 | + The physical parent observation ID, if present. | ||
| 57 | + Observations marked as app roots by the SDK may retain a non-null parent ID. | ||
| 57 | 58 | """ | |
| 58 | 59 | ||
| 59 | 60 | type: str = pydantic.Field() | |
| 60 | 61 | """ | |
| 61 | 62 | The type of the observation (e.g. GENERATION, SPAN, EVENT) | |
| 62 | 63 | """ | |
| 63 | 64 | ||
| 65 | + is_root_observation: typing_extensions.Annotated[ | ||
| 66 | + typing.Optional[bool], FieldMetadata(alias="isRootObservation") | ||
| 67 | + ] = pydantic.Field(default=None) | ||
| 68 | + """ | ||
| 69 | + Whether this observation is a logical root. | ||
| 70 | + This is true for observations without a physical parent and observations marked as app roots by the SDK. | ||
| 71 | + """ | ||
| 72 | + | ||
| 64 | 73 | name: typing.Optional[str] = pydantic.Field(default=None) | |
| 65 | 74 | """ | |
| 66 | 75 | The name of the observation | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,11 +9,7 @@ | |||
| 9 | 9 | from . import metrics_v1, observations_v1, score_v1 | |
| 10 | 10 | from .metrics_v1 import MetricsResponse | |
| 11 | 11 | from .observations_v1 import Observations, ObservationsViews | |
| 12 | - from .score_v1 import CreateScoreRequest, CreateScoreResponse, CreateScoreSource | ||
| 13 | 12 | _dynamic_imports: typing.Dict[str, str] = { | |
| 14 | - "CreateScoreRequest": ".score_v1", | ||
| 15 | - "CreateScoreResponse": ".score_v1", | ||
| 16 | - "CreateScoreSource": ".score_v1", | ||
| 17 | 13 | "MetricsResponse": ".metrics_v1", | |
| 18 | 14 | "Observations": ".observations_v1", | |
| 19 | 15 | "ObservationsViews": ".observations_v1", | |
@@ -51,13 +47,17 @@ def __dir__(): | |||
| 51 | 47 | ||
| 52 | 48 | ||
| 53 | 49 | __all__ = [ | |
| 54 | - "CreateScoreRequest", | ||
| 55 | - "CreateScoreResponse", | ||
| 56 | - "CreateScoreSource", | ||
| 57 | 50 | "MetricsResponse", | |
| 58 | 51 | "Observations", | |
| 59 | 52 | "ObservationsViews", | |
| 60 | 53 | "metrics_v1", | |
| 61 | 54 | "observations_v1", | |
| 62 | 55 | "score_v1", | |
| 63 | 56 | ] | |
| 57 | + | ||
| 58 | + # Score-create compatibility aliases (LFE-10397). | ||
| 59 | + from .score_v1 import CreateScoreRequest | ||
| 60 | + from .score_v1 import CreateScoreResponse | ||
| 61 | + from .score_v1 import CreateScoreSource | ||
| 62 | + | ||
| 63 | + __all__ = [*__all__, "CreateScoreRequest", "CreateScoreResponse", "CreateScoreSource"] | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,43 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | 3 | # isort: skip_file | |
| 4 | 4 | ||
| 5 | - import typing | ||
| 6 | - from importlib import import_module | ||
| 7 | - | ||
| 8 | - if typing.TYPE_CHECKING: | ||
| 9 | - from .types import CreateScoreRequest, CreateScoreResponse, CreateScoreSource | ||
| 10 | - _dynamic_imports: typing.Dict[str, str] = { | ||
| 11 | - "CreateScoreRequest": ".types", | ||
| 12 | - "CreateScoreResponse": ".types", | ||
| 13 | - "CreateScoreSource": ".types", | ||
| 14 | - } | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - def __getattr__(attr_name: str) -> typing.Any: | ||
| 18 | - module_name = _dynamic_imports.get(attr_name) | ||
| 19 | - if module_name is None: | ||
| 20 | - raise AttributeError( | ||
| 21 | - f"No {attr_name} found in _dynamic_imports for module name -> {__name__}" | ||
| 22 | - ) | ||
| 23 | - try: | ||
| 24 | - module = import_module(module_name, __package__) | ||
| 25 | - if module_name == f".{attr_name}": | ||
| 26 | - return module | ||
| 27 | - else: | ||
| 28 | - return getattr(module, attr_name) | ||
| 29 | - except ImportError as e: | ||
| 30 | - raise ImportError( | ||
| 31 | - f"Failed to import {attr_name} from {module_name}: {e}" | ||
| 32 | - ) from e | ||
| 33 | - except AttributeError as e: | ||
| 34 | - raise AttributeError( | ||
| 35 | - f"Failed to get {attr_name} from {module_name}: {e}" | ||
| 36 | - ) from e | ||
| 37 | - | ||
| 38 | - | ||
| 39 | - def __dir__(): | ||
| 40 | - lazy_attrs = list(_dynamic_imports.keys()) | ||
| 41 | - return sorted(lazy_attrs) | ||
| 42 | - | ||
| 5 | + # Score-create compatibility aliases (LFE-10397). | ||
| 6 | + from .types import CreateScoreRequest | ||
| 7 | + from .types import CreateScoreResponse | ||
| 8 | + from .types import CreateScoreSource | ||
| 43 | 9 | ||
| 44 | 10 | __all__ = ["CreateScoreRequest", "CreateScoreResponse", "CreateScoreSource"] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,16 +2,18 @@ | |||
| 2 | 2 | ||
| 3 | 3 | import typing | |
| 4 | 4 | ||
| 5 | + from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper | ||
| 5 | 6 | from ...commons.types.create_score_value import CreateScoreValue | |
| 6 | 7 | from ...commons.types.score_data_type import ScoreDataType | |
| 7 | - from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper | ||
| 8 | + from ...scores.client import ( | ||
| 9 | + AsyncScoresClient as CanonicalAsyncScoresClient, | ||
| 10 | + ScoresClient as CanonicalScoresClient, | ||
| 11 | + OMIT, | ||
| 12 | + ) | ||
| 13 | + from ...scores.types.create_score_response import CreateScoreResponse | ||
| 14 | + from ...scores.types.create_score_source import CreateScoreSource | ||
| 8 | 15 | from ...core.request_options import RequestOptions | |
| 9 | 16 | from .raw_client import AsyncRawScoreV1Client, RawScoreV1Client | |
| 10 | - from .types.create_score_response import CreateScoreResponse | ||
| 11 | - from .types.create_score_source import CreateScoreSource | ||
| 12 | - | ||
| 13 | - # this is used as the default value for optional parameters | ||
| 14 | - OMIT = typing.cast(typing.Any, ...) | ||
| 15 | 17 | ||
| 16 | 18 | ||
| 17 | 19 | class ScoreV1Client: | |
@@ -48,70 +50,10 @@ def create( | |||
| 48 | 50 | source: typing.Optional[CreateScoreSource] = OMIT, | |
| 49 | 51 | request_options: typing.Optional[RequestOptions] = None, | |
| 50 | 52 | ) -> CreateScoreResponse: | |
| 51 | - """ | ||
| 52 | - Create a score (supports both trace and session scores) | ||
| 53 | - | ||
| 54 | - Parameters | ||
| 55 | - ---------- | ||
| 56 | - name : str | ||
| 57 | - | ||
| 58 | - value : CreateScoreValue | ||
| 59 | - The value of the score. Must be passed as string for categorical and text scores, and numeric for boolean and numeric scores. Boolean score values must equal either 1 or 0 (true or false). Text score values must be between 1 and 500 characters. | ||
| 60 | - | ||
| 61 | - id : typing.Optional[str] | ||
| 62 | - | ||
| 63 | - trace_id : typing.Optional[str] | ||
| 64 | - | ||
| 65 | - session_id : typing.Optional[str] | ||
| 66 | - | ||
| 67 | - observation_id : typing.Optional[str] | ||
| 68 | - | ||
| 69 | - dataset_run_id : typing.Optional[str] | ||
| 70 | - | ||
| 71 | - comment : typing.Optional[str] | ||
| 72 | - | ||
| 73 | - metadata : typing.Optional[typing.Dict[str, typing.Any]] | ||
| 74 | - | ||
| 75 | - environment : typing.Optional[str] | ||
| 76 | - The environment of the score. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. | ||
| 77 | - | ||
| 78 | - queue_id : typing.Optional[str] | ||
| 79 | - The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue. | ||
| 80 | - | ||
| 81 | - data_type : typing.Optional[ScoreDataType] | ||
| 82 | - The data type of the score. When passing a configId this field is inferred. Otherwise, this field must be passed or will default to numeric. | ||
| 83 | - | ||
| 84 | - config_id : typing.Optional[str] | ||
| 85 | - Reference a score config on a score. The unique langfuse identifier of a score config. When passing this field, the dataType and stringValue fields are automatically populated. | ||
| 86 | - | ||
| 87 | - source : typing.Optional[CreateScoreSource] | ||
| 88 | - The source of the score. Defaults to API. Set to ANNOTATION to prefill scores (e.g. from an LLM) for a human reviewer to verify in an annotation queue. When source is ANNOTATION, a configId is required unless dataType is CORRECTION. EVAL is reserved for internal evaluator outputs and is not accepted on this endpoint. | ||
| 89 | - | ||
| 90 | - request_options : typing.Optional[RequestOptions] | ||
| 91 | - Request-specific configuration. | ||
| 92 | - | ||
| 93 | - Returns | ||
| 94 | - ------- | ||
| 95 | - CreateScoreResponse | ||
| 96 | - | ||
| 97 | - Examples | ||
| 98 | - -------- | ||
| 99 | - from langfuse import LangfuseAPI | ||
| 100 | - | ||
| 101 | - client = LangfuseAPI( | ||
| 102 | - x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", | ||
| 103 | - x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", | ||
| 104 | - x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", | ||
| 105 | - username="YOUR_USERNAME", | ||
| 106 | - password="YOUR_PASSWORD", | ||
| 107 | - base_url="https://yourhost.com/path/to/api", | ||
| 108 | - ) | ||
| 109 | - client.legacy.score_v1.create( | ||
| 110 | - name="name", | ||
| 111 | - value=1.1, | ||
| 112 | - ) | ||
| 113 | - """ | ||
| 114 | - _response = self._raw_client.create( | ||
| 53 | + """**Deprecated compatibility alias.** Use ``client.scores.create``.""" | ||
| 54 | + return CanonicalScoresClient( | ||
| 55 | + client_wrapper=self._raw_client._client_wrapper | ||
| 56 | + ).create( | ||
| 115 | 57 | name=name, | |
| 116 | 58 | value=value, | |
| 117 | 59 | id=id, | |
@@ -128,7 +70,6 @@ def create( | |||
| 128 | 70 | source=source, | |
| 129 | 71 | request_options=request_options, | |
| 130 | 72 | ) | |
| 131 | - return _response.data | ||
| 132 | 73 | ||
| 133 | 74 | def delete( | |
| 134 | 75 | self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None | |
@@ -202,78 +143,10 @@ async def create( | |||
| 202 | 143 | source: typing.Optional[CreateScoreSource] = OMIT, | |
| 203 | 144 | request_options: typing.Optional[RequestOptions] = None, | |
| 204 | 145 | ) -> CreateScoreResponse: | |
| 205 | - """ | ||
| 206 | - Create a score (supports both trace and session scores) | ||
| 207 | - | ||
| 208 | - Parameters | ||
| 209 | - ---------- | ||
| 210 | - name : str | ||
| 211 | - | ||
| 212 | - value : CreateScoreValue | ||
| 213 | - The value of the score. Must be passed as string for categorical and text scores, and numeric for boolean and numeric scores. Boolean score values must equal either 1 or 0 (true or false). Text score values must be between 1 and 500 characters. | ||
| 214 | - | ||
| 215 | - id : typing.Optional[str] | ||
| 216 | - | ||
| 217 | - trace_id : typing.Optional[str] | ||
| 218 | - | ||
| 219 | - session_id : typing.Optional[str] | ||
| 220 | - | ||
| 221 | - observation_id : typing.Optional[str] | ||
| 222 | - | ||
| 223 | - dataset_run_id : typing.Optional[str] | ||
| 224 | - | ||
| 225 | - comment : typing.Optional[str] | ||
| 226 | - | ||
| 227 | - metadata : typing.Optional[typing.Dict[str, typing.Any]] | ||
| 228 | - | ||
| 229 | - environment : typing.Optional[str] | ||
| 230 | - The environment of the score. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. | ||
| 231 | - | ||
| 232 | - queue_id : typing.Optional[str] | ||
| 233 | - The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue. | ||
| 234 | - | ||
| 235 | - data_type : typing.Optional[ScoreDataType] | ||
| 236 | - The data type of the score. When passing a configId this field is inferred. Otherwise, this field must be passed or will default to numeric. | ||
| 237 | - | ||
| 238 | - config_id : typing.Optional[str] | ||
| 239 | - Reference a score config on a score. The unique langfuse identifier of a score config. When passing this field, the dataType and stringValue fields are automatically populated. | ||
| 240 | - | ||
| 241 | - source : typing.Optional[CreateScoreSource] | ||
| 242 | - The source of the score. Defaults to API. Set to ANNOTATION to prefill scores (e.g. from an LLM) for a human reviewer to verify in an annotation queue. When source is ANNOTATION, a configId is required unless dataType is CORRECTION. EVAL is reserved for internal evaluator outputs and is not accepted on this endpoint. | ||
| 243 | - | ||
| 244 | - request_options : typing.Optional[RequestOptions] | ||
| 245 | - Request-specific configuration. | ||
| 246 | - | ||
| 247 | - Returns | ||
| 248 | - ------- | ||
| 249 | - CreateScoreResponse | ||
| 250 | - | ||
| 251 | - Examples | ||
| 252 | - -------- | ||
| 253 | - import asyncio | ||
| 254 | - | ||
| 255 | - from langfuse import AsyncLangfuseAPI | ||
| 256 | - | ||
| 257 | - client = AsyncLangfuseAPI( | ||
| 258 | - x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", | ||
| 259 | - x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", | ||
| 260 | - x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", | ||
| 261 | - username="YOUR_USERNAME", | ||
| 262 | - password="YOUR_PASSWORD", | ||
| 263 | - base_url="https://yourhost.com/path/to/api", | ||
| 264 | - ) | ||
| 265 | - | ||
| 266 | - | ||
| 267 | - async def main() -> None: | ||
| 268 | - await client.legacy.score_v1.create( | ||
| 269 | - name="name", | ||
| 270 | - value=1.1, | ||
| 271 | - ) | ||
| 272 | - | ||
| 273 | - | ||
| 274 | - asyncio.run(main()) | ||
| 275 | - """ | ||
| 276 | - _response = await self._raw_client.create( | ||
| 146 | + """**Deprecated compatibility alias.** Use ``client.scores.create``.""" | ||
| 147 | + return await CanonicalAsyncScoresClient( | ||
| 148 | + client_wrapper=self._raw_client._client_wrapper | ||
| 149 | + ).create( | ||
| 277 | 150 | name=name, | |
| 278 | 151 | value=value, | |
| 279 | 152 | id=id, | |
@@ -290,7 +163,6 @@ async def main() -> None: | |||
| 290 | 163 | source=source, | |
| 291 | 164 | request_options=request_options, | |
| 292 | 165 | ) | |
| 293 | - return _response.data | ||
| 294 | 166 | ||
| 295 | 167 | async def delete( | |
| 296 | 168 | self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None | |
| Back | FazBrowse Home | New Git URL |
0 commit comments