langfuse.api.commons

  1# This file was auto-generated by Fern from our API Definition.
  2
  3# isort: skip_file
  4
  5import typing
  6from importlib import import_module
  7
  8if typing.TYPE_CHECKING:
  9    from .types import (
 10        BaseScore,
 11        BaseScoreV1,
 12        BooleanScore,
 13        BooleanScoreV1,
 14        CategoricalScore,
 15        CategoricalScoreV1,
 16        Comment,
 17        CommentObjectType,
 18        ConfigCategory,
 19        CorrectionScore,
 20        CreateScoreValue,
 21        Dataset,
 22        DatasetItem,
 23        DatasetItemMediaReference,
 24        DatasetItemMediaReferenceField,
 25        DatasetItemMediaReferenceMedia,
 26        DatasetRun,
 27        DatasetRunItem,
 28        DatasetRunWithItems,
 29        DatasetStatus,
 30        MapValue,
 31        Model,
 32        ModelPrice,
 33        ModelUsageUnit,
 34        NumericScore,
 35        NumericScoreV1,
 36        Observation,
 37        ObservationLevel,
 38        ObservationV2,
 39        ObservationsView,
 40        PricingTier,
 41        PricingTierCondition,
 42        PricingTierInput,
 43        PricingTierOperator,
 44        Score,
 45        ScoreConfig,
 46        ScoreConfigDataType,
 47        ScoreDataType,
 48        ScoreSource,
 49        ScoreV1,
 50        ScoreV1_Boolean,
 51        ScoreV1_Categorical,
 52        ScoreV1_Numeric,
 53        ScoreV1_Text,
 54        Score_Boolean,
 55        Score_Categorical,
 56        Score_Correction,
 57        Score_Numeric,
 58        Score_Text,
 59        Session,
 60        SessionWithTraces,
 61        TextScore,
 62        TextScoreV1,
 63        Trace,
 64        TraceWithDetails,
 65        TraceWithFullDetails,
 66        Usage,
 67    )
 68    from .errors import (
 69        AccessDeniedError,
 70        Error,
 71        MethodNotAllowedError,
 72        NotFoundError,
 73        UnauthorizedError,
 74    )
 75_dynamic_imports: typing.Dict[str, str] = {
 76    "AccessDeniedError": ".errors",
 77    "BaseScore": ".types",
 78    "BaseScoreV1": ".types",
 79    "BooleanScore": ".types",
 80    "BooleanScoreV1": ".types",
 81    "CategoricalScore": ".types",
 82    "CategoricalScoreV1": ".types",
 83    "Comment": ".types",
 84    "CommentObjectType": ".types",
 85    "ConfigCategory": ".types",
 86    "CorrectionScore": ".types",
 87    "CreateScoreValue": ".types",
 88    "Dataset": ".types",
 89    "DatasetItem": ".types",
 90    "DatasetItemMediaReference": ".types",
 91    "DatasetItemMediaReferenceField": ".types",
 92    "DatasetItemMediaReferenceMedia": ".types",
 93    "DatasetRun": ".types",
 94    "DatasetRunItem": ".types",
 95    "DatasetRunWithItems": ".types",
 96    "DatasetStatus": ".types",
 97    "Error": ".errors",
 98    "MapValue": ".types",
 99    "MethodNotAllowedError": ".errors",
100    "Model": ".types",
101    "ModelPrice": ".types",
102    "ModelUsageUnit": ".types",
103    "NotFoundError": ".errors",
104    "NumericScore": ".types",
105    "NumericScoreV1": ".types",
106    "Observation": ".types",
107    "ObservationLevel": ".types",
108    "ObservationV2": ".types",
109    "ObservationsView": ".types",
110    "PricingTier": ".types",
111    "PricingTierCondition": ".types",
112    "PricingTierInput": ".types",
113    "PricingTierOperator": ".types",
114    "Score": ".types",
115    "ScoreConfig": ".types",
116    "ScoreConfigDataType": ".types",
117    "ScoreDataType": ".types",
118    "ScoreSource": ".types",
119    "ScoreV1": ".types",
120    "ScoreV1_Boolean": ".types",
121    "ScoreV1_Categorical": ".types",
122    "ScoreV1_Numeric": ".types",
123    "ScoreV1_Text": ".types",
124    "Score_Boolean": ".types",
125    "Score_Categorical": ".types",
126    "Score_Correction": ".types",
127    "Score_Numeric": ".types",
128    "Score_Text": ".types",
129    "Session": ".types",
130    "SessionWithTraces": ".types",
131    "TextScore": ".types",
132    "TextScoreV1": ".types",
133    "Trace": ".types",
134    "TraceWithDetails": ".types",
135    "TraceWithFullDetails": ".types",
136    "UnauthorizedError": ".errors",
137    "Usage": ".types",
138}
139
140
141def __getattr__(attr_name: str) -> typing.Any:
142    module_name = _dynamic_imports.get(attr_name)
143    if module_name is None:
144        raise AttributeError(
145            f"No {attr_name} found in _dynamic_imports for module name -> {__name__}"
146        )
147    try:
148        module = import_module(module_name, __package__)
149        if module_name == f".{attr_name}":
150            return module
151        else:
152            return getattr(module, attr_name)
153    except ImportError as e:
154        raise ImportError(
155            f"Failed to import {attr_name} from {module_name}: {e}"
156        ) from e
157    except AttributeError as e:
158        raise AttributeError(
159            f"Failed to get {attr_name} from {module_name}: {e}"
160        ) from e
161
162
163def __dir__():
164    lazy_attrs = list(_dynamic_imports.keys())
165    return sorted(lazy_attrs)
166
167
168__all__ = [
169    "AccessDeniedError",
170    "BaseScore",
171    "BaseScoreV1",
172    "BooleanScore",
173    "BooleanScoreV1",
174    "CategoricalScore",
175    "CategoricalScoreV1",
176    "Comment",
177    "CommentObjectType",
178    "ConfigCategory",
179    "CorrectionScore",
180    "CreateScoreValue",
181    "Dataset",
182    "DatasetItem",
183    "DatasetItemMediaReference",
184    "DatasetItemMediaReferenceField",
185    "DatasetItemMediaReferenceMedia",
186    "DatasetRun",
187    "DatasetRunItem",
188    "DatasetRunWithItems",
189    "DatasetStatus",
190    "Error",
191    "MapValue",
192    "MethodNotAllowedError",
193    "Model",
194    "ModelPrice",
195    "ModelUsageUnit",
196    "NotFoundError",
197    "NumericScore",
198    "NumericScoreV1",
199    "Observation",
200    "ObservationLevel",
201    "ObservationV2",
202    "ObservationsView",
203    "PricingTier",
204    "PricingTierCondition",
205    "PricingTierInput",
206    "PricingTierOperator",
207    "Score",
208    "ScoreConfig",
209    "ScoreConfigDataType",
210    "ScoreDataType",
211    "ScoreSource",
212    "ScoreV1",
213    "ScoreV1_Boolean",
214    "ScoreV1_Categorical",
215    "ScoreV1_Numeric",
216    "ScoreV1_Text",
217    "Score_Boolean",
218    "Score_Categorical",
219    "Score_Correction",
220    "Score_Numeric",
221    "Score_Text",
222    "Session",
223    "SessionWithTraces",
224    "TextScore",
225    "TextScoreV1",
226    "Trace",
227    "TraceWithDetails",
228    "TraceWithFullDetails",
229    "UnauthorizedError",
230    "Usage",
231]
AccessDeniedError
BaseScore
BaseScoreV1
BooleanScore
BooleanScoreV1
CategoricalScore
CategoricalScoreV1
Comment
CommentObjectType
ConfigCategory
CorrectionScore
CreateScoreValue
Dataset
DatasetItem
DatasetItemMediaReference
DatasetItemMediaReferenceField
DatasetItemMediaReferenceMedia
DatasetRun
DatasetRunItem
DatasetRunWithItems
DatasetStatus
Error
MapValue
MethodNotAllowedError
Model
ModelPrice
ModelUsageUnit
NotFoundError
NumericScore
NumericScoreV1
Observation
ObservationLevel
ObservationV2
ObservationsView
PricingTier
PricingTierCondition
PricingTierInput
PricingTierOperator
Score
ScoreConfig
ScoreConfigDataType
ScoreDataType
ScoreSource
ScoreV1
ScoreV1_Boolean
ScoreV1_Categorical
ScoreV1_Numeric
ScoreV1_Text
Score_Boolean
Score_Categorical
Score_Correction
Score_Numeric
Score_Text
Session
SessionWithTraces
TextScore
TextScoreV1
Trace
TraceWithDetails
TraceWithFullDetails
UnauthorizedError
Usage