Skip to content
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

[Fix] UI Usage tab for internal users #5895

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions litellm/proxy/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ class LiteLLMRoutes(enum.Enum):
"/global/predict/spend/logs",
"/global/spend/report",
"/global/spend/provider",
"/global/spend/tags",
"/global/activity",
"/global/activity/model",
]

public_routes = [
Expand All @@ -351,16 +354,10 @@ class LiteLLMRoutes(enum.Enum):
"/key/update",
"/key/delete",
"/key/info",
"/global/spend/tags",
"/global/spend/keys",
"/global/spend/models",
"/global/spend/provider",
"/global/spend/end_users",
"/global/activity",
"/global/activity/model",
]
+ spend_tracking_routes
+ sso_only_routes
+ global_spend_tracking_routes
)

internal_user_view_only_routes = (
Expand Down
7 changes: 6 additions & 1 deletion litellm/proxy/example_config_yaml/simple_config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
model_list:
- model_name: gpt-3.5-turbo
litellm_params:
model: gpt-3.5-turbo
model: gpt-3.5-turbo
- model_name: fake-gpt-3.5-turbo
litellm_params:
model: openai/gpt-3.5-turbo
api_key: fake-key
api_base: https://exampleopenaiendpoint-production.up.railway.app/
27 changes: 14 additions & 13 deletions litellm/proxy/proxy_config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
model_list:
- model_name: gpt-3.5-turbo
- model_name: fake-gpt-3.5-turbo
litellm_params:
model: openai/gpt-3.5-turbo
api_key: os.environ/OPENAI_API_KEY
api_key: fake-key
api_base: https://exampleopenaiendpoint-production.up.railway.app/
tags: ["teamB"]
model_info:
supported_environments: ["development", "production", "staging"]
- model_name: gpt-4
id: "team-b-model"
- model_name: rerank-english-v3.0
litellm_params:
model: openai/gpt-4
api_key: os.environ/OPENAI_API_KEY
model_info:
supported_environments: ["production", "staging"]
- model_name: gpt-4o
model: cohere/rerank-english-v3.0
api_key: os.environ/COHERE_API_KEY
- model_name: llava-hf
litellm_params:
model: openai/gpt-4o
api_key: os.environ/OPENAI_API_KEY
model: openai/llava-hf/llava-v1.6-vicuna-7b-hf
api_base: http://localhost:8000
api_key: fake-key
model_info:
supported_environments: ["production"]
supports_vision: True


litellm_settings:
cache: true
callbacks: ["otel"]
# callbacks: ["otel"]


general_settings:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*

Login to Admin UI
Basic UI Test

Click on all the tabs ensure nothing is broken
*/

import { test, expect } from '@playwright/test';

test('internal user', async ({ page }) => {
// Go to the specified URL
await page.goto('http://localhost:4000/ui');

// Enter "internal user id" in the username input field
await page.fill('input[name="username"]', 'sw12@berri.ai');

// Enter "gm" in the password input field
await page.fill('input[name="password"]', 'gm');

// Optionally, you can add an assertion to verify the login button is enabled
const loginButton = page.locator('input[type="submit"]');
await expect(loginButton).toBeEnabled();

// Optionally, you can click the login button to submit the form
await loginButton.click();


// Create a new key for the user
// click on span '+ Create New Key'

await page.locator('span:has-text("+ Create New Key")').click();


// set a random string for input where id="key_alias"
const key_alias = Math.random().toString(36).slice(-8);
await page.locator('input#key_alias').fill('key_alias' + key_alias);

// select model = "fake-gpt-3.5-turbo" for the
// Select the model "fake-gpt-3.5-turbo"
await page.click('#models'); // Open the select dropdown
await page.click('div[title="fake-gpt-3.5-turbo"]'); // Select the specific option

// click this button <button type="submit" class="ant-btn css-1qhpsh8 ant-btn-default"><span>Create Key</span></button>
await page.click('button[type="submit"]');

// store the content under here as "key" - <pre style="overflow-wrap: break-word; white-space: normal;">sk-9vEIOyLVd2Hmjrif9DQHJA</pre>
const key = await page.textContent('pre');

console.log(key);










});
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*

Login to Admin UI
Basic UI Test

Click on all the tabs ensure nothing is broken
*/

import { test, expect } from '@playwright/test';

test('internal user', async ({ page }) => {
// Go to the specified URL
await page.goto('http://localhost:4000/ui');

// Enter "internal user id" in the username input field
await page.fill('input[name="username"]', 'sw12@berri.ai');

// Enter "gm" in the password input field
await page.fill('input[name="password"]', 'gm');

// Optionally, you can add an assertion to verify the login button is enabled
const loginButton = page.locator('input[type="submit"]');
await expect(loginButton).toBeEnabled();

// Optionally, you can click the login button to submit the form
await loginButton.click();

// Navigate to the 'Usage' tab
const usageTab = page.locator('p.text-tremor-default.text-tremor-content.dark\\:text-dark-tremor-content', { hasText: 'Usage' });
await usageTab.click();

// wait 3 seconds
await page.waitForTimeout(1000);











});