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