braintrust 0.5.2__py3-none-any.whl → 0.5.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
braintrust/__init__.py CHANGED
@@ -49,6 +49,17 @@ BRAINTRUST_API_KEY=<YOUR_BRAINTRUST_API_KEY> braintrust eval eval_hello.py
49
49
  ### API Reference
50
50
  """
51
51
 
52
+ # Check env var at import time for auto-instrumentation
53
+ import os
54
+
55
+ if os.getenv("BRAINTRUST_INSTRUMENT_THREADS", "").lower() in ("true", "1", "yes"):
56
+ try:
57
+ from .wrappers.threads import setup_threads
58
+
59
+ setup_threads()
60
+ except Exception:
61
+ pass # Never break on import
62
+
52
63
  from .audit import *
53
64
  from .auto import (
54
65
  auto_instrument, # noqa: F401 # type: ignore[reportUnusedImport]
@@ -167,6 +167,10 @@ AsyncScoringState: TypeAlias = AsyncScoringStateAsyncScoringState | AsyncScoring
167
167
  class PreprocessorPreprocessor(TypedDict):
168
168
  type: Literal['function']
169
169
  id: str
170
+ version: NotRequired[str | None]
171
+ """
172
+ The version of the function
173
+ """
170
174
 
171
175
 
172
176
  class PreprocessorPreprocessor2(TypedDict):
@@ -638,6 +642,10 @@ class ExperimentEventContext(TypedDict):
638
642
  class ExtendedSavedFunctionIdExtendedSavedFunctionId(TypedDict):
639
643
  type: Literal['function']
640
644
  id: str
645
+ version: NotRequired[str | None]
646
+ """
647
+ The version of the function
648
+ """
641
649
 
642
650
 
643
651
  class ExtendedSavedFunctionIdExtendedSavedFunctionId2(TypedDict):
@@ -668,6 +676,10 @@ class ExternalAttachmentReference(TypedDict):
668
676
  class Preprocessor1Preprocessor1(TypedDict):
669
677
  type: Literal['function']
670
678
  id: str
679
+ version: NotRequired[str | None]
680
+ """
681
+ The version of the function
682
+ """
671
683
 
672
684
 
673
685
  class Preprocessor1Preprocessor12(TypedDict):
@@ -803,7 +815,7 @@ FunctionOutputType: TypeAlias = Literal['completion', 'score', 'facet', 'classif
803
815
 
804
816
 
805
817
  FunctionTypeEnum: TypeAlias = Literal[
806
- 'llm', 'scorer', 'task', 'tool', 'custom_view', 'preprocessor', 'facet', 'classifier'
818
+ 'llm', 'scorer', 'task', 'tool', 'custom_view', 'preprocessor', 'facet', 'classifier', 'tag'
807
819
  ]
808
820
  """
809
821
  The type of global function. Defaults to 'scorer'.
@@ -811,7 +823,7 @@ The type of global function. Defaults to 'scorer'.
811
823
 
812
824
 
813
825
  FunctionTypeEnumNullish: TypeAlias = Literal[
814
- 'llm', 'scorer', 'task', 'tool', 'custom_view', 'preprocessor', 'facet', 'classifier'
826
+ 'llm', 'scorer', 'task', 'tool', 'custom_view', 'preprocessor', 'facet', 'classifier', 'tag'
815
827
  ]
816
828
 
817
829
 
@@ -1108,6 +1120,12 @@ class GroupScope(TypedDict):
1108
1120
  IfExists: TypeAlias = Literal['error', 'ignore', 'replace']
1109
1121
 
1110
1122
 
1123
+ ImageRenderingMode: TypeAlias = Literal['auto', 'click_to_load', 'blocked']
1124
+ """
1125
+ Controls how images are rendered in the UI: 'auto' loads images automatically, 'click_to_load' shows a placeholder until clicked, 'blocked' prevents image loading entirely
1126
+ """
1127
+
1128
+
1111
1129
  class InvokeFunctionInvokeFunction(TypedDict):
1112
1130
  function_id: str
1113
1131
  """
@@ -1311,6 +1329,10 @@ class ModelParamsModelParams4(TypedDict):
1311
1329
  class NullableSavedFunctionIdNullableSavedFunctionId(TypedDict):
1312
1330
  type: Literal['function']
1313
1331
  id: str
1332
+ version: NotRequired[str | None]
1333
+ """
1334
+ The version of the function
1335
+ """
1314
1336
 
1315
1337
 
1316
1338
  class NullableSavedFunctionIdNullableSavedFunctionId1(TypedDict):
@@ -1390,6 +1412,7 @@ class Organization(TypedDict):
1390
1412
  """
1391
1413
  Date of organization creation
1392
1414
  """
1415
+ image_rendering_mode: NotRequired[ImageRenderingMode | None]
1393
1416
 
1394
1417
 
1395
1418
  Permission: TypeAlias = Literal[
@@ -2078,6 +2101,10 @@ class RunEvalMcpAuth(TypedDict):
2078
2101
  class SavedFunctionIdSavedFunctionId(TypedDict):
2079
2102
  type: Literal['function']
2080
2103
  id: str
2104
+ version: NotRequired[str | None]
2105
+ """
2106
+ The version of the function
2107
+ """
2081
2108
 
2082
2109
 
2083
2110
  class SavedFunctionIdSavedFunctionId1(TypedDict):
@@ -2590,6 +2617,14 @@ class DatasetEvent(TypedDict):
2590
2617
  """
2591
2618
  Optional list of audit entries attached to this event
2592
2619
  """
2620
+ facets: NotRequired[Mapping[str, Any] | None]
2621
+ """
2622
+ Facets for categorization (dictionary from facet id to value)
2623
+ """
2624
+ classifications: NotRequired[Mapping[str, Any] | None]
2625
+ """
2626
+ Classifications for this event (dictionary from classification name to items)
2627
+ """
2593
2628
 
2594
2629
 
2595
2630
  class EvalStatusPage(TypedDict):
@@ -3101,6 +3136,14 @@ class ExperimentEvent(TypedDict):
3101
3136
  """
3102
3137
  Optional list of audit entries attached to this event
3103
3138
  """
3139
+ facets: NotRequired[Mapping[str, Any] | None]
3140
+ """
3141
+ Facets for categorization (dictionary from facet id to value)
3142
+ """
3143
+ classifications: NotRequired[Mapping[str, Any] | None]
3144
+ """
3145
+ Classifications for this event (dictionary from classification name to items)
3146
+ """
3104
3147
 
3105
3148
 
3106
3149
  class GraphNodeGraphNode7(TypedDict):
@@ -3223,6 +3266,14 @@ class ProjectLogsEvent(TypedDict):
3223
3266
  """
3224
3267
  The async scoring state for this event
3225
3268
  """
3269
+ facets: NotRequired[Mapping[str, Any] | None]
3270
+ """
3271
+ Facets for categorization (dictionary from facet id to value)
3272
+ """
3273
+ classifications: NotRequired[Mapping[str, Any] | None]
3274
+ """
3275
+ Classifications for this event (dictionary from classification name to items)
3276
+ """
3226
3277
 
3227
3278
 
3228
3279
  class ProjectScore(TypedDict):
@@ -3330,7 +3381,9 @@ class View(TypedDict):
3330
3381
  'classifiers',
3331
3382
  'logs',
3332
3383
  'monitor',
3333
- 'for_review',
3384
+ 'for_review_project_log',
3385
+ 'for_review_experiments',
3386
+ 'for_review_datasets',
3334
3387
  ]
3335
3388
  """
3336
3389
  Type of object that the view corresponds to.
braintrust/db_fields.py CHANGED
@@ -15,3 +15,13 @@ PARENT_ID_FIELD = "_parent_id"
15
15
 
16
16
  ASYNC_SCORING_CONTROL_FIELD = "_async_scoring_control"
17
17
  SKIP_ASYNC_SCORING_FIELD = "_skip_async_scoring"
18
+
19
+ # Keys that identify which object (experiment, dataset, project logs, etc.) a row belongs to.
20
+ OBJECT_ID_KEYS = (
21
+ "experiment_id",
22
+ "dataset_id",
23
+ "prompt_session_id",
24
+ "project_id",
25
+ "log_id",
26
+ "function_data",
27
+ )
@@ -1,4 +1,4 @@
1
- """Auto-generated file (internal git SHA 21146f64bf5ad1eadd3a99d186274728e25e5399) -- do not modify"""
1
+ """Auto-generated file (internal git SHA 7178200dd3c7869f27b677260303cda0b798bf42) -- do not modify"""
2
2
 
3
3
  from ._generated_types import (
4
4
  Acl,
@@ -53,6 +53,7 @@ from ._generated_types import (
53
53
  Group,
54
54
  GroupScope,
55
55
  IfExists,
56
+ ImageRenderingMode,
56
57
  InvokeFunction,
57
58
  InvokeParent,
58
59
  MCPServer,
@@ -163,6 +164,7 @@ __all__ = [
163
164
  "Group",
164
165
  "GroupScope",
165
166
  "IfExists",
167
+ "ImageRenderingMode",
166
168
  "InvokeFunction",
167
169
  "InvokeParent",
168
170
  "MCPServer",