Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions py/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,16 @@ def test_agno(session, version):


LIVEKIT_AGENTS_VERSIONS = _get_matrix_versions("livekit-agents")
ELEVENLABS_VERSIONS = _get_matrix_versions("elevenlabs")


@nox.session()
@nox.parametrize("version", ELEVENLABS_VERSIONS, ids=ELEVENLABS_VERSIONS)
def test_elevenlabs(session, version):
_install_test_deps(session)
_install_matrix_dep(session, "elevenlabs", version)
_install_group_locked(session, "test-elevenlabs")
_run_tests(session, f"{INTEGRATION_DIR}/elevenlabs/test_elevenlabs.py", version=version)


@nox.session()
Expand Down
9 changes: 9 additions & 0 deletions py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ test-livekit-agents = [
"opentelemetry-sdk<1.39",
]

test-elevenlabs = [
{include-group = "test"},
]

test-crewai = [
{include-group = "test"},
# CrewAI's no-network smoke test forces the LiteLLM fallback path via
Expand Down Expand Up @@ -326,6 +330,9 @@ latest = "litellm==1.85.0"
latest = "livekit-agents==1.5.10"
"1.3.1" = "livekit-agents==1.3.1"

[tool.braintrust.matrix.elevenlabs]
latest = "elevenlabs==2.48.0"

[tool.braintrust.matrix.claude-agent-sdk]
latest = "claude-agent-sdk==0.2.82"
"0.1.10" = "claude-agent-sdk==0.1.10"
Expand Down Expand Up @@ -441,6 +448,7 @@ cohere = ["cohere"]
claude_agent_sdk = ["claude-agent-sdk"]
crewai = ["crewai"]
dspy = ["dspy"]
elevenlabs = ["elevenlabs"]
google_genai = ["google-genai"]
langchain = ["langchain-core"]
litellm = ["litellm"]
Expand All @@ -464,6 +472,7 @@ autoevals = "autoevals"
braintrust-core = "braintrust_core"
crewai = "crewai"
dspy = "dspy"
elevenlabs = "elevenlabs"
google-adk = "google.adk"
google-genai = "google.genai"
litellm = "litellm"
Expand Down
5 changes: 5 additions & 0 deletions py/src/braintrust/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
CohereIntegration,
CrewAIIntegration,
DSPyIntegration,
ElevenLabsIntegration,
GoogleGenAIIntegration,
LangChainIntegration,
LiteLLMIntegration,
Expand Down Expand Up @@ -72,6 +73,7 @@ def auto_instrument(
strands: bool = True,
temporal: bool = True,
livekit_agents: bool = True,
elevenlabs: bool = True,
) -> dict[str, bool]:
"""
Auto-instrument supported AI/ML libraries for Braintrust tracing.
Expand Down Expand Up @@ -104,6 +106,7 @@ def auto_instrument(
strands: Enable Strands Agents instrumentation (default: True)
temporal: Enable Temporal instrumentation (default: True)
livekit_agents: Enable LiveKit Agents instrumentation (default: True)
elevenlabs: Enable ElevenLabs instrumentation (default: True)

Returns:
Dict mapping integration name to whether it was successfully instrumented.
Expand Down Expand Up @@ -193,6 +196,8 @@ def auto_instrument(
results["temporal"] = _instrument_integration(TemporalIntegration)
if livekit_agents:
results["livekit_agents"] = _instrument_integration(LiveKitAgentsIntegration)
if elevenlabs:
results["elevenlabs"] = _instrument_integration(ElevenLabsIntegration)

return results

Expand Down
1 change: 1 addition & 0 deletions py/src/braintrust/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def get_vcr_config():
"Authorization",
"openai-organization",
"x-api-key",
"xi-api-key",
"api-key",
"openai-api-key",
"x-goog-api-key",
Expand Down
2 changes: 2 additions & 0 deletions py/src/braintrust/integrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .cohere import CohereIntegration
from .crewai import CrewAIIntegration
from .dspy import DSPyIntegration
from .elevenlabs import ElevenLabsIntegration
from .google_genai import GoogleGenAIIntegration
from .langchain import LangChainIntegration
from .litellm import LiteLLMIntegration
Expand All @@ -31,6 +32,7 @@
"CohereIntegration",
"CrewAIIntegration",
"DSPyIntegration",
"ElevenLabsIntegration",
"GoogleGenAIIntegration",
"LiteLLMIntegration",
"LiveKitAgentsIntegration",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""Test auto_instrument for ElevenLabs."""

# pylint: disable=import-error

import inspect

from braintrust.auto import auto_instrument
from wrapt import FunctionWrapper


def _is_braintrust_wrapped(target, attr: str) -> bool:
return isinstance(inspect.getattr_static(target, attr, None), FunctionWrapper)


from elevenlabs.speech_to_speech.client import AsyncSpeechToSpeechClient, SpeechToSpeechClient # noqa: E402
from elevenlabs.speech_to_text.client import AsyncSpeechToTextClient, SpeechToTextClient # noqa: E402
from elevenlabs.text_to_sound_effects.client import ( # noqa: E402
AsyncTextToSoundEffectsClient,
TextToSoundEffectsClient,
)
from elevenlabs.text_to_speech.client import AsyncTextToSpeechClient, TextToSpeechClient # noqa: E402


assert not _is_braintrust_wrapped(TextToSpeechClient, "convert")
assert not _is_braintrust_wrapped(TextToSpeechClient, "stream")
assert not _is_braintrust_wrapped(AsyncTextToSpeechClient, "convert")
assert not _is_braintrust_wrapped(AsyncTextToSpeechClient, "stream")
assert not _is_braintrust_wrapped(SpeechToTextClient, "convert")
assert not _is_braintrust_wrapped(SpeechToSpeechClient, "convert")
assert not _is_braintrust_wrapped(TextToSoundEffectsClient, "convert")
assert not _is_braintrust_wrapped(AsyncSpeechToTextClient, "convert")
assert not _is_braintrust_wrapped(AsyncSpeechToSpeechClient, "convert")
assert not _is_braintrust_wrapped(AsyncTextToSoundEffectsClient, "convert")

results = auto_instrument()
assert results.get("elevenlabs") is True
assert _is_braintrust_wrapped(TextToSpeechClient, "convert")
assert _is_braintrust_wrapped(TextToSpeechClient, "stream")
assert _is_braintrust_wrapped(AsyncTextToSpeechClient, "convert")
assert _is_braintrust_wrapped(AsyncTextToSpeechClient, "stream")
assert _is_braintrust_wrapped(SpeechToTextClient, "convert")
assert _is_braintrust_wrapped(SpeechToSpeechClient, "convert")
assert _is_braintrust_wrapped(TextToSoundEffectsClient, "convert")
assert _is_braintrust_wrapped(AsyncSpeechToTextClient, "convert")
assert _is_braintrust_wrapped(AsyncSpeechToSpeechClient, "convert")
assert _is_braintrust_wrapped(AsyncTextToSoundEffectsClient, "convert")

results2 = auto_instrument()
assert results2.get("elevenlabs") is True

print("SUCCESS")
12 changes: 12 additions & 0 deletions py/src/braintrust/integrations/elevenlabs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Braintrust integration for ElevenLabs."""

from .integration import ElevenLabsIntegration
from .patchers import wrap_elevenlabs


def setup_elevenlabs() -> bool:
"""Instrument the ElevenLabs Python SDK."""
return ElevenLabsIntegration.setup()


__all__ = ["ElevenLabsIntegration", "setup_elevenlabs", "wrap_elevenlabs"]
Loading
Loading