mirror of
https://github.com/BerriAI/litellm.git
synced 2025-12-06 11:33:26 +08:00
[Bug fix] WatsonX audio transcriptions, don't force content type in request headers (#17546)
* fix watsonx content type * watsonx content type
This commit is contained in:
@@ -8,7 +8,10 @@ from typing import Any, Dict, List, Optional
|
||||
|
||||
import litellm
|
||||
from litellm.litellm_core_utils.audio_utils.utils import process_audio_file
|
||||
from litellm.types.llms.openai import OpenAIAudioTranscriptionOptionalParams
|
||||
from litellm.types.llms.openai import (
|
||||
AllMessageValues,
|
||||
OpenAIAudioTranscriptionOptionalParams,
|
||||
)
|
||||
from litellm.types.llms.watsonx import WatsonXAudioTranscriptionRequestBody
|
||||
from litellm.types.utils import FileTypes
|
||||
|
||||
@@ -32,6 +35,35 @@ class IBMWatsonXAudioTranscriptionConfig(
|
||||
for authentication and URL construction.
|
||||
"""
|
||||
|
||||
def validate_environment(
|
||||
self,
|
||||
headers: Dict,
|
||||
model: str,
|
||||
messages: List[AllMessageValues],
|
||||
optional_params: Dict,
|
||||
litellm_params: dict,
|
||||
api_key: Optional[str] = None,
|
||||
api_base: Optional[str] = None,
|
||||
) -> Dict:
|
||||
"""
|
||||
Validate environment for audio transcription.
|
||||
|
||||
Removes Content-Type header so httpx can set multipart/form-data automatically.
|
||||
"""
|
||||
result = IBMWatsonXMixin.validate_environment(
|
||||
self,
|
||||
headers=headers,
|
||||
model=model,
|
||||
messages=messages,
|
||||
optional_params=optional_params,
|
||||
litellm_params=litellm_params,
|
||||
api_key=api_key,
|
||||
api_base=api_base,
|
||||
)
|
||||
# Remove Content-Type so httpx sets multipart/form-data automatically
|
||||
result.pop("Content-Type", None)
|
||||
return result
|
||||
|
||||
def get_supported_openai_params(
|
||||
self, model: str
|
||||
) -> List[OpenAIAudioTranscriptionOptionalParams]:
|
||||
|
||||
@@ -63,6 +63,9 @@ class TestWatsonXAudioTranscription:
|
||||
assert "Authorization" in captured_request["headers"]
|
||||
assert "Bearer test-bearer-token" in captured_request["headers"]["Authorization"]
|
||||
|
||||
# Validate Content-Type is NOT set (httpx sets multipart/form-data automatically)
|
||||
assert "Content-Type" not in captured_request["headers"]
|
||||
|
||||
# Validate project_id is in form data, not URL
|
||||
assert captured_request["data"].get("project_id") == "test-project-123"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user