braintrust 0.3.14__py3-none-any.whl → 0.4.0__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 +4 -0
- braintrust/_generated_types.py +1200 -611
- braintrust/audit.py +2 -2
- braintrust/cli/eval.py +6 -7
- braintrust/cli/push.py +11 -11
- braintrust/conftest.py +1 -0
- braintrust/context.py +12 -17
- braintrust/contrib/temporal/__init__.py +16 -27
- braintrust/contrib/temporal/test_temporal.py +8 -3
- braintrust/devserver/auth.py +8 -8
- braintrust/devserver/cache.py +3 -4
- braintrust/devserver/cors.py +8 -7
- braintrust/devserver/dataset.py +3 -5
- braintrust/devserver/eval_hooks.py +7 -6
- braintrust/devserver/schemas.py +22 -19
- braintrust/devserver/server.py +19 -12
- braintrust/devserver/test_cached_login.py +4 -4
- braintrust/framework.py +128 -140
- braintrust/framework2.py +88 -87
- braintrust/functions/invoke.py +93 -53
- braintrust/functions/stream.py +3 -2
- braintrust/generated_types.py +17 -1
- braintrust/git_fields.py +11 -11
- braintrust/gitutil.py +2 -3
- braintrust/graph_util.py +10 -10
- braintrust/id_gen.py +2 -2
- braintrust/logger.py +346 -357
- braintrust/merge_row_batch.py +10 -9
- braintrust/oai.py +107 -24
- braintrust/otel/__init__.py +49 -49
- braintrust/otel/context.py +16 -30
- braintrust/otel/test_distributed_tracing.py +14 -11
- braintrust/otel/test_otel_bt_integration.py +32 -31
- braintrust/parameters.py +8 -8
- braintrust/prompt.py +14 -14
- braintrust/prompt_cache/disk_cache.py +5 -4
- braintrust/prompt_cache/lru_cache.py +3 -2
- braintrust/prompt_cache/prompt_cache.py +13 -14
- braintrust/queue.py +4 -4
- braintrust/score.py +4 -4
- braintrust/serializable_data_class.py +4 -4
- braintrust/span_identifier_v1.py +1 -2
- braintrust/span_identifier_v2.py +3 -4
- braintrust/span_identifier_v3.py +23 -20
- braintrust/span_identifier_v4.py +34 -25
- braintrust/test_framework.py +16 -6
- braintrust/test_helpers.py +5 -5
- braintrust/test_id_gen.py +2 -3
- braintrust/test_otel.py +61 -53
- braintrust/test_queue.py +0 -1
- braintrust/test_score.py +1 -3
- braintrust/test_span_components.py +29 -44
- braintrust/util.py +9 -8
- braintrust/version.py +2 -2
- braintrust/wrappers/_anthropic_utils.py +4 -4
- braintrust/wrappers/agno/__init__.py +3 -4
- braintrust/wrappers/agno/agent.py +1 -2
- braintrust/wrappers/agno/function_call.py +1 -2
- braintrust/wrappers/agno/model.py +1 -2
- braintrust/wrappers/agno/team.py +1 -2
- braintrust/wrappers/agno/utils.py +12 -12
- braintrust/wrappers/anthropic.py +7 -8
- braintrust/wrappers/claude_agent_sdk/__init__.py +3 -4
- braintrust/wrappers/claude_agent_sdk/_wrapper.py +29 -27
- braintrust/wrappers/dspy.py +15 -17
- braintrust/wrappers/google_genai/__init__.py +16 -16
- braintrust/wrappers/langchain.py +22 -24
- braintrust/wrappers/litellm.py +4 -3
- braintrust/wrappers/openai.py +15 -15
- braintrust/wrappers/pydantic_ai.py +1204 -0
- braintrust/wrappers/test_agno.py +0 -1
- braintrust/wrappers/test_dspy.py +0 -1
- braintrust/wrappers/test_google_genai.py +2 -3
- braintrust/wrappers/test_litellm.py +0 -1
- braintrust/wrappers/test_oai_attachments.py +322 -0
- braintrust/wrappers/test_pydantic_ai_integration.py +1788 -0
- braintrust/wrappers/{test_pydantic_ai.py → test_pydantic_ai_wrap_openai.py} +1 -2
- {braintrust-0.3.14.dist-info → braintrust-0.4.0.dist-info}/METADATA +3 -2
- braintrust-0.4.0.dist-info/RECORD +120 -0
- braintrust-0.3.14.dist-info/RECORD +0 -117
- {braintrust-0.3.14.dist-info → braintrust-0.4.0.dist-info}/WHEEL +0 -0
- {braintrust-0.3.14.dist-info → braintrust-0.4.0.dist-info}/entry_points.txt +0 -0
- {braintrust-0.3.14.dist-info → braintrust-0.4.0.dist-info}/top_level.txt +0 -0
braintrust/gitutil.py
CHANGED
|
@@ -4,7 +4,6 @@ import re
|
|
|
4
4
|
import subprocess
|
|
5
5
|
import threading
|
|
6
6
|
from functools import lru_cache as _cache
|
|
7
|
-
from typing import Optional
|
|
8
7
|
|
|
9
8
|
from .git_fields import GitMetadataSettings, RepoInfo
|
|
10
9
|
|
|
@@ -42,7 +41,7 @@ def _get_base_branch(remote=None):
|
|
|
42
41
|
# To speed this up in the short term, we pick from a list of common names
|
|
43
42
|
# and only fall back to the remote origin if required.
|
|
44
43
|
COMMON_BASE_BRANCHES = ["main", "master", "develop"]
|
|
45
|
-
repo_branches =
|
|
44
|
+
repo_branches = {b.name for b in repo.branches}
|
|
46
45
|
if sum(b in repo_branches for b in COMMON_BASE_BRANCHES) == 1:
|
|
47
46
|
for b in COMMON_BASE_BRANCHES:
|
|
48
47
|
if b in repo_branches:
|
|
@@ -121,7 +120,7 @@ def truncate_to_byte_limit(input_string, byte_limit=65536):
|
|
|
121
120
|
return encoded[:byte_limit].decode("utf-8", errors="ignore")
|
|
122
121
|
|
|
123
122
|
|
|
124
|
-
def get_repo_info(settings:
|
|
123
|
+
def get_repo_info(settings: GitMetadataSettings | None = None):
|
|
125
124
|
if settings is None:
|
|
126
125
|
settings = GitMetadataSettings()
|
|
127
126
|
|
braintrust/graph_util.py
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
# Generic graph algorithms.
|
|
2
2
|
|
|
3
3
|
import dataclasses
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import Protocol
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
# An UndirectedGraph consists of a set of vertex labels and a set of edges
|
|
8
8
|
# between vertices.
|
|
9
9
|
@dataclasses.dataclass
|
|
10
10
|
class UndirectedGraph:
|
|
11
|
-
vertices:
|
|
12
|
-
edges:
|
|
11
|
+
vertices: set[int]
|
|
12
|
+
edges: set[tuple[int, int]]
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
# An AdjacencyListGraph is a mapping from vertex label to the list of vertices
|
|
16
16
|
# where there is a directed edge from the key to the value.
|
|
17
|
-
AdjacencyListGraph =
|
|
17
|
+
AdjacencyListGraph = dict[int, set[int]]
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class FirstVisitF(Protocol):
|
|
21
|
-
def __call__(self, vertex: int, *, parent_vertex:
|
|
21
|
+
def __call__(self, vertex: int, *, parent_vertex: int | None, **kwargs) -> None:
|
|
22
22
|
"""Extras:
|
|
23
23
|
- parent_vertex: the vertex which spawned the current vertex as its
|
|
24
24
|
child during the depth-first search. `parent_vertex` is guaranteed
|
|
@@ -33,9 +33,9 @@ class LastVisitF(Protocol):
|
|
|
33
33
|
|
|
34
34
|
def depth_first_search(
|
|
35
35
|
graph: AdjacencyListGraph,
|
|
36
|
-
first_visit_f:
|
|
37
|
-
last_visit_f:
|
|
38
|
-
visitation_order:
|
|
36
|
+
first_visit_f: FirstVisitF | None = None,
|
|
37
|
+
last_visit_f: LastVisitF | None = None,
|
|
38
|
+
visitation_order: list[int] | None = None,
|
|
39
39
|
) -> None:
|
|
40
40
|
"""A general depth-first search algorithm over a directed graph. As it
|
|
41
41
|
traverses the graph, it invokes user-provided hooks when a vertex is *first*
|
|
@@ -86,7 +86,7 @@ def depth_first_search(
|
|
|
86
86
|
events.append(("first", child, dict(parent_vertex=vertex)))
|
|
87
87
|
|
|
88
88
|
|
|
89
|
-
def undirected_connected_components(graph: UndirectedGraph) ->
|
|
89
|
+
def undirected_connected_components(graph: UndirectedGraph) -> list[list[int]]:
|
|
90
90
|
"""Group together all the connected components of an undirected graph.
|
|
91
91
|
Return each group as a list of vertices.
|
|
92
92
|
"""
|
|
@@ -124,7 +124,7 @@ def undirected_connected_components(graph: UndirectedGraph) -> List[List[int]]:
|
|
|
124
124
|
return output
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
def topological_sort(graph: AdjacencyListGraph, visitation_order:
|
|
127
|
+
def topological_sort(graph: AdjacencyListGraph, visitation_order: list[int] | None = None) -> list[int]:
|
|
128
128
|
"""The topological_sort function accepts a graph as input, with edges from
|
|
129
129
|
parents to children. It returns an ordering where parents are guaranteed to
|
|
130
130
|
come before their children.
|
braintrust/id_gen.py
CHANGED
|
@@ -45,8 +45,8 @@ class UUIDGenerator(IDGenerator):
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
class OTELIDGenerator(IDGenerator):
|
|
48
|
-
"""
|
|
49
|
-
|
|
48
|
+
"""ID generator that generates OpenTelemetry-compatible IDs. We use this to have ids that can
|
|
49
|
+
seamlessly flow between Braintrust and OpenTelemetry.
|
|
50
50
|
"""
|
|
51
51
|
|
|
52
52
|
def get_span_id(self):
|