mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-23 01:35:23 +00:00
fix/refac: stt default content type
This commit is contained in:
parent
7f0ca8c4b7
commit
4ab917c74b
3 changed files with 6 additions and 3 deletions
|
|
@ -1151,10 +1151,9 @@ def transcription(
|
|||
user=Depends(get_verified_user),
|
||||
):
|
||||
log.info(f"file.content_type: {file.content_type}")
|
||||
|
||||
stt_supported_content_types = getattr(
|
||||
request.app.state.config, "STT_SUPPORTED_CONTENT_TYPES", []
|
||||
) or ["audio/*", "video/webm"]
|
||||
)
|
||||
|
||||
if not strict_match_mime_type(stt_supported_content_types, file.content_type):
|
||||
raise HTTPException(
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ def process_uploaded_file(request, file, file_path, file_item, file_metadata, us
|
|||
if file.content_type:
|
||||
stt_supported_content_types = getattr(
|
||||
request.app.state.config, "STT_SUPPORTED_CONTENT_TYPES", []
|
||||
) or ["audio/*", "video/webm"]
|
||||
)
|
||||
|
||||
if strict_match_mime_type(stt_supported_content_types, file.content_type):
|
||||
file_path = Storage.get_file(file_path)
|
||||
|
|
|
|||
|
|
@ -622,6 +622,10 @@ def strict_match_mime_type(supported: list[str] | str, header: str) -> Optional[
|
|||
|
||||
supported = [s for s in supported if s.strip() and "/" in s]
|
||||
|
||||
if len(supported) == 0:
|
||||
# Default to common types if none are specified
|
||||
supported = ["audio/*", "video/webm"]
|
||||
|
||||
match = mimeparse.best_match(supported, header)
|
||||
if not match:
|
||||
return None
|
||||
|
|
|
|||
Loading…
Reference in a new issue