Skip to content
Merged
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion py/src/braintrust/integrations/mistral/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

from braintrust.integrations.base import BaseIntegration

from .patchers import AgentsPatcher, ChatPatcher, EmbeddingsPatcher, FimPatcher, OcrPatcher
from .patchers import (
AgentsPatcher,
ChatPatcher,
EmbeddingsPatcher,
FimPatcher,
OcrPatcher,
SpeechPatcher,
TranscriptionsPatcher,
)


class MistralIntegration(BaseIntegration):
Expand All @@ -17,4 +25,6 @@ class MistralIntegration(BaseIntegration):
FimPatcher,
AgentsPatcher,
OcrPatcher,
TranscriptionsPatcher,
SpeechPatcher,
)
102 changes: 102 additions & 0 deletions py/src/braintrust/integrations/mistral/patchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
_fim_stream_wrapper,
_ocr_process_async_wrapper,
_ocr_process_wrapper,
_speech_complete_async_wrapper,
_speech_complete_wrapper,
_transcriptions_complete_async_wrapper,
_transcriptions_complete_wrapper,
_transcriptions_stream_async_wrapper,
_transcriptions_stream_wrapper,
)


Expand Down Expand Up @@ -136,6 +142,102 @@ class EmbeddingsPatcher(CompositeFunctionWrapperPatcher):
)


class _TranscriptionsCompleteV2Patcher(FunctionWrapperPatcher):
name = "mistral.audio.transcriptions.complete.v2"
target_module = "mistralai.client.transcriptions"
target_path = "Transcriptions.complete"
wrapper = _transcriptions_complete_wrapper


class _TranscriptionsCompleteV1Patcher(FunctionWrapperPatcher):
name = "mistral.audio.transcriptions.complete.v1"
target_module = "mistralai.transcriptions"
target_path = "Transcriptions.complete"
wrapper = _transcriptions_complete_wrapper
superseded_by = (_TranscriptionsCompleteV2Patcher,)


class _TranscriptionsCompleteAsyncV2Patcher(FunctionWrapperPatcher):
name = "mistral.audio.transcriptions.complete_async.v2"
target_module = "mistralai.client.transcriptions"
target_path = "Transcriptions.complete_async"
wrapper = _transcriptions_complete_async_wrapper


class _TranscriptionsCompleteAsyncV1Patcher(FunctionWrapperPatcher):
name = "mistral.audio.transcriptions.complete_async.v1"
target_module = "mistralai.transcriptions"
target_path = "Transcriptions.complete_async"
wrapper = _transcriptions_complete_async_wrapper
superseded_by = (_TranscriptionsCompleteAsyncV2Patcher,)


class _TranscriptionsStreamV2Patcher(FunctionWrapperPatcher):
name = "mistral.audio.transcriptions.stream.v2"
target_module = "mistralai.client.transcriptions"
target_path = "Transcriptions.stream"
wrapper = _transcriptions_stream_wrapper


class _TranscriptionsStreamV1Patcher(FunctionWrapperPatcher):
name = "mistral.audio.transcriptions.stream.v1"
target_module = "mistralai.transcriptions"
target_path = "Transcriptions.stream"
wrapper = _transcriptions_stream_wrapper
superseded_by = (_TranscriptionsStreamV2Patcher,)


class _TranscriptionsStreamAsyncV2Patcher(FunctionWrapperPatcher):
name = "mistral.audio.transcriptions.stream_async.v2"
target_module = "mistralai.client.transcriptions"
target_path = "Transcriptions.stream_async"
wrapper = _transcriptions_stream_async_wrapper


class _TranscriptionsStreamAsyncV1Patcher(FunctionWrapperPatcher):
name = "mistral.audio.transcriptions.stream_async.v1"
target_module = "mistralai.transcriptions"
target_path = "Transcriptions.stream_async"
wrapper = _transcriptions_stream_async_wrapper
superseded_by = (_TranscriptionsStreamAsyncV2Patcher,)


class TranscriptionsPatcher(CompositeFunctionWrapperPatcher):
name = "mistral.audio.transcriptions"
sub_patchers = (
_TranscriptionsCompleteV2Patcher,
_TranscriptionsCompleteV1Patcher,
_TranscriptionsCompleteAsyncV2Patcher,
_TranscriptionsCompleteAsyncV1Patcher,
_TranscriptionsStreamV2Patcher,
_TranscriptionsStreamV1Patcher,
_TranscriptionsStreamAsyncV2Patcher,
_TranscriptionsStreamAsyncV1Patcher,
)


class _SpeechCompleteV2Patcher(FunctionWrapperPatcher):
name = "mistral.audio.speech.complete.v2"
target_module = "mistralai.client.speech"
target_path = "Speech.complete"
wrapper = _speech_complete_wrapper


class _SpeechCompleteAsyncV2Patcher(FunctionWrapperPatcher):
name = "mistral.audio.speech.complete_async.v2"
target_module = "mistralai.client.speech"
target_path = "Speech.complete_async"
wrapper = _speech_complete_async_wrapper


class SpeechPatcher(CompositeFunctionWrapperPatcher):
name = "mistral.audio.speech"
sub_patchers = (
_SpeechCompleteV2Patcher,
_SpeechCompleteAsyncV2Patcher,
)


class _FimCompleteV2Patcher(FunctionWrapperPatcher):
name = "mistral.fim.complete.v2"
target_module = "mistralai.client.fim"
Expand Down
Loading
Loading