-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
(fix) don't block proxy startup if license check fails & using prometheus #6839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6d00074
fix - don't block proxy startup if not a premium user
ishaan-jaff e124753
test_litellm_proxy_server_config_with_prometheus
ishaan-jaff 048c137
add test for proxy startup
ishaan-jaff 9e040e1
fix remove unused test
ishaan-jaff 8334cdc
fix startup test
ishaan-jaff 8df5dc0
add comment on bad-license
ishaan-jaff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| model_list: | ||
| - model_name: gpt-4 | ||
| litellm_params: | ||
| model: openai/fake | ||
| api_key: fake-key | ||
| api_base: https://exampleopenaiendpoint-production.up.railway.app/ | ||
| tags: ["teamA"] | ||
| model_info: | ||
| id: "team-a-model" | ||
|
|
||
| litellm_settings: | ||
| cache: true | ||
| callbacks: ["prometheus"] | ||
|
|
||
| router_settings: | ||
| enable_tag_filtering: True # 👈 Key Change | ||
|
|
51 changes: 51 additions & 0 deletions
51
tests/basic_proxy_startup_tests/test_basic_proxy_startup.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| """ | ||
| This test ensures that the proxy starts and serves requests even with a bad license. | ||
|
|
||
|
|
||
| in ci/cd config.yml, we set the license to "bad-license" | ||
| """ | ||
|
|
||
| import pytest | ||
| import aiohttp | ||
| from typing import Optional | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_health_and_chat_completion(): | ||
| """ | ||
| Test health endpoints and chat completion: | ||
| 1. Check /health/readiness | ||
| 2. Check /health/liveness | ||
| 3. Make a chat completion call | ||
| """ | ||
| async with aiohttp.ClientSession() as session: | ||
| # Test readiness endpoint | ||
| async with session.get("http://0.0.0.0:4000/health/readiness") as response: | ||
| assert response.status == 200 | ||
| readiness_response = await response.json() | ||
| assert readiness_response["status"] == "connected" | ||
|
|
||
| # Test liveness endpoint | ||
| async with session.get("http://0.0.0.0:4000/health/liveness") as response: | ||
| assert response.status == 200 | ||
| liveness_response = await response.json() | ||
| print("liveness_response", liveness_response) | ||
|
|
||
| # Make a chat completion call | ||
| url = "http://0.0.0.0:4000/chat/completions" | ||
| headers = { | ||
| "Authorization": "Bearer sk-1234", | ||
| "Content-Type": "application/json", | ||
| } | ||
| data = { | ||
| "model": "gpt-4", | ||
| "messages": [ | ||
| {"role": "system", "content": "You are a helpful assistant."}, | ||
| {"role": "user", "content": "Hello!"}, | ||
| ], | ||
| } | ||
|
|
||
| async with session.post(url, headers=headers, json=data) as response: | ||
| assert response.status == 200 | ||
| completion_response = await response.json() | ||
| assert "choices" in completion_response |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revise user-facing warning message for clarity.
Tell me more
Logging issue identified: The warning message
Prometheus metrics are only available for premium users. {CommonProxyErrors.not_premium_user.value}might be confusing for end-users as it includes system-centric error codes. It would be more helpful to tailor this message towards the user's perspective, indicating that they cannot access Prometheus metrics due to their non-premium status. Please consider revising this log message for better clarity and user experience.