fix(proxy_server.py): check if input list > 0 before indexing into it

resolves 'list index out of range' error
This commit is contained in:
Krrish Dholakia 2024-07-25 14:23:07 -07:00
parent 397451570e
commit bfdda089c8
2 changed files with 4 additions and 3 deletions

View file

@ -1,4 +1,4 @@
model_list: model_list:
- model_name: "test-model" - model_name: "test-model"
litellm_params: litellm_params:
model: "openai/gpt-3.5-turbo-instruct-0914" model: "openai/text-embedding-ada-002"

View file

@ -3334,6 +3334,7 @@ async def embeddings(
if ( if (
"input" in data "input" in data
and isinstance(data["input"], list) and isinstance(data["input"], list)
and len(data["input"]) > 0
and isinstance(data["input"][0], list) and isinstance(data["input"][0], list)
and isinstance(data["input"][0][0], int) and isinstance(data["input"][0][0], int)
): # check if array of tokens passed in ): # check if array of tokens passed in
@ -3464,8 +3465,8 @@ async def embeddings(
litellm_debug_info, litellm_debug_info,
) )
verbose_proxy_logger.error( verbose_proxy_logger.error(
"litellm.proxy.proxy_server.embeddings(): Exception occured - {}".format( "litellm.proxy.proxy_server.embeddings(): Exception occured - {}\n{}".format(
str(e) str(e), traceback.format_exc()
) )
) )
verbose_proxy_logger.debug(traceback.format_exc()) verbose_proxy_logger.debug(traceback.format_exc())