From b5a2090720fd68efab283e68b6792d7f9f19de73 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 15 Jul 2024 19:40:05 -0700 Subject: [PATCH] use helper to check check_file_size_under_limit --- litellm/proxy/proxy_server.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 03d35a1ce..7afa00f58 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -143,7 +143,10 @@ from litellm.proxy.common_utils.encrypt_decrypt_utils import ( decrypt_value_helper, encrypt_value_helper, ) -from litellm.proxy.common_utils.http_parsing_utils import _read_request_body +from litellm.proxy.common_utils.http_parsing_utils import ( + _read_request_body, + check_file_size_under_limit, +) from litellm.proxy.common_utils.init_callbacks import initialize_callbacks_on_proxy from litellm.proxy.common_utils.openai_endpoint_utils import ( remove_sensitive_info_from_deployment, @@ -3796,7 +3799,13 @@ async def audio_transcriptions( param="file", ) - # Instead of writing to a file + # Check if File can be read in memory before reading + check_file_size_under_limit( + request_data=data, + file=file, + router_model_names=router_model_names, + ) + file_content = await file.read() file_object = io.BytesIO(file_content) file_object.name = file.filename