From 01077b20b9cdb2d3818d2ba396eb5b85fe2d1f2b Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Fri, 16 Feb 2024 11:49:59 -0800 Subject: [PATCH] fix(proxy_server.py): restrict model access for /v1/completions endpoint --- litellm/model_prices_and_context_window_backup.json | 8 ++++---- litellm/proxy/proxy_server.py | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index fa50b06f1..8778aa360 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -965,15 +965,15 @@ }, "dolphin": { "max_tokens": 4096, - "input_cost_per_token": 0.00002, - "output_cost_per_token": 0.00002, + "input_cost_per_token": 0.0000005, + "output_cost_per_token": 0.0000005, "litellm_provider": "nlp_cloud", "mode": "completion" }, "chatdolphin": { "max_tokens": 4096, - "input_cost_per_token": 0.00002, - "output_cost_per_token": 0.00002, + "input_cost_per_token": 0.0000005, + "output_cost_per_token": 0.0000005, "litellm_provider": "nlp_cloud", "mode": "chat" }, diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 545540422..c56339638 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -2259,8 +2259,13 @@ async def completion( response = await llm_router.atext_completion( **data, specific_deployment=True ) - else: # router is not set + elif user_model is not None: # `litellm --model ` response = await litellm.atext_completion(**data) + else: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail={"error": "Invalid model name passed in"}, + ) if hasattr(response, "_hidden_params"): model_id = response._hidden_params.get("model_id", None) or ""