Strip mistral-specific fields in SpeechRequest.to_openai - #290
Open
jaideeppyne wants to merge 1 commit into
Open
Strip mistral-specific fields in SpeechRequest.to_openai#290jaideeppyne wants to merge 1 commit into
SpeechRequest.to_openai#290jaideeppyne wants to merge 1 commit into
Conversation
SpeechRequest.to_openai dumped the whole model and returned it as the
OpenAI-compatible request, leaking mistral-internal fields (id, max_tokens)
into the payload. Its sibling TranscriptionRequest.to_openai already removes
these (default_exclude = ('id', 'max_tokens', 'strict_audio_validation',
'streaming')), so the two conversions were inconsistent and a SpeechRequest's
internal id/max_tokens ended up in the OpenAI request.
Apply the same exclusion in SpeechRequest.to_openai and add an 'exclude'
parameter for parity with TranscriptionRequest.to_openai.
Adds a regression test asserting id/max_tokens are stripped, the OpenAI fields
are preserved, and the 'exclude' argument is honored.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
SpeechRequest.to_openai()leaks mistral-internal fields (id,max_tokens) into the OpenAI-compatible request payload, while its siblingTranscriptionRequest.to_openai()deliberately strips them.Why
SpeechRequest.to_openaidoesself.model_dump(...)and returns it directly, so every internal field ends up in the OpenAI request.TranscriptionRequest.to_openaialready handles exactly this:So the two
to_openaiconversions are inconsistent, and aSpeechRequest's internalid/max_tokensare sent to the OpenAI endpoint.How
Apply the same exclusion in
SpeechRequest.to_openai, and add anexcludeparameter for parity withTranscriptionRequest.to_openai:(I kept the exclusion list identical to
TranscriptionRequestso the two stay in sync;strict_audio_validation/streamingsimply aren't present onSpeechRequestandpop(..., None)is a no-op for them.)Tests
Added
test_speech_to_openai_excludes_mistral_specific_fields: assertsid/max_tokensare stripped, the OpenAI fields (model/input/voice) are preserved, and theexcludeargument is honored. It fails onmain(idis present) and passes with this change; the speechto_openaitests stay green (10 passed).ruff checkis clean.Disclosure: this change was prepared with AI assistance and reviewed/verified by me before submission.