From e02328c9f10be6589c3da8ed85756a25fcf3a313 Mon Sep 17 00:00:00 2001 From: sujan100000 Date: Sun, 26 May 2024 19:09:07 +0930 Subject: [PATCH 01/25] Improve validate-fallbacks method * No need to check for fallback_params length * Instead of asserting, used if condition and raised valueError * Improved Error message --- litellm/router.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/litellm/router.py b/litellm/router.py index 529ba0f75..4e7854a76 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -348,17 +348,13 @@ class Router: def validate_fallbacks(self, fallback_param: Optional[List]): if fallback_param is None: return - if len(fallback_param) > 0: # if set - ## for dictionary in list, check if only 1 key in dict - for _dict in fallback_param: - assert isinstance(_dict, dict), "Item={}, not a dictionary".format( - _dict - ) - assert ( - len(_dict.keys()) == 1 - ), "Only 1 key allows in dictionary. You set={} for dict={}".format( - len(_dict.keys()), _dict - ) + + for fallback_dict in fallback_param: + if not isinstance(fallback_dict, dict): + raise ValueError(f"Item '{fallback_dict}' is not a dictionary.") + if len(fallback_dict) != 1: + raise ValueError( + f"Dictionary '{fallback_dict}' must have exactly one key, but has {len(fallback_dict)} keys.") def routing_strategy_init(self, routing_strategy: str, routing_strategy_args: dict): if routing_strategy == "least-busy": From fa064c91fb2afd667b2470c388759d5dccf97f41 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sun, 26 May 2024 17:44:52 -0700 Subject: [PATCH 02/25] fix(model_hub.tsx): fix string --- .../src/components/model_hub.tsx | 280 +++++++----------- 1 file changed, 107 insertions(+), 173 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_hub.tsx b/ui/litellm-dashboard/src/components/model_hub.tsx index 63431d13b..6ce413c70 100644 --- a/ui/litellm-dashboard/src/components/model_hub.tsx +++ b/ui/litellm-dashboard/src/components/model_hub.tsx @@ -1,20 +1,26 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState } from "react"; import { modelHubCall } from "./networking"; -import { Card, Text, Title, Grid, Button, Badge, Tab, - TabGroup, - TabList, - TabPanel, - TabPanels, } from "@tremor/react"; +import { + Card, + Text, + Title, + Grid, + Button, + Badge, + Tab, + TabGroup, + TabList, + TabPanel, + TabPanels, +} from "@tremor/react"; -import { RightOutlined, CopyOutlined } from '@ant-design/icons'; +import { RightOutlined, CopyOutlined } from "@ant-design/icons"; -import { Modal, Tooltip } from 'antd'; +import { Modal, Tooltip } from "antd"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; - - interface ModelHubProps { userID: string | null; userRole: string | null; @@ -22,25 +28,20 @@ interface ModelHubProps { accessToken: string | null; keys: any; // Replace with the appropriate type for 'keys' prop premiumUser: boolean; - } interface ModelInfo { - model_group: string; - mode: string; - supports_function_calling: boolean; - supports_vision: boolean; - max_input_tokens?: number; - max_output_tokens?: number; - - // Add other properties if needed - - } - + model_group: string; + mode: string; + supports_function_calling: boolean; + supports_vision: boolean; + max_input_tokens?: number; + max_output_tokens?: number; + // Add other properties if needed +} const ModelHub: React.FC = ({ - userID, userRole, @@ -52,200 +53,141 @@ const ModelHub: React.FC = ({ keys, premiumUser, - }) => { - - const [modelHubData, setModelHubData] = useState(null); + const [modelHubData, setModelHubData] = useState(null); const [isModalVisible, setIsModalVisible] = useState(false); - const [selectedModel, setSelectedModel] = useState(null); - + const [selectedModel, setSelectedModel] = useState(null); useEffect(() => { - if (!accessToken || !token || !userRole || !userID) { return; } - - const fetchData = async () => { - try { - const _modelHubData = await modelHubCall(accessToken, userID, userRole); console.log("ModelHubData:", _modelHubData); setModelHubData(_modelHubData.data); - } catch (error) { - console.error("There was an error fetching the model data", error); - } - }; - - fetchData(); - }, [accessToken, token, userRole, userID]); - - const showModal = (model: ModelInfo) => { - setSelectedModel(model); setIsModalVisible(true); - }; - - const handleOk = () => { - setIsModalVisible(false); setSelectedModel(null); - }; - - const handleCancel = () => { - setIsModalVisible(false); setSelectedModel(null); - }; - - const copyToClipboard = (text: string) => { - navigator.clipboard.writeText(text); - }; - - return ( -
+
+
-
- -
- - - -
- - -
- - Model Hub - - +
+ Model Hub +
- - +
+ {modelHubData && + modelHubData.map((model: ModelInfo) => ( + +
+                  {model.model_group}
+                  
+                     copyToClipboard(model.model_group)}
+                      style={{ cursor: "pointer", marginRight: "10px" }}
+                    />
+                  
+                
- - {modelHubData && modelHubData.map((model: ModelInfo) => ( - - - - - -
-                
-
-                {model.model_group}
-                
-
-                     copyToClipboard(model.model_group)} style={{ cursor: 'pointer', marginRight: '10px' }} />
-
-                    
-
-              
- -
- - Mode: {model.mode} - Supports Function Calling: {model?.supports_function_calling == true ? "Yes" : "No"} - Supports Vision: {model?.supports_vision == true ? "Yes" : "No"} - Max Input Tokens: {model?.max_input_tokens ? model?.max_input_tokens : "N/A"} - Max Output Tokens: {model?.max_output_tokens ? model?.max_output_tokens : "N/A"} - -
- - - -
- - ))} +
+ Mode: {model.mode} + + Supports Function Calling:{" "} + {model?.supports_function_calling == true ? "Yes" : "No"} + + + Supports Vision:{" "} + {model?.supports_vision == true ? "Yes" : "No"} + + + Max Input Tokens:{" "} + {model?.max_input_tokens ? model?.max_input_tokens : "N/A"} + + + Max Output Tokens:{" "} + {model?.max_output_tokens + ? model?.max_output_tokens + : "N/A"} + +
+ +
+ ))}
-
- {selectedModel && ( -
+

+ Model Name: {selectedModel.model_group} +

-

Model Name: {selectedModel.model_group}

- - - OpenAI Python SDK - LlamaIndex - Langchain Py - - - - - {` + + OpenAI Python SDK + LlamaIndex + Langchain Py + + + + + {` import openai client = openai.OpenAI( api_key="your_api_key", @@ -264,11 +206,11 @@ response = client.chat.completions.create( print(response) `} - - - - - {` + + + + + {` import os, dotenv from llama_index.llms import AzureOpenAI @@ -300,11 +242,11 @@ response = query_engine.query("What did the author do growing up?") print(response) `} - - - - - {` + + + + + {` from langchain.chat_models import ChatOpenAI from langchain.prompts.chat import ( ChatPromptTemplate, @@ -332,27 +274,19 @@ response = chat(messages) print(response) `} - - - - + + + + {/*

Additional Params: {JSON.stringify(selectedModel.litellm_params)}

*/} {/* Add other model details here */} -
- )} -
-
- ); - }; - - -export default ModelHub; \ No newline at end of file +export default ModelHub; From f9f2a72845417828c8e89c7eea8e678578126e7d Mon Sep 17 00:00:00 2001 From: mogith-pn <143642606+mogith-pn@users.noreply.github.com> Date: Mon, 27 May 2024 14:27:01 +0000 Subject: [PATCH 03/25] updated clarifai.md doc --- docs/my-website/docs/providers/clarifai.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/my-website/docs/providers/clarifai.md b/docs/my-website/docs/providers/clarifai.md index 6a0bd2211..85ee8fa26 100644 --- a/docs/my-website/docs/providers/clarifai.md +++ b/docs/my-website/docs/providers/clarifai.md @@ -11,7 +11,7 @@ Anthropic, OpenAI, Mistral, Llama and Gemini LLMs are Supported on Clarifai. To obtain your Clarifai Personal access token follow this [link](https://docs.clarifai.com/clarifai-basics/authentication/personal-access-tokens/). Optionally the PAT can also be passed in `completion` function. ```python -os.environ["CALRIFAI_API_KEY"] = "YOUR_CLARIFAI_PAT" # CLARIFAI_PAT +os.environ["CLARIFAI_API_KEY"] = "YOUR_CLARIFAI_PAT" # CLARIFAI_PAT ``` ## Usage From 4408b717f08597e07366b43994f1f6f3d27e80d5 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 27 May 2024 08:48:23 -0700 Subject: [PATCH 04/25] fix(parallel_request_limiter.py): fix user+team tpm/rpm limit check Closes https://github.com/BerriAI/litellm/issues/3788 --- litellm/proxy/_types.py | 4 - .../proxy/hooks/parallel_request_limiter.py | 14 +- litellm/proxy/hooks/tpm_rpm_limiter.py | 379 ------------------ litellm/proxy/proxy_server.py | 11 + litellm/proxy/utils.py | 4 - litellm/tests/test_max_tpm_rpm_limiter.py | 261 ++++++------ .../tests/test_parallel_request_limiter.py | 16 +- 7 files changed, 157 insertions(+), 532 deletions(-) delete mode 100644 litellm/proxy/hooks/tpm_rpm_limiter.py diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py index 2e131d2b2..e85f116f7 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -984,10 +984,6 @@ class LiteLLM_VerificationToken(LiteLLMBase): org_id: Optional[str] = None # org id for a given key - # hidden params used for parallel request limiting, not required to create a token - user_id_rate_limits: Optional[dict] = None - team_id_rate_limits: Optional[dict] = None - class Config: protected_namespaces = () diff --git a/litellm/proxy/hooks/parallel_request_limiter.py b/litellm/proxy/hooks/parallel_request_limiter.py index 0558cdf05..4ba7a2229 100644 --- a/litellm/proxy/hooks/parallel_request_limiter.py +++ b/litellm/proxy/hooks/parallel_request_limiter.py @@ -164,8 +164,9 @@ class _PROXY_MaxParallelRequestsHandler(CustomLogger): # check if REQUEST ALLOWED for user_id user_id = user_api_key_dict.user_id if user_id is not None: - _user_id_rate_limits = user_api_key_dict.user_id_rate_limits - + _user_id_rate_limits = await self.user_api_key_cache.async_get_cache( + key=user_id + ) # get user tpm/rpm limits if _user_id_rate_limits is not None and isinstance( _user_id_rate_limits, dict @@ -196,13 +197,8 @@ class _PROXY_MaxParallelRequestsHandler(CustomLogger): ## get team tpm/rpm limits team_id = user_api_key_dict.team_id if team_id is not None: - team_tpm_limit = getattr(user_api_key_dict, "team_tpm_limit", sys.maxsize) - - if team_tpm_limit is None: - team_tpm_limit = sys.maxsize - team_rpm_limit = getattr(user_api_key_dict, "team_rpm_limit", sys.maxsize) - if team_rpm_limit is None: - team_rpm_limit = sys.maxsize + team_tpm_limit = user_api_key_dict.team_tpm_limit + team_rpm_limit = user_api_key_dict.team_rpm_limit if team_tpm_limit is None: team_tpm_limit = sys.maxsize diff --git a/litellm/proxy/hooks/tpm_rpm_limiter.py b/litellm/proxy/hooks/tpm_rpm_limiter.py deleted file mode 100644 index 8951991d2..000000000 --- a/litellm/proxy/hooks/tpm_rpm_limiter.py +++ /dev/null @@ -1,379 +0,0 @@ -# What is this? -## Checks TPM/RPM Limits for a key/user/team on the proxy -## Works with Redis - if given - -from typing import Optional, Literal -import litellm, traceback, sys -from litellm.caching import DualCache, RedisCache -from litellm.proxy._types import ( - UserAPIKeyAuth, - LiteLLM_VerificationTokenView, - LiteLLM_UserTable, - LiteLLM_TeamTable, -) -from litellm.integrations.custom_logger import CustomLogger -from fastapi import HTTPException -from litellm._logging import verbose_proxy_logger -from litellm import ModelResponse -from datetime import datetime - - -class _PROXY_MaxTPMRPMLimiter(CustomLogger): - user_api_key_cache = None - - # Class variables or attributes - def __init__(self, internal_cache: Optional[DualCache]): - if internal_cache is None: - self.internal_cache = DualCache() - else: - self.internal_cache = internal_cache - - def print_verbose(self, print_statement): - try: - verbose_proxy_logger.debug(print_statement) - if litellm.set_verbose: - print(print_statement) # noqa - except: - pass - - ## check if admin has set tpm/rpm limits for this key/user/team - - def _check_limits_set( - self, - user_api_key_cache: DualCache, - key: Optional[str], - user_id: Optional[str], - team_id: Optional[str], - ) -> bool: - ## key - if key is not None: - key_val = user_api_key_cache.get_cache(key=key) - if isinstance(key_val, dict): - key_val = LiteLLM_VerificationTokenView(**key_val) - - if isinstance(key_val, LiteLLM_VerificationTokenView): - user_api_key_tpm_limit = key_val.tpm_limit - - user_api_key_rpm_limit = key_val.rpm_limit - - if ( - user_api_key_tpm_limit is not None - or user_api_key_rpm_limit is not None - ): - return True - - ## team - if team_id is not None: - team_val = user_api_key_cache.get_cache(key=team_id) - if isinstance(team_val, dict): - team_val = LiteLLM_TeamTable(**team_val) - - if isinstance(team_val, LiteLLM_TeamTable): - team_tpm_limit = team_val.tpm_limit - - team_rpm_limit = team_val.rpm_limit - - if team_tpm_limit is not None or team_rpm_limit is not None: - return True - - ## user - if user_id is not None: - user_val = user_api_key_cache.get_cache(key=user_id) - if isinstance(user_val, dict): - user_val = LiteLLM_UserTable(**user_val) - - if isinstance(user_val, LiteLLM_UserTable): - user_tpm_limit = user_val.tpm_limit - - user_rpm_limit = user_val.rpm_limit - - if user_tpm_limit is not None or user_rpm_limit is not None: - return True - return False - - async def check_key_in_limits( - self, - user_api_key_dict: UserAPIKeyAuth, - current_minute_dict: dict, - tpm_limit: int, - rpm_limit: int, - request_count_api_key: str, - type: Literal["key", "user", "team"], - ): - - if type == "key" and user_api_key_dict.api_key is not None: - current = current_minute_dict["key"].get(user_api_key_dict.api_key, None) - elif type == "user" and user_api_key_dict.user_id is not None: - current = current_minute_dict["user"].get(user_api_key_dict.user_id, None) - elif type == "team" and user_api_key_dict.team_id is not None: - current = current_minute_dict["team"].get(user_api_key_dict.team_id, None) - else: - return - if current is None: - if tpm_limit == 0 or rpm_limit == 0: - # base case - raise HTTPException( - status_code=429, detail="Max tpm/rpm limit reached." - ) - elif current["current_tpm"] < tpm_limit and current["current_rpm"] < rpm_limit: - pass - else: - raise HTTPException(status_code=429, detail="Max tpm/rpm limit reached.") - - async def async_pre_call_hook( - self, - user_api_key_dict: UserAPIKeyAuth, - cache: DualCache, - data: dict, - call_type: str, - ): - self.print_verbose( - f"Inside Max TPM/RPM Limiter Pre-Call Hook - {user_api_key_dict}" - ) - api_key = user_api_key_dict.api_key - # check if REQUEST ALLOWED for user_id - user_id = user_api_key_dict.user_id - ## get team tpm/rpm limits - team_id = user_api_key_dict.team_id - - self.user_api_key_cache = cache - - _set_limits = self._check_limits_set( - user_api_key_cache=cache, key=api_key, user_id=user_id, team_id=team_id - ) - - self.print_verbose(f"_set_limits: {_set_limits}") - - if _set_limits == False: - return - - # ------------ - # Setup values - # ------------ - - current_date = datetime.now().strftime("%Y-%m-%d") - current_hour = datetime.now().strftime("%H") - current_minute = datetime.now().strftime("%M") - precise_minute = f"{current_date}-{current_hour}-{current_minute}" - cache_key = "usage:{}".format(precise_minute) - current_minute_dict = await self.internal_cache.async_get_cache( - key=cache_key - ) # {"usage:{curr_minute}": {"key": {: {"current_requests": 1, "current_tpm": 1, "current_rpm": 10}}}} - - if current_minute_dict is None: - current_minute_dict = {"key": {}, "user": {}, "team": {}} - - if api_key is not None: - tpm_limit = getattr(user_api_key_dict, "tpm_limit", sys.maxsize) - if tpm_limit is None: - tpm_limit = sys.maxsize - rpm_limit = getattr(user_api_key_dict, "rpm_limit", sys.maxsize) - if rpm_limit is None: - rpm_limit = sys.maxsize - request_count_api_key = f"{api_key}::{precise_minute}::request_count" - await self.check_key_in_limits( - user_api_key_dict=user_api_key_dict, - current_minute_dict=current_minute_dict, - request_count_api_key=request_count_api_key, - tpm_limit=tpm_limit, - rpm_limit=rpm_limit, - type="key", - ) - - if user_id is not None: - _user_id_rate_limits = user_api_key_dict.user_id_rate_limits - - # get user tpm/rpm limits - if _user_id_rate_limits is not None and isinstance( - _user_id_rate_limits, dict - ): - user_tpm_limit = _user_id_rate_limits.get("tpm_limit", None) - user_rpm_limit = _user_id_rate_limits.get("rpm_limit", None) - if user_tpm_limit is None: - user_tpm_limit = sys.maxsize - if user_rpm_limit is None: - user_rpm_limit = sys.maxsize - - # now do the same tpm/rpm checks - request_count_api_key = f"{user_id}::{precise_minute}::request_count" - # print(f"Checking if {request_count_api_key} is allowed to make request for minute {precise_minute}") - await self.check_key_in_limits( - user_api_key_dict=user_api_key_dict, - current_minute_dict=current_minute_dict, - request_count_api_key=request_count_api_key, - tpm_limit=user_tpm_limit, - rpm_limit=user_rpm_limit, - type="user", - ) - - # TEAM RATE LIMITS - if team_id is not None: - team_tpm_limit = getattr(user_api_key_dict, "team_tpm_limit", sys.maxsize) - - if team_tpm_limit is None: - team_tpm_limit = sys.maxsize - team_rpm_limit = getattr(user_api_key_dict, "team_rpm_limit", sys.maxsize) - if team_rpm_limit is None: - team_rpm_limit = sys.maxsize - - if team_tpm_limit is None: - team_tpm_limit = sys.maxsize - if team_rpm_limit is None: - team_rpm_limit = sys.maxsize - - # now do the same tpm/rpm checks - request_count_api_key = f"{team_id}::{precise_minute}::request_count" - - # print(f"Checking if {request_count_api_key} is allowed to make request for minute {precise_minute}") - await self.check_key_in_limits( - user_api_key_dict=user_api_key_dict, - current_minute_dict=current_minute_dict, - request_count_api_key=request_count_api_key, - tpm_limit=team_tpm_limit, - rpm_limit=team_rpm_limit, - type="team", - ) - - return - - async def async_log_success_event(self, kwargs, response_obj, start_time, end_time): - try: - self.print_verbose(f"INSIDE TPM RPM Limiter ASYNC SUCCESS LOGGING") - - user_api_key = kwargs["litellm_params"]["metadata"]["user_api_key"] - user_api_key_user_id = kwargs["litellm_params"]["metadata"].get( - "user_api_key_user_id", None - ) - user_api_key_team_id = kwargs["litellm_params"]["metadata"].get( - "user_api_key_team_id", None - ) - _limits_set = self._check_limits_set( - user_api_key_cache=self.user_api_key_cache, - key=user_api_key, - user_id=user_api_key_user_id, - team_id=user_api_key_team_id, - ) - - if _limits_set == False: # don't waste cache calls if no tpm/rpm limits set - return - - # ------------ - # Setup values - # ------------ - - current_date = datetime.now().strftime("%Y-%m-%d") - current_hour = datetime.now().strftime("%H") - current_minute = datetime.now().strftime("%M") - precise_minute = f"{current_date}-{current_hour}-{current_minute}" - - total_tokens = 0 - - if isinstance(response_obj, ModelResponse): - total_tokens = response_obj.usage.total_tokens - - """ - - get value from redis - - increment requests + 1 - - increment tpm + 1 - - increment rpm + 1 - - update value in-memory + redis - """ - cache_key = "usage:{}".format(precise_minute) - if ( - self.internal_cache.redis_cache is not None - ): # get straight from redis if possible - current_minute_dict = ( - await self.internal_cache.redis_cache.async_get_cache( - key=cache_key, - ) - ) # {"usage:{current_minute}": {"key": {}, "team": {}, "user": {}}} - else: - current_minute_dict = await self.internal_cache.async_get_cache( - key=cache_key, - ) - - if current_minute_dict is None: - current_minute_dict = {"key": {}, "user": {}, "team": {}} - - _cache_updated = False # check if a cache update is required. prevent unnecessary rewrites. - - # ------------ - # Update usage - API Key - # ------------ - - if user_api_key is not None: - _cache_updated = True - ## API KEY ## - if user_api_key in current_minute_dict["key"]: - current_key_usage = current_minute_dict["key"][user_api_key] - new_val = { - "current_tpm": current_key_usage["current_tpm"] + total_tokens, - "current_rpm": current_key_usage["current_rpm"] + 1, - } - else: - new_val = { - "current_tpm": total_tokens, - "current_rpm": 1, - } - - current_minute_dict["key"][user_api_key] = new_val - - self.print_verbose( - f"updated_value in success call: {new_val}, precise_minute: {precise_minute}" - ) - - # ------------ - # Update usage - User - # ------------ - if user_api_key_user_id is not None: - _cache_updated = True - total_tokens = 0 - - if isinstance(response_obj, ModelResponse): - total_tokens = response_obj.usage.total_tokens - - if user_api_key_user_id in current_minute_dict["key"]: - current_key_usage = current_minute_dict["key"][user_api_key_user_id] - new_val = { - "current_tpm": current_key_usage["current_tpm"] + total_tokens, - "current_rpm": current_key_usage["current_rpm"] + 1, - } - else: - new_val = { - "current_tpm": total_tokens, - "current_rpm": 1, - } - - current_minute_dict["user"][user_api_key_user_id] = new_val - - # ------------ - # Update usage - Team - # ------------ - if user_api_key_team_id is not None: - _cache_updated = True - total_tokens = 0 - - if isinstance(response_obj, ModelResponse): - total_tokens = response_obj.usage.total_tokens - - if user_api_key_team_id in current_minute_dict["key"]: - current_key_usage = current_minute_dict["key"][user_api_key_team_id] - new_val = { - "current_tpm": current_key_usage["current_tpm"] + total_tokens, - "current_rpm": current_key_usage["current_rpm"] + 1, - } - else: - new_val = { - "current_tpm": total_tokens, - "current_rpm": 1, - } - - current_minute_dict["team"][user_api_key_team_id] = new_val - - if _cache_updated == True: - await self.internal_cache.async_set_cache( - key=cache_key, value=current_minute_dict - ) - - except Exception as e: - self.print_verbose("{}\n{}".format(e, traceback.format_exc())) # noqa diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 6f1a3e557..1bdb5edba 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -397,6 +397,7 @@ def _get_pydantic_json_dict(pydantic_obj: BaseModel) -> dict: def get_custom_headers( *, + user_api_key_dict: UserAPIKeyAuth, model_id: Optional[str] = None, cache_key: Optional[str] = None, api_base: Optional[str] = None, @@ -410,6 +411,8 @@ def get_custom_headers( "x-litellm-model-api-base": api_base, "x-litellm-version": version, "x-litellm-model-region": model_region, + "x-litellm-key-tpm-limit": str(user_api_key_dict.tpm_limit), + "x-litellm-key-rpm-limit": str(user_api_key_dict.rpm_limit), } try: return { @@ -4059,6 +4062,7 @@ async def chat_completion( "stream" in data and data["stream"] == True ): # use generate_responses to stream responses custom_headers = get_custom_headers( + user_api_key_dict=user_api_key_dict, model_id=model_id, cache_key=cache_key, api_base=api_base, @@ -4078,6 +4082,7 @@ async def chat_completion( fastapi_response.headers.update( get_custom_headers( + user_api_key_dict=user_api_key_dict, model_id=model_id, cache_key=cache_key, api_base=api_base, @@ -4298,6 +4303,7 @@ async def completion( "stream" in data and data["stream"] == True ): # use generate_responses to stream responses custom_headers = get_custom_headers( + user_api_key_dict=user_api_key_dict, model_id=model_id, cache_key=cache_key, api_base=api_base, @@ -4316,6 +4322,7 @@ async def completion( ) fastapi_response.headers.update( get_custom_headers( + user_api_key_dict=user_api_key_dict, model_id=model_id, cache_key=cache_key, api_base=api_base, @@ -4565,6 +4572,7 @@ async def embeddings( fastapi_response.headers.update( get_custom_headers( + user_api_key_dict=user_api_key_dict, model_id=model_id, cache_key=cache_key, api_base=api_base, @@ -4748,6 +4756,7 @@ async def image_generation( fastapi_response.headers.update( get_custom_headers( + user_api_key_dict=user_api_key_dict, model_id=model_id, cache_key=cache_key, api_base=api_base, @@ -4949,6 +4958,7 @@ async def audio_transcriptions( fastapi_response.headers.update( get_custom_headers( + user_api_key_dict=user_api_key_dict, model_id=model_id, cache_key=cache_key, api_base=api_base, @@ -5132,6 +5142,7 @@ async def moderations( fastapi_response.headers.update( get_custom_headers( + user_api_key_dict=user_api_key_dict, model_id=model_id, cache_key=cache_key, api_base=api_base, diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 2bca287e2..709ddbd3d 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -35,7 +35,6 @@ from litellm import ( ) from litellm.utils import ModelResponseIterator from litellm.proxy.hooks.max_budget_limiter import _PROXY_MaxBudgetLimiter -from litellm.proxy.hooks.tpm_rpm_limiter import _PROXY_MaxTPMRPMLimiter from litellm.proxy.hooks.cache_control_check import _PROXY_CacheControlCheck from litellm.integrations.custom_logger import CustomLogger from litellm.proxy.db.base_client import CustomDB @@ -81,9 +80,6 @@ class ProxyLogging: self.call_details["user_api_key_cache"] = user_api_key_cache self.internal_usage_cache = DualCache() self.max_parallel_request_limiter = _PROXY_MaxParallelRequestsHandler() - self.max_tpm_rpm_limiter = _PROXY_MaxTPMRPMLimiter( - internal_cache=self.internal_usage_cache - ) self.max_budget_limiter = _PROXY_MaxBudgetLimiter() self.cache_control_check = _PROXY_CacheControlCheck() self.alerting: Optional[List] = None diff --git a/litellm/tests/test_max_tpm_rpm_limiter.py b/litellm/tests/test_max_tpm_rpm_limiter.py index fbaf30c59..43489d5d9 100644 --- a/litellm/tests/test_max_tpm_rpm_limiter.py +++ b/litellm/tests/test_max_tpm_rpm_limiter.py @@ -1,162 +1,163 @@ +### REPLACED BY 'test_parallel_request_limiter.py' ### # What is this? ## Unit tests for the max tpm / rpm limiter hook for proxy -import sys, os, asyncio, time, random -from datetime import datetime -import traceback -from dotenv import load_dotenv -from typing import Optional +# import sys, os, asyncio, time, random +# from datetime import datetime +# import traceback +# from dotenv import load_dotenv +# from typing import Optional -load_dotenv() -import os +# load_dotenv() +# import os -sys.path.insert( - 0, os.path.abspath("../..") -) # Adds the parent directory to the system path -import pytest -import litellm -from litellm import Router -from litellm.proxy.utils import ProxyLogging, hash_token -from litellm.proxy._types import UserAPIKeyAuth -from litellm.caching import DualCache, RedisCache -from litellm.proxy.hooks.tpm_rpm_limiter import _PROXY_MaxTPMRPMLimiter -from datetime import datetime +# sys.path.insert( +# 0, os.path.abspath("../..") +# ) # Adds the parent directory to the system path +# import pytest +# import litellm +# from litellm import Router +# from litellm.proxy.utils import ProxyLogging, hash_token +# from litellm.proxy._types import UserAPIKeyAuth +# from litellm.caching import DualCache, RedisCache +# from litellm.proxy.hooks.tpm_rpm_limiter import _PROXY_MaxTPMRPMLimiter +# from datetime import datetime -@pytest.mark.asyncio -async def test_pre_call_hook_rpm_limits(): - """ - Test if error raised on hitting rpm limits - """ - litellm.set_verbose = True - _api_key = hash_token("sk-12345") - user_api_key_dict = UserAPIKeyAuth(api_key=_api_key, tpm_limit=9, rpm_limit=1) - local_cache = DualCache() - # redis_usage_cache = RedisCache() +# @pytest.mark.asyncio +# async def test_pre_call_hook_rpm_limits(): +# """ +# Test if error raised on hitting rpm limits +# """ +# litellm.set_verbose = True +# _api_key = hash_token("sk-12345") +# user_api_key_dict = UserAPIKeyAuth(api_key=_api_key, tpm_limit=9, rpm_limit=1) +# local_cache = DualCache() +# # redis_usage_cache = RedisCache() - local_cache.set_cache( - key=_api_key, value={"api_key": _api_key, "tpm_limit": 9, "rpm_limit": 1} - ) +# local_cache.set_cache( +# key=_api_key, value={"api_key": _api_key, "tpm_limit": 9, "rpm_limit": 1} +# ) - tpm_rpm_limiter = _PROXY_MaxTPMRPMLimiter(internal_cache=DualCache()) +# tpm_rpm_limiter = _PROXY_MaxTPMRPMLimiter(internal_cache=DualCache()) - await tpm_rpm_limiter.async_pre_call_hook( - user_api_key_dict=user_api_key_dict, cache=local_cache, data={}, call_type="" - ) +# await tpm_rpm_limiter.async_pre_call_hook( +# user_api_key_dict=user_api_key_dict, cache=local_cache, data={}, call_type="" +# ) - kwargs = {"litellm_params": {"metadata": {"user_api_key": _api_key}}} +# kwargs = {"litellm_params": {"metadata": {"user_api_key": _api_key}}} - await tpm_rpm_limiter.async_log_success_event( - kwargs=kwargs, - response_obj="", - start_time="", - end_time="", - ) +# await tpm_rpm_limiter.async_log_success_event( +# kwargs=kwargs, +# response_obj="", +# start_time="", +# end_time="", +# ) - ## Expected cache val: {"current_requests": 0, "current_tpm": 0, "current_rpm": 1} +# ## Expected cache val: {"current_requests": 0, "current_tpm": 0, "current_rpm": 1} - try: - await tpm_rpm_limiter.async_pre_call_hook( - user_api_key_dict=user_api_key_dict, - cache=local_cache, - data={}, - call_type="", - ) +# try: +# await tpm_rpm_limiter.async_pre_call_hook( +# user_api_key_dict=user_api_key_dict, +# cache=local_cache, +# data={}, +# call_type="", +# ) - pytest.fail(f"Expected call to fail") - except Exception as e: - assert e.status_code == 429 +# pytest.fail(f"Expected call to fail") +# except Exception as e: +# assert e.status_code == 429 -@pytest.mark.asyncio -async def test_pre_call_hook_team_rpm_limits( - _redis_usage_cache: Optional[RedisCache] = None, -): - """ - Test if error raised on hitting team rpm limits - """ - litellm.set_verbose = True - _api_key = "sk-12345" - _team_id = "unique-team-id" - _user_api_key_dict = { - "api_key": _api_key, - "max_parallel_requests": 1, - "tpm_limit": 9, - "rpm_limit": 10, - "team_rpm_limit": 1, - "team_id": _team_id, - } - user_api_key_dict = UserAPIKeyAuth(**_user_api_key_dict) # type: ignore - _api_key = hash_token(_api_key) - local_cache = DualCache() - local_cache.set_cache(key=_api_key, value=_user_api_key_dict) - internal_cache = DualCache(redis_cache=_redis_usage_cache) - tpm_rpm_limiter = _PROXY_MaxTPMRPMLimiter(internal_cache=internal_cache) - await tpm_rpm_limiter.async_pre_call_hook( - user_api_key_dict=user_api_key_dict, cache=local_cache, data={}, call_type="" - ) +# @pytest.mark.asyncio +# async def test_pre_call_hook_team_rpm_limits( +# _redis_usage_cache: Optional[RedisCache] = None, +# ): +# """ +# Test if error raised on hitting team rpm limits +# """ +# litellm.set_verbose = True +# _api_key = "sk-12345" +# _team_id = "unique-team-id" +# _user_api_key_dict = { +# "api_key": _api_key, +# "max_parallel_requests": 1, +# "tpm_limit": 9, +# "rpm_limit": 10, +# "team_rpm_limit": 1, +# "team_id": _team_id, +# } +# user_api_key_dict = UserAPIKeyAuth(**_user_api_key_dict) # type: ignore +# _api_key = hash_token(_api_key) +# local_cache = DualCache() +# local_cache.set_cache(key=_api_key, value=_user_api_key_dict) +# internal_cache = DualCache(redis_cache=_redis_usage_cache) +# tpm_rpm_limiter = _PROXY_MaxTPMRPMLimiter(internal_cache=internal_cache) +# await tpm_rpm_limiter.async_pre_call_hook( +# user_api_key_dict=user_api_key_dict, cache=local_cache, data={}, call_type="" +# ) - kwargs = { - "litellm_params": { - "metadata": {"user_api_key": _api_key, "user_api_key_team_id": _team_id} - } - } +# kwargs = { +# "litellm_params": { +# "metadata": {"user_api_key": _api_key, "user_api_key_team_id": _team_id} +# } +# } - await tpm_rpm_limiter.async_log_success_event( - kwargs=kwargs, - response_obj="", - start_time="", - end_time="", - ) +# await tpm_rpm_limiter.async_log_success_event( +# kwargs=kwargs, +# response_obj="", +# start_time="", +# end_time="", +# ) - print(f"local_cache: {local_cache}") +# print(f"local_cache: {local_cache}") - ## Expected cache val: {"current_requests": 0, "current_tpm": 0, "current_rpm": 1} +# ## Expected cache val: {"current_requests": 0, "current_tpm": 0, "current_rpm": 1} - try: - await tpm_rpm_limiter.async_pre_call_hook( - user_api_key_dict=user_api_key_dict, - cache=local_cache, - data={}, - call_type="", - ) +# try: +# await tpm_rpm_limiter.async_pre_call_hook( +# user_api_key_dict=user_api_key_dict, +# cache=local_cache, +# data={}, +# call_type="", +# ) - pytest.fail(f"Expected call to fail") - except Exception as e: - assert e.status_code == 429 # type: ignore +# pytest.fail(f"Expected call to fail") +# except Exception as e: +# assert e.status_code == 429 # type: ignore -@pytest.mark.asyncio -async def test_namespace(): - """ - - test if default namespace set via `proxyconfig._init_cache` - - respected for tpm/rpm caching - """ - from litellm.proxy.proxy_server import ProxyConfig +# @pytest.mark.asyncio +# async def test_namespace(): +# """ +# - test if default namespace set via `proxyconfig._init_cache` +# - respected for tpm/rpm caching +# """ +# from litellm.proxy.proxy_server import ProxyConfig - redis_usage_cache: Optional[RedisCache] = None - cache_params = {"type": "redis", "namespace": "litellm_default"} +# redis_usage_cache: Optional[RedisCache] = None +# cache_params = {"type": "redis", "namespace": "litellm_default"} - ## INIT CACHE ## - proxy_config = ProxyConfig() - setattr(litellm.proxy.proxy_server, "proxy_config", proxy_config) +# ## INIT CACHE ## +# proxy_config = ProxyConfig() +# setattr(litellm.proxy.proxy_server, "proxy_config", proxy_config) - proxy_config._init_cache(cache_params=cache_params) +# proxy_config._init_cache(cache_params=cache_params) - redis_cache: Optional[RedisCache] = getattr( - litellm.proxy.proxy_server, "redis_usage_cache" - ) +# redis_cache: Optional[RedisCache] = getattr( +# litellm.proxy.proxy_server, "redis_usage_cache" +# ) - ## CHECK IF NAMESPACE SET ## - assert redis_cache.namespace == "litellm_default" +# ## CHECK IF NAMESPACE SET ## +# assert redis_cache.namespace == "litellm_default" - ## CHECK IF TPM/RPM RATE LIMITING WORKS ## - await test_pre_call_hook_team_rpm_limits(_redis_usage_cache=redis_cache) - current_date = datetime.now().strftime("%Y-%m-%d") - current_hour = datetime.now().strftime("%H") - current_minute = datetime.now().strftime("%M") - precise_minute = f"{current_date}-{current_hour}-{current_minute}" +# ## CHECK IF TPM/RPM RATE LIMITING WORKS ## +# await test_pre_call_hook_team_rpm_limits(_redis_usage_cache=redis_cache) +# current_date = datetime.now().strftime("%Y-%m-%d") +# current_hour = datetime.now().strftime("%H") +# current_minute = datetime.now().strftime("%M") +# precise_minute = f"{current_date}-{current_hour}-{current_minute}" - cache_key = "litellm_default:usage:{}".format(precise_minute) - value = await redis_cache.async_get_cache(key=cache_key) - assert value is not None +# cache_key = "litellm_default:usage:{}".format(precise_minute) +# value = await redis_cache.async_get_cache(key=cache_key) +# assert value is not None diff --git a/litellm/tests/test_parallel_request_limiter.py b/litellm/tests/test_parallel_request_limiter.py index 00da199d9..94652c2a6 100644 --- a/litellm/tests/test_parallel_request_limiter.py +++ b/litellm/tests/test_parallel_request_limiter.py @@ -229,17 +229,21 @@ async def test_pre_call_hook_user_tpm_limits(): """ Test if error raised on hitting tpm limits """ + local_cache = DualCache() # create user with tpm/rpm limits + user_id = "test-user" + user_obj = {"tpm_limit": 9, "rpm_limit": 10} + + local_cache.set_cache(key=user_id, value=user_obj) _api_key = "sk-12345" user_api_key_dict = UserAPIKeyAuth( api_key=_api_key, - user_id="ishaan", - user_id_rate_limits={"tpm_limit": 9, "rpm_limit": 10}, + user_id=user_id, ) res = dict(user_api_key_dict) print("dict user", res) - local_cache = DualCache() + parallel_request_handler = MaxParallelRequestsHandler() await parallel_request_handler.async_pre_call_hook( @@ -248,7 +252,7 @@ async def test_pre_call_hook_user_tpm_limits(): kwargs = { "litellm_params": { - "metadata": {"user_api_key_user_id": "ishaan", "user_api_key": "gm"} + "metadata": {"user_api_key_user_id": user_id, "user_api_key": "gm"} } } @@ -734,7 +738,7 @@ async def test_bad_router_call(): request_count_api_key = f"{_api_key}::{precise_minute}::request_count" assert ( - parallel_request_handler.user_api_key_cache.get_cache( + parallel_request_handler.user_api_key_cache.get_cache( # type: ignore key=request_count_api_key )["current_requests"] == 1 @@ -751,7 +755,7 @@ async def test_bad_router_call(): except: pass assert ( - parallel_request_handler.user_api_key_cache.get_cache( + parallel_request_handler.user_api_key_cache.get_cache( # type: ignore key=request_count_api_key )["current_requests"] == 0 From b5f883ab74ffa5e6fd92dc89b00e200c756e1c0c Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 08:49:51 -0700 Subject: [PATCH 05/25] feat - show openai params on model hub ui --- litellm/router.py | 12 ++++++++---- litellm/types/router.py | 1 + litellm/types/utils.py | 5 +++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/litellm/router.py b/litellm/router.py index 3243e09fa..384c7f338 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -3072,7 +3072,7 @@ class Router: model=litellm_params.model, custom_llm_provider=litellm_params.custom_llm_provider, ) - except Exception as e: + except litellm.exceptions.BadRequestError as e: continue if model_group_info is None: @@ -3124,19 +3124,23 @@ class Router: if ( model_info.get("supports_parallel_function_calling", None) is not None - and model_info["supports_parallel_function_calling"] == True # type: ignore + and model_info["supports_parallel_function_calling"] is True # type: ignore ): model_group_info.supports_parallel_function_calling = True if ( model_info.get("supports_vision", None) is not None - and model_info["supports_vision"] == True # type: ignore + and model_info["supports_vision"] is True # type: ignore ): model_group_info.supports_vision = True if ( model_info.get("supports_function_calling", None) is not None - and model_info["supports_function_calling"] == True # type: ignore + and model_info["supports_function_calling"] is True # type: ignore ): model_group_info.supports_function_calling = True + if model_info.get("supported_openai_params", None) is not None: + model_group_info.supported_openai_params = model_info[ + "supported_openai_params" + ] return model_group_info diff --git a/litellm/types/router.py b/litellm/types/router.py index 5e6f2c148..93c65a1cf 100644 --- a/litellm/types/router.py +++ b/litellm/types/router.py @@ -426,3 +426,4 @@ class ModelGroupInfo(BaseModel): supports_parallel_function_calling: bool = Field(default=False) supports_vision: bool = Field(default=False) supports_function_calling: bool = Field(default=False) + supported_openai_params: List[str] = Field(default=[]) diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 5c730cca8..cc0836132 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -15,6 +15,10 @@ class ProviderField(TypedDict): class ModelInfo(TypedDict): + """ + Model info for a given model, this is information found in litellm.model_prices_and_context_window.json + """ + max_tokens: int max_input_tokens: int max_output_tokens: int @@ -22,3 +26,4 @@ class ModelInfo(TypedDict): output_cost_per_token: float litellm_provider: str mode: str + supported_openai_params: List[str] From d3b724af7d06c62da31d4deeedd533c21bc70cbe Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 27 May 2024 08:52:01 -0700 Subject: [PATCH 06/25] refactor(proxy/utils.py): cleanup dead code --- litellm/proxy/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 709ddbd3d..b01312478 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -140,7 +140,6 @@ class ProxyLogging: print_verbose(f"INITIALIZING LITELLM CALLBACKS!") self.service_logging_obj = ServiceLogging() litellm.callbacks.append(self.max_parallel_request_limiter) - litellm.callbacks.append(self.max_tpm_rpm_limiter) litellm.callbacks.append(self.max_budget_limiter) litellm.callbacks.append(self.cache_control_check) litellm.callbacks.append(self.service_logging_obj) From 245990597ec3b262bf5df002372ec97295221784 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 09:00:12 -0700 Subject: [PATCH 07/25] fix - return supported_openai_params from get_model_info --- litellm/utils.py | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index b777819e5..5729395d3 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -7107,6 +7107,7 @@ def get_model_info(model: str) -> ModelInfo: - output_cost_per_token (float): The cost per token for output. - litellm_provider (str): The provider of the model (e.g., "openai"). - mode (str): The mode of the model (e.g., "chat" or "completion"). + - supported_openai_params (List[str]): A list of supported OpenAI parameters for the model. Raises: Exception: If the model is not mapped yet. @@ -7118,9 +7119,11 @@ def get_model_info(model: str) -> ModelInfo: "input_cost_per_token": 0.00003, "output_cost_per_token": 0.00006, "litellm_provider": "openai", - "mode": "chat" + "mode": "chat", + "supported_openai_params": ["temperature", "max_tokens", "top_p", "frequency_penalty", "presence_penalty"] } """ + supported_openai_params: Union[List[str], None] = [] def _get_max_position_embeddings(model_name): # Construct the URL for the config.json file @@ -7148,9 +7151,18 @@ def get_model_info(model: str) -> ModelInfo: azure_llms = litellm.azure_llms if model in azure_llms: model = azure_llms[model] - if model in litellm.model_cost: - return litellm.model_cost[model] - model, custom_llm_provider, _, _ = get_llm_provider(model=model) + ########################## + # Get custom_llm_provider + split_model, custom_llm_provider = model, "" + try: + split_model, custom_llm_provider, _, _ = get_llm_provider(model=model) + except: + pass + ######################### + + supported_openai_params = litellm.get_supported_openai_params( + model=model, custom_llm_provider=custom_llm_provider + ) if custom_llm_provider == "huggingface": max_tokens = _get_max_position_embeddings(model_name=model) return { @@ -7159,15 +7171,26 @@ def get_model_info(model: str) -> ModelInfo: "output_cost_per_token": 0, "litellm_provider": "huggingface", "mode": "chat", + "supported_openai_params": supported_openai_params, } else: """ - Check if model in model cost map + Check if: + 1. 'model' in litellm.model_cost. Checks "groq/llama3-8b-8192" in litellm.model_cost + 2. 'split_model' in litellm.model_cost. Checks "llama3-8b-8192" in litellm.model_cost """ if model in litellm.model_cost: - return litellm.model_cost[model] + _model_info = litellm.model_cost[model] + _model_info["supported_openai_params"] = supported_openai_params + return _model_info + if split_model in litellm.model_cost: + _model_info = litellm.model_cost[split_model] + _model_info["supported_openai_params"] = supported_openai_params + return _model_info else: - raise Exception() + raise ValueError( + "This model isn't mapped yet. Add it here - https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json" + ) except: raise Exception( "This model isn't mapped yet. Add it here - https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json" From 408130619bfccae868f1d89340272f37a622f925 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 09:01:47 -0700 Subject: [PATCH 08/25] ui - show supported openai params --- .../src/components/model_hub.tsx | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_hub.tsx b/ui/litellm-dashboard/src/components/model_hub.tsx index 63431d13b..2bec7d013 100644 --- a/ui/litellm-dashboard/src/components/model_hub.tsx +++ b/ui/litellm-dashboard/src/components/model_hub.tsx @@ -32,6 +32,7 @@ interface ModelInfo { supports_vision: boolean; max_input_tokens?: number; max_output_tokens?: number; + supported_openai_params?: string[]; // Add other properties if needed @@ -193,6 +194,7 @@ const ModelHub: React.FC = ({ Supports Vision: {model?.supports_vision == true ? "Yes" : "No"} Max Input Tokens: {model?.max_input_tokens ? model?.max_input_tokens : "N/A"} Max Output Tokens: {model?.max_output_tokens ? model?.max_output_tokens : "N/A"} +
@@ -218,7 +220,7 @@ const ModelHub: React.FC = ({ = ({
-

Model Name: {selectedModel.model_group}

+

Model Information & Usage: {selectedModel.model_group}

OpenAI Python SDK + Supported OpenAI Params LlamaIndex Langchain Py @@ -265,6 +268,22 @@ response = client.chat.completions.create( print(response) `} + + + + + { + selectedModel?.supported_openai_params?.map((param) => ( + +
+                              {param}
+                             
+ + + )) + } + +
From 983514dc77921abd33fa76a7a0e0c6f2fe1dcb58 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sun, 26 May 2024 17:44:52 -0700 Subject: [PATCH 09/25] fix(model_hub.tsx): fix string --- .../src/components/model_hub.tsx | 161 +++++++----------- 1 file changed, 66 insertions(+), 95 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_hub.tsx b/ui/litellm-dashboard/src/components/model_hub.tsx index 2bec7d013..c4b776ec2 100644 --- a/ui/litellm-dashboard/src/components/model_hub.tsx +++ b/ui/litellm-dashboard/src/components/model_hub.tsx @@ -1,20 +1,26 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState } from "react"; import { modelHubCall } from "./networking"; -import { Card, Text, Title, Grid, Button, Badge, Tab, - TabGroup, - TabList, - TabPanel, - TabPanels, } from "@tremor/react"; +import { + Card, + Text, + Title, + Grid, + Button, + Badge, + Tab, + TabGroup, + TabList, + TabPanel, + TabPanels, +} from "@tremor/react"; -import { RightOutlined, CopyOutlined } from '@ant-design/icons'; +import { RightOutlined, CopyOutlined } from "@ant-design/icons"; -import { Modal, Tooltip } from 'antd'; +import { Modal, Tooltip } from "antd"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; - - interface ModelHubProps { userID: string | null; userRole: string | null; @@ -22,7 +28,6 @@ interface ModelHubProps { accessToken: string | null; keys: any; // Replace with the appropriate type for 'keys' prop premiumUser: boolean; - } interface ModelInfo { @@ -39,9 +44,10 @@ interface ModelInfo { } + // Add other properties if needed +} const ModelHub: React.FC = ({ - userID, userRole, @@ -53,114 +59,80 @@ const ModelHub: React.FC = ({ keys, premiumUser, - }) => { - - const [modelHubData, setModelHubData] = useState(null); + const [modelHubData, setModelHubData] = useState(null); const [isModalVisible, setIsModalVisible] = useState(false); - const [selectedModel, setSelectedModel] = useState(null); - + const [selectedModel, setSelectedModel] = useState(null); useEffect(() => { - if (!accessToken || !token || !userRole || !userID) { return; } - - const fetchData = async () => { - try { - const _modelHubData = await modelHubCall(accessToken, userID, userRole); console.log("ModelHubData:", _modelHubData); setModelHubData(_modelHubData.data); - } catch (error) { - console.error("There was an error fetching the model data", error); - } - }; - - fetchData(); - }, [accessToken, token, userRole, userID]); - - const showModal = (model: ModelInfo) => { - setSelectedModel(model); setIsModalVisible(true); - }; - - const handleOk = () => { - setIsModalVisible(false); setSelectedModel(null); - }; - - const handleCancel = () => { - setIsModalVisible(false); setSelectedModel(null); - }; - - const copyToClipboard = (text: string) => { - navigator.clipboard.writeText(text); - }; - - return ( -
+
+
-
- -
- - - -
- - -
- - Model Hub - - +
+ Model Hub +
- - +
+ {modelHubData && + modelHubData.map((model: ModelInfo) => ( + +
+                  {model.model_group}
+                  
+                     copyToClipboard(model.model_group)}
+                      style={{ cursor: "pointer", marginRight: "10px" }}
+                    />
+                  
+                
{modelHubData && modelHubData.map((model: ModelInfo) => ( @@ -214,27 +186,34 @@ const ModelHub: React.FC = ({ ))} + +
+ ))}
-
- {selectedModel && ( -
+

+ Model Name: {selectedModel.model_group} +

Model Information & Usage: {selectedModel.model_group}

@@ -319,11 +298,11 @@ response = query_engine.query("What did the author do growing up?") print(response) `} - - - - - {` + + + + + {` from langchain.chat_models import ChatOpenAI from langchain.prompts.chat import ( ChatPromptTemplate, @@ -351,27 +330,19 @@ response = chat(messages) print(response) `} - - - - + + + + {/*

Additional Params: {JSON.stringify(selectedModel.litellm_params)}

*/} {/* Add other model details here */} -
- )} -
-
- ); - }; - - -export default ModelHub; \ No newline at end of file +export default ModelHub; From 1aa2530c5c01e313298a5bdbddfdb65720a128e2 Mon Sep 17 00:00:00 2001 From: mogith-pn <143642606+mogith-pn@users.noreply.github.com> Date: Mon, 27 May 2024 14:27:01 +0000 Subject: [PATCH 10/25] updated clarifai.md doc --- docs/my-website/docs/providers/clarifai.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/my-website/docs/providers/clarifai.md b/docs/my-website/docs/providers/clarifai.md index 6a0bd2211..85ee8fa26 100644 --- a/docs/my-website/docs/providers/clarifai.md +++ b/docs/my-website/docs/providers/clarifai.md @@ -11,7 +11,7 @@ Anthropic, OpenAI, Mistral, Llama and Gemini LLMs are Supported on Clarifai. To obtain your Clarifai Personal access token follow this [link](https://docs.clarifai.com/clarifai-basics/authentication/personal-access-tokens/). Optionally the PAT can also be passed in `completion` function. ```python -os.environ["CALRIFAI_API_KEY"] = "YOUR_CLARIFAI_PAT" # CLARIFAI_PAT +os.environ["CLARIFAI_API_KEY"] = "YOUR_CLARIFAI_PAT" # CLARIFAI_PAT ``` ## Usage From 752e432b23f263f014bfb9b688dd55e15a7bda73 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 09:10:49 -0700 Subject: [PATCH 11/25] ui - fix showing openai params --- .../src/components/model_hub.tsx | 56 +------------------ 1 file changed, 2 insertions(+), 54 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_hub.tsx b/ui/litellm-dashboard/src/components/model_hub.tsx index c4b776ec2..f64e20e3a 100644 --- a/ui/litellm-dashboard/src/components/model_hub.tsx +++ b/ui/litellm-dashboard/src/components/model_hub.tsx @@ -39,11 +39,6 @@ interface ModelInfo { max_output_tokens?: number; supported_openai_params?: string[]; - // Add other properties if needed - - } - - // Add other properties if needed } @@ -133,31 +128,7 @@ const ModelHub: React.FC = ({ /> - - - {modelHubData && modelHubData.map((model: ModelInfo) => ( - - - - - -
-                
-
-                {model.model_group}
-                
-
-                     copyToClipboard(model.model_group)} style={{ cursor: 'pointer', marginRight: '10px' }} />
-
-                    
-
-              
+
@@ -166,26 +137,7 @@ const ModelHub: React.FC = ({ Supports Vision: {model?.supports_vision == true ? "Yes" : "No"} Max Input Tokens: {model?.max_input_tokens ? model?.max_input_tokens : "N/A"} Max Output Tokens: {model?.max_output_tokens ? model?.max_output_tokens : "N/A"} - -
- - - -
- - ))} -
= ({ > {selectedModel && (
-

- Model Name: {selectedModel.model_group} -

- -

Model Information & Usage: {selectedModel.model_group}

+

Model Information & Usage

From bd65f89c74b21c0015b734efee35ca662bfb4d8c Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 09:16:24 -0700 Subject: [PATCH 12/25] ui - new build --- litellm/proxy/_experimental/out/404.html | 2 +- .../_buildManifest.js | 0 .../_ssgManifest.js | 0 .../{page-e266cb0126026d40.js => page-2421e763699a7dc4.js} | 2 +- litellm/proxy/_experimental/out/index.html | 2 +- litellm/proxy/_experimental/out/index.txt | 4 ++-- ui/litellm-dashboard/out/404.html | 2 +- .../_buildManifest.js | 0 .../_ssgManifest.js | 0 .../{page-e266cb0126026d40.js => page-2421e763699a7dc4.js} | 2 +- ui/litellm-dashboard/out/index.html | 2 +- ui/litellm-dashboard/out/index.txt | 4 ++-- ui/litellm-dashboard/src/components/model_hub.tsx | 2 +- 13 files changed, 11 insertions(+), 11 deletions(-) rename litellm/proxy/_experimental/out/_next/static/{dYIEEO-62OCgyckEhgBd- => N-Poqi-YBhDAzJSVSMX3L}/_buildManifest.js (100%) rename litellm/proxy/_experimental/out/_next/static/{dYIEEO-62OCgyckEhgBd- => N-Poqi-YBhDAzJSVSMX3L}/_ssgManifest.js (100%) rename litellm/proxy/_experimental/out/_next/static/chunks/app/{page-e266cb0126026d40.js => page-2421e763699a7dc4.js} (82%) rename ui/litellm-dashboard/out/_next/static/{dYIEEO-62OCgyckEhgBd- => N-Poqi-YBhDAzJSVSMX3L}/_buildManifest.js (100%) rename ui/litellm-dashboard/out/_next/static/{dYIEEO-62OCgyckEhgBd- => N-Poqi-YBhDAzJSVSMX3L}/_ssgManifest.js (100%) rename ui/litellm-dashboard/out/_next/static/chunks/app/{page-e266cb0126026d40.js => page-2421e763699a7dc4.js} (82%) diff --git a/litellm/proxy/_experimental/out/404.html b/litellm/proxy/_experimental/out/404.html index 3716021f5..dca0b9a75 100644 --- a/litellm/proxy/_experimental/out/404.html +++ b/litellm/proxy/_experimental/out/404.html @@ -1 +1 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/dYIEEO-62OCgyckEhgBd-/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_buildManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/dYIEEO-62OCgyckEhgBd-/_buildManifest.js rename to litellm/proxy/_experimental/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_buildManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/dYIEEO-62OCgyckEhgBd-/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_ssgManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/dYIEEO-62OCgyckEhgBd-/_ssgManifest.js rename to litellm/proxy/_experimental/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_ssgManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-e266cb0126026d40.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-2421e763699a7dc4.js similarity index 82% rename from litellm/proxy/_experimental/out/_next/static/chunks/app/page-e266cb0126026d40.js rename to litellm/proxy/_experimental/out/_next/static/chunks/app/page-2421e763699a7dc4.js index 44e0921bd..ce8149624 100644 --- a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-e266cb0126026d40.js +++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-2421e763699a7dc4.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,t){Promise.resolve().then(t.bind(t,39712))},39712:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return lH}});var s,r,a=t(3827),n=t(64090),o=t(47907),i=t(8792),c=t(40491),d=t(65270),m=e=>{let{userID:l,userRole:t,userEmail:s,showSSOBanner:r,premiumUser:n}=e;console.log("User ID:",l),console.log("userEmail:",s),console.log("showSSOBanner:",r),console.log("premiumUser:",n);let o=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",t]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(i.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[r?(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(c.Z,{menu:{items:o},children:(0,a.jsx)(d.Z,{children:s})})})]})]})},h=t(80588);let u=async()=>{try{let e=await fetch("https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"),l=await e.json();return console.log("received data: ".concat(l)),l}catch(e){throw console.error("Failed to get model cost map:",e),e}},x=async(e,l)=>{try{let t=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),s}catch(e){throw console.error("Failed to create key:",e),e}},p=async e=>{try{let l=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},j=async(e,l)=>{console.log("model_id in model delete call: ".concat(l));try{let t=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model deleted successfully. Restart server to see this."),s}catch(e){throw console.error("Failed to create key:",e),e}},g=async(e,l)=>{if(console.log("budget_id in budget delete call: ".concat(l)),null!=e)try{let t=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,l)=>{try{console.log("Form Values in budgetCreateCall:",l),console.log("Form Values after check:",l);let t=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},f=async e=>{try{let l=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},Z=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,l)=>{try{console.log("in keyDeleteCall:",l);let t=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,l)=>{try{console.log("in teamDeleteCall:",l);let t=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,l,t){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;try{let n="/user/info";"App Owner"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),"App User"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),console.log("in userInfoCall viewAll=",s),s&&a&&null!=r&&void 0!=r&&(n="".concat(n,"?view_all=true&page=").concat(r,"&page_size=").concat(a));let o=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let i=await o.json();return console.log("API Response:",i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,l)=>{try{let t="/team/info";l&&(t="".concat(t,"?team_id=").concat(l)),console.log("in teamInfoCall");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},S=async e=>{try{let l=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,l,t)=>{try{let l=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelInfoCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,l,t)=>{try{let l=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelHubCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,l,t,s,r,a)=>{try{let l="/model/metrics";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},I=async(e,l,t,s)=>{try{let r="/model/streaming_metrics";l&&(r="".concat(r,"?_selected_model_group=").concat(l,"&startTime=").concat(t,"&endTime=").concat(s));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},C=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/slow_responses";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/exceptions";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,l,t)=>{try{let l=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},F=async e=>{try{let l="/global/spend/teams";console.log("in teamSpendLogsCall:",l);let t=await fetch("".concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=async(e,l,t)=>{try{let s="/global/spend/tags";l&&t&&(s="".concat(s,"?start_date=").concat(l,"&end_date=").concat(t)),console.log("in tagsSpendLogsCall:",s);let r=await fetch("".concat(s),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},R=async(e,l,t,s,r,a)=>{try{console.log("user role in spend logs call: ".concat(t));let l="/spend/logs";l="App Owner"==t?"".concat(l,"?user_id=").concat(s,"&start_date=").concat(r,"&end_date=").concat(a):"".concat(l,"?start_date=").concat(r,"&end_date=").concat(a);let n=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},M=async e=>{try{let l=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},L=async e=>{try{let l=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,l,t,s)=>{try{let r="";r=l?JSON.stringify({api_key:l,startTime:t,endTime:s}):JSON.stringify({startTime:t,endTime:s});let a={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};a.body=r;let n=await fetch("/global/spend/end_users",a);if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,l,t,s)=>{try{let r="/global/spend/provider";t&&s&&(r+="?start_date=".concat(t,"&end_date=").concat(s)),l&&(r+="&api_key=".concat(l));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log(n),n}catch(e){throw console.error("Failed to fetch spend data:",e),e}},B=async(e,l,t)=>{try{let s="/global/activity";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},z=async(e,l,t)=>{try{let s="/global/activity/model";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},K=async e=>{try{let l=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},G=async(e,l)=>{try{let t=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},q=async(e,l)=>{try{let t="/user/get_users?role=".concat(l);console.log("in userGetAllUsersCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let r=await s.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},V=async(e,l)=>{try{console.log("Form Values in teamCreateCall:",l);let t=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,l)=>{try{console.log("Form Values in keyUpdateCall:",l);let t=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},H=async(e,l)=>{try{console.log("Form Values in teamUpateCall:",l);let t=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},Y=async(e,l)=>{try{console.log("Form Values in modelUpateCall:",l);let t=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update model Response:",s),s}catch(e){throw console.error("Failed to update model:",e),e}},J=async(e,l,t)=>{try{console.log("Form Values in teamMemberAddCall:",t);let s=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:l,member:t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},$=async(e,l,t)=>{try{console.log("Form Values in userUpdateUserCall:",l);let s={...l};null!==t&&(s.user_role=t),s=JSON.stringify(s);let r=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:s});if(!r.ok){let e=await r.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await r.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,l)=>{try{let t="/health/services?service=".concat(l);console.log("Checking Slack Budget Alerts service health");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed ".concat(l," service health check ")+e),Error(e)}let r=await s.json();return h.ZP.success("Test request to ".concat(l," made - check logs/alerts on ").concat(l," to verify")),r}catch(e){throw console.error("Failed to perform health check:",e),e}},Q=async e=>{try{let l=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async(e,l,t)=>{try{let l=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},el=async e=>{try{let l=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,l,t)=>{try{let s=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,field_value:t,config_type:"general_settings"})});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return h.ZP.success("Successfully updated value!"),r}catch(e){throw console.error("Failed to set callbacks:",e),e}},es=async(e,l)=>{try{let t=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,config_type:"general_settings"})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return h.ZP.success("Field reset on proxy"),s}catch(e){throw console.error("Failed to get callbacks:",e),e}},er=async(e,l)=>{try{let t=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},ea=async e=>{try{let l=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to call /health:",e),e}};var en=t(10384),eo=t(46453),ei=t(16450),ec=t(52273),ed=t(26780),em=t(15595),eh=t(6698),eu=t(71801),ex=t(42440),ep=t(42308),ej=t(50670),eg=t(81583),ey=t(99129),ef=t(44839),eZ=t(88707),e_=t(1861);let{Option:ew}=ej.default;var eb=e=>{let{userID:l,team:t,userRole:s,accessToken:r,data:o,setData:i}=e,[c]=eg.Z.useForm(),[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(null),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,_]=(0,n.useState)([]),w=()=>{m(!1),c.resetFields()},b=()=>{m(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==r){let e=(await P(r,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,s]);let k=async e=>{try{var t,s,a;let n=null!==(t=null==e?void 0:e.key_alias)&&void 0!==t?t:"",d=null!==(s=null==e?void 0:e.team_id)&&void 0!==s?s:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===d).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(n))throw Error("Key alias ".concat(n," already exists for team with ID ").concat(d,", please provide another key alias"));h.ZP.info("Making API Call"),m(!0);let u=await Z(r,l,e);console.log("key create Response:",u),i(e=>e?[...e,u]:[u]),x(u.key),j(u.soft_budget),h.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.useEffect)(()=>{_(t&&t.models.length>0?t.models.includes("all-proxy-models")?g:t.models:g)},[t,g]),(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(ey.Z,{title:"Create Key",visible:d,width:800,footer:null,onOk:w,onCancel:b,children:(0,a.jsxs)(eg.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:t?t.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t?t.team_alias:"",disabled:!0})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(ew,{value:"all-team-models",children:"All Team Models"},"all-team-models"),f.map(e=>(0,a.jsx)(ew,{value:e,children:e},e))]})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==t?void 0:t.max_budget)!==null&&(null==t?void 0:t.max_budget)!==void 0?null==t?void 0:t.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.max_budget&&l>t.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(t.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==t?void 0:t.budget_duration)!==null&&(null==t?void 0:t.budget_duration)!==void 0?null==t?void 0:t.budget_duration:"None"),children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==t?void 0:t.tpm_limit)!==null&&(null==t?void 0:t.tpm_limit)!==void 0?null==t?void 0:t.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.tpm_limit&&l>t.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(t.tpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==t?void 0:t.rpm_limit)!==null&&(null==t?void 0:t.rpm_limit)!==void 0?null==t?void 0:t.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.rpm_limit&&l>t.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(t.rpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Key"})})]})}),u&&(0,a.jsx)(ey.Z,{visible:d,onOk:w,onCancel:b,footer:null,children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Save your Key"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:null!=u?(0,a.jsxs)("div",{children:[(0,a.jsx)(eu.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:u})}),(0,a.jsx)(ep.CopyToClipboard,{text:u,onCopy:()=>{h.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(ei.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(eu.Z,{children:"Key being created, this might take 30s"})})]})})]})},ek=t(9454),ev=t(98941),eS=t(33393),eN=t(5),eA=t(13810),eE=t(61244),eI=t(10827),eC=t(3851),eT=t(2044),eP=t(64167),eF=t(74480),eO=t(7178),eR=t(95093),eM=t(27166);let{Option:eL}=ej.default;var eU=e=>{let{userID:l,userRole:t,accessToken:s,selectedTeam:r,data:o,setData:i,teams:c}=e,[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(!1),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(""),[k,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(!1),[A,E]=(0,n.useState)(null),[I,C]=(0,n.useState)([]),T=new Set,[F,O]=(0,n.useState)(T);(0,n.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==s&&null!==t){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),C(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[s,l,t]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,t)=>{let s=l.team_id;e.add(s)}),O(e)}},[c]);let R=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),E(e),v(!0)},M=async e=>{if(null==s)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let t=await W(s,e);console.log("handleEditSubmit: newKeyValues",t),o&&i(o.map(e=>e.token===l?t:e)),h.ZP.success("Key updated successfully"),v(!1),E(null)},L=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+l),x(!0))},U=async()=>{if(null!=p&&null!=o){try{await w(s,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(eI.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Key Alias"}),(0,a.jsx)(eF.Z,{children:"Secret Key"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(eC.Z,{children:o.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(r){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(F.has(e.team_id),", selectedTeam id: ").concat(r.team_id)),(null!=r.team_id||null===e.team_id||F.has(e.team_id))&&e.team_id!=r.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(eu.Z,{children:e.key_alias}):(0,a.jsx)(eu.Z,{children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:e.key_name})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(eT.Z,{children:null!=e.max_budget?(0,a.jsx)(eu.Z,{children:e.max_budget}):(0,a.jsx)(eu.Z,{children:"Unlimited"})}),(0,a.jsx)(eT.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:r&&r.models&&r.models.length>0?r.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{onClick:()=>{E(e),N(!0)},icon:ek.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:S,onCancel:()=>{N(!1),E(null)},footer:null,width:800,children:A&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(A.spend).toFixed(4)}catch(e){return A.spend}})()})})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.max_budget?(0,a.jsx)(a.Fragment,{children:A.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.expires?(0,a.jsx)(a.Fragment,{children:new Date(A.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(eA.Z,{className:"my-4",children:[(0,a.jsx)(ex.Z,{children:"Token Name"}),(0,a.jsx)(eu.Z,{className:"my-1",children:A.key_alias?A.key_alias:A.key_name}),(0,a.jsx)(ex.Z,{children:"Token ID"}),(0,a.jsx)(eu.Z,{className:"my-1 text-[12px]",children:A.token}),(0,a.jsx)(ex.Z,{children:"Metadata"}),(0,a.jsx)(eu.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(A.metadata)," "]})})]}),(0,a.jsx)(ei.Z,{className:"mx-auto flex items-center",onClick:()=>{N(!1),E(null)},children:"Close"})]})}),(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>R(e)}),(0,a.jsx)(eE.Z,{onClick:()=>L(e),icon:eS.Z,size:"sm"})]})]},e.token)})})]}),u&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{x(!1),j(null)},children:"Cancel"})]})]})]})})]}),A&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,token:s,onSubmit:o}=e,[i]=eg.Z.useForm(),[d,m]=(0,n.useState)(r),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1);return(0,a.jsx)(ey.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:i,onFinish:M,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let t=l.filter(e=>!d.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!d.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(t)),t.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(t,"Team models: ").concat(d.models)):Promise.resolve()}}],children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(eL,{value:"all-team-models",children:"All Team Models"},"all-team-models"),d&&d.models?d.models.includes("all-proxy-models")?I.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):d.models.map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):I.map(e=>(0,a.jsx)(eL,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==d?void 0:d.max_budget)!==null&&(null==d?void 0:d.max_budget)!==void 0?null==d?void 0:d.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&d&&null!==d.max_budget&&l>d.max_budget)throw console.log("keyTeam.max_budget: ".concat(d.max_budget)),Error("Budget cannot exceed team max budget: $".concat(d.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(eg.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(eR.Z,{value:s.team_alias,children:null==c?void 0:c.map((e,l)=>(0,a.jsx)(eM.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:k,onCancel:()=>{v(!1),E(null)},token:A,onSubmit:M})]})},eD=t(76032),eB=t(35152),ez=e=>{let{userID:l,userRole:t,accessToken:s,userSpend:r,selectedTeam:o}=e;console.log("userSpend: ".concat(r));let[i,c]=(0,n.useState)(null!==r?r:0),[d,m]=(0,n.useState)(0),[h,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(s&&l&&t&&"Admin"===t&&null==r)try{let e=await S(s);e&&(e.spend?c(e.spend):c(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(async()=>{try{if(null===l||null===t)return;if(null!==s){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),u(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,s,l]),(0,n.useEffect)(()=>{null!==r&&c(r)},[r]);let x=[];o&&o.models&&(x=o.models),x&&x.includes("all-proxy-models")?(console.log("user models:",h),x=h):x&&x.includes("all-team-models")?x=o.models:x&&0===x.length&&(x=h);let p=void 0!==i?i.toFixed(4):null;return console.log("spend in view user spend: ".concat(i)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:["Total Spend"," "]}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",p]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Team Models"})}),(0,a.jsx)(em.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(eD.Z,{children:x.map(e=>(0,a.jsx)(eB.Z,{children:(0,a.jsx)(eu.Z,{children:e})},e))})})]})})]})},eK=e=>{let{userID:l,userRole:t,selectedTeam:s,accessToken:r}=e,[o,i]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==r){let e=(await P(r,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),i(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,t]);let c=[];return s&&s.models&&(c=s.models),c&&c.includes("all-proxy-models")&&(console.log("user models:",o),c=o),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"mb-5",children:(0,a.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==s?void 0:s.team_alias})})})},eG=e=>{let l,{teams:t,setSelectedTeam:s,userRole:r}=e,o={models:[],team_id:null,team_alias:"Default Team"},[i,c]=(0,n.useState)(o);return(l="App User"===r?t:t?[...t,o]:[o],"App User"===r)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(ex.Z,{children:"Select Team"}),(0,a.jsx)(eu.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(eu.Z,{className:"mt-3 mb-3",children:[(0,a.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>s(e),children:e.team_alias},l))}):(0,a.jsxs)(eu.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},eq=t(37963),eV=t(97482);console.log("isLocal:",!1);var eW=e=>{let{userID:l,userRole:t,teams:s,keys:r,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,n.useState)(null),p=(0,o.useSearchParams)();p.get("viewSpend"),(0,o.useRouter)();let j=p.get("token"),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)([]),b={models:[],team_alias:"Default Team",team_id:null},[v,N]=(0,n.useState)(s?s[0]:b);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(j){let e=(0,eq.o)(j);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),i(l)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&g&&t&&!r&&!u){let e=sessionStorage.getItem("userModels"+l);e?w(JSON.parse(e)):(async()=>{try{let e=await k(g,l,t,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==t){let e=await S(g);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(e.teams);let s=[...e.teams];s.length>0?(console.log("response['teams']: ".concat(s)),N(s[0])):N(b),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let r=(await P(g,l,t)).data.map(e=>e.id);console.log("available_model_names:",r),w(r),console.log("userModels:",_),sessionStorage.setItem("userModels"+l,JSON.stringify(r))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,j,g,r,t]),(0,n.useEffect)(()=>{if(null!==r&&null!=v){let e=0;for(let l of r)v.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===v.team_id&&(e+=l.spend);Z(e)}else if(null!==r){let e=0;for(let l of r)e+=l.spend;Z(e)}},[v]),null==l||null==j){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==g)return null;if(null==t&&i("App Owner"),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",v),console.log("teamSpend: ".concat(f)),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eK,{userID:l,userRole:t,selectedTeam:v||null,accessToken:g}),(0,a.jsx)(ez,{userID:l,userRole:t,accessToken:g,userSpend:f,selectedTeam:v||null}),(0,a.jsx)(eU,{userID:l,userRole:t,accessToken:g,selectedTeam:v||null,data:r,setData:h,teams:s}),(0,a.jsx)(eb,{userID:l,team:v||null,userRole:t,accessToken:g,data:r,setData:h},v?v.team_id:null),(0,a.jsx)(eG,{teams:s,setSelectedTeam:N,userRole:t})]})})})},eH=t(35087),eY=t(92836),eJ=t(26734),e$=t(41608),eX=t(32126),eQ=t(23682),e0=t(47047),e1=t(76628),e2=t(25707),e4=t(44041),e5=t(38302),e8=t(28683),e3=t(1460),e6=t(78578),e7=t(63954),e9=t(90252),le=t(7905),ll=e=>{let{modelID:l,accessToken:t}=e,[s,r]=(0,n.useState)(!1),o=async()=>{try{h.ZP.info("Making API Call"),r(!0);let e=await j(t,l);console.log("model delete Response:",e),h.ZP.success("Model ".concat(l," deleted successfully")),r(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(eE.Z,{onClick:()=>r(!0),icon:eS.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:s,onOk:o,okType:"danger",onCancel:()=>r(!1),children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Delete Model"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},lt=t(97766),ls=t(46495),lr=t(18190),la=t(91118),ln=e=>{let{modelMetrics:l,modelMetricsCategories:t,customTooltip:s,premiumUser:r}=e;return r?(0,a.jsx)(la.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:t,colors:["indigo","rose"],connectNulls:!0,customTooltip:s}):(0,a.jsxs)("div",{children:[(0,a.jsx)(lr.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,a.jsx)(ei.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},lo=e=>{let{fields:l,selectedProvider:t}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,a.jsx)(ec.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})};let{Title:li,Link:lc}=eV.default;(s=r||(r={})).OpenAI="OpenAI",s.Azure="Azure",s.Anthropic="Anthropic",s.Google_AI_Studio="Google AI Studio",s.Bedrock="Amazon Bedrock",s.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",s.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",s.Databricks="Databricks";let ld={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},lm={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},lh=async(e,l,t)=>{try{let s=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(s)),console.log("received type of deployments: ".concat(typeof s)),s.forEach(async t=>{console.log("litellm_model: ".concat(t));let s={},r={};s.model=t;let a="";for(let[l,t]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==t){if("model_name"==l)a+=t;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)r[l]=t;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",t);let e={};if(t&&void 0!=t){try{e=JSON.parse(t)}catch(e){throw h.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,t]of Object.entries(e))s[l]=t}}else s[l]=t}let n={model_name:a,litellm_params:s,model_info:r},o=await x(l,n);console.log("response for model create call: ".concat(o.data))}),t.resetFields()}catch(e){h.ZP.error("Failed to create model: "+e,10)}};var lu=e=>{var l,t,s;let o,{accessToken:i,token:c,userRole:d,userID:m,modelData:x={data:[]},setModelData:j,premiumUser:g}=e,[y,f]=(0,n.useState)([]),[Z]=eg.Z.useForm(),[_,w]=(0,n.useState)(null),[b,k]=(0,n.useState)(""),[v,S]=(0,n.useState)([]),A=Object.values(r).filter(e=>isNaN(Number(e))),[P,F]=(0,n.useState)([]),[O,R]=(0,n.useState)("OpenAI"),[M,L]=(0,n.useState)(""),[U,D]=(0,n.useState)(!1),[B,z]=(0,n.useState)(null),[K,G]=(0,n.useState)([]),[q,V]=(0,n.useState)(null),[W,H]=(0,n.useState)([]),[J,$]=(0,n.useState)([]),[X,Q]=(0,n.useState)([]),[el,et]=(0,n.useState)([]),[es,en]=(0,n.useState)([]),[ep,ej]=(0,n.useState)([]),[ef,ew]=(0,n.useState)([]),[eb,ek]=(0,n.useState)([]),[eS,eL]=(0,n.useState)([]),[eU,eD]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eB,ez]=(0,n.useState)(null),[eK,eG]=(0,n.useState)(0),eq=e=>{z(e),D(!0)},eW=async e=>{if(console.log("handleEditSubmit:",e),null==i)return;let l={},t=null;for(let[s,r]of Object.entries(e))"model_id"!==s?l[s]=r:t=r;let s={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",s);try{await Y(i,s),h.ZP.success("Model updated successfully, restart server to see updates"),D(!1),z(null)}catch(e){console.log("Error occurred")}},lr=()=>{k(new Date().toLocaleString())},la=async()=>{if(!i){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eB);try{await er(i,{router_settings:{model_group_retry_policy:eB}}),h.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),h.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!i||!c||!d||!m)return;let e=async()=>{try{var e,l,t,s,r,a,n,o;let c=await p(i);F(c);let h=await N(i,m,d);console.log("Model data response:",h.data),j(h);let u=new Set;for(let e=0;e0&&(g=x[x.length-1],console.log("_initial_model_group:",g),V(g)),console.log("selectedModelGroup:",q);let y=await E(i,m,d,g,null===(e=eU.from)||void 0===e?void 0:e.toISOString(),null===(l=eU.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",y),$(y.data),Q(y.all_api_bases);let f=await I(i,g,null===(t=eU.from)||void 0===t?void 0:t.toISOString(),null===(s=eU.to)||void 0===s?void 0:s.toISOString());et(f.data),en(f.all_api_bases);let Z=await T(i,m,d,g,null===(r=eU.from)||void 0===r?void 0:r.toISOString(),null===(a=eU.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",Z),ej(Z.data),ew(Z.exception_types);let _=await C(i,m,d,g,null===(n=eU.from)||void 0===n?void 0:n.toISOString(),null===(o=eU.to)||void 0===o?void 0:o.toISOString());console.log("slowResponses:",_),eL(_);let w=(await ee(i,m,d)).router_settings;console.log("routerSettingsInfo:",w);let b=w.model_group_retry_policy,k=w.num_retries;console.log("model_group_retry_policy:",b),console.log("default_retries:",k),ez(b),eG(k)}catch(e){console.error("There was an error fetching the model data",e)}};i&&c&&d&&m&&e();let l=async()=>{let e=await u();console.log("received model cost map data: ".concat(Object.keys(e))),w(e)};null==_&&l(),lr()},[i,c,d,m,_,b]),!x||!i||!c||!d||!m)return(0,a.jsx)("div",{children:"Loading..."});let lu=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(_)),null!=_&&"object"==typeof _&&e in _)?_[e].litellm_provider:"openai";if(r){let e=r.split("/"),l=e[0];n=1===e.length?h(r):l}else n="openai";a&&(o=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,c=null==a?void 0:a.max_tokens,d=null==a?void 0:a.max_input_tokens),(null==s?void 0:s.litellm_params)&&(m=Object.fromEntries(Object.entries(null==s?void 0:s.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),x.data[e].provider=n,x.data[e].input_cost=o,x.data[e].output_cost=i,x.data[e].input_cost&&(x.data[e].input_cost=(1e6*Number(x.data[e].input_cost)).toFixed(2)),x.data[e].output_cost&&(x.data[e].output_cost=(1e6*Number(x.data[e].output_cost)).toFixed(2)),x.data[e].max_tokens=c,x.data[e].max_input_tokens=d,x.data[e].api_base=null==s?void 0:null===(t=s.litellm_params)||void 0===t?void 0:t.api_base,x.data[e].cleanedLitellmParams=m,lu.push(s.model_name),console.log(x.data[e])}if(d&&"Admin Viewer"==d){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lx=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(r).find(l=>r[l]===e);if(l){let e=ld[l];console.log("mappingResult: ".concat(e));let t=[];"object"==typeof _&&Object.entries(_).forEach(l=>{let[s,r]=l;null!==r&&"object"==typeof r&&"litellm_provider"in r&&(r.litellm_provider===e||r.litellm_provider.includes(e))&&t.push(s)}),S(t),console.log("providerModels: ".concat(v))}},lp=async()=>{try{h.ZP.info("Running health check..."),L("");let e=await ea(i);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lj=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),i&&m&&d&&l&&t){console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),V(e);try{let s=await E(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model metrics response:",s),$(s.data),Q(s.all_api_bases);let r=await I(i,e,l.toISOString(),t.toISOString());et(r.data),en(r.all_api_bases);let a=await T(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model exceptions response:",a),ej(a.data),ew(a.exception_types);let n=await C(i,m,d,e,l.toISOString(),t.toISOString());console.log("slowResponses:",n),eL(n)}catch(e){console.error("Failed to fetch model metrics",e)}}},lg=e=>{var l,t;let{payload:s,active:r}=e;if(!r||!s)return null;let n=null===(t=s[0])||void 0===t?void 0:null===(l=t.payload)||void 0===l?void 0:l.date,o=s.sort((e,l)=>l.value-e.value);if(o.length>5){let e=o.length-5;(o=o.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:s.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,a.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[n&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),o.map((e,l)=>{let t=parseFloat(e.value.toFixed(5)),s=0===t&&e.value>0?"<0.00001":t.toFixed(5);return(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:s})]},l)})]})};console.log("selectedProvider: ".concat(O)),console.log("providerModels.length: ".concat(v.length));let ly=Object.keys(r).find(e=>r[e]===O);return ly&&(o=P.find(e=>e.name===ld[ly])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eY.Z,{children:"All Models"}),(0,a.jsx)(eY.Z,{children:"Add Model"}),(0,a.jsx)(eY.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eY.Z,{children:"Model Analytics"}),(0,a.jsx)(eY.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[b&&(0,a.jsxs)(eu.Z,{children:["Last Refreshed: ",b]}),(0,a.jsx)(eE.Z,{icon:e7.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lr})]})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],onValueChange:e=>V("all"===e?"all":e),value:q||K[0],children:[(0,a.jsx)(eM.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))]})]}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"Public Model Name"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:"Provider"}),"Admin"===d&&(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"API Base"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:"Extra litellm Params"}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(eF.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:"Max Tokens"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word"},children:"Status"})]})}),(0,a.jsx)(eC.Z,{children:x.data.filter(e=>"all"===q||e.model_name===q||null==q||""===q).map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{children:e.model_name})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.provider}),"Admin"===d&&(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:e.api_base}),(0,a.jsx)(eT.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Litellm params"})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)("pre",{children:JSON.stringify(e.cleanedLitellmParams,null,2)})})]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.input_cost||e.litellm_params.input_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.output_cost||e.litellm_params.output_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)("p",{style:{fontSize:"10px"},children:["Max Tokens: ",e.max_tokens," ",(0,a.jsx)("br",{}),"Max Input Tokens: ",e.max_input_tokens]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(eN.Z,{icon:e9.Z,size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(eN.Z,{icon:le.Z,size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsxs)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>eq(e)}),(0,a.jsx)(ll,{modelID:e.model_info.id,accessToken:i})]})]},l))})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:t,model:s,onSubmit:r}=e,[n]=eg.Z.useForm(),o={},i="",c="";if(s){o=s.litellm_params,i=s.model_name;let e=s.model_info;e&&(c=e.id,console.log("model_id: ".concat(c)),o.model_id=c)}return(0,a.jsx)(ey.Z,{title:"Edit Model "+i,visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r(e),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:eW,initialValues:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:U,onCancel:()=>{D(!1),z(null)},model:B,onSubmit:eW})]}),(0,a.jsxs)(eX.Z,{className:"h-full",children:[(0,a.jsx)(li,{level:2,children:"Add new model"}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eg.Z,{form:Z,onFinish:()=>{Z.validateFields().then(e=>{lh(e,i,Z)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:O.toString(),children:A.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>{lx(e),R(e)},children:e},l))})}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(s=O.toString())?"gemini-pro":"Anthropic"==s?"claude-3-opus":"Amazon Bedrock"==s?"claude-3-opus":"Google AI Studio"==s?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===O?(0,a.jsx)(ec.Z,{placeholder:"Enter model name"}):v.length>0?(0,a.jsx)(e0.Z,{value:v,children:v.map((e,l)=>(0,a.jsx)(e1.Z,{value:e,children:e},l))}):(0,a.jsx)(ec.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==o&&o.fields.length>0&&(0,a.jsx)(lo,{fields:o.fields,selectedProvider:o.name}),"Amazon Bedrock"!=O&&"Vertex AI (Anthropic, Gemini, etc.)"!=O&&void 0===o&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(ec.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==O&&(0,a.jsx)(eg.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(ec.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(ec.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ls.Z,{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;Z.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?h.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&h.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(e_.ZP,{icon:(0,a.jsx)(lt.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==O||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==O)&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(ec.Z,{placeholder:"https://..."})}),"Azure"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(ec.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==O&&(0,a.jsxs)("div",{children:[(0,a.jsx)(eg.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(lc,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(eg.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,a.jsx)(e6.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(e3.Z,{title:"Get help on our github",children:(0,a.jsx)(eV.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(ei.Z,{onClick:lp,children:"Run `/health`"}),M&&(0,a.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:eU,onValueChange:e=>{eD(e),lj(q,e.from,e.to)}})]}),(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Model Group"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2",defaultValue:q||K[0],value:q||K[0],children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>lj(e,eU.from,eU.to),children:e},l))})]})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eY.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(eu.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),J&&X&&(0,a.jsx)(e2.Z,{title:"Model Latency",className:"h-72",data:J,showLegend:!1,index:"date",categories:X,connectNulls:!0,customTooltip:lg})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(ln,{modelMetrics:el,modelMetricsCategories:es,customTooltip:lg,premiumUser:g})})]})]})})}),(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Deployment"}),(0,a.jsx)(eF.Z,{children:"Success Responses"}),(0,a.jsxs)(eF.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(eC.Z,{children:eS.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.api_base}),(0,a.jsx)(eT.Z,{children:e.total_count}),(0,a.jsx)(eT.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(eA.Z,{className:"mt-4",children:[(0,a.jsx)(ex.Z,{children:"Exceptions per Model"}),(0,a.jsx)(e4.Z,{className:"h-72",data:ep,index:"model",categories:ef,stack:!0,colors:["indigo-300","rose-200","#ffcc33"],yAxisWidth:30})]})]}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],value:q||K[0],onValueChange:e=>V(e),children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))})]}),(0,a.jsxs)(ex.Z,{children:["Retry Policy for ",q]}),(0,a.jsx)(eu.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),lm&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(lm).map((e,l)=>{var t;let[s,r]=e,n=null==eB?void 0:null===(t=eB[q])||void 0===t?void 0:t[r];return null==n&&(n=eK),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)("td",{children:(0,a.jsx)(eZ.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{ez(l=>{var t;let s=null!==(t=null==l?void 0:l[q])&&void 0!==t?t:{};return{...null!=l?l:{},[q]:{...s,[r]:e}}})}})})]},l)})})}),(0,a.jsx)(ei.Z,{className:"mt-6 mr-8",onClick:la,children:"Save"})]})]})]})})};let{Option:lx}=ej.default;var lp=e=>{let{userID:l,accessToken:t,teams:s}=e,[r]=eg.Z.useForm(),[o,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[m,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{let e=await P(t,l,"any"),s=[];for(let l=0;l{i(!1),r.resetFields()},p=()=>{i(!1),d(null),r.resetFields()},j=async e=>{try{h.ZP.info("Making API Call"),i(!0),console.log("formValues in create user:",e);let s=await _(t,null,e);console.log("user create Response:",s),d(s.key),h.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-0",onClick:()=>i(!0),children:"+ Invite User"}),(0,a.jsxs)(ey.Z,{title:"Invite User",visible:o,width:800,footer:null,onOk:x,onCancel:p,children:[(0,a.jsx)(eu.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(eu.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(eg.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(eg.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(ej.default,{placeholder:"Select Team ID",style:{width:"100%"},children:s?s.map(e=>(0,a.jsx)(lx,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(lx,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create User"})})]})]}),c&&(0,a.jsxs)(ey.Z,{title:"User Created Successfully",visible:o,onOk:x,onCancel:p,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},lj=e=>{let{accessToken:l,token:t,keys:s,userRole:r,userID:o,teams:i,setKeys:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(0),[j,g]=n.useState(null),[y,f]=(0,n.useState)(null);return((0,n.useEffect)(()=>{if(!l||!t||!r||!o)return;let e=async()=>{try{let e=await k(l,null,r,!0,x,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&r&&o&&e()},[l,t,r,o,x]),d&&l&&t&&r&&o)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(eo.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(lp,{userID:o,accessToken:l,teams:i}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(eu.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(eJ.Z,{children:(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"User ID"}),(0,a.jsx)(eF.Z,{children:"User Email"}),(0,a.jsx)(eF.Z,{children:"User Models"}),(0,a.jsx)(eF.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User API Key Aliases"})]})}),(0,a.jsx)(eC.Z,{children:d.map(e=>{var l;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_id}),(0,a.jsx)(eT.Z,{children:e.user_email}),(0,a.jsx)(eT.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(eT.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eo.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsx)(eN.Z,{size:"xs",color:"indigo",children:e.key_aliases.filter(e=>null!==e).join(", ")}):(0,a.jsx)(eN.Z,{size:"xs",color:"gray",children:"No Keys"})})})]},e.user_id)})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})})]}),function(){if(!d)return null;let e=Math.ceil(d.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",x+1," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:0===x,onClick:()=>p(x-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",onClick:()=>{p(x+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},lg=e=>{let{teams:l,searchParams:t,accessToken:s,setTeams:r,userID:o,userRole:i}=e,[c]=eg.Z.useForm(),[d]=eg.Z.useForm(),{Title:m,Paragraph:u}=eV.default,[x,p]=(0,n.useState)(""),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(l?l[0]:null),[Z,_]=(0,n.useState)(!1),[w,k]=(0,n.useState)(!1),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)(!1),[I,C]=(0,n.useState)(null),[T,F]=(0,n.useState)({}),O=e=>{f(e),g(!0)},R=async e=>{let t=e.team_id;if(console.log("handleEditSubmit:",e),null==s)return;let a=await H(s,e);l&&r(l.map(e=>e.team_id===t?a.data:e)),h.ZP.success("Team updated successfully"),g(!1),f(null)},M=async e=>{C(e),E(!0)},L=async()=>{if(null!=I&&null!=l&&null!=s){try{await b(s,I);let e=l.filter(e=>e.team_id!==I);r(e)}catch(e){console.error("Error deleting the team:",e)}E(!1),C(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{if(null===o||null===i||null===s||null===l)return;console.log("fetching team info:");let e={};for(let t=0;t<(null==l?void 0:l.length);t++){let r=l[t].team_id,a=await v(s,r);console.log("teamInfo response:",a),null!==a&&(e={...e,[r]:a})}F(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===o||null===i)return;if(null!==s){let e=(await P(s,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,o,i,l]);let U=async e=>{try{if(null!=s){var t;let a=null==e?void 0:e.team_alias;if((null!==(t=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==t?t:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));h.ZP.info("Creating Team");let n=await V(s,e);null!==l?r([...l,n]):r([n]),console.log("response for team create call: ".concat(n)),h.ZP.success("Team created"),_(!1)}}catch(e){console.error("Error creating the team:",e),h.ZP.error("Error creating the team: "+e,20)}},D=async e=>{try{if(null!=s&&null!=l){h.ZP.info("Adding Member");let t={role:"user",user_email:e.user_email,user_id:e.user_id},a=await J(s,y.team_id,t);console.log("response for team create call: ".concat(a.data));let n=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(n)),-1!==n){let e=[...l];e[n]=a.data,r(e),f(a.data)}k(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Team Name"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(eF.Z,{children:"Info"})]})}),(0,a.jsx)(eC.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(eT.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].keys&&T[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].team_info&&T[e.team_id].team_info.members_with_roles&&T[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>O(e)}),(0,a.jsx)(eE.Z,{onClick:()=>M(e.team_id),icon:eS.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{E(!1),C(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>_(!0),children:"+ Create New Team"}),(0,a.jsx)(ey.Z,{title:"Create Team",visible:Z,width:800,footer:null,onOk:()=>{_(!1),c.resetFields()},onCancel:()=>{_(!1),c.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:U,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{f(e)},children:e.team_alias},l))}):(0,a.jsxs)(u,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:y?y.members_with_roles.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.role})]},l)):null})]})}),y&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,team:s,onSubmit:r}=e,[n]=eg.Z.useForm();return(0,a.jsx)(ey.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:s.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:R,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:j,onCancel:()=>{g(!1),f(null)},team:y,onSubmit:R})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-5",onClick:()=>k(!0),children:"+ Add member"}),(0,a.jsx)(ey.Z,{title:"Add member",visible:w,width:800,footer:null,onOk:()=>{k(!1),d.resetFields()},onCancel:()=>{k(!1),d.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:D,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},ly=e=>{let l,{searchParams:t,accessToken:s,showSSOBanner:r}=e,[o]=eg.Z.useForm(),[i]=eg.Z.useForm(),{Title:c,Paragraph:d}=eV.default,[m,u]=(0,n.useState)(""),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(!1),[Z,_]=(0,n.useState)(!1),[w,b]=(0,n.useState)(!1),[k,v]=(0,n.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let S=()=>{v(!1)},N=["proxy_admin","proxy_admin_viewer"];(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await q(s,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let t=await q(s,"proxy_admin");t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(t)),console.log("combinedList: ".concat(e)),p(e)}})()},[s]);let A=()=>{_(!1),i.resetFields()},E=()=>{_(!1),i.resetFields()},I=e=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]}),C=(e,l,t)=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:l,children:N.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:t,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update role"})})]}),T=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,null);console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),h.ZP.success("Refresh tab to see updated user role"),_(!1)}}catch(e){console.error("Error creating the key:",e)}},P=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),g(!1)}}catch(e){console.error("Error creating the key:",e)}},F=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await $(s,e,"proxy_admin");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),f(!1)}}catch(e){console.error("Error creating the key:",e)}},O=async e=>{null!=s&&er(s,{environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}})};return console.log("admins: ".concat(null==x?void 0:x.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(c,{level:4,children:"Admin Access "}),(0,a.jsxs)(d,{children:[r&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc. ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:x?x.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.user_role}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>_(!0)}),(0,a.jsx)(ey.Z,{title:"Update role",visible:Z,width:800,footer:null,onOk:A,onCancel:E,children:C(T,e.user_role,e.user_id)})]})]},l)):null})]})})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(ei.Z,{className:"mr-4 mb-5",onClick:()=>f(!0),children:"+ Add admin"}),(0,a.jsx)(ey.Z,{title:"Add admin",visible:y,width:800,footer:null,onOk:()=>{f(!1),i.resetFields()},onCancel:()=>{f(!1),i.resetFields()},children:I(F)}),(0,a.jsx)(ei.Z,{className:"mb-5",onClick:()=>g(!0),children:"+ Add viewer"}),(0,a.jsx)(ey.Z,{title:"Add viewer",visible:j,width:800,footer:null,onOk:()=>{g(!1),i.resetFields()},onCancel:()=>{g(!1),i.resetFields()},children:I(P)})]})})]}),(0,a.jsxs)(eo.Z,{children:[(0,a.jsx)(c,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(ei.Z,{onClick:()=>b(!0),children:"Add SSO"}),(0,a.jsx)(ey.Z,{title:"Add SSO",visible:w,width:800,footer:null,onOk:()=>{b(!1),o.resetFields()},onCancel:()=>{b(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{F(e),O(e),b(!1),v(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(ef.Z.Password,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(ef.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(ey.Z,{title:"SSO Setup Instructions",visible:k,width:800,footer:null,onOk:S,onCancel:()=>{v(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{onClick:S,children:"Done"})})]})]}),(0,a.jsxs)(lr.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},lf=t(42556),lZ=e=>{let{alertingSettings:l,handleInputChange:t,handleResetField:s,handleSubmit:r,premiumUser:n}=e,[o]=eg.Z.useForm();return(0,a.jsxs)(eg.Z,{form:o,onFinish:()=>{let e=o.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):r(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{align:"center",children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?n?(0,a.jsx)(eg.Z.Item,{name:e.field_name,children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l)}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}):(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(eg.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l),className:"p-0"}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>s(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update Settings"})})]})},l_=e=>{let{accessToken:l,premiumUser:t}=e,[s,r]=(0,n.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,n.useEffect)(()=>{l&&f(l).then(e=>{r(e)})},[l]),(0,a.jsx)(lZ,{alertingSettings:s,handleInputChange:(e,l)=>{r(s.map(t=>t.field_name===e?{...t,field_value:l}:t))},handleResetField:(e,t)=>{if(l)try{let l=s.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),r(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let t={};s.forEach(e=>{t[e.field_name]=e.field_value});let r={...e,...t};try{et(l,"alerting_args",r),h.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:t})};let lw=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var lb=e=>{let{accessToken:l,userRole:t,userID:s,premiumUser:r}=e,[o,i]=(0,n.useState)(lw),[c,d]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[x]=eg.Z.useForm(),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,Z]=(0,n.useState)(""),[_,w]=(0,n.useState)({}),[b,k]=(0,n.useState)([]),v=e=>{b.includes(e)?k(b.filter(l=>l!==e)):k([...b,e])},S={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,n.useEffect)(()=>{l&&t&&s&&ee(l,s,t).then(e=>{console.log("callbacks",e);let l=lw;i(l=l.map(l=>{let t=e.callbacks.find(e=>e.name===l.name);return t?{...l,variables:{...l.variables,...t.variables}}:l}));let t=e.alerts;if(console.log("alerts_data",t),t&&t.length>0){let e=t[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),k(e.active_alerts),Z(l),w(e.alerts_to_webhook)}d(t)})},[l,t,s]);let N=e=>b&&b.includes(e),A=e=>{if(!l)return;let t=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[t,s]=e;return[t,(null===(l=document.querySelector('input[name="'.concat(t,'"]')))||void 0===l?void 0:l.value)||s]}));console.log("updatedVariables",t),console.log("updateAlertTypes",g);let s={environment_variables:t,litellm_settings:{success_callback:[e.name]}};try{er(l,s)}catch(e){h.ZP.error("Failed to update callback: "+e,20)}h.ZP.success("Callback updated successfully")},E=()=>{l&&x.validateFields().then(e=>{if(console.log("Form values:",e),"langfuse"===e.callback){er(l,{environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),er(l,{general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}}),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),er(l,{environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};i(o?[...o,t]:[t])}u(!1),x.resetFields(),j(null)})};return l?(console.log("callbacks: ".concat(o)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(lr.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Settings"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Callback"}),(0,a.jsx)(eF.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(eC.Z,{children:o.filter(e=>"slack"!==e.name).map((e,t)=>{var s;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eN.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).filter(l=>{let[t,s]=l;return t.toLowerCase().includes(e.name)}).map(e=>{let[l,t]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(eu.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(ec.Z,{name:l,defaultValue:t,type:"password"})]},l)})}),(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(e),children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,e.name),className:"mx-2",children:"Test Callback"})]})]},t)})})]})})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eu.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(S).map((e,l)=>{let[t,s]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:"region_outage_alerts"==t?r?(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)}):(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:t,type:"password",defaultValue:_&&_[t]?_[t]:f})})]},l)})})]}),(0,a.jsx)(ei.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(S).forEach(l=>{let[t,s]=l,r=document.querySelector('input[name="'.concat(t,'"]'));console.log("key",t),console.log("webhookInput",r);let a=(null==r?void 0:r.value)||"";console.log("newWebhookValue",a),e[t]=a}),console.log("updatedAlertToWebhooks",e);let t={general_settings:{alert_to_webhook_url:e,alert_types:b}};console.log("payload",t);try{er(l,t)}catch(e){h.ZP.error("Failed to update alerts: "+e,20)}h.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(l_,{accessToken:l,premiumUser:r})})]})]})]}),(0,a.jsx)(ey.Z,{title:"Add Callback",visible:m,onOk:E,width:800,onCancel:()=>{u(!1),x.resetFields(),j(null)},footer:null,children:(0,a.jsxs)(eg.Z,{form:x,layout:"vertical",onFinish:E,children:[(0,a.jsx)(eg.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(ej.default,{onChange:e=>{j(e)},children:[(0,a.jsx)(ej.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(ej.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(ec.Z,{type:"password"})}),(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})]}),"openmeter"==p&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eg.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:lk}=ej.default;var lv=e=>{let{models:l,accessToken:t,routerSettings:s,setRouterSettings:r}=e,[o]=eg.Z.useForm(),[i,c]=(0,n.useState)(!1),[d,m]=(0,n.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>c(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(ey.Z,{title:"Add Fallbacks",visible:i,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,n=[...s.fallbacks||[],{[l]:a}],i={...s,fallbacks:n};console.log(i);try{er(t,{router_settings:i}),r(i)}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully"),c(!1),o.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(eR.Z,{defaultValue:d,children:l&&l.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(e0.Z,{value:l,children:l&&l.filter(e=>e!=d).map(e=>(0,a.jsx)(e1.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lS=t(12968);async function lN(e,l){console.log("isLocal:",!1);let t=window.location.origin,s=new lS.ZP.OpenAI({apiKey:l,baseURL:t,dangerouslyAllowBrowser:!0});try{let l=await s.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});h.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lA={ttl:3600,lowest_latency_buffer:0},lE=e=>{let{selectedStrategy:l,strategyArgs:t,paramExplanation:s}=e;return(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(em.Z,{children:"latency-based-routing"==l?(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(t).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:s[l]})]}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]})}):(0,a.jsx)(eu.Z,{children:"No specific settings"})})]})};var lI=e=>{let{accessToken:l,userRole:t,userID:s,modelData:r}=e,[o,i]=(0,n.useState)({}),[c,d]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1),[j]=eg.Z.useForm(),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)(null),b={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,n.useEffect)(()=>{l&&t&&s&&(ee(l,s,t).then(e=>{console.log("callbacks",e),i(e.router_settings)}),el(l).then(e=>{u(e)}))},[l,t,s]);let k=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(o.fallbacks)),o.fallbacks.map(l=>(e in l&&delete l[e],l));try{await er(l,{router_settings:o}),i({...o}),Z(o.routing_strategy),h.ZP.success("Router settings updated successfully")}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}}},v=(e,l)=>{u(m.map(t=>t.field_name===e?{...t,field_value:l}:t))},S=(e,t)=>{if(!l)return;let s=m[t].field_value;if(null!=s&&void 0!=s)try{et(l,e,s);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(t)}catch(e){}},N=(e,t)=>{if(l)try{es(l,e);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(t)}catch(e){}},A=e=>{if(!l)return;console.log("router_settings",e);let t=Object.fromEntries(Object.entries(e).map(e=>{let[l,t]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var s;return[l,(null===(s=document.querySelector('input[name="'.concat(l,'"]')))||void 0===s?void 0:s.value)||t]}if("routing_strategy"==l)return[l,f];if("routing_strategy_args"==l&&"latency-based-routing"==f){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),t=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==t?void 0:t.value)&&(e.ttl=Number(t.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",t);try{er(l,{router_settings:t})}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eY.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eY.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(ex.Z,{children:"Router Settings"}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(o).filter(e=>{let[l,t]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:b[l]})]}),(0,a.jsx)(eT.Z,{children:"routing_strategy"==l?(0,a.jsxs)(eR.Z,{defaultValue:t,className:"w-full max-w-md",onValueChange:Z,children:[(0,a.jsx)(eM.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(eM.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(eM.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]}),(0,a.jsx)(lE,{selectedStrategy:f,strategyArgs:o&&o.routing_strategy_args&&Object.keys(o.routing_strategy_args).length>0?o.routing_strategy_args:lA,paramExplanation:b})]}),(0,a.jsx)(en.Z,{children:(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(o),children:"Save Changes"})})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Model Name"}),(0,a.jsx)(eF.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(eC.Z,{children:o.fallbacks&&o.fallbacks.map((e,t)=>Object.entries(e).map(e=>{let[s,r]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:s}),(0,a.jsx)(eT.Z,{children:Array.isArray(r)?r.join(", "):r}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{onClick:()=>lN(s,l),children:"Test Fallback"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>k(s)})})]},t.toString()+s)}))})]}),(0,a.jsx)(lv,{models:(null==r?void 0:r.data)?r.data.map(e=>e.model_name):[],accessToken:l,routerSettings:o,setRouterSettings:i})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"}),(0,a.jsx)(eF.Z,{children:"Status"}),(0,a.jsx)(eF.Z,{children:"Action"})]})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(eT.Z,{children:"Integer"==e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>v(e.field_name,l)}):null}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(ei.Z,{onClick:()=>S(e.field_name,l),children:"Update"}),(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>N(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lC=e=>{let{isModalVisible:l,accessToken:t,setIsModalVisible:s,setBudgetList:r}=e,[n]=eg.Z.useForm(),o=async e=>{if(null!=t&&void 0!=t)try{h.ZP.info("Making API Call");let l=await y(t,e);console.log("key create Response:",l),r(e=>e?[...e,l]:[l]),h.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(ey.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{s(!1),n.resetFields()},onCancel:()=>{s(!1),n.resetFields()},children:(0,a.jsxs)(eg.Z,{form:n,onFinish:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lT=t(67951),lP=e=>{let{accessToken:l}=e,[t,s]=(0,n.useState)(!1),[r,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&Q(l).then(e=>{o(e)})},[l]);let i=async(e,t)=>{if(null==l)return;h.ZP.info("Request made"),await g(l,e);let s=[...r];s.splice(t,1),o(s),h.ZP.success("Budget Deleted.")};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(ei.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>s(!0),children:"+ Create Budget"}),(0,a.jsx)(lC,{accessToken:l,isModalVisible:t,setIsModalVisible:s,setBudgetList:o}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Budget ID"}),(0,a.jsx)(eF.Z,{children:"Max Budget"}),(0,a.jsx)(eF.Z,{children:"TPM"}),(0,a.jsx)(eF.Z,{children:"RPM"})]})}),(0,a.jsx)(eC.Z,{children:r.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.budget_id}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(eT.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(eT.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>i(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(eu.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eY.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eY.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{let{userID:l,userRole:t,token:s,accessToken:r,keys:o,premiumUser:i}=e,[c,d]=(0,n.useState)(null),[m,h]=(0,n.useState)(!1),[u,x]=(0,n.useState)(null);(0,n.useEffect)(()=>{r&&s&&t&&l&&(async()=>{try{let e=await A(r,l,t);console.log("ModelHubData:",e),d(e.data)}catch(e){console.error("There was an error fetching the model data",e)}})()},[r,s,t,l]);let p=e=>{x(e),h(!0)},j=e=>{navigator.clipboard.writeText(e)};return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)("div",{className:"relative w-full"}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(ex.Z,{className:"ml-8 text-center ",children:"Model Hub"}),(0,a.jsx)(ei.Z,{className:"ml-4",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Share"})})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4",children:c&&c.map(e=>(0,a.jsxs)(eA.Z,{className:"mt-5 mx-8",children:[(0,a.jsxs)("pre",{className:"flex justify-between",children:[(0,a.jsx)(ex.Z,{children:e.model_group}),(0,a.jsx)(e3.Z,{title:e.model_group,children:(0,a.jsx)(lF.Z,{onClick:()=>j(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,a.jsxs)("div",{className:"my-5",children:[(0,a.jsxs)(eu.Z,{children:["Mode: ",e.mode]}),(0,a.jsxs)(eu.Z,{children:["Supports Function Calling: ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Supports Vision: ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Max Input Tokens: ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,a.jsxs)(eu.Z,{children:["Max Output Tokens: ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,a.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,a.jsxs)("a",{href:"#",onClick:()=>p(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,a.jsx)(lO.Z,{})]})})]},e.model_group))})]}),(0,a.jsx)(ey.Z,{title:"Model Usage",width:800,visible:m,footer:null,onOk:()=>{h(!1),x(null)},onCancel:()=>{h(!1),x(null)},children:u&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Model Name:"})," ",u.model_group]}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(u.model_group,'", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="'.concat(u.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "'.concat(u.model_group,'",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})]})},lM=e=>{let{}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(eu.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n '})})]})]})]})})})};async function lL(e,l,t,s){console.log("isLocal:",!1);let r=window.location.origin,a=new lS.ZP.OpenAI({apiKey:s,baseURL:r,dangerouslyAllowBrowser:!0});try{for await(let s of(await a.chat.completions.create({model:t,stream:!0,messages:[{role:"user",content:e}]})))console.log(s),s.choices[0].delta.content&&l(s.choices[0].delta.content)}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lU=e=>{let{accessToken:l,token:t,userRole:s,userID:r}=e,[o,i]=(0,n.useState)(""),[c,d]=(0,n.useState)(""),[m,h]=(0,n.useState)([]),[u,x]=(0,n.useState)(void 0),[p,j]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{let e=await P(l,r,s);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));console.log(l),j(l),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,r,s]);let g=(e,l)=>{h(t=>{let s=t[t.length-1];return s&&s.role===e?[...t.slice(0,t.length-1),{role:e,content:s.content+l}]:[...t,{role:e,content:l}]})},y=async()=>{if(""!==c.trim()&&o&&t&&s&&r){h(e=>[...e,{role:"user",content:c}]);try{u&&await lL(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsx)(e$.Z,{children:(0,a.jsx)(eY.Z,{children:"Chat"})}),(0,a.jsx)(eQ.Z,{children:(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"API Key"}),(0,a.jsx)(ec.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,a.jsxs)(en.Z,{className:"mx-2",children:[(0,a.jsx)(eu.Z,{children:"Select Model:"}),(0,a.jsx)(ej.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,a.jsxs)(eI.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{})})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(ec.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,a.jsx)(ei.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]})})]})})})})},lD=t(33509),lB=t(95781);let{Sider:lz}=lD.default;var lK=e=>{let{setPage:l,userRole:t,defaultSelectedKey:s}=e;return"Admin Viewer"==t?(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(lz,{width:120,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(lz,{width:145,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(eu.Z,{children:"API Keys"})},"1"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(eu.Z,{children:"Test Key"})},"3"),"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(eu.Z,{children:"Models"})},"2"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(eu.Z,{children:"Usage"})},"4"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(eu.Z,{children:"Teams"})},"6"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(eu.Z,{children:"Users"})},"5"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(eu.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(eu.Z,{children:"Rate Limits"})},"9"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(eu.Z,{children:"Router Settings"})},"10"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(eu.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(eu.Z,{children:"API Reference"})},"12"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(eu.Z,{children:"Model Hub"})},"14")]})})})},lG=t(67989),lq=t(49167),lV=t(52703),lW=e=>{let{accessToken:l,token:t,userRole:s,userID:r,keys:o,premiumUser:i}=e,c=new Date,[d,m]=(0,n.useState)([]),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)([]),[j,g]=(0,n.useState)([]),[y,f]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[w,b]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)({}),[I,C]=(0,n.useState)([]),[T,P]=(0,n.useState)(""),[q,V]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),W=new Date(c.getFullYear(),c.getMonth(),1),H=new Date(c.getFullYear(),c.getMonth()+1,0),Y=Q(W),J=Q(H);console.log("keys in usage",o),console.log("premium user in usage",i);let $=async(e,t,s)=>{if(!e||!t||!l)return;t.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",s);let r=await U(l,s,e.toISOString(),t.toISOString());console.log("End user data updated successfully",r),g(r)},X=async(e,t)=>{e&&t&&l&&(t.setHours(23,59,59,999),e.setHours(0,0,0,0),_((await O(l,e.toISOString(),t.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function Q(e){let l=e.getFullYear(),t=e.getMonth()+1,s=e.getDate();return"".concat(l,"-").concat(t<10?"0"+t:t,"-").concat(s<10?"0"+s:s)}return console.log("Start date is ".concat(Y)),console.log("End date is ".concat(J)),(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{if(console.log("user role: ".concat(s)),"Admin"==s||"Admin Viewer"==s){var e,a;let s=await M(l);m(s);let r=await D(l,t,Y,J);console.log("provider_spend",r),N(r);let n=(await L(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));u(n);let o=(await K(l)).map(e=>({key:e.model,spend:e.total_spend}));p(o);let i=await F(l);console.log("teamSpend",i),f(i.daily_spend),b(i.teams);let c=i.total_spend_per_team;c=c.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),v(c);let d=await O(l,null===(e=q.from)||void 0===e?void 0:e.toISOString(),null===(a=q.to)||void 0===a?void 0:a.toISOString());_(d.spend_per_tag);let h=await U(l,null,void 0,void 0);g(h),console.log("spend/user result",h);let x=await B(l,Y,J);E(x);let j=await z(l,Y,J);console.log("global activity per model",j),C(j)}else"App Owner"==s&&await R(l,t,s,r,Y,J).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let t=e.top_api_keys;u(t)}else{let t=(await G(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[t,s]=e;"spend"!==t&&"startTime"!==t&&"models"!==t&&"users"!==t&&l.push({key:t,spend:s})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let t=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(t[0]))),t}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));u(t),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,t,s,r,Y,J]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(ez,{userID:r,userRole:s,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{className:"mt-2",children:[(0,a.jsx)(eY.Z,{children:"All Up"}),(0,a.jsx)(eY.Z,{children:"Team Based Usage"}),(0,a.jsx)(eY.Z,{children:"End User Usage"}),(0,a.jsx)(eY.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eY.Z,{children:"Cost"}),(0,a.jsx)(eY.Z,{children:"Activity"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Monthly Spend"}),(0,a.jsx)(e4.Z,{data:d,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top API Keys"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top Models"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:x,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1}),(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"✨ Spend by Provider"}),i?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(lV.Z,{className:"mt-4 h-40",variant:"pie",data:S,index:"provider",category:"spend"})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Provider"}),(0,a.jsx)(eF.Z,{children:"Spend"})]})}),(0,a.jsx)(eC.Z,{children:S.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.provider}),(0,a.jsx)(eT.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"All Up"}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",A.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",A.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),i?(0,a.jsx)(a.Fragment,{children:I.map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:I&&I.length>0&&I.slice(0,1).map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lG.Z,{data:k})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(e4.Z,{className:"h-72",data:y,showLegend:!0,index:"date",categories:w,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:q,onValueChange:e=>{V(e),$(e.from,e.to,null)}})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Key"}),(0,a.jsxs)(eR.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(eM.Z,{value:"all-keys",onClick:()=>{$(q.from,q.to,null)},children:"All Keys"},"all-keys"),null==o?void 0:o.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{$(q.from,q.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(eA.Z,{className:"mt-4",children:(0,a.jsxs)(eI.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"End User"}),(0,a.jsx)(eF.Z,{children:"Spend"}),(0,a.jsx)(eF.Z,{children:"Total Events"})]})}),(0,a.jsx)(eC.Z,{children:null==j?void 0:j.map((e,l)=>{var t;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.end_user}),(0,a.jsx)(eT.Z,{children:null===(t=e.total_spend)||void 0===t?void 0:t.toFixed(4)}),(0,a.jsx)(eT.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsx)(eH.Z,{className:"mb-4",enableSelect:!0,value:q,onValueChange:e=>{V(e),X(e.from,e.to)}}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(eu.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(e4.Z,{className:"h-72",data:Z,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})})]})]})]})},lH=()=>{let{Title:e,Paragraph:l}=eV.default,[t,s]=(0,n.useState)(""),[r,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!0),y=(0,o.useSearchParams)(),[f,Z]=(0,n.useState)({data:[]}),_=y.get("userID"),w=y.get("token"),[b,k]=(0,n.useState)("api-keys"),[v,S]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(w){let e=(0,eq.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),S(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),s(l),"Admin Viewer"==l&&k("usage")}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&i(e.premium_user)}}},[w]),(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:_,userRole:t,userEmail:c,showSSOBanner:j,premiumUser:r}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lK,{setPage:k,userRole:t,defaultSelectedKey:null})}),"api-keys"==b?(0,a.jsx)(eW,{userID:_,userRole:t,teams:h,keys:x,setUserRole:s,userEmail:c,setUserEmail:d,setTeams:u,setKeys:p}):"models"==b?(0,a.jsx)(lu,{userID:_,userRole:t,token:w,accessToken:v,modelData:f,setModelData:Z,premiumUser:r}):"llm-playground"==b?(0,a.jsx)(lU,{userID:_,userRole:t,token:w,accessToken:v}):"users"==b?(0,a.jsx)(lj,{userID:_,userRole:t,token:w,keys:x,teams:h,accessToken:v,setKeys:p}):"teams"==b?(0,a.jsx)(lg,{teams:h,setTeams:u,searchParams:y,accessToken:v,userID:_,userRole:t}):"admin-panel"==b?(0,a.jsx)(ly,{setTeams:u,searchParams:y,accessToken:v,showSSOBanner:j}):"api_ref"==b?(0,a.jsx)(lM,{}):"settings"==b?(0,a.jsx)(lb,{userID:_,userRole:t,accessToken:v,premiumUser:r}):"budgets"==b?(0,a.jsx)(lP,{accessToken:v}):"general-settings"==b?(0,a.jsx)(lI,{userID:_,userRole:t,accessToken:v,modelData:f}):"model-hub"==b?(0,a.jsx)(lR,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r}):(0,a.jsx)(lW,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r})]})]})})}}},function(e){e.O(0,[936,608,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]); \ No newline at end of file +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,t){Promise.resolve().then(t.bind(t,39712))},39712:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return lH}});var s,r,a=t(3827),n=t(64090),o=t(47907),i=t(8792),c=t(40491),d=t(65270),m=e=>{let{userID:l,userRole:t,userEmail:s,showSSOBanner:r,premiumUser:n}=e;console.log("User ID:",l),console.log("userEmail:",s),console.log("showSSOBanner:",r),console.log("premiumUser:",n);let o=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",t]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(i.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[r?(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(c.Z,{menu:{items:o},children:(0,a.jsx)(d.Z,{children:s})})})]})]})},h=t(80588);let u=async()=>{try{let e=await fetch("https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"),l=await e.json();return console.log("received data: ".concat(l)),l}catch(e){throw console.error("Failed to get model cost map:",e),e}},x=async(e,l)=>{try{let t=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),s}catch(e){throw console.error("Failed to create key:",e),e}},p=async e=>{try{let l=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},j=async(e,l)=>{console.log("model_id in model delete call: ".concat(l));try{let t=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model deleted successfully. Restart server to see this."),s}catch(e){throw console.error("Failed to create key:",e),e}},g=async(e,l)=>{if(console.log("budget_id in budget delete call: ".concat(l)),null!=e)try{let t=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,l)=>{try{console.log("Form Values in budgetCreateCall:",l),console.log("Form Values after check:",l);let t=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},f=async e=>{try{let l=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},Z=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,l)=>{try{console.log("in keyDeleteCall:",l);let t=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,l)=>{try{console.log("in teamDeleteCall:",l);let t=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,l,t){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;try{let n="/user/info";"App Owner"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),"App User"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),console.log("in userInfoCall viewAll=",s),s&&a&&null!=r&&void 0!=r&&(n="".concat(n,"?view_all=true&page=").concat(r,"&page_size=").concat(a));let o=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let i=await o.json();return console.log("API Response:",i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,l)=>{try{let t="/team/info";l&&(t="".concat(t,"?team_id=").concat(l)),console.log("in teamInfoCall");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},S=async e=>{try{let l=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,l,t)=>{try{let l=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelInfoCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,l,t)=>{try{let l=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelHubCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,l,t,s,r,a)=>{try{let l="/model/metrics";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},I=async(e,l,t,s)=>{try{let r="/model/streaming_metrics";l&&(r="".concat(r,"?_selected_model_group=").concat(l,"&startTime=").concat(t,"&endTime=").concat(s));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},C=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/slow_responses";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/exceptions";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,l,t)=>{try{let l=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},F=async e=>{try{let l="/global/spend/teams";console.log("in teamSpendLogsCall:",l);let t=await fetch("".concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=async(e,l,t)=>{try{let s="/global/spend/tags";l&&t&&(s="".concat(s,"?start_date=").concat(l,"&end_date=").concat(t)),console.log("in tagsSpendLogsCall:",s);let r=await fetch("".concat(s),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},R=async(e,l,t,s,r,a)=>{try{console.log("user role in spend logs call: ".concat(t));let l="/spend/logs";l="App Owner"==t?"".concat(l,"?user_id=").concat(s,"&start_date=").concat(r,"&end_date=").concat(a):"".concat(l,"?start_date=").concat(r,"&end_date=").concat(a);let n=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},M=async e=>{try{let l=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},L=async e=>{try{let l=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,l,t,s)=>{try{let r="";r=l?JSON.stringify({api_key:l,startTime:t,endTime:s}):JSON.stringify({startTime:t,endTime:s});let a={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};a.body=r;let n=await fetch("/global/spend/end_users",a);if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,l,t,s)=>{try{let r="/global/spend/provider";t&&s&&(r+="?start_date=".concat(t,"&end_date=").concat(s)),l&&(r+="&api_key=".concat(l));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log(n),n}catch(e){throw console.error("Failed to fetch spend data:",e),e}},B=async(e,l,t)=>{try{let s="/global/activity";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},z=async(e,l,t)=>{try{let s="/global/activity/model";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},K=async e=>{try{let l=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},G=async(e,l)=>{try{let t=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},q=async(e,l)=>{try{let t="/user/get_users?role=".concat(l);console.log("in userGetAllUsersCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let r=await s.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},V=async(e,l)=>{try{console.log("Form Values in teamCreateCall:",l);let t=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,l)=>{try{console.log("Form Values in keyUpdateCall:",l);let t=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},H=async(e,l)=>{try{console.log("Form Values in teamUpateCall:",l);let t=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},Y=async(e,l)=>{try{console.log("Form Values in modelUpateCall:",l);let t=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update model Response:",s),s}catch(e){throw console.error("Failed to update model:",e),e}},J=async(e,l,t)=>{try{console.log("Form Values in teamMemberAddCall:",t);let s=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:l,member:t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},$=async(e,l,t)=>{try{console.log("Form Values in userUpdateUserCall:",l);let s={...l};null!==t&&(s.user_role=t),s=JSON.stringify(s);let r=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:s});if(!r.ok){let e=await r.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await r.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,l)=>{try{let t="/health/services?service=".concat(l);console.log("Checking Slack Budget Alerts service health");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed ".concat(l," service health check ")+e),Error(e)}let r=await s.json();return h.ZP.success("Test request to ".concat(l," made - check logs/alerts on ").concat(l," to verify")),r}catch(e){throw console.error("Failed to perform health check:",e),e}},Q=async e=>{try{let l=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async(e,l,t)=>{try{let l=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},el=async e=>{try{let l=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,l,t)=>{try{let s=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,field_value:t,config_type:"general_settings"})});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return h.ZP.success("Successfully updated value!"),r}catch(e){throw console.error("Failed to set callbacks:",e),e}},es=async(e,l)=>{try{let t=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,config_type:"general_settings"})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return h.ZP.success("Field reset on proxy"),s}catch(e){throw console.error("Failed to get callbacks:",e),e}},er=async(e,l)=>{try{let t=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},ea=async e=>{try{let l=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to call /health:",e),e}};var en=t(10384),eo=t(46453),ei=t(16450),ec=t(52273),ed=t(26780),em=t(15595),eh=t(6698),eu=t(71801),ex=t(42440),ep=t(42308),ej=t(50670),eg=t(81583),ey=t(99129),ef=t(44839),eZ=t(88707),e_=t(1861);let{Option:ew}=ej.default;var eb=e=>{let{userID:l,team:t,userRole:s,accessToken:r,data:o,setData:i}=e,[c]=eg.Z.useForm(),[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(null),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,_]=(0,n.useState)([]),w=()=>{m(!1),c.resetFields()},b=()=>{m(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==r){let e=(await P(r,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,s]);let k=async e=>{try{var t,s,a;let n=null!==(t=null==e?void 0:e.key_alias)&&void 0!==t?t:"",d=null!==(s=null==e?void 0:e.team_id)&&void 0!==s?s:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===d).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(n))throw Error("Key alias ".concat(n," already exists for team with ID ").concat(d,", please provide another key alias"));h.ZP.info("Making API Call"),m(!0);let u=await Z(r,l,e);console.log("key create Response:",u),i(e=>e?[...e,u]:[u]),x(u.key),j(u.soft_budget),h.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.useEffect)(()=>{_(t&&t.models.length>0?t.models.includes("all-proxy-models")?g:t.models:g)},[t,g]),(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(ey.Z,{title:"Create Key",visible:d,width:800,footer:null,onOk:w,onCancel:b,children:(0,a.jsxs)(eg.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:t?t.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t?t.team_alias:"",disabled:!0})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(ew,{value:"all-team-models",children:"All Team Models"},"all-team-models"),f.map(e=>(0,a.jsx)(ew,{value:e,children:e},e))]})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==t?void 0:t.max_budget)!==null&&(null==t?void 0:t.max_budget)!==void 0?null==t?void 0:t.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.max_budget&&l>t.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(t.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==t?void 0:t.budget_duration)!==null&&(null==t?void 0:t.budget_duration)!==void 0?null==t?void 0:t.budget_duration:"None"),children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==t?void 0:t.tpm_limit)!==null&&(null==t?void 0:t.tpm_limit)!==void 0?null==t?void 0:t.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.tpm_limit&&l>t.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(t.tpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==t?void 0:t.rpm_limit)!==null&&(null==t?void 0:t.rpm_limit)!==void 0?null==t?void 0:t.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.rpm_limit&&l>t.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(t.rpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Key"})})]})}),u&&(0,a.jsx)(ey.Z,{visible:d,onOk:w,onCancel:b,footer:null,children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Save your Key"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:null!=u?(0,a.jsxs)("div",{children:[(0,a.jsx)(eu.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:u})}),(0,a.jsx)(ep.CopyToClipboard,{text:u,onCopy:()=>{h.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(ei.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(eu.Z,{children:"Key being created, this might take 30s"})})]})})]})},ek=t(9454),ev=t(98941),eS=t(33393),eN=t(5),eA=t(13810),eE=t(61244),eI=t(10827),eC=t(3851),eT=t(2044),eP=t(64167),eF=t(74480),eO=t(7178),eR=t(95093),eM=t(27166);let{Option:eL}=ej.default;var eU=e=>{let{userID:l,userRole:t,accessToken:s,selectedTeam:r,data:o,setData:i,teams:c}=e,[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(!1),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(""),[k,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(!1),[A,E]=(0,n.useState)(null),[I,C]=(0,n.useState)([]),T=new Set,[F,O]=(0,n.useState)(T);(0,n.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==s&&null!==t){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),C(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[s,l,t]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,t)=>{let s=l.team_id;e.add(s)}),O(e)}},[c]);let R=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),E(e),v(!0)},M=async e=>{if(null==s)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let t=await W(s,e);console.log("handleEditSubmit: newKeyValues",t),o&&i(o.map(e=>e.token===l?t:e)),h.ZP.success("Key updated successfully"),v(!1),E(null)},L=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+l),x(!0))},U=async()=>{if(null!=p&&null!=o){try{await w(s,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(eI.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Key Alias"}),(0,a.jsx)(eF.Z,{children:"Secret Key"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(eC.Z,{children:o.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(r){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(F.has(e.team_id),", selectedTeam id: ").concat(r.team_id)),(null!=r.team_id||null===e.team_id||F.has(e.team_id))&&e.team_id!=r.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(eu.Z,{children:e.key_alias}):(0,a.jsx)(eu.Z,{children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:e.key_name})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(eT.Z,{children:null!=e.max_budget?(0,a.jsx)(eu.Z,{children:e.max_budget}):(0,a.jsx)(eu.Z,{children:"Unlimited"})}),(0,a.jsx)(eT.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:r&&r.models&&r.models.length>0?r.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{onClick:()=>{E(e),N(!0)},icon:ek.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:S,onCancel:()=>{N(!1),E(null)},footer:null,width:800,children:A&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(A.spend).toFixed(4)}catch(e){return A.spend}})()})})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.max_budget?(0,a.jsx)(a.Fragment,{children:A.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.expires?(0,a.jsx)(a.Fragment,{children:new Date(A.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(eA.Z,{className:"my-4",children:[(0,a.jsx)(ex.Z,{children:"Token Name"}),(0,a.jsx)(eu.Z,{className:"my-1",children:A.key_alias?A.key_alias:A.key_name}),(0,a.jsx)(ex.Z,{children:"Token ID"}),(0,a.jsx)(eu.Z,{className:"my-1 text-[12px]",children:A.token}),(0,a.jsx)(ex.Z,{children:"Metadata"}),(0,a.jsx)(eu.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(A.metadata)," "]})})]}),(0,a.jsx)(ei.Z,{className:"mx-auto flex items-center",onClick:()=>{N(!1),E(null)},children:"Close"})]})}),(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>R(e)}),(0,a.jsx)(eE.Z,{onClick:()=>L(e),icon:eS.Z,size:"sm"})]})]},e.token)})})]}),u&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{x(!1),j(null)},children:"Cancel"})]})]})]})})]}),A&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,token:s,onSubmit:o}=e,[i]=eg.Z.useForm(),[d,m]=(0,n.useState)(r),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1);return(0,a.jsx)(ey.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:i,onFinish:M,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let t=l.filter(e=>!d.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!d.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(t)),t.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(t,"Team models: ").concat(d.models)):Promise.resolve()}}],children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(eL,{value:"all-team-models",children:"All Team Models"},"all-team-models"),d&&d.models?d.models.includes("all-proxy-models")?I.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):d.models.map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):I.map(e=>(0,a.jsx)(eL,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==d?void 0:d.max_budget)!==null&&(null==d?void 0:d.max_budget)!==void 0?null==d?void 0:d.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&d&&null!==d.max_budget&&l>d.max_budget)throw console.log("keyTeam.max_budget: ".concat(d.max_budget)),Error("Budget cannot exceed team max budget: $".concat(d.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(eg.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(eR.Z,{value:s.team_alias,children:null==c?void 0:c.map((e,l)=>(0,a.jsx)(eM.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:k,onCancel:()=>{v(!1),E(null)},token:A,onSubmit:M})]})},eD=t(76032),eB=t(35152),ez=e=>{let{userID:l,userRole:t,accessToken:s,userSpend:r,selectedTeam:o}=e;console.log("userSpend: ".concat(r));let[i,c]=(0,n.useState)(null!==r?r:0),[d,m]=(0,n.useState)(0),[h,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(s&&l&&t&&"Admin"===t&&null==r)try{let e=await S(s);e&&(e.spend?c(e.spend):c(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(async()=>{try{if(null===l||null===t)return;if(null!==s){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),u(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,s,l]),(0,n.useEffect)(()=>{null!==r&&c(r)},[r]);let x=[];o&&o.models&&(x=o.models),x&&x.includes("all-proxy-models")?(console.log("user models:",h),x=h):x&&x.includes("all-team-models")?x=o.models:x&&0===x.length&&(x=h);let p=void 0!==i?i.toFixed(4):null;return console.log("spend in view user spend: ".concat(i)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:["Total Spend"," "]}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",p]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Team Models"})}),(0,a.jsx)(em.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(eD.Z,{children:x.map(e=>(0,a.jsx)(eB.Z,{children:(0,a.jsx)(eu.Z,{children:e})},e))})})]})})]})},eK=e=>{let{userID:l,userRole:t,selectedTeam:s,accessToken:r}=e,[o,i]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==r){let e=(await P(r,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),i(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,t]);let c=[];return s&&s.models&&(c=s.models),c&&c.includes("all-proxy-models")&&(console.log("user models:",o),c=o),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"mb-5",children:(0,a.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==s?void 0:s.team_alias})})})},eG=e=>{let l,{teams:t,setSelectedTeam:s,userRole:r}=e,o={models:[],team_id:null,team_alias:"Default Team"},[i,c]=(0,n.useState)(o);return(l="App User"===r?t:t?[...t,o]:[o],"App User"===r)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(ex.Z,{children:"Select Team"}),(0,a.jsx)(eu.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(eu.Z,{className:"mt-3 mb-3",children:[(0,a.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>s(e),children:e.team_alias},l))}):(0,a.jsxs)(eu.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},eq=t(37963),eV=t(97482);console.log("isLocal:",!1);var eW=e=>{let{userID:l,userRole:t,teams:s,keys:r,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,n.useState)(null),p=(0,o.useSearchParams)();p.get("viewSpend"),(0,o.useRouter)();let j=p.get("token"),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)([]),b={models:[],team_alias:"Default Team",team_id:null},[v,N]=(0,n.useState)(s?s[0]:b);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(j){let e=(0,eq.o)(j);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),i(l)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&g&&t&&!r&&!u){let e=sessionStorage.getItem("userModels"+l);e?w(JSON.parse(e)):(async()=>{try{let e=await k(g,l,t,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==t){let e=await S(g);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(e.teams);let s=[...e.teams];s.length>0?(console.log("response['teams']: ".concat(s)),N(s[0])):N(b),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let r=(await P(g,l,t)).data.map(e=>e.id);console.log("available_model_names:",r),w(r),console.log("userModels:",_),sessionStorage.setItem("userModels"+l,JSON.stringify(r))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,j,g,r,t]),(0,n.useEffect)(()=>{if(null!==r&&null!=v){let e=0;for(let l of r)v.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===v.team_id&&(e+=l.spend);Z(e)}else if(null!==r){let e=0;for(let l of r)e+=l.spend;Z(e)}},[v]),null==l||null==j){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==g)return null;if(null==t&&i("App Owner"),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",v),console.log("teamSpend: ".concat(f)),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eK,{userID:l,userRole:t,selectedTeam:v||null,accessToken:g}),(0,a.jsx)(ez,{userID:l,userRole:t,accessToken:g,userSpend:f,selectedTeam:v||null}),(0,a.jsx)(eU,{userID:l,userRole:t,accessToken:g,selectedTeam:v||null,data:r,setData:h,teams:s}),(0,a.jsx)(eb,{userID:l,team:v||null,userRole:t,accessToken:g,data:r,setData:h},v?v.team_id:null),(0,a.jsx)(eG,{teams:s,setSelectedTeam:N,userRole:t})]})})})},eH=t(35087),eY=t(92836),eJ=t(26734),e$=t(41608),eX=t(32126),eQ=t(23682),e0=t(47047),e1=t(76628),e2=t(25707),e4=t(44041),e5=t(38302),e8=t(28683),e3=t(1460),e6=t(78578),e7=t(63954),e9=t(90252),le=t(7905),ll=e=>{let{modelID:l,accessToken:t}=e,[s,r]=(0,n.useState)(!1),o=async()=>{try{h.ZP.info("Making API Call"),r(!0);let e=await j(t,l);console.log("model delete Response:",e),h.ZP.success("Model ".concat(l," deleted successfully")),r(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(eE.Z,{onClick:()=>r(!0),icon:eS.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:s,onOk:o,okType:"danger",onCancel:()=>r(!1),children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Delete Model"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},lt=t(97766),ls=t(46495),lr=t(18190),la=t(91118),ln=e=>{let{modelMetrics:l,modelMetricsCategories:t,customTooltip:s,premiumUser:r}=e;return r?(0,a.jsx)(la.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:t,colors:["indigo","rose"],connectNulls:!0,customTooltip:s}):(0,a.jsxs)("div",{children:[(0,a.jsx)(lr.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,a.jsx)(ei.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},lo=e=>{let{fields:l,selectedProvider:t}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,a.jsx)(ec.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})};let{Title:li,Link:lc}=eV.default;(s=r||(r={})).OpenAI="OpenAI",s.Azure="Azure",s.Anthropic="Anthropic",s.Google_AI_Studio="Google AI Studio",s.Bedrock="Amazon Bedrock",s.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",s.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",s.Databricks="Databricks";let ld={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},lm={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},lh=async(e,l,t)=>{try{let s=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(s)),console.log("received type of deployments: ".concat(typeof s)),s.forEach(async t=>{console.log("litellm_model: ".concat(t));let s={},r={};s.model=t;let a="";for(let[l,t]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==t){if("model_name"==l)a+=t;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)r[l]=t;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",t);let e={};if(t&&void 0!=t){try{e=JSON.parse(t)}catch(e){throw h.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,t]of Object.entries(e))s[l]=t}}else s[l]=t}let n={model_name:a,litellm_params:s,model_info:r},o=await x(l,n);console.log("response for model create call: ".concat(o.data))}),t.resetFields()}catch(e){h.ZP.error("Failed to create model: "+e,10)}};var lu=e=>{var l,t,s;let o,{accessToken:i,token:c,userRole:d,userID:m,modelData:x={data:[]},setModelData:j,premiumUser:g}=e,[y,f]=(0,n.useState)([]),[Z]=eg.Z.useForm(),[_,w]=(0,n.useState)(null),[b,k]=(0,n.useState)(""),[v,S]=(0,n.useState)([]),A=Object.values(r).filter(e=>isNaN(Number(e))),[P,F]=(0,n.useState)([]),[O,R]=(0,n.useState)("OpenAI"),[M,L]=(0,n.useState)(""),[U,D]=(0,n.useState)(!1),[B,z]=(0,n.useState)(null),[K,G]=(0,n.useState)([]),[q,V]=(0,n.useState)(null),[W,H]=(0,n.useState)([]),[J,$]=(0,n.useState)([]),[X,Q]=(0,n.useState)([]),[el,et]=(0,n.useState)([]),[es,en]=(0,n.useState)([]),[ep,ej]=(0,n.useState)([]),[ef,ew]=(0,n.useState)([]),[eb,ek]=(0,n.useState)([]),[eS,eL]=(0,n.useState)([]),[eU,eD]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eB,ez]=(0,n.useState)(null),[eK,eG]=(0,n.useState)(0),eq=e=>{z(e),D(!0)},eW=async e=>{if(console.log("handleEditSubmit:",e),null==i)return;let l={},t=null;for(let[s,r]of Object.entries(e))"model_id"!==s?l[s]=r:t=r;let s={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",s);try{await Y(i,s),h.ZP.success("Model updated successfully, restart server to see updates"),D(!1),z(null)}catch(e){console.log("Error occurred")}},lr=()=>{k(new Date().toLocaleString())},la=async()=>{if(!i){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eB);try{await er(i,{router_settings:{model_group_retry_policy:eB}}),h.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),h.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!i||!c||!d||!m)return;let e=async()=>{try{var e,l,t,s,r,a,n,o;let c=await p(i);F(c);let h=await N(i,m,d);console.log("Model data response:",h.data),j(h);let u=new Set;for(let e=0;e0&&(g=x[x.length-1],console.log("_initial_model_group:",g),V(g)),console.log("selectedModelGroup:",q);let y=await E(i,m,d,g,null===(e=eU.from)||void 0===e?void 0:e.toISOString(),null===(l=eU.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",y),$(y.data),Q(y.all_api_bases);let f=await I(i,g,null===(t=eU.from)||void 0===t?void 0:t.toISOString(),null===(s=eU.to)||void 0===s?void 0:s.toISOString());et(f.data),en(f.all_api_bases);let Z=await T(i,m,d,g,null===(r=eU.from)||void 0===r?void 0:r.toISOString(),null===(a=eU.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",Z),ej(Z.data),ew(Z.exception_types);let _=await C(i,m,d,g,null===(n=eU.from)||void 0===n?void 0:n.toISOString(),null===(o=eU.to)||void 0===o?void 0:o.toISOString());console.log("slowResponses:",_),eL(_);let w=(await ee(i,m,d)).router_settings;console.log("routerSettingsInfo:",w);let b=w.model_group_retry_policy,k=w.num_retries;console.log("model_group_retry_policy:",b),console.log("default_retries:",k),ez(b),eG(k)}catch(e){console.error("There was an error fetching the model data",e)}};i&&c&&d&&m&&e();let l=async()=>{let e=await u();console.log("received model cost map data: ".concat(Object.keys(e))),w(e)};null==_&&l(),lr()},[i,c,d,m,_,b]),!x||!i||!c||!d||!m)return(0,a.jsx)("div",{children:"Loading..."});let lu=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(_)),null!=_&&"object"==typeof _&&e in _)?_[e].litellm_provider:"openai";if(r){let e=r.split("/"),l=e[0];n=1===e.length?h(r):l}else n="openai";a&&(o=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,c=null==a?void 0:a.max_tokens,d=null==a?void 0:a.max_input_tokens),(null==s?void 0:s.litellm_params)&&(m=Object.fromEntries(Object.entries(null==s?void 0:s.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),x.data[e].provider=n,x.data[e].input_cost=o,x.data[e].output_cost=i,x.data[e].input_cost&&(x.data[e].input_cost=(1e6*Number(x.data[e].input_cost)).toFixed(2)),x.data[e].output_cost&&(x.data[e].output_cost=(1e6*Number(x.data[e].output_cost)).toFixed(2)),x.data[e].max_tokens=c,x.data[e].max_input_tokens=d,x.data[e].api_base=null==s?void 0:null===(t=s.litellm_params)||void 0===t?void 0:t.api_base,x.data[e].cleanedLitellmParams=m,lu.push(s.model_name),console.log(x.data[e])}if(d&&"Admin Viewer"==d){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lx=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(r).find(l=>r[l]===e);if(l){let e=ld[l];console.log("mappingResult: ".concat(e));let t=[];"object"==typeof _&&Object.entries(_).forEach(l=>{let[s,r]=l;null!==r&&"object"==typeof r&&"litellm_provider"in r&&(r.litellm_provider===e||r.litellm_provider.includes(e))&&t.push(s)}),S(t),console.log("providerModels: ".concat(v))}},lp=async()=>{try{h.ZP.info("Running health check..."),L("");let e=await ea(i);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lj=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),i&&m&&d&&l&&t){console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),V(e);try{let s=await E(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model metrics response:",s),$(s.data),Q(s.all_api_bases);let r=await I(i,e,l.toISOString(),t.toISOString());et(r.data),en(r.all_api_bases);let a=await T(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model exceptions response:",a),ej(a.data),ew(a.exception_types);let n=await C(i,m,d,e,l.toISOString(),t.toISOString());console.log("slowResponses:",n),eL(n)}catch(e){console.error("Failed to fetch model metrics",e)}}},lg=e=>{var l,t;let{payload:s,active:r}=e;if(!r||!s)return null;let n=null===(t=s[0])||void 0===t?void 0:null===(l=t.payload)||void 0===l?void 0:l.date,o=s.sort((e,l)=>l.value-e.value);if(o.length>5){let e=o.length-5;(o=o.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:s.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,a.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[n&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),o.map((e,l)=>{let t=parseFloat(e.value.toFixed(5)),s=0===t&&e.value>0?"<0.00001":t.toFixed(5);return(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:s})]},l)})]})};console.log("selectedProvider: ".concat(O)),console.log("providerModels.length: ".concat(v.length));let ly=Object.keys(r).find(e=>r[e]===O);return ly&&(o=P.find(e=>e.name===ld[ly])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eY.Z,{children:"All Models"}),(0,a.jsx)(eY.Z,{children:"Add Model"}),(0,a.jsx)(eY.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eY.Z,{children:"Model Analytics"}),(0,a.jsx)(eY.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[b&&(0,a.jsxs)(eu.Z,{children:["Last Refreshed: ",b]}),(0,a.jsx)(eE.Z,{icon:e7.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lr})]})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],onValueChange:e=>V("all"===e?"all":e),value:q||K[0],children:[(0,a.jsx)(eM.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))]})]}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"Public Model Name"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:"Provider"}),"Admin"===d&&(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"API Base"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:"Extra litellm Params"}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(eF.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:"Max Tokens"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word"},children:"Status"})]})}),(0,a.jsx)(eC.Z,{children:x.data.filter(e=>"all"===q||e.model_name===q||null==q||""===q).map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{children:e.model_name})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.provider}),"Admin"===d&&(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:e.api_base}),(0,a.jsx)(eT.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Litellm params"})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)("pre",{children:JSON.stringify(e.cleanedLitellmParams,null,2)})})]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.input_cost||e.litellm_params.input_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.output_cost||e.litellm_params.output_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)("p",{style:{fontSize:"10px"},children:["Max Tokens: ",e.max_tokens," ",(0,a.jsx)("br",{}),"Max Input Tokens: ",e.max_input_tokens]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(eN.Z,{icon:e9.Z,size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(eN.Z,{icon:le.Z,size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsxs)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>eq(e)}),(0,a.jsx)(ll,{modelID:e.model_info.id,accessToken:i})]})]},l))})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:t,model:s,onSubmit:r}=e,[n]=eg.Z.useForm(),o={},i="",c="";if(s){o=s.litellm_params,i=s.model_name;let e=s.model_info;e&&(c=e.id,console.log("model_id: ".concat(c)),o.model_id=c)}return(0,a.jsx)(ey.Z,{title:"Edit Model "+i,visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r(e),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:eW,initialValues:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:U,onCancel:()=>{D(!1),z(null)},model:B,onSubmit:eW})]}),(0,a.jsxs)(eX.Z,{className:"h-full",children:[(0,a.jsx)(li,{level:2,children:"Add new model"}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eg.Z,{form:Z,onFinish:()=>{Z.validateFields().then(e=>{lh(e,i,Z)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:O.toString(),children:A.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>{lx(e),R(e)},children:e},l))})}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(s=O.toString())?"gemini-pro":"Anthropic"==s?"claude-3-opus":"Amazon Bedrock"==s?"claude-3-opus":"Google AI Studio"==s?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===O?(0,a.jsx)(ec.Z,{placeholder:"Enter model name"}):v.length>0?(0,a.jsx)(e0.Z,{value:v,children:v.map((e,l)=>(0,a.jsx)(e1.Z,{value:e,children:e},l))}):(0,a.jsx)(ec.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==o&&o.fields.length>0&&(0,a.jsx)(lo,{fields:o.fields,selectedProvider:o.name}),"Amazon Bedrock"!=O&&"Vertex AI (Anthropic, Gemini, etc.)"!=O&&void 0===o&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(ec.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==O&&(0,a.jsx)(eg.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(ec.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(ec.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ls.Z,{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;Z.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?h.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&h.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(e_.ZP,{icon:(0,a.jsx)(lt.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==O||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==O)&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(ec.Z,{placeholder:"https://..."})}),"Azure"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(ec.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==O&&(0,a.jsxs)("div",{children:[(0,a.jsx)(eg.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(lc,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(eg.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,a.jsx)(e6.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(e3.Z,{title:"Get help on our github",children:(0,a.jsx)(eV.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(ei.Z,{onClick:lp,children:"Run `/health`"}),M&&(0,a.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:eU,onValueChange:e=>{eD(e),lj(q,e.from,e.to)}})]}),(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Model Group"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2",defaultValue:q||K[0],value:q||K[0],children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>lj(e,eU.from,eU.to),children:e},l))})]})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eY.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(eu.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),J&&X&&(0,a.jsx)(e2.Z,{title:"Model Latency",className:"h-72",data:J,showLegend:!1,index:"date",categories:X,connectNulls:!0,customTooltip:lg})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(ln,{modelMetrics:el,modelMetricsCategories:es,customTooltip:lg,premiumUser:g})})]})]})})}),(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Deployment"}),(0,a.jsx)(eF.Z,{children:"Success Responses"}),(0,a.jsxs)(eF.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(eC.Z,{children:eS.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.api_base}),(0,a.jsx)(eT.Z,{children:e.total_count}),(0,a.jsx)(eT.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(eA.Z,{className:"mt-4",children:[(0,a.jsx)(ex.Z,{children:"Exceptions per Model"}),(0,a.jsx)(e4.Z,{className:"h-72",data:ep,index:"model",categories:ef,stack:!0,colors:["indigo-300","rose-200","#ffcc33"],yAxisWidth:30})]})]}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],value:q||K[0],onValueChange:e=>V(e),children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))})]}),(0,a.jsxs)(ex.Z,{children:["Retry Policy for ",q]}),(0,a.jsx)(eu.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),lm&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(lm).map((e,l)=>{var t;let[s,r]=e,n=null==eB?void 0:null===(t=eB[q])||void 0===t?void 0:t[r];return null==n&&(n=eK),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)("td",{children:(0,a.jsx)(eZ.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{ez(l=>{var t;let s=null!==(t=null==l?void 0:l[q])&&void 0!==t?t:{};return{...null!=l?l:{},[q]:{...s,[r]:e}}})}})})]},l)})})}),(0,a.jsx)(ei.Z,{className:"mt-6 mr-8",onClick:la,children:"Save"})]})]})]})})};let{Option:lx}=ej.default;var lp=e=>{let{userID:l,accessToken:t,teams:s}=e,[r]=eg.Z.useForm(),[o,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[m,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{let e=await P(t,l,"any"),s=[];for(let l=0;l{i(!1),r.resetFields()},p=()=>{i(!1),d(null),r.resetFields()},j=async e=>{try{h.ZP.info("Making API Call"),i(!0),console.log("formValues in create user:",e);let s=await _(t,null,e);console.log("user create Response:",s),d(s.key),h.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-0",onClick:()=>i(!0),children:"+ Invite User"}),(0,a.jsxs)(ey.Z,{title:"Invite User",visible:o,width:800,footer:null,onOk:x,onCancel:p,children:[(0,a.jsx)(eu.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(eu.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(eg.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(eg.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(ej.default,{placeholder:"Select Team ID",style:{width:"100%"},children:s?s.map(e=>(0,a.jsx)(lx,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(lx,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create User"})})]})]}),c&&(0,a.jsxs)(ey.Z,{title:"User Created Successfully",visible:o,onOk:x,onCancel:p,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},lj=e=>{let{accessToken:l,token:t,keys:s,userRole:r,userID:o,teams:i,setKeys:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(0),[j,g]=n.useState(null),[y,f]=(0,n.useState)(null);return((0,n.useEffect)(()=>{if(!l||!t||!r||!o)return;let e=async()=>{try{let e=await k(l,null,r,!0,x,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&r&&o&&e()},[l,t,r,o,x]),d&&l&&t&&r&&o)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(eo.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(lp,{userID:o,accessToken:l,teams:i}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(eu.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(eJ.Z,{children:(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"User ID"}),(0,a.jsx)(eF.Z,{children:"User Email"}),(0,a.jsx)(eF.Z,{children:"User Models"}),(0,a.jsx)(eF.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User API Key Aliases"})]})}),(0,a.jsx)(eC.Z,{children:d.map(e=>{var l;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_id}),(0,a.jsx)(eT.Z,{children:e.user_email}),(0,a.jsx)(eT.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(eT.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eo.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsx)(eN.Z,{size:"xs",color:"indigo",children:e.key_aliases.filter(e=>null!==e).join(", ")}):(0,a.jsx)(eN.Z,{size:"xs",color:"gray",children:"No Keys"})})})]},e.user_id)})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})})]}),function(){if(!d)return null;let e=Math.ceil(d.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",x+1," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:0===x,onClick:()=>p(x-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",onClick:()=>{p(x+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},lg=e=>{let{teams:l,searchParams:t,accessToken:s,setTeams:r,userID:o,userRole:i}=e,[c]=eg.Z.useForm(),[d]=eg.Z.useForm(),{Title:m,Paragraph:u}=eV.default,[x,p]=(0,n.useState)(""),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(l?l[0]:null),[Z,_]=(0,n.useState)(!1),[w,k]=(0,n.useState)(!1),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)(!1),[I,C]=(0,n.useState)(null),[T,F]=(0,n.useState)({}),O=e=>{f(e),g(!0)},R=async e=>{let t=e.team_id;if(console.log("handleEditSubmit:",e),null==s)return;let a=await H(s,e);l&&r(l.map(e=>e.team_id===t?a.data:e)),h.ZP.success("Team updated successfully"),g(!1),f(null)},M=async e=>{C(e),E(!0)},L=async()=>{if(null!=I&&null!=l&&null!=s){try{await b(s,I);let e=l.filter(e=>e.team_id!==I);r(e)}catch(e){console.error("Error deleting the team:",e)}E(!1),C(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{if(null===o||null===i||null===s||null===l)return;console.log("fetching team info:");let e={};for(let t=0;t<(null==l?void 0:l.length);t++){let r=l[t].team_id,a=await v(s,r);console.log("teamInfo response:",a),null!==a&&(e={...e,[r]:a})}F(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===o||null===i)return;if(null!==s){let e=(await P(s,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,o,i,l]);let U=async e=>{try{if(null!=s){var t;let a=null==e?void 0:e.team_alias;if((null!==(t=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==t?t:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));h.ZP.info("Creating Team");let n=await V(s,e);null!==l?r([...l,n]):r([n]),console.log("response for team create call: ".concat(n)),h.ZP.success("Team created"),_(!1)}}catch(e){console.error("Error creating the team:",e),h.ZP.error("Error creating the team: "+e,20)}},D=async e=>{try{if(null!=s&&null!=l){h.ZP.info("Adding Member");let t={role:"user",user_email:e.user_email,user_id:e.user_id},a=await J(s,y.team_id,t);console.log("response for team create call: ".concat(a.data));let n=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(n)),-1!==n){let e=[...l];e[n]=a.data,r(e),f(a.data)}k(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Team Name"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(eF.Z,{children:"Info"})]})}),(0,a.jsx)(eC.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(eT.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].keys&&T[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].team_info&&T[e.team_id].team_info.members_with_roles&&T[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>O(e)}),(0,a.jsx)(eE.Z,{onClick:()=>M(e.team_id),icon:eS.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{E(!1),C(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>_(!0),children:"+ Create New Team"}),(0,a.jsx)(ey.Z,{title:"Create Team",visible:Z,width:800,footer:null,onOk:()=>{_(!1),c.resetFields()},onCancel:()=>{_(!1),c.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:U,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{f(e)},children:e.team_alias},l))}):(0,a.jsxs)(u,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:y?y.members_with_roles.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.role})]},l)):null})]})}),y&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,team:s,onSubmit:r}=e,[n]=eg.Z.useForm();return(0,a.jsx)(ey.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:s.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:R,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:j,onCancel:()=>{g(!1),f(null)},team:y,onSubmit:R})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-5",onClick:()=>k(!0),children:"+ Add member"}),(0,a.jsx)(ey.Z,{title:"Add member",visible:w,width:800,footer:null,onOk:()=>{k(!1),d.resetFields()},onCancel:()=>{k(!1),d.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:D,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},ly=e=>{let l,{searchParams:t,accessToken:s,showSSOBanner:r}=e,[o]=eg.Z.useForm(),[i]=eg.Z.useForm(),{Title:c,Paragraph:d}=eV.default,[m,u]=(0,n.useState)(""),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(!1),[Z,_]=(0,n.useState)(!1),[w,b]=(0,n.useState)(!1),[k,v]=(0,n.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let S=()=>{v(!1)},N=["proxy_admin","proxy_admin_viewer"];(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await q(s,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let t=await q(s,"proxy_admin");t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(t)),console.log("combinedList: ".concat(e)),p(e)}})()},[s]);let A=()=>{_(!1),i.resetFields()},E=()=>{_(!1),i.resetFields()},I=e=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]}),C=(e,l,t)=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:l,children:N.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:t,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update role"})})]}),T=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,null);console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),h.ZP.success("Refresh tab to see updated user role"),_(!1)}}catch(e){console.error("Error creating the key:",e)}},P=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),g(!1)}}catch(e){console.error("Error creating the key:",e)}},F=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await $(s,e,"proxy_admin");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),f(!1)}}catch(e){console.error("Error creating the key:",e)}},O=async e=>{null!=s&&er(s,{environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}})};return console.log("admins: ".concat(null==x?void 0:x.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(c,{level:4,children:"Admin Access "}),(0,a.jsxs)(d,{children:[r&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc. ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:x?x.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.user_role}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>_(!0)}),(0,a.jsx)(ey.Z,{title:"Update role",visible:Z,width:800,footer:null,onOk:A,onCancel:E,children:C(T,e.user_role,e.user_id)})]})]},l)):null})]})})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(ei.Z,{className:"mr-4 mb-5",onClick:()=>f(!0),children:"+ Add admin"}),(0,a.jsx)(ey.Z,{title:"Add admin",visible:y,width:800,footer:null,onOk:()=>{f(!1),i.resetFields()},onCancel:()=>{f(!1),i.resetFields()},children:I(F)}),(0,a.jsx)(ei.Z,{className:"mb-5",onClick:()=>g(!0),children:"+ Add viewer"}),(0,a.jsx)(ey.Z,{title:"Add viewer",visible:j,width:800,footer:null,onOk:()=>{g(!1),i.resetFields()},onCancel:()=>{g(!1),i.resetFields()},children:I(P)})]})})]}),(0,a.jsxs)(eo.Z,{children:[(0,a.jsx)(c,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(ei.Z,{onClick:()=>b(!0),children:"Add SSO"}),(0,a.jsx)(ey.Z,{title:"Add SSO",visible:w,width:800,footer:null,onOk:()=>{b(!1),o.resetFields()},onCancel:()=>{b(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{F(e),O(e),b(!1),v(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(ef.Z.Password,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(ef.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(ey.Z,{title:"SSO Setup Instructions",visible:k,width:800,footer:null,onOk:S,onCancel:()=>{v(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{onClick:S,children:"Done"})})]})]}),(0,a.jsxs)(lr.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},lf=t(42556),lZ=e=>{let{alertingSettings:l,handleInputChange:t,handleResetField:s,handleSubmit:r,premiumUser:n}=e,[o]=eg.Z.useForm();return(0,a.jsxs)(eg.Z,{form:o,onFinish:()=>{let e=o.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):r(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{align:"center",children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?n?(0,a.jsx)(eg.Z.Item,{name:e.field_name,children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l)}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}):(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(eg.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l),className:"p-0"}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>s(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update Settings"})})]})},l_=e=>{let{accessToken:l,premiumUser:t}=e,[s,r]=(0,n.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,n.useEffect)(()=>{l&&f(l).then(e=>{r(e)})},[l]),(0,a.jsx)(lZ,{alertingSettings:s,handleInputChange:(e,l)=>{r(s.map(t=>t.field_name===e?{...t,field_value:l}:t))},handleResetField:(e,t)=>{if(l)try{let l=s.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),r(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let t={};s.forEach(e=>{t[e.field_name]=e.field_value});let r={...e,...t};try{et(l,"alerting_args",r),h.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:t})};let lw=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var lb=e=>{let{accessToken:l,userRole:t,userID:s,premiumUser:r}=e,[o,i]=(0,n.useState)(lw),[c,d]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[x]=eg.Z.useForm(),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,Z]=(0,n.useState)(""),[_,w]=(0,n.useState)({}),[b,k]=(0,n.useState)([]),v=e=>{b.includes(e)?k(b.filter(l=>l!==e)):k([...b,e])},S={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,n.useEffect)(()=>{l&&t&&s&&ee(l,s,t).then(e=>{console.log("callbacks",e);let l=lw;i(l=l.map(l=>{let t=e.callbacks.find(e=>e.name===l.name);return t?{...l,variables:{...l.variables,...t.variables}}:l}));let t=e.alerts;if(console.log("alerts_data",t),t&&t.length>0){let e=t[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),k(e.active_alerts),Z(l),w(e.alerts_to_webhook)}d(t)})},[l,t,s]);let N=e=>b&&b.includes(e),A=e=>{if(!l)return;let t=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[t,s]=e;return[t,(null===(l=document.querySelector('input[name="'.concat(t,'"]')))||void 0===l?void 0:l.value)||s]}));console.log("updatedVariables",t),console.log("updateAlertTypes",g);let s={environment_variables:t,litellm_settings:{success_callback:[e.name]}};try{er(l,s)}catch(e){h.ZP.error("Failed to update callback: "+e,20)}h.ZP.success("Callback updated successfully")},E=()=>{l&&x.validateFields().then(e=>{if(console.log("Form values:",e),"langfuse"===e.callback){er(l,{environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),er(l,{general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}}),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),er(l,{environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};i(o?[...o,t]:[t])}u(!1),x.resetFields(),j(null)})};return l?(console.log("callbacks: ".concat(o)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(lr.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Settings"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Callback"}),(0,a.jsx)(eF.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(eC.Z,{children:o.filter(e=>"slack"!==e.name).map((e,t)=>{var s;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eN.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).filter(l=>{let[t,s]=l;return t.toLowerCase().includes(e.name)}).map(e=>{let[l,t]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(eu.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(ec.Z,{name:l,defaultValue:t,type:"password"})]},l)})}),(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(e),children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,e.name),className:"mx-2",children:"Test Callback"})]})]},t)})})]})})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eu.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(S).map((e,l)=>{let[t,s]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:"region_outage_alerts"==t?r?(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)}):(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:t,type:"password",defaultValue:_&&_[t]?_[t]:f})})]},l)})})]}),(0,a.jsx)(ei.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(S).forEach(l=>{let[t,s]=l,r=document.querySelector('input[name="'.concat(t,'"]'));console.log("key",t),console.log("webhookInput",r);let a=(null==r?void 0:r.value)||"";console.log("newWebhookValue",a),e[t]=a}),console.log("updatedAlertToWebhooks",e);let t={general_settings:{alert_to_webhook_url:e,alert_types:b}};console.log("payload",t);try{er(l,t)}catch(e){h.ZP.error("Failed to update alerts: "+e,20)}h.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(l_,{accessToken:l,premiumUser:r})})]})]})]}),(0,a.jsx)(ey.Z,{title:"Add Callback",visible:m,onOk:E,width:800,onCancel:()=>{u(!1),x.resetFields(),j(null)},footer:null,children:(0,a.jsxs)(eg.Z,{form:x,layout:"vertical",onFinish:E,children:[(0,a.jsx)(eg.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(ej.default,{onChange:e=>{j(e)},children:[(0,a.jsx)(ej.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(ej.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(ec.Z,{type:"password"})}),(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})]}),"openmeter"==p&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eg.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:lk}=ej.default;var lv=e=>{let{models:l,accessToken:t,routerSettings:s,setRouterSettings:r}=e,[o]=eg.Z.useForm(),[i,c]=(0,n.useState)(!1),[d,m]=(0,n.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>c(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(ey.Z,{title:"Add Fallbacks",visible:i,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,n=[...s.fallbacks||[],{[l]:a}],i={...s,fallbacks:n};console.log(i);try{er(t,{router_settings:i}),r(i)}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully"),c(!1),o.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(eR.Z,{defaultValue:d,children:l&&l.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(e0.Z,{value:l,children:l&&l.filter(e=>e!=d).map(e=>(0,a.jsx)(e1.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lS=t(12968);async function lN(e,l){console.log("isLocal:",!1);let t=window.location.origin,s=new lS.ZP.OpenAI({apiKey:l,baseURL:t,dangerouslyAllowBrowser:!0});try{let l=await s.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});h.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lA={ttl:3600,lowest_latency_buffer:0},lE=e=>{let{selectedStrategy:l,strategyArgs:t,paramExplanation:s}=e;return(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(em.Z,{children:"latency-based-routing"==l?(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(t).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:s[l]})]}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]})}):(0,a.jsx)(eu.Z,{children:"No specific settings"})})]})};var lI=e=>{let{accessToken:l,userRole:t,userID:s,modelData:r}=e,[o,i]=(0,n.useState)({}),[c,d]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1),[j]=eg.Z.useForm(),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)(null),b={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,n.useEffect)(()=>{l&&t&&s&&(ee(l,s,t).then(e=>{console.log("callbacks",e),i(e.router_settings)}),el(l).then(e=>{u(e)}))},[l,t,s]);let k=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(o.fallbacks)),o.fallbacks.map(l=>(e in l&&delete l[e],l));try{await er(l,{router_settings:o}),i({...o}),Z(o.routing_strategy),h.ZP.success("Router settings updated successfully")}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}}},v=(e,l)=>{u(m.map(t=>t.field_name===e?{...t,field_value:l}:t))},S=(e,t)=>{if(!l)return;let s=m[t].field_value;if(null!=s&&void 0!=s)try{et(l,e,s);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(t)}catch(e){}},N=(e,t)=>{if(l)try{es(l,e);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(t)}catch(e){}},A=e=>{if(!l)return;console.log("router_settings",e);let t=Object.fromEntries(Object.entries(e).map(e=>{let[l,t]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var s;return[l,(null===(s=document.querySelector('input[name="'.concat(l,'"]')))||void 0===s?void 0:s.value)||t]}if("routing_strategy"==l)return[l,f];if("routing_strategy_args"==l&&"latency-based-routing"==f){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),t=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==t?void 0:t.value)&&(e.ttl=Number(t.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",t);try{er(l,{router_settings:t})}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eY.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eY.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(ex.Z,{children:"Router Settings"}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(o).filter(e=>{let[l,t]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:b[l]})]}),(0,a.jsx)(eT.Z,{children:"routing_strategy"==l?(0,a.jsxs)(eR.Z,{defaultValue:t,className:"w-full max-w-md",onValueChange:Z,children:[(0,a.jsx)(eM.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(eM.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(eM.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]}),(0,a.jsx)(lE,{selectedStrategy:f,strategyArgs:o&&o.routing_strategy_args&&Object.keys(o.routing_strategy_args).length>0?o.routing_strategy_args:lA,paramExplanation:b})]}),(0,a.jsx)(en.Z,{children:(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(o),children:"Save Changes"})})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Model Name"}),(0,a.jsx)(eF.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(eC.Z,{children:o.fallbacks&&o.fallbacks.map((e,t)=>Object.entries(e).map(e=>{let[s,r]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:s}),(0,a.jsx)(eT.Z,{children:Array.isArray(r)?r.join(", "):r}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{onClick:()=>lN(s,l),children:"Test Fallback"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>k(s)})})]},t.toString()+s)}))})]}),(0,a.jsx)(lv,{models:(null==r?void 0:r.data)?r.data.map(e=>e.model_name):[],accessToken:l,routerSettings:o,setRouterSettings:i})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"}),(0,a.jsx)(eF.Z,{children:"Status"}),(0,a.jsx)(eF.Z,{children:"Action"})]})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(eT.Z,{children:"Integer"==e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>v(e.field_name,l)}):null}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(ei.Z,{onClick:()=>S(e.field_name,l),children:"Update"}),(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>N(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lC=e=>{let{isModalVisible:l,accessToken:t,setIsModalVisible:s,setBudgetList:r}=e,[n]=eg.Z.useForm(),o=async e=>{if(null!=t&&void 0!=t)try{h.ZP.info("Making API Call");let l=await y(t,e);console.log("key create Response:",l),r(e=>e?[...e,l]:[l]),h.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(ey.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{s(!1),n.resetFields()},onCancel:()=>{s(!1),n.resetFields()},children:(0,a.jsxs)(eg.Z,{form:n,onFinish:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lT=t(67951),lP=e=>{let{accessToken:l}=e,[t,s]=(0,n.useState)(!1),[r,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&Q(l).then(e=>{o(e)})},[l]);let i=async(e,t)=>{if(null==l)return;h.ZP.info("Request made"),await g(l,e);let s=[...r];s.splice(t,1),o(s),h.ZP.success("Budget Deleted.")};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(ei.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>s(!0),children:"+ Create Budget"}),(0,a.jsx)(lC,{accessToken:l,isModalVisible:t,setIsModalVisible:s,setBudgetList:o}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Budget ID"}),(0,a.jsx)(eF.Z,{children:"Max Budget"}),(0,a.jsx)(eF.Z,{children:"TPM"}),(0,a.jsx)(eF.Z,{children:"RPM"})]})}),(0,a.jsx)(eC.Z,{children:r.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.budget_id}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(eT.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(eT.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>i(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(eu.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eY.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eY.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{var l;let{userID:t,userRole:s,token:r,accessToken:o,keys:i,premiumUser:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);(0,n.useEffect)(()=>{o&&r&&s&&t&&(async()=>{try{let e=await A(o,t,s);console.log("ModelHubData:",e),m(e.data)}catch(e){console.error("There was an error fetching the model data",e)}})()},[o,r,s,t]);let j=e=>{p(e),u(!0)},g=e=>{navigator.clipboard.writeText(e)};return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)("div",{className:"relative w-full"}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(ex.Z,{className:"ml-8 text-center ",children:"Model Hub"}),(0,a.jsx)(ei.Z,{className:"ml-4",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4",children:d&&d.map(e=>(0,a.jsxs)(eA.Z,{className:"mt-5 mx-8",children:[(0,a.jsxs)("pre",{className:"flex justify-between",children:[(0,a.jsx)(ex.Z,{children:e.model_group}),(0,a.jsx)(e3.Z,{title:e.model_group,children:(0,a.jsx)(lF.Z,{onClick:()=>g(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,a.jsxs)("div",{className:"my-5",children:[(0,a.jsxs)(eu.Z,{children:["Mode: ",e.mode]}),(0,a.jsxs)(eu.Z,{children:["Supports Function Calling: ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Supports Vision: ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Max Input Tokens: ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,a.jsxs)(eu.Z,{children:["Max Output Tokens: ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,a.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,a.jsxs)("a",{href:"#",onClick:()=>j(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,a.jsx)(lO.Z,{})]})})]},e.model_group))})]}),(0,a.jsx)(ey.Z,{title:x&&x.model_group?x.model_group:"Unknown Model",width:800,visible:h,footer:null,onOk:()=>{u(!1),p(null)},onCancel:()=>{u(!1),p(null)},children:x&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-4",children:(0,a.jsx)("strong",{children:"Model Information & Usage"})}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"Supported OpenAI Params"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(x.model_group,'", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,a.jsx)(eX.Z,{children:null==x?void 0:null===(l=x.supported_openai_params)||void 0===l?void 0:l.map(e=>(0,a.jsx)("pre",{children:e},e))}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="'.concat(x.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "'.concat(x.model_group,'",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})]})},lM=e=>{let{}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(eu.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n '})})]})]})]})})})};async function lL(e,l,t,s){console.log("isLocal:",!1);let r=window.location.origin,a=new lS.ZP.OpenAI({apiKey:s,baseURL:r,dangerouslyAllowBrowser:!0});try{for await(let s of(await a.chat.completions.create({model:t,stream:!0,messages:[{role:"user",content:e}]})))console.log(s),s.choices[0].delta.content&&l(s.choices[0].delta.content)}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lU=e=>{let{accessToken:l,token:t,userRole:s,userID:r}=e,[o,i]=(0,n.useState)(""),[c,d]=(0,n.useState)(""),[m,h]=(0,n.useState)([]),[u,x]=(0,n.useState)(void 0),[p,j]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{let e=await P(l,r,s);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));console.log(l),j(l),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,r,s]);let g=(e,l)=>{h(t=>{let s=t[t.length-1];return s&&s.role===e?[...t.slice(0,t.length-1),{role:e,content:s.content+l}]:[...t,{role:e,content:l}]})},y=async()=>{if(""!==c.trim()&&o&&t&&s&&r){h(e=>[...e,{role:"user",content:c}]);try{u&&await lL(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsx)(e$.Z,{children:(0,a.jsx)(eY.Z,{children:"Chat"})}),(0,a.jsx)(eQ.Z,{children:(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"API Key"}),(0,a.jsx)(ec.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,a.jsxs)(en.Z,{className:"mx-2",children:[(0,a.jsx)(eu.Z,{children:"Select Model:"}),(0,a.jsx)(ej.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,a.jsxs)(eI.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{})})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(ec.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,a.jsx)(ei.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]})})]})})})})},lD=t(33509),lB=t(95781);let{Sider:lz}=lD.default;var lK=e=>{let{setPage:l,userRole:t,defaultSelectedKey:s}=e;return"Admin Viewer"==t?(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(lz,{width:120,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(lz,{width:145,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(eu.Z,{children:"API Keys"})},"1"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(eu.Z,{children:"Test Key"})},"3"),"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(eu.Z,{children:"Models"})},"2"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(eu.Z,{children:"Usage"})},"4"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(eu.Z,{children:"Teams"})},"6"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(eu.Z,{children:"Users"})},"5"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(eu.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(eu.Z,{children:"Rate Limits"})},"9"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(eu.Z,{children:"Router Settings"})},"10"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(eu.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(eu.Z,{children:"API Reference"})},"12"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(eu.Z,{children:"Model Hub"})},"14")]})})})},lG=t(67989),lq=t(49167),lV=t(52703),lW=e=>{let{accessToken:l,token:t,userRole:s,userID:r,keys:o,premiumUser:i}=e,c=new Date,[d,m]=(0,n.useState)([]),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)([]),[j,g]=(0,n.useState)([]),[y,f]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[w,b]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)({}),[I,C]=(0,n.useState)([]),[T,P]=(0,n.useState)(""),[q,V]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),W=new Date(c.getFullYear(),c.getMonth(),1),H=new Date(c.getFullYear(),c.getMonth()+1,0),Y=Q(W),J=Q(H);console.log("keys in usage",o),console.log("premium user in usage",i);let $=async(e,t,s)=>{if(!e||!t||!l)return;t.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",s);let r=await U(l,s,e.toISOString(),t.toISOString());console.log("End user data updated successfully",r),g(r)},X=async(e,t)=>{e&&t&&l&&(t.setHours(23,59,59,999),e.setHours(0,0,0,0),_((await O(l,e.toISOString(),t.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function Q(e){let l=e.getFullYear(),t=e.getMonth()+1,s=e.getDate();return"".concat(l,"-").concat(t<10?"0"+t:t,"-").concat(s<10?"0"+s:s)}return console.log("Start date is ".concat(Y)),console.log("End date is ".concat(J)),(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{if(console.log("user role: ".concat(s)),"Admin"==s||"Admin Viewer"==s){var e,a;let s=await M(l);m(s);let r=await D(l,t,Y,J);console.log("provider_spend",r),N(r);let n=(await L(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));u(n);let o=(await K(l)).map(e=>({key:e.model,spend:e.total_spend}));p(o);let i=await F(l);console.log("teamSpend",i),f(i.daily_spend),b(i.teams);let c=i.total_spend_per_team;c=c.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),v(c);let d=await O(l,null===(e=q.from)||void 0===e?void 0:e.toISOString(),null===(a=q.to)||void 0===a?void 0:a.toISOString());_(d.spend_per_tag);let h=await U(l,null,void 0,void 0);g(h),console.log("spend/user result",h);let x=await B(l,Y,J);E(x);let j=await z(l,Y,J);console.log("global activity per model",j),C(j)}else"App Owner"==s&&await R(l,t,s,r,Y,J).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let t=e.top_api_keys;u(t)}else{let t=(await G(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[t,s]=e;"spend"!==t&&"startTime"!==t&&"models"!==t&&"users"!==t&&l.push({key:t,spend:s})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let t=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(t[0]))),t}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));u(t),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,t,s,r,Y,J]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(ez,{userID:r,userRole:s,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{className:"mt-2",children:[(0,a.jsx)(eY.Z,{children:"All Up"}),(0,a.jsx)(eY.Z,{children:"Team Based Usage"}),(0,a.jsx)(eY.Z,{children:"End User Usage"}),(0,a.jsx)(eY.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eY.Z,{children:"Cost"}),(0,a.jsx)(eY.Z,{children:"Activity"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Monthly Spend"}),(0,a.jsx)(e4.Z,{data:d,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top API Keys"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top Models"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:x,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1}),(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"✨ Spend by Provider"}),i?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(lV.Z,{className:"mt-4 h-40",variant:"pie",data:S,index:"provider",category:"spend"})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Provider"}),(0,a.jsx)(eF.Z,{children:"Spend"})]})}),(0,a.jsx)(eC.Z,{children:S.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.provider}),(0,a.jsx)(eT.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"All Up"}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",A.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",A.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),i?(0,a.jsx)(a.Fragment,{children:I.map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:I&&I.length>0&&I.slice(0,1).map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lG.Z,{data:k})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(e4.Z,{className:"h-72",data:y,showLegend:!0,index:"date",categories:w,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:q,onValueChange:e=>{V(e),$(e.from,e.to,null)}})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Key"}),(0,a.jsxs)(eR.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(eM.Z,{value:"all-keys",onClick:()=>{$(q.from,q.to,null)},children:"All Keys"},"all-keys"),null==o?void 0:o.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{$(q.from,q.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(eA.Z,{className:"mt-4",children:(0,a.jsxs)(eI.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"End User"}),(0,a.jsx)(eF.Z,{children:"Spend"}),(0,a.jsx)(eF.Z,{children:"Total Events"})]})}),(0,a.jsx)(eC.Z,{children:null==j?void 0:j.map((e,l)=>{var t;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.end_user}),(0,a.jsx)(eT.Z,{children:null===(t=e.total_spend)||void 0===t?void 0:t.toFixed(4)}),(0,a.jsx)(eT.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsx)(eH.Z,{className:"mb-4",enableSelect:!0,value:q,onValueChange:e=>{V(e),X(e.from,e.to)}}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(eu.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(e4.Z,{className:"h-72",data:Z,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})})]})]})]})},lH=()=>{let{Title:e,Paragraph:l}=eV.default,[t,s]=(0,n.useState)(""),[r,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!0),y=(0,o.useSearchParams)(),[f,Z]=(0,n.useState)({data:[]}),_=y.get("userID"),w=y.get("token"),[b,k]=(0,n.useState)("api-keys"),[v,S]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(w){let e=(0,eq.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),S(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),s(l),"Admin Viewer"==l&&k("usage")}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&i(e.premium_user)}}},[w]),(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:_,userRole:t,userEmail:c,showSSOBanner:j,premiumUser:r}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lK,{setPage:k,userRole:t,defaultSelectedKey:null})}),"api-keys"==b?(0,a.jsx)(eW,{userID:_,userRole:t,teams:h,keys:x,setUserRole:s,userEmail:c,setUserEmail:d,setTeams:u,setKeys:p}):"models"==b?(0,a.jsx)(lu,{userID:_,userRole:t,token:w,accessToken:v,modelData:f,setModelData:Z,premiumUser:r}):"llm-playground"==b?(0,a.jsx)(lU,{userID:_,userRole:t,token:w,accessToken:v}):"users"==b?(0,a.jsx)(lj,{userID:_,userRole:t,token:w,keys:x,teams:h,accessToken:v,setKeys:p}):"teams"==b?(0,a.jsx)(lg,{teams:h,setTeams:u,searchParams:y,accessToken:v,userID:_,userRole:t}):"admin-panel"==b?(0,a.jsx)(ly,{setTeams:u,searchParams:y,accessToken:v,showSSOBanner:j}):"api_ref"==b?(0,a.jsx)(lM,{}):"settings"==b?(0,a.jsx)(lb,{userID:_,userRole:t,accessToken:v,premiumUser:r}):"budgets"==b?(0,a.jsx)(lP,{accessToken:v}):"general-settings"==b?(0,a.jsx)(lI,{userID:_,userRole:t,accessToken:v,modelData:f}):"model-hub"==b?(0,a.jsx)(lR,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r}):(0,a.jsx)(lW,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r})]})]})})}}},function(e){e.O(0,[936,608,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/index.html b/litellm/proxy/_experimental/out/index.html index 29cf19287..963865a00 100644 --- a/litellm/proxy/_experimental/out/index.html +++ b/litellm/proxy/_experimental/out/index.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/index.txt b/litellm/proxy/_experimental/out/index.txt index ee14514d8..730ddfbc2 100644 --- a/litellm/proxy/_experimental/out/index.txt +++ b/litellm/proxy/_experimental/out/index.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[39712,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","608","static/chunks/608-d128caa3cfe973c1.js","931","static/chunks/app/page-e266cb0126026d40.js"],""] +3:I[39712,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","608","static/chunks/608-d128caa3cfe973c1.js","931","static/chunks/app/page-2421e763699a7dc4.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["dYIEEO-62OCgyckEhgBd-",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/5d93d4a9fa59d72f.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["N-Poqi-YBhDAzJSVSMX3L",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/5d93d4a9fa59d72f.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/out/404.html b/ui/litellm-dashboard/out/404.html index 3716021f5..dca0b9a75 100644 --- a/ui/litellm-dashboard/out/404.html +++ b/ui/litellm-dashboard/out/404.html @@ -1 +1 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file diff --git a/ui/litellm-dashboard/out/_next/static/dYIEEO-62OCgyckEhgBd-/_buildManifest.js b/ui/litellm-dashboard/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_buildManifest.js similarity index 100% rename from ui/litellm-dashboard/out/_next/static/dYIEEO-62OCgyckEhgBd-/_buildManifest.js rename to ui/litellm-dashboard/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_buildManifest.js diff --git a/ui/litellm-dashboard/out/_next/static/dYIEEO-62OCgyckEhgBd-/_ssgManifest.js b/ui/litellm-dashboard/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_ssgManifest.js similarity index 100% rename from ui/litellm-dashboard/out/_next/static/dYIEEO-62OCgyckEhgBd-/_ssgManifest.js rename to ui/litellm-dashboard/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_ssgManifest.js diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/page-e266cb0126026d40.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-2421e763699a7dc4.js similarity index 82% rename from ui/litellm-dashboard/out/_next/static/chunks/app/page-e266cb0126026d40.js rename to ui/litellm-dashboard/out/_next/static/chunks/app/page-2421e763699a7dc4.js index 44e0921bd..ce8149624 100644 --- a/ui/litellm-dashboard/out/_next/static/chunks/app/page-e266cb0126026d40.js +++ b/ui/litellm-dashboard/out/_next/static/chunks/app/page-2421e763699a7dc4.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,t){Promise.resolve().then(t.bind(t,39712))},39712:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return lH}});var s,r,a=t(3827),n=t(64090),o=t(47907),i=t(8792),c=t(40491),d=t(65270),m=e=>{let{userID:l,userRole:t,userEmail:s,showSSOBanner:r,premiumUser:n}=e;console.log("User ID:",l),console.log("userEmail:",s),console.log("showSSOBanner:",r),console.log("premiumUser:",n);let o=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",t]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(i.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[r?(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(c.Z,{menu:{items:o},children:(0,a.jsx)(d.Z,{children:s})})})]})]})},h=t(80588);let u=async()=>{try{let e=await fetch("https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"),l=await e.json();return console.log("received data: ".concat(l)),l}catch(e){throw console.error("Failed to get model cost map:",e),e}},x=async(e,l)=>{try{let t=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),s}catch(e){throw console.error("Failed to create key:",e),e}},p=async e=>{try{let l=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},j=async(e,l)=>{console.log("model_id in model delete call: ".concat(l));try{let t=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model deleted successfully. Restart server to see this."),s}catch(e){throw console.error("Failed to create key:",e),e}},g=async(e,l)=>{if(console.log("budget_id in budget delete call: ".concat(l)),null!=e)try{let t=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,l)=>{try{console.log("Form Values in budgetCreateCall:",l),console.log("Form Values after check:",l);let t=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},f=async e=>{try{let l=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},Z=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,l)=>{try{console.log("in keyDeleteCall:",l);let t=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,l)=>{try{console.log("in teamDeleteCall:",l);let t=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,l,t){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;try{let n="/user/info";"App Owner"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),"App User"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),console.log("in userInfoCall viewAll=",s),s&&a&&null!=r&&void 0!=r&&(n="".concat(n,"?view_all=true&page=").concat(r,"&page_size=").concat(a));let o=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let i=await o.json();return console.log("API Response:",i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,l)=>{try{let t="/team/info";l&&(t="".concat(t,"?team_id=").concat(l)),console.log("in teamInfoCall");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},S=async e=>{try{let l=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,l,t)=>{try{let l=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelInfoCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,l,t)=>{try{let l=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelHubCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,l,t,s,r,a)=>{try{let l="/model/metrics";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},I=async(e,l,t,s)=>{try{let r="/model/streaming_metrics";l&&(r="".concat(r,"?_selected_model_group=").concat(l,"&startTime=").concat(t,"&endTime=").concat(s));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},C=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/slow_responses";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/exceptions";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,l,t)=>{try{let l=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},F=async e=>{try{let l="/global/spend/teams";console.log("in teamSpendLogsCall:",l);let t=await fetch("".concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=async(e,l,t)=>{try{let s="/global/spend/tags";l&&t&&(s="".concat(s,"?start_date=").concat(l,"&end_date=").concat(t)),console.log("in tagsSpendLogsCall:",s);let r=await fetch("".concat(s),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},R=async(e,l,t,s,r,a)=>{try{console.log("user role in spend logs call: ".concat(t));let l="/spend/logs";l="App Owner"==t?"".concat(l,"?user_id=").concat(s,"&start_date=").concat(r,"&end_date=").concat(a):"".concat(l,"?start_date=").concat(r,"&end_date=").concat(a);let n=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},M=async e=>{try{let l=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},L=async e=>{try{let l=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,l,t,s)=>{try{let r="";r=l?JSON.stringify({api_key:l,startTime:t,endTime:s}):JSON.stringify({startTime:t,endTime:s});let a={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};a.body=r;let n=await fetch("/global/spend/end_users",a);if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,l,t,s)=>{try{let r="/global/spend/provider";t&&s&&(r+="?start_date=".concat(t,"&end_date=").concat(s)),l&&(r+="&api_key=".concat(l));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log(n),n}catch(e){throw console.error("Failed to fetch spend data:",e),e}},B=async(e,l,t)=>{try{let s="/global/activity";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},z=async(e,l,t)=>{try{let s="/global/activity/model";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},K=async e=>{try{let l=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},G=async(e,l)=>{try{let t=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},q=async(e,l)=>{try{let t="/user/get_users?role=".concat(l);console.log("in userGetAllUsersCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let r=await s.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},V=async(e,l)=>{try{console.log("Form Values in teamCreateCall:",l);let t=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,l)=>{try{console.log("Form Values in keyUpdateCall:",l);let t=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},H=async(e,l)=>{try{console.log("Form Values in teamUpateCall:",l);let t=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},Y=async(e,l)=>{try{console.log("Form Values in modelUpateCall:",l);let t=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update model Response:",s),s}catch(e){throw console.error("Failed to update model:",e),e}},J=async(e,l,t)=>{try{console.log("Form Values in teamMemberAddCall:",t);let s=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:l,member:t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},$=async(e,l,t)=>{try{console.log("Form Values in userUpdateUserCall:",l);let s={...l};null!==t&&(s.user_role=t),s=JSON.stringify(s);let r=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:s});if(!r.ok){let e=await r.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await r.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,l)=>{try{let t="/health/services?service=".concat(l);console.log("Checking Slack Budget Alerts service health");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed ".concat(l," service health check ")+e),Error(e)}let r=await s.json();return h.ZP.success("Test request to ".concat(l," made - check logs/alerts on ").concat(l," to verify")),r}catch(e){throw console.error("Failed to perform health check:",e),e}},Q=async e=>{try{let l=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async(e,l,t)=>{try{let l=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},el=async e=>{try{let l=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,l,t)=>{try{let s=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,field_value:t,config_type:"general_settings"})});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return h.ZP.success("Successfully updated value!"),r}catch(e){throw console.error("Failed to set callbacks:",e),e}},es=async(e,l)=>{try{let t=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,config_type:"general_settings"})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return h.ZP.success("Field reset on proxy"),s}catch(e){throw console.error("Failed to get callbacks:",e),e}},er=async(e,l)=>{try{let t=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},ea=async e=>{try{let l=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to call /health:",e),e}};var en=t(10384),eo=t(46453),ei=t(16450),ec=t(52273),ed=t(26780),em=t(15595),eh=t(6698),eu=t(71801),ex=t(42440),ep=t(42308),ej=t(50670),eg=t(81583),ey=t(99129),ef=t(44839),eZ=t(88707),e_=t(1861);let{Option:ew}=ej.default;var eb=e=>{let{userID:l,team:t,userRole:s,accessToken:r,data:o,setData:i}=e,[c]=eg.Z.useForm(),[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(null),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,_]=(0,n.useState)([]),w=()=>{m(!1),c.resetFields()},b=()=>{m(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==r){let e=(await P(r,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,s]);let k=async e=>{try{var t,s,a;let n=null!==(t=null==e?void 0:e.key_alias)&&void 0!==t?t:"",d=null!==(s=null==e?void 0:e.team_id)&&void 0!==s?s:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===d).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(n))throw Error("Key alias ".concat(n," already exists for team with ID ").concat(d,", please provide another key alias"));h.ZP.info("Making API Call"),m(!0);let u=await Z(r,l,e);console.log("key create Response:",u),i(e=>e?[...e,u]:[u]),x(u.key),j(u.soft_budget),h.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.useEffect)(()=>{_(t&&t.models.length>0?t.models.includes("all-proxy-models")?g:t.models:g)},[t,g]),(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(ey.Z,{title:"Create Key",visible:d,width:800,footer:null,onOk:w,onCancel:b,children:(0,a.jsxs)(eg.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:t?t.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t?t.team_alias:"",disabled:!0})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(ew,{value:"all-team-models",children:"All Team Models"},"all-team-models"),f.map(e=>(0,a.jsx)(ew,{value:e,children:e},e))]})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==t?void 0:t.max_budget)!==null&&(null==t?void 0:t.max_budget)!==void 0?null==t?void 0:t.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.max_budget&&l>t.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(t.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==t?void 0:t.budget_duration)!==null&&(null==t?void 0:t.budget_duration)!==void 0?null==t?void 0:t.budget_duration:"None"),children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==t?void 0:t.tpm_limit)!==null&&(null==t?void 0:t.tpm_limit)!==void 0?null==t?void 0:t.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.tpm_limit&&l>t.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(t.tpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==t?void 0:t.rpm_limit)!==null&&(null==t?void 0:t.rpm_limit)!==void 0?null==t?void 0:t.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.rpm_limit&&l>t.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(t.rpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Key"})})]})}),u&&(0,a.jsx)(ey.Z,{visible:d,onOk:w,onCancel:b,footer:null,children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Save your Key"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:null!=u?(0,a.jsxs)("div",{children:[(0,a.jsx)(eu.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:u})}),(0,a.jsx)(ep.CopyToClipboard,{text:u,onCopy:()=>{h.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(ei.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(eu.Z,{children:"Key being created, this might take 30s"})})]})})]})},ek=t(9454),ev=t(98941),eS=t(33393),eN=t(5),eA=t(13810),eE=t(61244),eI=t(10827),eC=t(3851),eT=t(2044),eP=t(64167),eF=t(74480),eO=t(7178),eR=t(95093),eM=t(27166);let{Option:eL}=ej.default;var eU=e=>{let{userID:l,userRole:t,accessToken:s,selectedTeam:r,data:o,setData:i,teams:c}=e,[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(!1),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(""),[k,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(!1),[A,E]=(0,n.useState)(null),[I,C]=(0,n.useState)([]),T=new Set,[F,O]=(0,n.useState)(T);(0,n.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==s&&null!==t){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),C(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[s,l,t]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,t)=>{let s=l.team_id;e.add(s)}),O(e)}},[c]);let R=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),E(e),v(!0)},M=async e=>{if(null==s)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let t=await W(s,e);console.log("handleEditSubmit: newKeyValues",t),o&&i(o.map(e=>e.token===l?t:e)),h.ZP.success("Key updated successfully"),v(!1),E(null)},L=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+l),x(!0))},U=async()=>{if(null!=p&&null!=o){try{await w(s,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(eI.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Key Alias"}),(0,a.jsx)(eF.Z,{children:"Secret Key"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(eC.Z,{children:o.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(r){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(F.has(e.team_id),", selectedTeam id: ").concat(r.team_id)),(null!=r.team_id||null===e.team_id||F.has(e.team_id))&&e.team_id!=r.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(eu.Z,{children:e.key_alias}):(0,a.jsx)(eu.Z,{children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:e.key_name})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(eT.Z,{children:null!=e.max_budget?(0,a.jsx)(eu.Z,{children:e.max_budget}):(0,a.jsx)(eu.Z,{children:"Unlimited"})}),(0,a.jsx)(eT.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:r&&r.models&&r.models.length>0?r.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{onClick:()=>{E(e),N(!0)},icon:ek.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:S,onCancel:()=>{N(!1),E(null)},footer:null,width:800,children:A&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(A.spend).toFixed(4)}catch(e){return A.spend}})()})})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.max_budget?(0,a.jsx)(a.Fragment,{children:A.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.expires?(0,a.jsx)(a.Fragment,{children:new Date(A.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(eA.Z,{className:"my-4",children:[(0,a.jsx)(ex.Z,{children:"Token Name"}),(0,a.jsx)(eu.Z,{className:"my-1",children:A.key_alias?A.key_alias:A.key_name}),(0,a.jsx)(ex.Z,{children:"Token ID"}),(0,a.jsx)(eu.Z,{className:"my-1 text-[12px]",children:A.token}),(0,a.jsx)(ex.Z,{children:"Metadata"}),(0,a.jsx)(eu.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(A.metadata)," "]})})]}),(0,a.jsx)(ei.Z,{className:"mx-auto flex items-center",onClick:()=>{N(!1),E(null)},children:"Close"})]})}),(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>R(e)}),(0,a.jsx)(eE.Z,{onClick:()=>L(e),icon:eS.Z,size:"sm"})]})]},e.token)})})]}),u&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{x(!1),j(null)},children:"Cancel"})]})]})]})})]}),A&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,token:s,onSubmit:o}=e,[i]=eg.Z.useForm(),[d,m]=(0,n.useState)(r),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1);return(0,a.jsx)(ey.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:i,onFinish:M,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let t=l.filter(e=>!d.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!d.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(t)),t.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(t,"Team models: ").concat(d.models)):Promise.resolve()}}],children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(eL,{value:"all-team-models",children:"All Team Models"},"all-team-models"),d&&d.models?d.models.includes("all-proxy-models")?I.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):d.models.map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):I.map(e=>(0,a.jsx)(eL,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==d?void 0:d.max_budget)!==null&&(null==d?void 0:d.max_budget)!==void 0?null==d?void 0:d.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&d&&null!==d.max_budget&&l>d.max_budget)throw console.log("keyTeam.max_budget: ".concat(d.max_budget)),Error("Budget cannot exceed team max budget: $".concat(d.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(eg.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(eR.Z,{value:s.team_alias,children:null==c?void 0:c.map((e,l)=>(0,a.jsx)(eM.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:k,onCancel:()=>{v(!1),E(null)},token:A,onSubmit:M})]})},eD=t(76032),eB=t(35152),ez=e=>{let{userID:l,userRole:t,accessToken:s,userSpend:r,selectedTeam:o}=e;console.log("userSpend: ".concat(r));let[i,c]=(0,n.useState)(null!==r?r:0),[d,m]=(0,n.useState)(0),[h,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(s&&l&&t&&"Admin"===t&&null==r)try{let e=await S(s);e&&(e.spend?c(e.spend):c(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(async()=>{try{if(null===l||null===t)return;if(null!==s){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),u(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,s,l]),(0,n.useEffect)(()=>{null!==r&&c(r)},[r]);let x=[];o&&o.models&&(x=o.models),x&&x.includes("all-proxy-models")?(console.log("user models:",h),x=h):x&&x.includes("all-team-models")?x=o.models:x&&0===x.length&&(x=h);let p=void 0!==i?i.toFixed(4):null;return console.log("spend in view user spend: ".concat(i)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:["Total Spend"," "]}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",p]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Team Models"})}),(0,a.jsx)(em.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(eD.Z,{children:x.map(e=>(0,a.jsx)(eB.Z,{children:(0,a.jsx)(eu.Z,{children:e})},e))})})]})})]})},eK=e=>{let{userID:l,userRole:t,selectedTeam:s,accessToken:r}=e,[o,i]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==r){let e=(await P(r,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),i(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,t]);let c=[];return s&&s.models&&(c=s.models),c&&c.includes("all-proxy-models")&&(console.log("user models:",o),c=o),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"mb-5",children:(0,a.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==s?void 0:s.team_alias})})})},eG=e=>{let l,{teams:t,setSelectedTeam:s,userRole:r}=e,o={models:[],team_id:null,team_alias:"Default Team"},[i,c]=(0,n.useState)(o);return(l="App User"===r?t:t?[...t,o]:[o],"App User"===r)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(ex.Z,{children:"Select Team"}),(0,a.jsx)(eu.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(eu.Z,{className:"mt-3 mb-3",children:[(0,a.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>s(e),children:e.team_alias},l))}):(0,a.jsxs)(eu.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},eq=t(37963),eV=t(97482);console.log("isLocal:",!1);var eW=e=>{let{userID:l,userRole:t,teams:s,keys:r,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,n.useState)(null),p=(0,o.useSearchParams)();p.get("viewSpend"),(0,o.useRouter)();let j=p.get("token"),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)([]),b={models:[],team_alias:"Default Team",team_id:null},[v,N]=(0,n.useState)(s?s[0]:b);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(j){let e=(0,eq.o)(j);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),i(l)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&g&&t&&!r&&!u){let e=sessionStorage.getItem("userModels"+l);e?w(JSON.parse(e)):(async()=>{try{let e=await k(g,l,t,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==t){let e=await S(g);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(e.teams);let s=[...e.teams];s.length>0?(console.log("response['teams']: ".concat(s)),N(s[0])):N(b),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let r=(await P(g,l,t)).data.map(e=>e.id);console.log("available_model_names:",r),w(r),console.log("userModels:",_),sessionStorage.setItem("userModels"+l,JSON.stringify(r))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,j,g,r,t]),(0,n.useEffect)(()=>{if(null!==r&&null!=v){let e=0;for(let l of r)v.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===v.team_id&&(e+=l.spend);Z(e)}else if(null!==r){let e=0;for(let l of r)e+=l.spend;Z(e)}},[v]),null==l||null==j){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==g)return null;if(null==t&&i("App Owner"),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",v),console.log("teamSpend: ".concat(f)),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eK,{userID:l,userRole:t,selectedTeam:v||null,accessToken:g}),(0,a.jsx)(ez,{userID:l,userRole:t,accessToken:g,userSpend:f,selectedTeam:v||null}),(0,a.jsx)(eU,{userID:l,userRole:t,accessToken:g,selectedTeam:v||null,data:r,setData:h,teams:s}),(0,a.jsx)(eb,{userID:l,team:v||null,userRole:t,accessToken:g,data:r,setData:h},v?v.team_id:null),(0,a.jsx)(eG,{teams:s,setSelectedTeam:N,userRole:t})]})})})},eH=t(35087),eY=t(92836),eJ=t(26734),e$=t(41608),eX=t(32126),eQ=t(23682),e0=t(47047),e1=t(76628),e2=t(25707),e4=t(44041),e5=t(38302),e8=t(28683),e3=t(1460),e6=t(78578),e7=t(63954),e9=t(90252),le=t(7905),ll=e=>{let{modelID:l,accessToken:t}=e,[s,r]=(0,n.useState)(!1),o=async()=>{try{h.ZP.info("Making API Call"),r(!0);let e=await j(t,l);console.log("model delete Response:",e),h.ZP.success("Model ".concat(l," deleted successfully")),r(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(eE.Z,{onClick:()=>r(!0),icon:eS.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:s,onOk:o,okType:"danger",onCancel:()=>r(!1),children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Delete Model"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},lt=t(97766),ls=t(46495),lr=t(18190),la=t(91118),ln=e=>{let{modelMetrics:l,modelMetricsCategories:t,customTooltip:s,premiumUser:r}=e;return r?(0,a.jsx)(la.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:t,colors:["indigo","rose"],connectNulls:!0,customTooltip:s}):(0,a.jsxs)("div",{children:[(0,a.jsx)(lr.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,a.jsx)(ei.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},lo=e=>{let{fields:l,selectedProvider:t}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,a.jsx)(ec.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})};let{Title:li,Link:lc}=eV.default;(s=r||(r={})).OpenAI="OpenAI",s.Azure="Azure",s.Anthropic="Anthropic",s.Google_AI_Studio="Google AI Studio",s.Bedrock="Amazon Bedrock",s.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",s.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",s.Databricks="Databricks";let ld={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},lm={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},lh=async(e,l,t)=>{try{let s=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(s)),console.log("received type of deployments: ".concat(typeof s)),s.forEach(async t=>{console.log("litellm_model: ".concat(t));let s={},r={};s.model=t;let a="";for(let[l,t]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==t){if("model_name"==l)a+=t;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)r[l]=t;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",t);let e={};if(t&&void 0!=t){try{e=JSON.parse(t)}catch(e){throw h.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,t]of Object.entries(e))s[l]=t}}else s[l]=t}let n={model_name:a,litellm_params:s,model_info:r},o=await x(l,n);console.log("response for model create call: ".concat(o.data))}),t.resetFields()}catch(e){h.ZP.error("Failed to create model: "+e,10)}};var lu=e=>{var l,t,s;let o,{accessToken:i,token:c,userRole:d,userID:m,modelData:x={data:[]},setModelData:j,premiumUser:g}=e,[y,f]=(0,n.useState)([]),[Z]=eg.Z.useForm(),[_,w]=(0,n.useState)(null),[b,k]=(0,n.useState)(""),[v,S]=(0,n.useState)([]),A=Object.values(r).filter(e=>isNaN(Number(e))),[P,F]=(0,n.useState)([]),[O,R]=(0,n.useState)("OpenAI"),[M,L]=(0,n.useState)(""),[U,D]=(0,n.useState)(!1),[B,z]=(0,n.useState)(null),[K,G]=(0,n.useState)([]),[q,V]=(0,n.useState)(null),[W,H]=(0,n.useState)([]),[J,$]=(0,n.useState)([]),[X,Q]=(0,n.useState)([]),[el,et]=(0,n.useState)([]),[es,en]=(0,n.useState)([]),[ep,ej]=(0,n.useState)([]),[ef,ew]=(0,n.useState)([]),[eb,ek]=(0,n.useState)([]),[eS,eL]=(0,n.useState)([]),[eU,eD]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eB,ez]=(0,n.useState)(null),[eK,eG]=(0,n.useState)(0),eq=e=>{z(e),D(!0)},eW=async e=>{if(console.log("handleEditSubmit:",e),null==i)return;let l={},t=null;for(let[s,r]of Object.entries(e))"model_id"!==s?l[s]=r:t=r;let s={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",s);try{await Y(i,s),h.ZP.success("Model updated successfully, restart server to see updates"),D(!1),z(null)}catch(e){console.log("Error occurred")}},lr=()=>{k(new Date().toLocaleString())},la=async()=>{if(!i){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eB);try{await er(i,{router_settings:{model_group_retry_policy:eB}}),h.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),h.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!i||!c||!d||!m)return;let e=async()=>{try{var e,l,t,s,r,a,n,o;let c=await p(i);F(c);let h=await N(i,m,d);console.log("Model data response:",h.data),j(h);let u=new Set;for(let e=0;e0&&(g=x[x.length-1],console.log("_initial_model_group:",g),V(g)),console.log("selectedModelGroup:",q);let y=await E(i,m,d,g,null===(e=eU.from)||void 0===e?void 0:e.toISOString(),null===(l=eU.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",y),$(y.data),Q(y.all_api_bases);let f=await I(i,g,null===(t=eU.from)||void 0===t?void 0:t.toISOString(),null===(s=eU.to)||void 0===s?void 0:s.toISOString());et(f.data),en(f.all_api_bases);let Z=await T(i,m,d,g,null===(r=eU.from)||void 0===r?void 0:r.toISOString(),null===(a=eU.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",Z),ej(Z.data),ew(Z.exception_types);let _=await C(i,m,d,g,null===(n=eU.from)||void 0===n?void 0:n.toISOString(),null===(o=eU.to)||void 0===o?void 0:o.toISOString());console.log("slowResponses:",_),eL(_);let w=(await ee(i,m,d)).router_settings;console.log("routerSettingsInfo:",w);let b=w.model_group_retry_policy,k=w.num_retries;console.log("model_group_retry_policy:",b),console.log("default_retries:",k),ez(b),eG(k)}catch(e){console.error("There was an error fetching the model data",e)}};i&&c&&d&&m&&e();let l=async()=>{let e=await u();console.log("received model cost map data: ".concat(Object.keys(e))),w(e)};null==_&&l(),lr()},[i,c,d,m,_,b]),!x||!i||!c||!d||!m)return(0,a.jsx)("div",{children:"Loading..."});let lu=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(_)),null!=_&&"object"==typeof _&&e in _)?_[e].litellm_provider:"openai";if(r){let e=r.split("/"),l=e[0];n=1===e.length?h(r):l}else n="openai";a&&(o=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,c=null==a?void 0:a.max_tokens,d=null==a?void 0:a.max_input_tokens),(null==s?void 0:s.litellm_params)&&(m=Object.fromEntries(Object.entries(null==s?void 0:s.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),x.data[e].provider=n,x.data[e].input_cost=o,x.data[e].output_cost=i,x.data[e].input_cost&&(x.data[e].input_cost=(1e6*Number(x.data[e].input_cost)).toFixed(2)),x.data[e].output_cost&&(x.data[e].output_cost=(1e6*Number(x.data[e].output_cost)).toFixed(2)),x.data[e].max_tokens=c,x.data[e].max_input_tokens=d,x.data[e].api_base=null==s?void 0:null===(t=s.litellm_params)||void 0===t?void 0:t.api_base,x.data[e].cleanedLitellmParams=m,lu.push(s.model_name),console.log(x.data[e])}if(d&&"Admin Viewer"==d){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lx=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(r).find(l=>r[l]===e);if(l){let e=ld[l];console.log("mappingResult: ".concat(e));let t=[];"object"==typeof _&&Object.entries(_).forEach(l=>{let[s,r]=l;null!==r&&"object"==typeof r&&"litellm_provider"in r&&(r.litellm_provider===e||r.litellm_provider.includes(e))&&t.push(s)}),S(t),console.log("providerModels: ".concat(v))}},lp=async()=>{try{h.ZP.info("Running health check..."),L("");let e=await ea(i);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lj=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),i&&m&&d&&l&&t){console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),V(e);try{let s=await E(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model metrics response:",s),$(s.data),Q(s.all_api_bases);let r=await I(i,e,l.toISOString(),t.toISOString());et(r.data),en(r.all_api_bases);let a=await T(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model exceptions response:",a),ej(a.data),ew(a.exception_types);let n=await C(i,m,d,e,l.toISOString(),t.toISOString());console.log("slowResponses:",n),eL(n)}catch(e){console.error("Failed to fetch model metrics",e)}}},lg=e=>{var l,t;let{payload:s,active:r}=e;if(!r||!s)return null;let n=null===(t=s[0])||void 0===t?void 0:null===(l=t.payload)||void 0===l?void 0:l.date,o=s.sort((e,l)=>l.value-e.value);if(o.length>5){let e=o.length-5;(o=o.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:s.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,a.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[n&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),o.map((e,l)=>{let t=parseFloat(e.value.toFixed(5)),s=0===t&&e.value>0?"<0.00001":t.toFixed(5);return(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:s})]},l)})]})};console.log("selectedProvider: ".concat(O)),console.log("providerModels.length: ".concat(v.length));let ly=Object.keys(r).find(e=>r[e]===O);return ly&&(o=P.find(e=>e.name===ld[ly])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eY.Z,{children:"All Models"}),(0,a.jsx)(eY.Z,{children:"Add Model"}),(0,a.jsx)(eY.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eY.Z,{children:"Model Analytics"}),(0,a.jsx)(eY.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[b&&(0,a.jsxs)(eu.Z,{children:["Last Refreshed: ",b]}),(0,a.jsx)(eE.Z,{icon:e7.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lr})]})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],onValueChange:e=>V("all"===e?"all":e),value:q||K[0],children:[(0,a.jsx)(eM.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))]})]}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"Public Model Name"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:"Provider"}),"Admin"===d&&(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"API Base"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:"Extra litellm Params"}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(eF.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:"Max Tokens"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word"},children:"Status"})]})}),(0,a.jsx)(eC.Z,{children:x.data.filter(e=>"all"===q||e.model_name===q||null==q||""===q).map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{children:e.model_name})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.provider}),"Admin"===d&&(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:e.api_base}),(0,a.jsx)(eT.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Litellm params"})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)("pre",{children:JSON.stringify(e.cleanedLitellmParams,null,2)})})]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.input_cost||e.litellm_params.input_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.output_cost||e.litellm_params.output_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)("p",{style:{fontSize:"10px"},children:["Max Tokens: ",e.max_tokens," ",(0,a.jsx)("br",{}),"Max Input Tokens: ",e.max_input_tokens]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(eN.Z,{icon:e9.Z,size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(eN.Z,{icon:le.Z,size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsxs)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>eq(e)}),(0,a.jsx)(ll,{modelID:e.model_info.id,accessToken:i})]})]},l))})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:t,model:s,onSubmit:r}=e,[n]=eg.Z.useForm(),o={},i="",c="";if(s){o=s.litellm_params,i=s.model_name;let e=s.model_info;e&&(c=e.id,console.log("model_id: ".concat(c)),o.model_id=c)}return(0,a.jsx)(ey.Z,{title:"Edit Model "+i,visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r(e),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:eW,initialValues:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:U,onCancel:()=>{D(!1),z(null)},model:B,onSubmit:eW})]}),(0,a.jsxs)(eX.Z,{className:"h-full",children:[(0,a.jsx)(li,{level:2,children:"Add new model"}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eg.Z,{form:Z,onFinish:()=>{Z.validateFields().then(e=>{lh(e,i,Z)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:O.toString(),children:A.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>{lx(e),R(e)},children:e},l))})}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(s=O.toString())?"gemini-pro":"Anthropic"==s?"claude-3-opus":"Amazon Bedrock"==s?"claude-3-opus":"Google AI Studio"==s?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===O?(0,a.jsx)(ec.Z,{placeholder:"Enter model name"}):v.length>0?(0,a.jsx)(e0.Z,{value:v,children:v.map((e,l)=>(0,a.jsx)(e1.Z,{value:e,children:e},l))}):(0,a.jsx)(ec.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==o&&o.fields.length>0&&(0,a.jsx)(lo,{fields:o.fields,selectedProvider:o.name}),"Amazon Bedrock"!=O&&"Vertex AI (Anthropic, Gemini, etc.)"!=O&&void 0===o&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(ec.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==O&&(0,a.jsx)(eg.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(ec.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(ec.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ls.Z,{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;Z.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?h.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&h.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(e_.ZP,{icon:(0,a.jsx)(lt.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==O||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==O)&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(ec.Z,{placeholder:"https://..."})}),"Azure"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(ec.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==O&&(0,a.jsxs)("div",{children:[(0,a.jsx)(eg.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(lc,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(eg.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,a.jsx)(e6.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(e3.Z,{title:"Get help on our github",children:(0,a.jsx)(eV.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(ei.Z,{onClick:lp,children:"Run `/health`"}),M&&(0,a.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:eU,onValueChange:e=>{eD(e),lj(q,e.from,e.to)}})]}),(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Model Group"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2",defaultValue:q||K[0],value:q||K[0],children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>lj(e,eU.from,eU.to),children:e},l))})]})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eY.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(eu.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),J&&X&&(0,a.jsx)(e2.Z,{title:"Model Latency",className:"h-72",data:J,showLegend:!1,index:"date",categories:X,connectNulls:!0,customTooltip:lg})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(ln,{modelMetrics:el,modelMetricsCategories:es,customTooltip:lg,premiumUser:g})})]})]})})}),(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Deployment"}),(0,a.jsx)(eF.Z,{children:"Success Responses"}),(0,a.jsxs)(eF.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(eC.Z,{children:eS.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.api_base}),(0,a.jsx)(eT.Z,{children:e.total_count}),(0,a.jsx)(eT.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(eA.Z,{className:"mt-4",children:[(0,a.jsx)(ex.Z,{children:"Exceptions per Model"}),(0,a.jsx)(e4.Z,{className:"h-72",data:ep,index:"model",categories:ef,stack:!0,colors:["indigo-300","rose-200","#ffcc33"],yAxisWidth:30})]})]}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],value:q||K[0],onValueChange:e=>V(e),children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))})]}),(0,a.jsxs)(ex.Z,{children:["Retry Policy for ",q]}),(0,a.jsx)(eu.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),lm&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(lm).map((e,l)=>{var t;let[s,r]=e,n=null==eB?void 0:null===(t=eB[q])||void 0===t?void 0:t[r];return null==n&&(n=eK),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)("td",{children:(0,a.jsx)(eZ.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{ez(l=>{var t;let s=null!==(t=null==l?void 0:l[q])&&void 0!==t?t:{};return{...null!=l?l:{},[q]:{...s,[r]:e}}})}})})]},l)})})}),(0,a.jsx)(ei.Z,{className:"mt-6 mr-8",onClick:la,children:"Save"})]})]})]})})};let{Option:lx}=ej.default;var lp=e=>{let{userID:l,accessToken:t,teams:s}=e,[r]=eg.Z.useForm(),[o,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[m,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{let e=await P(t,l,"any"),s=[];for(let l=0;l{i(!1),r.resetFields()},p=()=>{i(!1),d(null),r.resetFields()},j=async e=>{try{h.ZP.info("Making API Call"),i(!0),console.log("formValues in create user:",e);let s=await _(t,null,e);console.log("user create Response:",s),d(s.key),h.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-0",onClick:()=>i(!0),children:"+ Invite User"}),(0,a.jsxs)(ey.Z,{title:"Invite User",visible:o,width:800,footer:null,onOk:x,onCancel:p,children:[(0,a.jsx)(eu.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(eu.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(eg.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(eg.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(ej.default,{placeholder:"Select Team ID",style:{width:"100%"},children:s?s.map(e=>(0,a.jsx)(lx,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(lx,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create User"})})]})]}),c&&(0,a.jsxs)(ey.Z,{title:"User Created Successfully",visible:o,onOk:x,onCancel:p,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},lj=e=>{let{accessToken:l,token:t,keys:s,userRole:r,userID:o,teams:i,setKeys:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(0),[j,g]=n.useState(null),[y,f]=(0,n.useState)(null);return((0,n.useEffect)(()=>{if(!l||!t||!r||!o)return;let e=async()=>{try{let e=await k(l,null,r,!0,x,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&r&&o&&e()},[l,t,r,o,x]),d&&l&&t&&r&&o)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(eo.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(lp,{userID:o,accessToken:l,teams:i}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(eu.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(eJ.Z,{children:(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"User ID"}),(0,a.jsx)(eF.Z,{children:"User Email"}),(0,a.jsx)(eF.Z,{children:"User Models"}),(0,a.jsx)(eF.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User API Key Aliases"})]})}),(0,a.jsx)(eC.Z,{children:d.map(e=>{var l;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_id}),(0,a.jsx)(eT.Z,{children:e.user_email}),(0,a.jsx)(eT.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(eT.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eo.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsx)(eN.Z,{size:"xs",color:"indigo",children:e.key_aliases.filter(e=>null!==e).join(", ")}):(0,a.jsx)(eN.Z,{size:"xs",color:"gray",children:"No Keys"})})})]},e.user_id)})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})})]}),function(){if(!d)return null;let e=Math.ceil(d.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",x+1," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:0===x,onClick:()=>p(x-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",onClick:()=>{p(x+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},lg=e=>{let{teams:l,searchParams:t,accessToken:s,setTeams:r,userID:o,userRole:i}=e,[c]=eg.Z.useForm(),[d]=eg.Z.useForm(),{Title:m,Paragraph:u}=eV.default,[x,p]=(0,n.useState)(""),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(l?l[0]:null),[Z,_]=(0,n.useState)(!1),[w,k]=(0,n.useState)(!1),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)(!1),[I,C]=(0,n.useState)(null),[T,F]=(0,n.useState)({}),O=e=>{f(e),g(!0)},R=async e=>{let t=e.team_id;if(console.log("handleEditSubmit:",e),null==s)return;let a=await H(s,e);l&&r(l.map(e=>e.team_id===t?a.data:e)),h.ZP.success("Team updated successfully"),g(!1),f(null)},M=async e=>{C(e),E(!0)},L=async()=>{if(null!=I&&null!=l&&null!=s){try{await b(s,I);let e=l.filter(e=>e.team_id!==I);r(e)}catch(e){console.error("Error deleting the team:",e)}E(!1),C(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{if(null===o||null===i||null===s||null===l)return;console.log("fetching team info:");let e={};for(let t=0;t<(null==l?void 0:l.length);t++){let r=l[t].team_id,a=await v(s,r);console.log("teamInfo response:",a),null!==a&&(e={...e,[r]:a})}F(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===o||null===i)return;if(null!==s){let e=(await P(s,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,o,i,l]);let U=async e=>{try{if(null!=s){var t;let a=null==e?void 0:e.team_alias;if((null!==(t=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==t?t:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));h.ZP.info("Creating Team");let n=await V(s,e);null!==l?r([...l,n]):r([n]),console.log("response for team create call: ".concat(n)),h.ZP.success("Team created"),_(!1)}}catch(e){console.error("Error creating the team:",e),h.ZP.error("Error creating the team: "+e,20)}},D=async e=>{try{if(null!=s&&null!=l){h.ZP.info("Adding Member");let t={role:"user",user_email:e.user_email,user_id:e.user_id},a=await J(s,y.team_id,t);console.log("response for team create call: ".concat(a.data));let n=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(n)),-1!==n){let e=[...l];e[n]=a.data,r(e),f(a.data)}k(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Team Name"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(eF.Z,{children:"Info"})]})}),(0,a.jsx)(eC.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(eT.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].keys&&T[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].team_info&&T[e.team_id].team_info.members_with_roles&&T[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>O(e)}),(0,a.jsx)(eE.Z,{onClick:()=>M(e.team_id),icon:eS.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{E(!1),C(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>_(!0),children:"+ Create New Team"}),(0,a.jsx)(ey.Z,{title:"Create Team",visible:Z,width:800,footer:null,onOk:()=>{_(!1),c.resetFields()},onCancel:()=>{_(!1),c.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:U,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{f(e)},children:e.team_alias},l))}):(0,a.jsxs)(u,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:y?y.members_with_roles.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.role})]},l)):null})]})}),y&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,team:s,onSubmit:r}=e,[n]=eg.Z.useForm();return(0,a.jsx)(ey.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:s.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:R,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:j,onCancel:()=>{g(!1),f(null)},team:y,onSubmit:R})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-5",onClick:()=>k(!0),children:"+ Add member"}),(0,a.jsx)(ey.Z,{title:"Add member",visible:w,width:800,footer:null,onOk:()=>{k(!1),d.resetFields()},onCancel:()=>{k(!1),d.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:D,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},ly=e=>{let l,{searchParams:t,accessToken:s,showSSOBanner:r}=e,[o]=eg.Z.useForm(),[i]=eg.Z.useForm(),{Title:c,Paragraph:d}=eV.default,[m,u]=(0,n.useState)(""),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(!1),[Z,_]=(0,n.useState)(!1),[w,b]=(0,n.useState)(!1),[k,v]=(0,n.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let S=()=>{v(!1)},N=["proxy_admin","proxy_admin_viewer"];(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await q(s,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let t=await q(s,"proxy_admin");t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(t)),console.log("combinedList: ".concat(e)),p(e)}})()},[s]);let A=()=>{_(!1),i.resetFields()},E=()=>{_(!1),i.resetFields()},I=e=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]}),C=(e,l,t)=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:l,children:N.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:t,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update role"})})]}),T=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,null);console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),h.ZP.success("Refresh tab to see updated user role"),_(!1)}}catch(e){console.error("Error creating the key:",e)}},P=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),g(!1)}}catch(e){console.error("Error creating the key:",e)}},F=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await $(s,e,"proxy_admin");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),f(!1)}}catch(e){console.error("Error creating the key:",e)}},O=async e=>{null!=s&&er(s,{environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}})};return console.log("admins: ".concat(null==x?void 0:x.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(c,{level:4,children:"Admin Access "}),(0,a.jsxs)(d,{children:[r&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc. ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:x?x.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.user_role}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>_(!0)}),(0,a.jsx)(ey.Z,{title:"Update role",visible:Z,width:800,footer:null,onOk:A,onCancel:E,children:C(T,e.user_role,e.user_id)})]})]},l)):null})]})})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(ei.Z,{className:"mr-4 mb-5",onClick:()=>f(!0),children:"+ Add admin"}),(0,a.jsx)(ey.Z,{title:"Add admin",visible:y,width:800,footer:null,onOk:()=>{f(!1),i.resetFields()},onCancel:()=>{f(!1),i.resetFields()},children:I(F)}),(0,a.jsx)(ei.Z,{className:"mb-5",onClick:()=>g(!0),children:"+ Add viewer"}),(0,a.jsx)(ey.Z,{title:"Add viewer",visible:j,width:800,footer:null,onOk:()=>{g(!1),i.resetFields()},onCancel:()=>{g(!1),i.resetFields()},children:I(P)})]})})]}),(0,a.jsxs)(eo.Z,{children:[(0,a.jsx)(c,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(ei.Z,{onClick:()=>b(!0),children:"Add SSO"}),(0,a.jsx)(ey.Z,{title:"Add SSO",visible:w,width:800,footer:null,onOk:()=>{b(!1),o.resetFields()},onCancel:()=>{b(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{F(e),O(e),b(!1),v(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(ef.Z.Password,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(ef.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(ey.Z,{title:"SSO Setup Instructions",visible:k,width:800,footer:null,onOk:S,onCancel:()=>{v(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{onClick:S,children:"Done"})})]})]}),(0,a.jsxs)(lr.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},lf=t(42556),lZ=e=>{let{alertingSettings:l,handleInputChange:t,handleResetField:s,handleSubmit:r,premiumUser:n}=e,[o]=eg.Z.useForm();return(0,a.jsxs)(eg.Z,{form:o,onFinish:()=>{let e=o.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):r(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{align:"center",children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?n?(0,a.jsx)(eg.Z.Item,{name:e.field_name,children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l)}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}):(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(eg.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l),className:"p-0"}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>s(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update Settings"})})]})},l_=e=>{let{accessToken:l,premiumUser:t}=e,[s,r]=(0,n.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,n.useEffect)(()=>{l&&f(l).then(e=>{r(e)})},[l]),(0,a.jsx)(lZ,{alertingSettings:s,handleInputChange:(e,l)=>{r(s.map(t=>t.field_name===e?{...t,field_value:l}:t))},handleResetField:(e,t)=>{if(l)try{let l=s.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),r(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let t={};s.forEach(e=>{t[e.field_name]=e.field_value});let r={...e,...t};try{et(l,"alerting_args",r),h.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:t})};let lw=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var lb=e=>{let{accessToken:l,userRole:t,userID:s,premiumUser:r}=e,[o,i]=(0,n.useState)(lw),[c,d]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[x]=eg.Z.useForm(),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,Z]=(0,n.useState)(""),[_,w]=(0,n.useState)({}),[b,k]=(0,n.useState)([]),v=e=>{b.includes(e)?k(b.filter(l=>l!==e)):k([...b,e])},S={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,n.useEffect)(()=>{l&&t&&s&&ee(l,s,t).then(e=>{console.log("callbacks",e);let l=lw;i(l=l.map(l=>{let t=e.callbacks.find(e=>e.name===l.name);return t?{...l,variables:{...l.variables,...t.variables}}:l}));let t=e.alerts;if(console.log("alerts_data",t),t&&t.length>0){let e=t[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),k(e.active_alerts),Z(l),w(e.alerts_to_webhook)}d(t)})},[l,t,s]);let N=e=>b&&b.includes(e),A=e=>{if(!l)return;let t=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[t,s]=e;return[t,(null===(l=document.querySelector('input[name="'.concat(t,'"]')))||void 0===l?void 0:l.value)||s]}));console.log("updatedVariables",t),console.log("updateAlertTypes",g);let s={environment_variables:t,litellm_settings:{success_callback:[e.name]}};try{er(l,s)}catch(e){h.ZP.error("Failed to update callback: "+e,20)}h.ZP.success("Callback updated successfully")},E=()=>{l&&x.validateFields().then(e=>{if(console.log("Form values:",e),"langfuse"===e.callback){er(l,{environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),er(l,{general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}}),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),er(l,{environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};i(o?[...o,t]:[t])}u(!1),x.resetFields(),j(null)})};return l?(console.log("callbacks: ".concat(o)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(lr.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Settings"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Callback"}),(0,a.jsx)(eF.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(eC.Z,{children:o.filter(e=>"slack"!==e.name).map((e,t)=>{var s;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eN.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).filter(l=>{let[t,s]=l;return t.toLowerCase().includes(e.name)}).map(e=>{let[l,t]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(eu.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(ec.Z,{name:l,defaultValue:t,type:"password"})]},l)})}),(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(e),children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,e.name),className:"mx-2",children:"Test Callback"})]})]},t)})})]})})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eu.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(S).map((e,l)=>{let[t,s]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:"region_outage_alerts"==t?r?(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)}):(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:t,type:"password",defaultValue:_&&_[t]?_[t]:f})})]},l)})})]}),(0,a.jsx)(ei.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(S).forEach(l=>{let[t,s]=l,r=document.querySelector('input[name="'.concat(t,'"]'));console.log("key",t),console.log("webhookInput",r);let a=(null==r?void 0:r.value)||"";console.log("newWebhookValue",a),e[t]=a}),console.log("updatedAlertToWebhooks",e);let t={general_settings:{alert_to_webhook_url:e,alert_types:b}};console.log("payload",t);try{er(l,t)}catch(e){h.ZP.error("Failed to update alerts: "+e,20)}h.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(l_,{accessToken:l,premiumUser:r})})]})]})]}),(0,a.jsx)(ey.Z,{title:"Add Callback",visible:m,onOk:E,width:800,onCancel:()=>{u(!1),x.resetFields(),j(null)},footer:null,children:(0,a.jsxs)(eg.Z,{form:x,layout:"vertical",onFinish:E,children:[(0,a.jsx)(eg.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(ej.default,{onChange:e=>{j(e)},children:[(0,a.jsx)(ej.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(ej.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(ec.Z,{type:"password"})}),(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})]}),"openmeter"==p&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eg.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:lk}=ej.default;var lv=e=>{let{models:l,accessToken:t,routerSettings:s,setRouterSettings:r}=e,[o]=eg.Z.useForm(),[i,c]=(0,n.useState)(!1),[d,m]=(0,n.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>c(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(ey.Z,{title:"Add Fallbacks",visible:i,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,n=[...s.fallbacks||[],{[l]:a}],i={...s,fallbacks:n};console.log(i);try{er(t,{router_settings:i}),r(i)}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully"),c(!1),o.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(eR.Z,{defaultValue:d,children:l&&l.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(e0.Z,{value:l,children:l&&l.filter(e=>e!=d).map(e=>(0,a.jsx)(e1.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lS=t(12968);async function lN(e,l){console.log("isLocal:",!1);let t=window.location.origin,s=new lS.ZP.OpenAI({apiKey:l,baseURL:t,dangerouslyAllowBrowser:!0});try{let l=await s.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});h.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lA={ttl:3600,lowest_latency_buffer:0},lE=e=>{let{selectedStrategy:l,strategyArgs:t,paramExplanation:s}=e;return(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(em.Z,{children:"latency-based-routing"==l?(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(t).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:s[l]})]}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]})}):(0,a.jsx)(eu.Z,{children:"No specific settings"})})]})};var lI=e=>{let{accessToken:l,userRole:t,userID:s,modelData:r}=e,[o,i]=(0,n.useState)({}),[c,d]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1),[j]=eg.Z.useForm(),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)(null),b={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,n.useEffect)(()=>{l&&t&&s&&(ee(l,s,t).then(e=>{console.log("callbacks",e),i(e.router_settings)}),el(l).then(e=>{u(e)}))},[l,t,s]);let k=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(o.fallbacks)),o.fallbacks.map(l=>(e in l&&delete l[e],l));try{await er(l,{router_settings:o}),i({...o}),Z(o.routing_strategy),h.ZP.success("Router settings updated successfully")}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}}},v=(e,l)=>{u(m.map(t=>t.field_name===e?{...t,field_value:l}:t))},S=(e,t)=>{if(!l)return;let s=m[t].field_value;if(null!=s&&void 0!=s)try{et(l,e,s);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(t)}catch(e){}},N=(e,t)=>{if(l)try{es(l,e);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(t)}catch(e){}},A=e=>{if(!l)return;console.log("router_settings",e);let t=Object.fromEntries(Object.entries(e).map(e=>{let[l,t]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var s;return[l,(null===(s=document.querySelector('input[name="'.concat(l,'"]')))||void 0===s?void 0:s.value)||t]}if("routing_strategy"==l)return[l,f];if("routing_strategy_args"==l&&"latency-based-routing"==f){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),t=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==t?void 0:t.value)&&(e.ttl=Number(t.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",t);try{er(l,{router_settings:t})}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eY.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eY.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(ex.Z,{children:"Router Settings"}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(o).filter(e=>{let[l,t]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:b[l]})]}),(0,a.jsx)(eT.Z,{children:"routing_strategy"==l?(0,a.jsxs)(eR.Z,{defaultValue:t,className:"w-full max-w-md",onValueChange:Z,children:[(0,a.jsx)(eM.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(eM.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(eM.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]}),(0,a.jsx)(lE,{selectedStrategy:f,strategyArgs:o&&o.routing_strategy_args&&Object.keys(o.routing_strategy_args).length>0?o.routing_strategy_args:lA,paramExplanation:b})]}),(0,a.jsx)(en.Z,{children:(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(o),children:"Save Changes"})})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Model Name"}),(0,a.jsx)(eF.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(eC.Z,{children:o.fallbacks&&o.fallbacks.map((e,t)=>Object.entries(e).map(e=>{let[s,r]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:s}),(0,a.jsx)(eT.Z,{children:Array.isArray(r)?r.join(", "):r}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{onClick:()=>lN(s,l),children:"Test Fallback"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>k(s)})})]},t.toString()+s)}))})]}),(0,a.jsx)(lv,{models:(null==r?void 0:r.data)?r.data.map(e=>e.model_name):[],accessToken:l,routerSettings:o,setRouterSettings:i})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"}),(0,a.jsx)(eF.Z,{children:"Status"}),(0,a.jsx)(eF.Z,{children:"Action"})]})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(eT.Z,{children:"Integer"==e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>v(e.field_name,l)}):null}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(ei.Z,{onClick:()=>S(e.field_name,l),children:"Update"}),(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>N(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lC=e=>{let{isModalVisible:l,accessToken:t,setIsModalVisible:s,setBudgetList:r}=e,[n]=eg.Z.useForm(),o=async e=>{if(null!=t&&void 0!=t)try{h.ZP.info("Making API Call");let l=await y(t,e);console.log("key create Response:",l),r(e=>e?[...e,l]:[l]),h.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(ey.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{s(!1),n.resetFields()},onCancel:()=>{s(!1),n.resetFields()},children:(0,a.jsxs)(eg.Z,{form:n,onFinish:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lT=t(67951),lP=e=>{let{accessToken:l}=e,[t,s]=(0,n.useState)(!1),[r,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&Q(l).then(e=>{o(e)})},[l]);let i=async(e,t)=>{if(null==l)return;h.ZP.info("Request made"),await g(l,e);let s=[...r];s.splice(t,1),o(s),h.ZP.success("Budget Deleted.")};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(ei.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>s(!0),children:"+ Create Budget"}),(0,a.jsx)(lC,{accessToken:l,isModalVisible:t,setIsModalVisible:s,setBudgetList:o}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Budget ID"}),(0,a.jsx)(eF.Z,{children:"Max Budget"}),(0,a.jsx)(eF.Z,{children:"TPM"}),(0,a.jsx)(eF.Z,{children:"RPM"})]})}),(0,a.jsx)(eC.Z,{children:r.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.budget_id}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(eT.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(eT.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>i(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(eu.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eY.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eY.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{let{userID:l,userRole:t,token:s,accessToken:r,keys:o,premiumUser:i}=e,[c,d]=(0,n.useState)(null),[m,h]=(0,n.useState)(!1),[u,x]=(0,n.useState)(null);(0,n.useEffect)(()=>{r&&s&&t&&l&&(async()=>{try{let e=await A(r,l,t);console.log("ModelHubData:",e),d(e.data)}catch(e){console.error("There was an error fetching the model data",e)}})()},[r,s,t,l]);let p=e=>{x(e),h(!0)},j=e=>{navigator.clipboard.writeText(e)};return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)("div",{className:"relative w-full"}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(ex.Z,{className:"ml-8 text-center ",children:"Model Hub"}),(0,a.jsx)(ei.Z,{className:"ml-4",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Share"})})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4",children:c&&c.map(e=>(0,a.jsxs)(eA.Z,{className:"mt-5 mx-8",children:[(0,a.jsxs)("pre",{className:"flex justify-between",children:[(0,a.jsx)(ex.Z,{children:e.model_group}),(0,a.jsx)(e3.Z,{title:e.model_group,children:(0,a.jsx)(lF.Z,{onClick:()=>j(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,a.jsxs)("div",{className:"my-5",children:[(0,a.jsxs)(eu.Z,{children:["Mode: ",e.mode]}),(0,a.jsxs)(eu.Z,{children:["Supports Function Calling: ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Supports Vision: ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Max Input Tokens: ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,a.jsxs)(eu.Z,{children:["Max Output Tokens: ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,a.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,a.jsxs)("a",{href:"#",onClick:()=>p(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,a.jsx)(lO.Z,{})]})})]},e.model_group))})]}),(0,a.jsx)(ey.Z,{title:"Model Usage",width:800,visible:m,footer:null,onOk:()=>{h(!1),x(null)},onCancel:()=>{h(!1),x(null)},children:u&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Model Name:"})," ",u.model_group]}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(u.model_group,'", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="'.concat(u.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "'.concat(u.model_group,'",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})]})},lM=e=>{let{}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(eu.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n '})})]})]})]})})})};async function lL(e,l,t,s){console.log("isLocal:",!1);let r=window.location.origin,a=new lS.ZP.OpenAI({apiKey:s,baseURL:r,dangerouslyAllowBrowser:!0});try{for await(let s of(await a.chat.completions.create({model:t,stream:!0,messages:[{role:"user",content:e}]})))console.log(s),s.choices[0].delta.content&&l(s.choices[0].delta.content)}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lU=e=>{let{accessToken:l,token:t,userRole:s,userID:r}=e,[o,i]=(0,n.useState)(""),[c,d]=(0,n.useState)(""),[m,h]=(0,n.useState)([]),[u,x]=(0,n.useState)(void 0),[p,j]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{let e=await P(l,r,s);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));console.log(l),j(l),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,r,s]);let g=(e,l)=>{h(t=>{let s=t[t.length-1];return s&&s.role===e?[...t.slice(0,t.length-1),{role:e,content:s.content+l}]:[...t,{role:e,content:l}]})},y=async()=>{if(""!==c.trim()&&o&&t&&s&&r){h(e=>[...e,{role:"user",content:c}]);try{u&&await lL(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsx)(e$.Z,{children:(0,a.jsx)(eY.Z,{children:"Chat"})}),(0,a.jsx)(eQ.Z,{children:(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"API Key"}),(0,a.jsx)(ec.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,a.jsxs)(en.Z,{className:"mx-2",children:[(0,a.jsx)(eu.Z,{children:"Select Model:"}),(0,a.jsx)(ej.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,a.jsxs)(eI.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{})})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(ec.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,a.jsx)(ei.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]})})]})})})})},lD=t(33509),lB=t(95781);let{Sider:lz}=lD.default;var lK=e=>{let{setPage:l,userRole:t,defaultSelectedKey:s}=e;return"Admin Viewer"==t?(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(lz,{width:120,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(lz,{width:145,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(eu.Z,{children:"API Keys"})},"1"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(eu.Z,{children:"Test Key"})},"3"),"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(eu.Z,{children:"Models"})},"2"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(eu.Z,{children:"Usage"})},"4"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(eu.Z,{children:"Teams"})},"6"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(eu.Z,{children:"Users"})},"5"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(eu.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(eu.Z,{children:"Rate Limits"})},"9"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(eu.Z,{children:"Router Settings"})},"10"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(eu.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(eu.Z,{children:"API Reference"})},"12"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(eu.Z,{children:"Model Hub"})},"14")]})})})},lG=t(67989),lq=t(49167),lV=t(52703),lW=e=>{let{accessToken:l,token:t,userRole:s,userID:r,keys:o,premiumUser:i}=e,c=new Date,[d,m]=(0,n.useState)([]),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)([]),[j,g]=(0,n.useState)([]),[y,f]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[w,b]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)({}),[I,C]=(0,n.useState)([]),[T,P]=(0,n.useState)(""),[q,V]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),W=new Date(c.getFullYear(),c.getMonth(),1),H=new Date(c.getFullYear(),c.getMonth()+1,0),Y=Q(W),J=Q(H);console.log("keys in usage",o),console.log("premium user in usage",i);let $=async(e,t,s)=>{if(!e||!t||!l)return;t.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",s);let r=await U(l,s,e.toISOString(),t.toISOString());console.log("End user data updated successfully",r),g(r)},X=async(e,t)=>{e&&t&&l&&(t.setHours(23,59,59,999),e.setHours(0,0,0,0),_((await O(l,e.toISOString(),t.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function Q(e){let l=e.getFullYear(),t=e.getMonth()+1,s=e.getDate();return"".concat(l,"-").concat(t<10?"0"+t:t,"-").concat(s<10?"0"+s:s)}return console.log("Start date is ".concat(Y)),console.log("End date is ".concat(J)),(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{if(console.log("user role: ".concat(s)),"Admin"==s||"Admin Viewer"==s){var e,a;let s=await M(l);m(s);let r=await D(l,t,Y,J);console.log("provider_spend",r),N(r);let n=(await L(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));u(n);let o=(await K(l)).map(e=>({key:e.model,spend:e.total_spend}));p(o);let i=await F(l);console.log("teamSpend",i),f(i.daily_spend),b(i.teams);let c=i.total_spend_per_team;c=c.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),v(c);let d=await O(l,null===(e=q.from)||void 0===e?void 0:e.toISOString(),null===(a=q.to)||void 0===a?void 0:a.toISOString());_(d.spend_per_tag);let h=await U(l,null,void 0,void 0);g(h),console.log("spend/user result",h);let x=await B(l,Y,J);E(x);let j=await z(l,Y,J);console.log("global activity per model",j),C(j)}else"App Owner"==s&&await R(l,t,s,r,Y,J).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let t=e.top_api_keys;u(t)}else{let t=(await G(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[t,s]=e;"spend"!==t&&"startTime"!==t&&"models"!==t&&"users"!==t&&l.push({key:t,spend:s})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let t=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(t[0]))),t}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));u(t),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,t,s,r,Y,J]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(ez,{userID:r,userRole:s,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{className:"mt-2",children:[(0,a.jsx)(eY.Z,{children:"All Up"}),(0,a.jsx)(eY.Z,{children:"Team Based Usage"}),(0,a.jsx)(eY.Z,{children:"End User Usage"}),(0,a.jsx)(eY.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eY.Z,{children:"Cost"}),(0,a.jsx)(eY.Z,{children:"Activity"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Monthly Spend"}),(0,a.jsx)(e4.Z,{data:d,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top API Keys"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top Models"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:x,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1}),(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"✨ Spend by Provider"}),i?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(lV.Z,{className:"mt-4 h-40",variant:"pie",data:S,index:"provider",category:"spend"})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Provider"}),(0,a.jsx)(eF.Z,{children:"Spend"})]})}),(0,a.jsx)(eC.Z,{children:S.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.provider}),(0,a.jsx)(eT.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"All Up"}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",A.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",A.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),i?(0,a.jsx)(a.Fragment,{children:I.map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:I&&I.length>0&&I.slice(0,1).map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lG.Z,{data:k})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(e4.Z,{className:"h-72",data:y,showLegend:!0,index:"date",categories:w,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:q,onValueChange:e=>{V(e),$(e.from,e.to,null)}})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Key"}),(0,a.jsxs)(eR.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(eM.Z,{value:"all-keys",onClick:()=>{$(q.from,q.to,null)},children:"All Keys"},"all-keys"),null==o?void 0:o.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{$(q.from,q.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(eA.Z,{className:"mt-4",children:(0,a.jsxs)(eI.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"End User"}),(0,a.jsx)(eF.Z,{children:"Spend"}),(0,a.jsx)(eF.Z,{children:"Total Events"})]})}),(0,a.jsx)(eC.Z,{children:null==j?void 0:j.map((e,l)=>{var t;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.end_user}),(0,a.jsx)(eT.Z,{children:null===(t=e.total_spend)||void 0===t?void 0:t.toFixed(4)}),(0,a.jsx)(eT.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsx)(eH.Z,{className:"mb-4",enableSelect:!0,value:q,onValueChange:e=>{V(e),X(e.from,e.to)}}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(eu.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(e4.Z,{className:"h-72",data:Z,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})})]})]})]})},lH=()=>{let{Title:e,Paragraph:l}=eV.default,[t,s]=(0,n.useState)(""),[r,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!0),y=(0,o.useSearchParams)(),[f,Z]=(0,n.useState)({data:[]}),_=y.get("userID"),w=y.get("token"),[b,k]=(0,n.useState)("api-keys"),[v,S]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(w){let e=(0,eq.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),S(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),s(l),"Admin Viewer"==l&&k("usage")}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&i(e.premium_user)}}},[w]),(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:_,userRole:t,userEmail:c,showSSOBanner:j,premiumUser:r}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lK,{setPage:k,userRole:t,defaultSelectedKey:null})}),"api-keys"==b?(0,a.jsx)(eW,{userID:_,userRole:t,teams:h,keys:x,setUserRole:s,userEmail:c,setUserEmail:d,setTeams:u,setKeys:p}):"models"==b?(0,a.jsx)(lu,{userID:_,userRole:t,token:w,accessToken:v,modelData:f,setModelData:Z,premiumUser:r}):"llm-playground"==b?(0,a.jsx)(lU,{userID:_,userRole:t,token:w,accessToken:v}):"users"==b?(0,a.jsx)(lj,{userID:_,userRole:t,token:w,keys:x,teams:h,accessToken:v,setKeys:p}):"teams"==b?(0,a.jsx)(lg,{teams:h,setTeams:u,searchParams:y,accessToken:v,userID:_,userRole:t}):"admin-panel"==b?(0,a.jsx)(ly,{setTeams:u,searchParams:y,accessToken:v,showSSOBanner:j}):"api_ref"==b?(0,a.jsx)(lM,{}):"settings"==b?(0,a.jsx)(lb,{userID:_,userRole:t,accessToken:v,premiumUser:r}):"budgets"==b?(0,a.jsx)(lP,{accessToken:v}):"general-settings"==b?(0,a.jsx)(lI,{userID:_,userRole:t,accessToken:v,modelData:f}):"model-hub"==b?(0,a.jsx)(lR,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r}):(0,a.jsx)(lW,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r})]})]})})}}},function(e){e.O(0,[936,608,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]); \ No newline at end of file +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,t){Promise.resolve().then(t.bind(t,39712))},39712:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return lH}});var s,r,a=t(3827),n=t(64090),o=t(47907),i=t(8792),c=t(40491),d=t(65270),m=e=>{let{userID:l,userRole:t,userEmail:s,showSSOBanner:r,premiumUser:n}=e;console.log("User ID:",l),console.log("userEmail:",s),console.log("showSSOBanner:",r),console.log("premiumUser:",n);let o=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",t]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(i.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[r?(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(c.Z,{menu:{items:o},children:(0,a.jsx)(d.Z,{children:s})})})]})]})},h=t(80588);let u=async()=>{try{let e=await fetch("https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"),l=await e.json();return console.log("received data: ".concat(l)),l}catch(e){throw console.error("Failed to get model cost map:",e),e}},x=async(e,l)=>{try{let t=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),s}catch(e){throw console.error("Failed to create key:",e),e}},p=async e=>{try{let l=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},j=async(e,l)=>{console.log("model_id in model delete call: ".concat(l));try{let t=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model deleted successfully. Restart server to see this."),s}catch(e){throw console.error("Failed to create key:",e),e}},g=async(e,l)=>{if(console.log("budget_id in budget delete call: ".concat(l)),null!=e)try{let t=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,l)=>{try{console.log("Form Values in budgetCreateCall:",l),console.log("Form Values after check:",l);let t=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},f=async e=>{try{let l=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},Z=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,l)=>{try{console.log("in keyDeleteCall:",l);let t=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,l)=>{try{console.log("in teamDeleteCall:",l);let t=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,l,t){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;try{let n="/user/info";"App Owner"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),"App User"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),console.log("in userInfoCall viewAll=",s),s&&a&&null!=r&&void 0!=r&&(n="".concat(n,"?view_all=true&page=").concat(r,"&page_size=").concat(a));let o=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let i=await o.json();return console.log("API Response:",i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,l)=>{try{let t="/team/info";l&&(t="".concat(t,"?team_id=").concat(l)),console.log("in teamInfoCall");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},S=async e=>{try{let l=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,l,t)=>{try{let l=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelInfoCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,l,t)=>{try{let l=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelHubCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,l,t,s,r,a)=>{try{let l="/model/metrics";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},I=async(e,l,t,s)=>{try{let r="/model/streaming_metrics";l&&(r="".concat(r,"?_selected_model_group=").concat(l,"&startTime=").concat(t,"&endTime=").concat(s));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},C=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/slow_responses";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/exceptions";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,l,t)=>{try{let l=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},F=async e=>{try{let l="/global/spend/teams";console.log("in teamSpendLogsCall:",l);let t=await fetch("".concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=async(e,l,t)=>{try{let s="/global/spend/tags";l&&t&&(s="".concat(s,"?start_date=").concat(l,"&end_date=").concat(t)),console.log("in tagsSpendLogsCall:",s);let r=await fetch("".concat(s),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},R=async(e,l,t,s,r,a)=>{try{console.log("user role in spend logs call: ".concat(t));let l="/spend/logs";l="App Owner"==t?"".concat(l,"?user_id=").concat(s,"&start_date=").concat(r,"&end_date=").concat(a):"".concat(l,"?start_date=").concat(r,"&end_date=").concat(a);let n=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},M=async e=>{try{let l=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},L=async e=>{try{let l=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,l,t,s)=>{try{let r="";r=l?JSON.stringify({api_key:l,startTime:t,endTime:s}):JSON.stringify({startTime:t,endTime:s});let a={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};a.body=r;let n=await fetch("/global/spend/end_users",a);if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,l,t,s)=>{try{let r="/global/spend/provider";t&&s&&(r+="?start_date=".concat(t,"&end_date=").concat(s)),l&&(r+="&api_key=".concat(l));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log(n),n}catch(e){throw console.error("Failed to fetch spend data:",e),e}},B=async(e,l,t)=>{try{let s="/global/activity";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},z=async(e,l,t)=>{try{let s="/global/activity/model";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},K=async e=>{try{let l=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},G=async(e,l)=>{try{let t=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},q=async(e,l)=>{try{let t="/user/get_users?role=".concat(l);console.log("in userGetAllUsersCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let r=await s.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},V=async(e,l)=>{try{console.log("Form Values in teamCreateCall:",l);let t=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,l)=>{try{console.log("Form Values in keyUpdateCall:",l);let t=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},H=async(e,l)=>{try{console.log("Form Values in teamUpateCall:",l);let t=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},Y=async(e,l)=>{try{console.log("Form Values in modelUpateCall:",l);let t=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update model Response:",s),s}catch(e){throw console.error("Failed to update model:",e),e}},J=async(e,l,t)=>{try{console.log("Form Values in teamMemberAddCall:",t);let s=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:l,member:t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},$=async(e,l,t)=>{try{console.log("Form Values in userUpdateUserCall:",l);let s={...l};null!==t&&(s.user_role=t),s=JSON.stringify(s);let r=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:s});if(!r.ok){let e=await r.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await r.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,l)=>{try{let t="/health/services?service=".concat(l);console.log("Checking Slack Budget Alerts service health");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed ".concat(l," service health check ")+e),Error(e)}let r=await s.json();return h.ZP.success("Test request to ".concat(l," made - check logs/alerts on ").concat(l," to verify")),r}catch(e){throw console.error("Failed to perform health check:",e),e}},Q=async e=>{try{let l=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async(e,l,t)=>{try{let l=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},el=async e=>{try{let l=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,l,t)=>{try{let s=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,field_value:t,config_type:"general_settings"})});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return h.ZP.success("Successfully updated value!"),r}catch(e){throw console.error("Failed to set callbacks:",e),e}},es=async(e,l)=>{try{let t=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,config_type:"general_settings"})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return h.ZP.success("Field reset on proxy"),s}catch(e){throw console.error("Failed to get callbacks:",e),e}},er=async(e,l)=>{try{let t=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},ea=async e=>{try{let l=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to call /health:",e),e}};var en=t(10384),eo=t(46453),ei=t(16450),ec=t(52273),ed=t(26780),em=t(15595),eh=t(6698),eu=t(71801),ex=t(42440),ep=t(42308),ej=t(50670),eg=t(81583),ey=t(99129),ef=t(44839),eZ=t(88707),e_=t(1861);let{Option:ew}=ej.default;var eb=e=>{let{userID:l,team:t,userRole:s,accessToken:r,data:o,setData:i}=e,[c]=eg.Z.useForm(),[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(null),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,_]=(0,n.useState)([]),w=()=>{m(!1),c.resetFields()},b=()=>{m(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==r){let e=(await P(r,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,s]);let k=async e=>{try{var t,s,a;let n=null!==(t=null==e?void 0:e.key_alias)&&void 0!==t?t:"",d=null!==(s=null==e?void 0:e.team_id)&&void 0!==s?s:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===d).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(n))throw Error("Key alias ".concat(n," already exists for team with ID ").concat(d,", please provide another key alias"));h.ZP.info("Making API Call"),m(!0);let u=await Z(r,l,e);console.log("key create Response:",u),i(e=>e?[...e,u]:[u]),x(u.key),j(u.soft_budget),h.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.useEffect)(()=>{_(t&&t.models.length>0?t.models.includes("all-proxy-models")?g:t.models:g)},[t,g]),(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(ey.Z,{title:"Create Key",visible:d,width:800,footer:null,onOk:w,onCancel:b,children:(0,a.jsxs)(eg.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:t?t.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t?t.team_alias:"",disabled:!0})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(ew,{value:"all-team-models",children:"All Team Models"},"all-team-models"),f.map(e=>(0,a.jsx)(ew,{value:e,children:e},e))]})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==t?void 0:t.max_budget)!==null&&(null==t?void 0:t.max_budget)!==void 0?null==t?void 0:t.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.max_budget&&l>t.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(t.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==t?void 0:t.budget_duration)!==null&&(null==t?void 0:t.budget_duration)!==void 0?null==t?void 0:t.budget_duration:"None"),children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==t?void 0:t.tpm_limit)!==null&&(null==t?void 0:t.tpm_limit)!==void 0?null==t?void 0:t.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.tpm_limit&&l>t.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(t.tpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==t?void 0:t.rpm_limit)!==null&&(null==t?void 0:t.rpm_limit)!==void 0?null==t?void 0:t.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.rpm_limit&&l>t.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(t.rpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Key"})})]})}),u&&(0,a.jsx)(ey.Z,{visible:d,onOk:w,onCancel:b,footer:null,children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Save your Key"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:null!=u?(0,a.jsxs)("div",{children:[(0,a.jsx)(eu.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:u})}),(0,a.jsx)(ep.CopyToClipboard,{text:u,onCopy:()=>{h.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(ei.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(eu.Z,{children:"Key being created, this might take 30s"})})]})})]})},ek=t(9454),ev=t(98941),eS=t(33393),eN=t(5),eA=t(13810),eE=t(61244),eI=t(10827),eC=t(3851),eT=t(2044),eP=t(64167),eF=t(74480),eO=t(7178),eR=t(95093),eM=t(27166);let{Option:eL}=ej.default;var eU=e=>{let{userID:l,userRole:t,accessToken:s,selectedTeam:r,data:o,setData:i,teams:c}=e,[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(!1),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(""),[k,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(!1),[A,E]=(0,n.useState)(null),[I,C]=(0,n.useState)([]),T=new Set,[F,O]=(0,n.useState)(T);(0,n.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==s&&null!==t){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),C(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[s,l,t]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,t)=>{let s=l.team_id;e.add(s)}),O(e)}},[c]);let R=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),E(e),v(!0)},M=async e=>{if(null==s)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let t=await W(s,e);console.log("handleEditSubmit: newKeyValues",t),o&&i(o.map(e=>e.token===l?t:e)),h.ZP.success("Key updated successfully"),v(!1),E(null)},L=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+l),x(!0))},U=async()=>{if(null!=p&&null!=o){try{await w(s,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(eI.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Key Alias"}),(0,a.jsx)(eF.Z,{children:"Secret Key"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(eC.Z,{children:o.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(r){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(F.has(e.team_id),", selectedTeam id: ").concat(r.team_id)),(null!=r.team_id||null===e.team_id||F.has(e.team_id))&&e.team_id!=r.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(eu.Z,{children:e.key_alias}):(0,a.jsx)(eu.Z,{children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:e.key_name})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(eT.Z,{children:null!=e.max_budget?(0,a.jsx)(eu.Z,{children:e.max_budget}):(0,a.jsx)(eu.Z,{children:"Unlimited"})}),(0,a.jsx)(eT.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:r&&r.models&&r.models.length>0?r.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{onClick:()=>{E(e),N(!0)},icon:ek.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:S,onCancel:()=>{N(!1),E(null)},footer:null,width:800,children:A&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(A.spend).toFixed(4)}catch(e){return A.spend}})()})})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.max_budget?(0,a.jsx)(a.Fragment,{children:A.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.expires?(0,a.jsx)(a.Fragment,{children:new Date(A.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(eA.Z,{className:"my-4",children:[(0,a.jsx)(ex.Z,{children:"Token Name"}),(0,a.jsx)(eu.Z,{className:"my-1",children:A.key_alias?A.key_alias:A.key_name}),(0,a.jsx)(ex.Z,{children:"Token ID"}),(0,a.jsx)(eu.Z,{className:"my-1 text-[12px]",children:A.token}),(0,a.jsx)(ex.Z,{children:"Metadata"}),(0,a.jsx)(eu.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(A.metadata)," "]})})]}),(0,a.jsx)(ei.Z,{className:"mx-auto flex items-center",onClick:()=>{N(!1),E(null)},children:"Close"})]})}),(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>R(e)}),(0,a.jsx)(eE.Z,{onClick:()=>L(e),icon:eS.Z,size:"sm"})]})]},e.token)})})]}),u&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{x(!1),j(null)},children:"Cancel"})]})]})]})})]}),A&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,token:s,onSubmit:o}=e,[i]=eg.Z.useForm(),[d,m]=(0,n.useState)(r),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1);return(0,a.jsx)(ey.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:i,onFinish:M,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let t=l.filter(e=>!d.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!d.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(t)),t.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(t,"Team models: ").concat(d.models)):Promise.resolve()}}],children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(eL,{value:"all-team-models",children:"All Team Models"},"all-team-models"),d&&d.models?d.models.includes("all-proxy-models")?I.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):d.models.map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):I.map(e=>(0,a.jsx)(eL,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==d?void 0:d.max_budget)!==null&&(null==d?void 0:d.max_budget)!==void 0?null==d?void 0:d.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&d&&null!==d.max_budget&&l>d.max_budget)throw console.log("keyTeam.max_budget: ".concat(d.max_budget)),Error("Budget cannot exceed team max budget: $".concat(d.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(eg.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(eR.Z,{value:s.team_alias,children:null==c?void 0:c.map((e,l)=>(0,a.jsx)(eM.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:k,onCancel:()=>{v(!1),E(null)},token:A,onSubmit:M})]})},eD=t(76032),eB=t(35152),ez=e=>{let{userID:l,userRole:t,accessToken:s,userSpend:r,selectedTeam:o}=e;console.log("userSpend: ".concat(r));let[i,c]=(0,n.useState)(null!==r?r:0),[d,m]=(0,n.useState)(0),[h,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(s&&l&&t&&"Admin"===t&&null==r)try{let e=await S(s);e&&(e.spend?c(e.spend):c(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(async()=>{try{if(null===l||null===t)return;if(null!==s){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),u(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,s,l]),(0,n.useEffect)(()=>{null!==r&&c(r)},[r]);let x=[];o&&o.models&&(x=o.models),x&&x.includes("all-proxy-models")?(console.log("user models:",h),x=h):x&&x.includes("all-team-models")?x=o.models:x&&0===x.length&&(x=h);let p=void 0!==i?i.toFixed(4):null;return console.log("spend in view user spend: ".concat(i)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:["Total Spend"," "]}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",p]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Team Models"})}),(0,a.jsx)(em.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(eD.Z,{children:x.map(e=>(0,a.jsx)(eB.Z,{children:(0,a.jsx)(eu.Z,{children:e})},e))})})]})})]})},eK=e=>{let{userID:l,userRole:t,selectedTeam:s,accessToken:r}=e,[o,i]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==r){let e=(await P(r,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),i(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,t]);let c=[];return s&&s.models&&(c=s.models),c&&c.includes("all-proxy-models")&&(console.log("user models:",o),c=o),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"mb-5",children:(0,a.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==s?void 0:s.team_alias})})})},eG=e=>{let l,{teams:t,setSelectedTeam:s,userRole:r}=e,o={models:[],team_id:null,team_alias:"Default Team"},[i,c]=(0,n.useState)(o);return(l="App User"===r?t:t?[...t,o]:[o],"App User"===r)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(ex.Z,{children:"Select Team"}),(0,a.jsx)(eu.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(eu.Z,{className:"mt-3 mb-3",children:[(0,a.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>s(e),children:e.team_alias},l))}):(0,a.jsxs)(eu.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},eq=t(37963),eV=t(97482);console.log("isLocal:",!1);var eW=e=>{let{userID:l,userRole:t,teams:s,keys:r,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,n.useState)(null),p=(0,o.useSearchParams)();p.get("viewSpend"),(0,o.useRouter)();let j=p.get("token"),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)([]),b={models:[],team_alias:"Default Team",team_id:null},[v,N]=(0,n.useState)(s?s[0]:b);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(j){let e=(0,eq.o)(j);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),i(l)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&g&&t&&!r&&!u){let e=sessionStorage.getItem("userModels"+l);e?w(JSON.parse(e)):(async()=>{try{let e=await k(g,l,t,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==t){let e=await S(g);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(e.teams);let s=[...e.teams];s.length>0?(console.log("response['teams']: ".concat(s)),N(s[0])):N(b),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let r=(await P(g,l,t)).data.map(e=>e.id);console.log("available_model_names:",r),w(r),console.log("userModels:",_),sessionStorage.setItem("userModels"+l,JSON.stringify(r))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,j,g,r,t]),(0,n.useEffect)(()=>{if(null!==r&&null!=v){let e=0;for(let l of r)v.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===v.team_id&&(e+=l.spend);Z(e)}else if(null!==r){let e=0;for(let l of r)e+=l.spend;Z(e)}},[v]),null==l||null==j){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==g)return null;if(null==t&&i("App Owner"),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",v),console.log("teamSpend: ".concat(f)),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eK,{userID:l,userRole:t,selectedTeam:v||null,accessToken:g}),(0,a.jsx)(ez,{userID:l,userRole:t,accessToken:g,userSpend:f,selectedTeam:v||null}),(0,a.jsx)(eU,{userID:l,userRole:t,accessToken:g,selectedTeam:v||null,data:r,setData:h,teams:s}),(0,a.jsx)(eb,{userID:l,team:v||null,userRole:t,accessToken:g,data:r,setData:h},v?v.team_id:null),(0,a.jsx)(eG,{teams:s,setSelectedTeam:N,userRole:t})]})})})},eH=t(35087),eY=t(92836),eJ=t(26734),e$=t(41608),eX=t(32126),eQ=t(23682),e0=t(47047),e1=t(76628),e2=t(25707),e4=t(44041),e5=t(38302),e8=t(28683),e3=t(1460),e6=t(78578),e7=t(63954),e9=t(90252),le=t(7905),ll=e=>{let{modelID:l,accessToken:t}=e,[s,r]=(0,n.useState)(!1),o=async()=>{try{h.ZP.info("Making API Call"),r(!0);let e=await j(t,l);console.log("model delete Response:",e),h.ZP.success("Model ".concat(l," deleted successfully")),r(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(eE.Z,{onClick:()=>r(!0),icon:eS.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:s,onOk:o,okType:"danger",onCancel:()=>r(!1),children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Delete Model"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},lt=t(97766),ls=t(46495),lr=t(18190),la=t(91118),ln=e=>{let{modelMetrics:l,modelMetricsCategories:t,customTooltip:s,premiumUser:r}=e;return r?(0,a.jsx)(la.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:t,colors:["indigo","rose"],connectNulls:!0,customTooltip:s}):(0,a.jsxs)("div",{children:[(0,a.jsx)(lr.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,a.jsx)(ei.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},lo=e=>{let{fields:l,selectedProvider:t}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,a.jsx)(ec.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})};let{Title:li,Link:lc}=eV.default;(s=r||(r={})).OpenAI="OpenAI",s.Azure="Azure",s.Anthropic="Anthropic",s.Google_AI_Studio="Google AI Studio",s.Bedrock="Amazon Bedrock",s.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",s.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",s.Databricks="Databricks";let ld={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},lm={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},lh=async(e,l,t)=>{try{let s=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(s)),console.log("received type of deployments: ".concat(typeof s)),s.forEach(async t=>{console.log("litellm_model: ".concat(t));let s={},r={};s.model=t;let a="";for(let[l,t]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==t){if("model_name"==l)a+=t;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)r[l]=t;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",t);let e={};if(t&&void 0!=t){try{e=JSON.parse(t)}catch(e){throw h.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,t]of Object.entries(e))s[l]=t}}else s[l]=t}let n={model_name:a,litellm_params:s,model_info:r},o=await x(l,n);console.log("response for model create call: ".concat(o.data))}),t.resetFields()}catch(e){h.ZP.error("Failed to create model: "+e,10)}};var lu=e=>{var l,t,s;let o,{accessToken:i,token:c,userRole:d,userID:m,modelData:x={data:[]},setModelData:j,premiumUser:g}=e,[y,f]=(0,n.useState)([]),[Z]=eg.Z.useForm(),[_,w]=(0,n.useState)(null),[b,k]=(0,n.useState)(""),[v,S]=(0,n.useState)([]),A=Object.values(r).filter(e=>isNaN(Number(e))),[P,F]=(0,n.useState)([]),[O,R]=(0,n.useState)("OpenAI"),[M,L]=(0,n.useState)(""),[U,D]=(0,n.useState)(!1),[B,z]=(0,n.useState)(null),[K,G]=(0,n.useState)([]),[q,V]=(0,n.useState)(null),[W,H]=(0,n.useState)([]),[J,$]=(0,n.useState)([]),[X,Q]=(0,n.useState)([]),[el,et]=(0,n.useState)([]),[es,en]=(0,n.useState)([]),[ep,ej]=(0,n.useState)([]),[ef,ew]=(0,n.useState)([]),[eb,ek]=(0,n.useState)([]),[eS,eL]=(0,n.useState)([]),[eU,eD]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eB,ez]=(0,n.useState)(null),[eK,eG]=(0,n.useState)(0),eq=e=>{z(e),D(!0)},eW=async e=>{if(console.log("handleEditSubmit:",e),null==i)return;let l={},t=null;for(let[s,r]of Object.entries(e))"model_id"!==s?l[s]=r:t=r;let s={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",s);try{await Y(i,s),h.ZP.success("Model updated successfully, restart server to see updates"),D(!1),z(null)}catch(e){console.log("Error occurred")}},lr=()=>{k(new Date().toLocaleString())},la=async()=>{if(!i){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eB);try{await er(i,{router_settings:{model_group_retry_policy:eB}}),h.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),h.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!i||!c||!d||!m)return;let e=async()=>{try{var e,l,t,s,r,a,n,o;let c=await p(i);F(c);let h=await N(i,m,d);console.log("Model data response:",h.data),j(h);let u=new Set;for(let e=0;e0&&(g=x[x.length-1],console.log("_initial_model_group:",g),V(g)),console.log("selectedModelGroup:",q);let y=await E(i,m,d,g,null===(e=eU.from)||void 0===e?void 0:e.toISOString(),null===(l=eU.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",y),$(y.data),Q(y.all_api_bases);let f=await I(i,g,null===(t=eU.from)||void 0===t?void 0:t.toISOString(),null===(s=eU.to)||void 0===s?void 0:s.toISOString());et(f.data),en(f.all_api_bases);let Z=await T(i,m,d,g,null===(r=eU.from)||void 0===r?void 0:r.toISOString(),null===(a=eU.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",Z),ej(Z.data),ew(Z.exception_types);let _=await C(i,m,d,g,null===(n=eU.from)||void 0===n?void 0:n.toISOString(),null===(o=eU.to)||void 0===o?void 0:o.toISOString());console.log("slowResponses:",_),eL(_);let w=(await ee(i,m,d)).router_settings;console.log("routerSettingsInfo:",w);let b=w.model_group_retry_policy,k=w.num_retries;console.log("model_group_retry_policy:",b),console.log("default_retries:",k),ez(b),eG(k)}catch(e){console.error("There was an error fetching the model data",e)}};i&&c&&d&&m&&e();let l=async()=>{let e=await u();console.log("received model cost map data: ".concat(Object.keys(e))),w(e)};null==_&&l(),lr()},[i,c,d,m,_,b]),!x||!i||!c||!d||!m)return(0,a.jsx)("div",{children:"Loading..."});let lu=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(_)),null!=_&&"object"==typeof _&&e in _)?_[e].litellm_provider:"openai";if(r){let e=r.split("/"),l=e[0];n=1===e.length?h(r):l}else n="openai";a&&(o=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,c=null==a?void 0:a.max_tokens,d=null==a?void 0:a.max_input_tokens),(null==s?void 0:s.litellm_params)&&(m=Object.fromEntries(Object.entries(null==s?void 0:s.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),x.data[e].provider=n,x.data[e].input_cost=o,x.data[e].output_cost=i,x.data[e].input_cost&&(x.data[e].input_cost=(1e6*Number(x.data[e].input_cost)).toFixed(2)),x.data[e].output_cost&&(x.data[e].output_cost=(1e6*Number(x.data[e].output_cost)).toFixed(2)),x.data[e].max_tokens=c,x.data[e].max_input_tokens=d,x.data[e].api_base=null==s?void 0:null===(t=s.litellm_params)||void 0===t?void 0:t.api_base,x.data[e].cleanedLitellmParams=m,lu.push(s.model_name),console.log(x.data[e])}if(d&&"Admin Viewer"==d){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lx=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(r).find(l=>r[l]===e);if(l){let e=ld[l];console.log("mappingResult: ".concat(e));let t=[];"object"==typeof _&&Object.entries(_).forEach(l=>{let[s,r]=l;null!==r&&"object"==typeof r&&"litellm_provider"in r&&(r.litellm_provider===e||r.litellm_provider.includes(e))&&t.push(s)}),S(t),console.log("providerModels: ".concat(v))}},lp=async()=>{try{h.ZP.info("Running health check..."),L("");let e=await ea(i);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lj=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),i&&m&&d&&l&&t){console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),V(e);try{let s=await E(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model metrics response:",s),$(s.data),Q(s.all_api_bases);let r=await I(i,e,l.toISOString(),t.toISOString());et(r.data),en(r.all_api_bases);let a=await T(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model exceptions response:",a),ej(a.data),ew(a.exception_types);let n=await C(i,m,d,e,l.toISOString(),t.toISOString());console.log("slowResponses:",n),eL(n)}catch(e){console.error("Failed to fetch model metrics",e)}}},lg=e=>{var l,t;let{payload:s,active:r}=e;if(!r||!s)return null;let n=null===(t=s[0])||void 0===t?void 0:null===(l=t.payload)||void 0===l?void 0:l.date,o=s.sort((e,l)=>l.value-e.value);if(o.length>5){let e=o.length-5;(o=o.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:s.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,a.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[n&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),o.map((e,l)=>{let t=parseFloat(e.value.toFixed(5)),s=0===t&&e.value>0?"<0.00001":t.toFixed(5);return(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:s})]},l)})]})};console.log("selectedProvider: ".concat(O)),console.log("providerModels.length: ".concat(v.length));let ly=Object.keys(r).find(e=>r[e]===O);return ly&&(o=P.find(e=>e.name===ld[ly])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eY.Z,{children:"All Models"}),(0,a.jsx)(eY.Z,{children:"Add Model"}),(0,a.jsx)(eY.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eY.Z,{children:"Model Analytics"}),(0,a.jsx)(eY.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[b&&(0,a.jsxs)(eu.Z,{children:["Last Refreshed: ",b]}),(0,a.jsx)(eE.Z,{icon:e7.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lr})]})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],onValueChange:e=>V("all"===e?"all":e),value:q||K[0],children:[(0,a.jsx)(eM.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))]})]}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"Public Model Name"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:"Provider"}),"Admin"===d&&(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"API Base"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:"Extra litellm Params"}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(eF.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:"Max Tokens"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word"},children:"Status"})]})}),(0,a.jsx)(eC.Z,{children:x.data.filter(e=>"all"===q||e.model_name===q||null==q||""===q).map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{children:e.model_name})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.provider}),"Admin"===d&&(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:e.api_base}),(0,a.jsx)(eT.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Litellm params"})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)("pre",{children:JSON.stringify(e.cleanedLitellmParams,null,2)})})]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.input_cost||e.litellm_params.input_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.output_cost||e.litellm_params.output_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)("p",{style:{fontSize:"10px"},children:["Max Tokens: ",e.max_tokens," ",(0,a.jsx)("br",{}),"Max Input Tokens: ",e.max_input_tokens]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(eN.Z,{icon:e9.Z,size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(eN.Z,{icon:le.Z,size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsxs)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>eq(e)}),(0,a.jsx)(ll,{modelID:e.model_info.id,accessToken:i})]})]},l))})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:t,model:s,onSubmit:r}=e,[n]=eg.Z.useForm(),o={},i="",c="";if(s){o=s.litellm_params,i=s.model_name;let e=s.model_info;e&&(c=e.id,console.log("model_id: ".concat(c)),o.model_id=c)}return(0,a.jsx)(ey.Z,{title:"Edit Model "+i,visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r(e),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:eW,initialValues:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:U,onCancel:()=>{D(!1),z(null)},model:B,onSubmit:eW})]}),(0,a.jsxs)(eX.Z,{className:"h-full",children:[(0,a.jsx)(li,{level:2,children:"Add new model"}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eg.Z,{form:Z,onFinish:()=>{Z.validateFields().then(e=>{lh(e,i,Z)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:O.toString(),children:A.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>{lx(e),R(e)},children:e},l))})}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(s=O.toString())?"gemini-pro":"Anthropic"==s?"claude-3-opus":"Amazon Bedrock"==s?"claude-3-opus":"Google AI Studio"==s?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===O?(0,a.jsx)(ec.Z,{placeholder:"Enter model name"}):v.length>0?(0,a.jsx)(e0.Z,{value:v,children:v.map((e,l)=>(0,a.jsx)(e1.Z,{value:e,children:e},l))}):(0,a.jsx)(ec.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==o&&o.fields.length>0&&(0,a.jsx)(lo,{fields:o.fields,selectedProvider:o.name}),"Amazon Bedrock"!=O&&"Vertex AI (Anthropic, Gemini, etc.)"!=O&&void 0===o&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(ec.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==O&&(0,a.jsx)(eg.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(ec.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(ec.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ls.Z,{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;Z.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?h.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&h.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(e_.ZP,{icon:(0,a.jsx)(lt.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==O||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==O)&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(ec.Z,{placeholder:"https://..."})}),"Azure"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(ec.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==O&&(0,a.jsxs)("div",{children:[(0,a.jsx)(eg.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(lc,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(eg.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,a.jsx)(e6.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(e3.Z,{title:"Get help on our github",children:(0,a.jsx)(eV.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(ei.Z,{onClick:lp,children:"Run `/health`"}),M&&(0,a.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:eU,onValueChange:e=>{eD(e),lj(q,e.from,e.to)}})]}),(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Model Group"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2",defaultValue:q||K[0],value:q||K[0],children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>lj(e,eU.from,eU.to),children:e},l))})]})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eY.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(eu.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),J&&X&&(0,a.jsx)(e2.Z,{title:"Model Latency",className:"h-72",data:J,showLegend:!1,index:"date",categories:X,connectNulls:!0,customTooltip:lg})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(ln,{modelMetrics:el,modelMetricsCategories:es,customTooltip:lg,premiumUser:g})})]})]})})}),(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Deployment"}),(0,a.jsx)(eF.Z,{children:"Success Responses"}),(0,a.jsxs)(eF.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(eC.Z,{children:eS.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.api_base}),(0,a.jsx)(eT.Z,{children:e.total_count}),(0,a.jsx)(eT.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(eA.Z,{className:"mt-4",children:[(0,a.jsx)(ex.Z,{children:"Exceptions per Model"}),(0,a.jsx)(e4.Z,{className:"h-72",data:ep,index:"model",categories:ef,stack:!0,colors:["indigo-300","rose-200","#ffcc33"],yAxisWidth:30})]})]}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],value:q||K[0],onValueChange:e=>V(e),children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))})]}),(0,a.jsxs)(ex.Z,{children:["Retry Policy for ",q]}),(0,a.jsx)(eu.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),lm&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(lm).map((e,l)=>{var t;let[s,r]=e,n=null==eB?void 0:null===(t=eB[q])||void 0===t?void 0:t[r];return null==n&&(n=eK),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)("td",{children:(0,a.jsx)(eZ.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{ez(l=>{var t;let s=null!==(t=null==l?void 0:l[q])&&void 0!==t?t:{};return{...null!=l?l:{},[q]:{...s,[r]:e}}})}})})]},l)})})}),(0,a.jsx)(ei.Z,{className:"mt-6 mr-8",onClick:la,children:"Save"})]})]})]})})};let{Option:lx}=ej.default;var lp=e=>{let{userID:l,accessToken:t,teams:s}=e,[r]=eg.Z.useForm(),[o,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[m,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{let e=await P(t,l,"any"),s=[];for(let l=0;l{i(!1),r.resetFields()},p=()=>{i(!1),d(null),r.resetFields()},j=async e=>{try{h.ZP.info("Making API Call"),i(!0),console.log("formValues in create user:",e);let s=await _(t,null,e);console.log("user create Response:",s),d(s.key),h.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-0",onClick:()=>i(!0),children:"+ Invite User"}),(0,a.jsxs)(ey.Z,{title:"Invite User",visible:o,width:800,footer:null,onOk:x,onCancel:p,children:[(0,a.jsx)(eu.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(eu.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(eg.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(eg.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(ej.default,{placeholder:"Select Team ID",style:{width:"100%"},children:s?s.map(e=>(0,a.jsx)(lx,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(lx,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create User"})})]})]}),c&&(0,a.jsxs)(ey.Z,{title:"User Created Successfully",visible:o,onOk:x,onCancel:p,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},lj=e=>{let{accessToken:l,token:t,keys:s,userRole:r,userID:o,teams:i,setKeys:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(0),[j,g]=n.useState(null),[y,f]=(0,n.useState)(null);return((0,n.useEffect)(()=>{if(!l||!t||!r||!o)return;let e=async()=>{try{let e=await k(l,null,r,!0,x,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&r&&o&&e()},[l,t,r,o,x]),d&&l&&t&&r&&o)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(eo.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(lp,{userID:o,accessToken:l,teams:i}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(eu.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(eJ.Z,{children:(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"User ID"}),(0,a.jsx)(eF.Z,{children:"User Email"}),(0,a.jsx)(eF.Z,{children:"User Models"}),(0,a.jsx)(eF.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User API Key Aliases"})]})}),(0,a.jsx)(eC.Z,{children:d.map(e=>{var l;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_id}),(0,a.jsx)(eT.Z,{children:e.user_email}),(0,a.jsx)(eT.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(eT.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eo.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsx)(eN.Z,{size:"xs",color:"indigo",children:e.key_aliases.filter(e=>null!==e).join(", ")}):(0,a.jsx)(eN.Z,{size:"xs",color:"gray",children:"No Keys"})})})]},e.user_id)})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})})]}),function(){if(!d)return null;let e=Math.ceil(d.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",x+1," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:0===x,onClick:()=>p(x-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",onClick:()=>{p(x+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},lg=e=>{let{teams:l,searchParams:t,accessToken:s,setTeams:r,userID:o,userRole:i}=e,[c]=eg.Z.useForm(),[d]=eg.Z.useForm(),{Title:m,Paragraph:u}=eV.default,[x,p]=(0,n.useState)(""),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(l?l[0]:null),[Z,_]=(0,n.useState)(!1),[w,k]=(0,n.useState)(!1),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)(!1),[I,C]=(0,n.useState)(null),[T,F]=(0,n.useState)({}),O=e=>{f(e),g(!0)},R=async e=>{let t=e.team_id;if(console.log("handleEditSubmit:",e),null==s)return;let a=await H(s,e);l&&r(l.map(e=>e.team_id===t?a.data:e)),h.ZP.success("Team updated successfully"),g(!1),f(null)},M=async e=>{C(e),E(!0)},L=async()=>{if(null!=I&&null!=l&&null!=s){try{await b(s,I);let e=l.filter(e=>e.team_id!==I);r(e)}catch(e){console.error("Error deleting the team:",e)}E(!1),C(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{if(null===o||null===i||null===s||null===l)return;console.log("fetching team info:");let e={};for(let t=0;t<(null==l?void 0:l.length);t++){let r=l[t].team_id,a=await v(s,r);console.log("teamInfo response:",a),null!==a&&(e={...e,[r]:a})}F(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===o||null===i)return;if(null!==s){let e=(await P(s,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,o,i,l]);let U=async e=>{try{if(null!=s){var t;let a=null==e?void 0:e.team_alias;if((null!==(t=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==t?t:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));h.ZP.info("Creating Team");let n=await V(s,e);null!==l?r([...l,n]):r([n]),console.log("response for team create call: ".concat(n)),h.ZP.success("Team created"),_(!1)}}catch(e){console.error("Error creating the team:",e),h.ZP.error("Error creating the team: "+e,20)}},D=async e=>{try{if(null!=s&&null!=l){h.ZP.info("Adding Member");let t={role:"user",user_email:e.user_email,user_id:e.user_id},a=await J(s,y.team_id,t);console.log("response for team create call: ".concat(a.data));let n=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(n)),-1!==n){let e=[...l];e[n]=a.data,r(e),f(a.data)}k(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Team Name"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(eF.Z,{children:"Info"})]})}),(0,a.jsx)(eC.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(eT.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].keys&&T[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].team_info&&T[e.team_id].team_info.members_with_roles&&T[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>O(e)}),(0,a.jsx)(eE.Z,{onClick:()=>M(e.team_id),icon:eS.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{E(!1),C(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>_(!0),children:"+ Create New Team"}),(0,a.jsx)(ey.Z,{title:"Create Team",visible:Z,width:800,footer:null,onOk:()=>{_(!1),c.resetFields()},onCancel:()=>{_(!1),c.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:U,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{f(e)},children:e.team_alias},l))}):(0,a.jsxs)(u,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:y?y.members_with_roles.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.role})]},l)):null})]})}),y&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,team:s,onSubmit:r}=e,[n]=eg.Z.useForm();return(0,a.jsx)(ey.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:s.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:R,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:j,onCancel:()=>{g(!1),f(null)},team:y,onSubmit:R})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-5",onClick:()=>k(!0),children:"+ Add member"}),(0,a.jsx)(ey.Z,{title:"Add member",visible:w,width:800,footer:null,onOk:()=>{k(!1),d.resetFields()},onCancel:()=>{k(!1),d.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:D,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},ly=e=>{let l,{searchParams:t,accessToken:s,showSSOBanner:r}=e,[o]=eg.Z.useForm(),[i]=eg.Z.useForm(),{Title:c,Paragraph:d}=eV.default,[m,u]=(0,n.useState)(""),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(!1),[Z,_]=(0,n.useState)(!1),[w,b]=(0,n.useState)(!1),[k,v]=(0,n.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let S=()=>{v(!1)},N=["proxy_admin","proxy_admin_viewer"];(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await q(s,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let t=await q(s,"proxy_admin");t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(t)),console.log("combinedList: ".concat(e)),p(e)}})()},[s]);let A=()=>{_(!1),i.resetFields()},E=()=>{_(!1),i.resetFields()},I=e=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]}),C=(e,l,t)=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:l,children:N.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:t,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update role"})})]}),T=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,null);console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),h.ZP.success("Refresh tab to see updated user role"),_(!1)}}catch(e){console.error("Error creating the key:",e)}},P=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),g(!1)}}catch(e){console.error("Error creating the key:",e)}},F=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await $(s,e,"proxy_admin");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),f(!1)}}catch(e){console.error("Error creating the key:",e)}},O=async e=>{null!=s&&er(s,{environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}})};return console.log("admins: ".concat(null==x?void 0:x.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(c,{level:4,children:"Admin Access "}),(0,a.jsxs)(d,{children:[r&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc. ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:x?x.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.user_role}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>_(!0)}),(0,a.jsx)(ey.Z,{title:"Update role",visible:Z,width:800,footer:null,onOk:A,onCancel:E,children:C(T,e.user_role,e.user_id)})]})]},l)):null})]})})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(ei.Z,{className:"mr-4 mb-5",onClick:()=>f(!0),children:"+ Add admin"}),(0,a.jsx)(ey.Z,{title:"Add admin",visible:y,width:800,footer:null,onOk:()=>{f(!1),i.resetFields()},onCancel:()=>{f(!1),i.resetFields()},children:I(F)}),(0,a.jsx)(ei.Z,{className:"mb-5",onClick:()=>g(!0),children:"+ Add viewer"}),(0,a.jsx)(ey.Z,{title:"Add viewer",visible:j,width:800,footer:null,onOk:()=>{g(!1),i.resetFields()},onCancel:()=>{g(!1),i.resetFields()},children:I(P)})]})})]}),(0,a.jsxs)(eo.Z,{children:[(0,a.jsx)(c,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(ei.Z,{onClick:()=>b(!0),children:"Add SSO"}),(0,a.jsx)(ey.Z,{title:"Add SSO",visible:w,width:800,footer:null,onOk:()=>{b(!1),o.resetFields()},onCancel:()=>{b(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{F(e),O(e),b(!1),v(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(ef.Z.Password,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(ef.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(ey.Z,{title:"SSO Setup Instructions",visible:k,width:800,footer:null,onOk:S,onCancel:()=>{v(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{onClick:S,children:"Done"})})]})]}),(0,a.jsxs)(lr.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},lf=t(42556),lZ=e=>{let{alertingSettings:l,handleInputChange:t,handleResetField:s,handleSubmit:r,premiumUser:n}=e,[o]=eg.Z.useForm();return(0,a.jsxs)(eg.Z,{form:o,onFinish:()=>{let e=o.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):r(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{align:"center",children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?n?(0,a.jsx)(eg.Z.Item,{name:e.field_name,children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l)}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}):(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(eg.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l),className:"p-0"}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>s(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update Settings"})})]})},l_=e=>{let{accessToken:l,premiumUser:t}=e,[s,r]=(0,n.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,n.useEffect)(()=>{l&&f(l).then(e=>{r(e)})},[l]),(0,a.jsx)(lZ,{alertingSettings:s,handleInputChange:(e,l)=>{r(s.map(t=>t.field_name===e?{...t,field_value:l}:t))},handleResetField:(e,t)=>{if(l)try{let l=s.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),r(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let t={};s.forEach(e=>{t[e.field_name]=e.field_value});let r={...e,...t};try{et(l,"alerting_args",r),h.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:t})};let lw=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var lb=e=>{let{accessToken:l,userRole:t,userID:s,premiumUser:r}=e,[o,i]=(0,n.useState)(lw),[c,d]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[x]=eg.Z.useForm(),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,Z]=(0,n.useState)(""),[_,w]=(0,n.useState)({}),[b,k]=(0,n.useState)([]),v=e=>{b.includes(e)?k(b.filter(l=>l!==e)):k([...b,e])},S={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,n.useEffect)(()=>{l&&t&&s&&ee(l,s,t).then(e=>{console.log("callbacks",e);let l=lw;i(l=l.map(l=>{let t=e.callbacks.find(e=>e.name===l.name);return t?{...l,variables:{...l.variables,...t.variables}}:l}));let t=e.alerts;if(console.log("alerts_data",t),t&&t.length>0){let e=t[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),k(e.active_alerts),Z(l),w(e.alerts_to_webhook)}d(t)})},[l,t,s]);let N=e=>b&&b.includes(e),A=e=>{if(!l)return;let t=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[t,s]=e;return[t,(null===(l=document.querySelector('input[name="'.concat(t,'"]')))||void 0===l?void 0:l.value)||s]}));console.log("updatedVariables",t),console.log("updateAlertTypes",g);let s={environment_variables:t,litellm_settings:{success_callback:[e.name]}};try{er(l,s)}catch(e){h.ZP.error("Failed to update callback: "+e,20)}h.ZP.success("Callback updated successfully")},E=()=>{l&&x.validateFields().then(e=>{if(console.log("Form values:",e),"langfuse"===e.callback){er(l,{environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),er(l,{general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}}),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),er(l,{environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};i(o?[...o,t]:[t])}u(!1),x.resetFields(),j(null)})};return l?(console.log("callbacks: ".concat(o)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(lr.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Settings"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Callback"}),(0,a.jsx)(eF.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(eC.Z,{children:o.filter(e=>"slack"!==e.name).map((e,t)=>{var s;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eN.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).filter(l=>{let[t,s]=l;return t.toLowerCase().includes(e.name)}).map(e=>{let[l,t]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(eu.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(ec.Z,{name:l,defaultValue:t,type:"password"})]},l)})}),(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(e),children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,e.name),className:"mx-2",children:"Test Callback"})]})]},t)})})]})})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eu.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(S).map((e,l)=>{let[t,s]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:"region_outage_alerts"==t?r?(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)}):(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:t,type:"password",defaultValue:_&&_[t]?_[t]:f})})]},l)})})]}),(0,a.jsx)(ei.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(S).forEach(l=>{let[t,s]=l,r=document.querySelector('input[name="'.concat(t,'"]'));console.log("key",t),console.log("webhookInput",r);let a=(null==r?void 0:r.value)||"";console.log("newWebhookValue",a),e[t]=a}),console.log("updatedAlertToWebhooks",e);let t={general_settings:{alert_to_webhook_url:e,alert_types:b}};console.log("payload",t);try{er(l,t)}catch(e){h.ZP.error("Failed to update alerts: "+e,20)}h.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(l_,{accessToken:l,premiumUser:r})})]})]})]}),(0,a.jsx)(ey.Z,{title:"Add Callback",visible:m,onOk:E,width:800,onCancel:()=>{u(!1),x.resetFields(),j(null)},footer:null,children:(0,a.jsxs)(eg.Z,{form:x,layout:"vertical",onFinish:E,children:[(0,a.jsx)(eg.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(ej.default,{onChange:e=>{j(e)},children:[(0,a.jsx)(ej.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(ej.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(ec.Z,{type:"password"})}),(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})]}),"openmeter"==p&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eg.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:lk}=ej.default;var lv=e=>{let{models:l,accessToken:t,routerSettings:s,setRouterSettings:r}=e,[o]=eg.Z.useForm(),[i,c]=(0,n.useState)(!1),[d,m]=(0,n.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>c(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(ey.Z,{title:"Add Fallbacks",visible:i,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,n=[...s.fallbacks||[],{[l]:a}],i={...s,fallbacks:n};console.log(i);try{er(t,{router_settings:i}),r(i)}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully"),c(!1),o.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(eR.Z,{defaultValue:d,children:l&&l.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(e0.Z,{value:l,children:l&&l.filter(e=>e!=d).map(e=>(0,a.jsx)(e1.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lS=t(12968);async function lN(e,l){console.log("isLocal:",!1);let t=window.location.origin,s=new lS.ZP.OpenAI({apiKey:l,baseURL:t,dangerouslyAllowBrowser:!0});try{let l=await s.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});h.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lA={ttl:3600,lowest_latency_buffer:0},lE=e=>{let{selectedStrategy:l,strategyArgs:t,paramExplanation:s}=e;return(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(em.Z,{children:"latency-based-routing"==l?(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(t).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:s[l]})]}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]})}):(0,a.jsx)(eu.Z,{children:"No specific settings"})})]})};var lI=e=>{let{accessToken:l,userRole:t,userID:s,modelData:r}=e,[o,i]=(0,n.useState)({}),[c,d]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1),[j]=eg.Z.useForm(),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)(null),b={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,n.useEffect)(()=>{l&&t&&s&&(ee(l,s,t).then(e=>{console.log("callbacks",e),i(e.router_settings)}),el(l).then(e=>{u(e)}))},[l,t,s]);let k=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(o.fallbacks)),o.fallbacks.map(l=>(e in l&&delete l[e],l));try{await er(l,{router_settings:o}),i({...o}),Z(o.routing_strategy),h.ZP.success("Router settings updated successfully")}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}}},v=(e,l)=>{u(m.map(t=>t.field_name===e?{...t,field_value:l}:t))},S=(e,t)=>{if(!l)return;let s=m[t].field_value;if(null!=s&&void 0!=s)try{et(l,e,s);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(t)}catch(e){}},N=(e,t)=>{if(l)try{es(l,e);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(t)}catch(e){}},A=e=>{if(!l)return;console.log("router_settings",e);let t=Object.fromEntries(Object.entries(e).map(e=>{let[l,t]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var s;return[l,(null===(s=document.querySelector('input[name="'.concat(l,'"]')))||void 0===s?void 0:s.value)||t]}if("routing_strategy"==l)return[l,f];if("routing_strategy_args"==l&&"latency-based-routing"==f){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),t=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==t?void 0:t.value)&&(e.ttl=Number(t.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",t);try{er(l,{router_settings:t})}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eY.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eY.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(ex.Z,{children:"Router Settings"}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(o).filter(e=>{let[l,t]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:b[l]})]}),(0,a.jsx)(eT.Z,{children:"routing_strategy"==l?(0,a.jsxs)(eR.Z,{defaultValue:t,className:"w-full max-w-md",onValueChange:Z,children:[(0,a.jsx)(eM.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(eM.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(eM.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]}),(0,a.jsx)(lE,{selectedStrategy:f,strategyArgs:o&&o.routing_strategy_args&&Object.keys(o.routing_strategy_args).length>0?o.routing_strategy_args:lA,paramExplanation:b})]}),(0,a.jsx)(en.Z,{children:(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(o),children:"Save Changes"})})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Model Name"}),(0,a.jsx)(eF.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(eC.Z,{children:o.fallbacks&&o.fallbacks.map((e,t)=>Object.entries(e).map(e=>{let[s,r]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:s}),(0,a.jsx)(eT.Z,{children:Array.isArray(r)?r.join(", "):r}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{onClick:()=>lN(s,l),children:"Test Fallback"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>k(s)})})]},t.toString()+s)}))})]}),(0,a.jsx)(lv,{models:(null==r?void 0:r.data)?r.data.map(e=>e.model_name):[],accessToken:l,routerSettings:o,setRouterSettings:i})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"}),(0,a.jsx)(eF.Z,{children:"Status"}),(0,a.jsx)(eF.Z,{children:"Action"})]})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(eT.Z,{children:"Integer"==e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>v(e.field_name,l)}):null}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(ei.Z,{onClick:()=>S(e.field_name,l),children:"Update"}),(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>N(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lC=e=>{let{isModalVisible:l,accessToken:t,setIsModalVisible:s,setBudgetList:r}=e,[n]=eg.Z.useForm(),o=async e=>{if(null!=t&&void 0!=t)try{h.ZP.info("Making API Call");let l=await y(t,e);console.log("key create Response:",l),r(e=>e?[...e,l]:[l]),h.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(ey.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{s(!1),n.resetFields()},onCancel:()=>{s(!1),n.resetFields()},children:(0,a.jsxs)(eg.Z,{form:n,onFinish:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lT=t(67951),lP=e=>{let{accessToken:l}=e,[t,s]=(0,n.useState)(!1),[r,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&Q(l).then(e=>{o(e)})},[l]);let i=async(e,t)=>{if(null==l)return;h.ZP.info("Request made"),await g(l,e);let s=[...r];s.splice(t,1),o(s),h.ZP.success("Budget Deleted.")};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(ei.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>s(!0),children:"+ Create Budget"}),(0,a.jsx)(lC,{accessToken:l,isModalVisible:t,setIsModalVisible:s,setBudgetList:o}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Budget ID"}),(0,a.jsx)(eF.Z,{children:"Max Budget"}),(0,a.jsx)(eF.Z,{children:"TPM"}),(0,a.jsx)(eF.Z,{children:"RPM"})]})}),(0,a.jsx)(eC.Z,{children:r.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.budget_id}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(eT.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(eT.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>i(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(eu.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eY.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eY.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{var l;let{userID:t,userRole:s,token:r,accessToken:o,keys:i,premiumUser:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);(0,n.useEffect)(()=>{o&&r&&s&&t&&(async()=>{try{let e=await A(o,t,s);console.log("ModelHubData:",e),m(e.data)}catch(e){console.error("There was an error fetching the model data",e)}})()},[o,r,s,t]);let j=e=>{p(e),u(!0)},g=e=>{navigator.clipboard.writeText(e)};return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)("div",{className:"relative w-full"}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(ex.Z,{className:"ml-8 text-center ",children:"Model Hub"}),(0,a.jsx)(ei.Z,{className:"ml-4",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4",children:d&&d.map(e=>(0,a.jsxs)(eA.Z,{className:"mt-5 mx-8",children:[(0,a.jsxs)("pre",{className:"flex justify-between",children:[(0,a.jsx)(ex.Z,{children:e.model_group}),(0,a.jsx)(e3.Z,{title:e.model_group,children:(0,a.jsx)(lF.Z,{onClick:()=>g(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,a.jsxs)("div",{className:"my-5",children:[(0,a.jsxs)(eu.Z,{children:["Mode: ",e.mode]}),(0,a.jsxs)(eu.Z,{children:["Supports Function Calling: ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Supports Vision: ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Max Input Tokens: ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,a.jsxs)(eu.Z,{children:["Max Output Tokens: ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,a.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,a.jsxs)("a",{href:"#",onClick:()=>j(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,a.jsx)(lO.Z,{})]})})]},e.model_group))})]}),(0,a.jsx)(ey.Z,{title:x&&x.model_group?x.model_group:"Unknown Model",width:800,visible:h,footer:null,onOk:()=>{u(!1),p(null)},onCancel:()=>{u(!1),p(null)},children:x&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-4",children:(0,a.jsx)("strong",{children:"Model Information & Usage"})}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"Supported OpenAI Params"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(x.model_group,'", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,a.jsx)(eX.Z,{children:null==x?void 0:null===(l=x.supported_openai_params)||void 0===l?void 0:l.map(e=>(0,a.jsx)("pre",{children:e},e))}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="'.concat(x.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "'.concat(x.model_group,'",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})]})},lM=e=>{let{}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(eu.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n '})})]})]})]})})})};async function lL(e,l,t,s){console.log("isLocal:",!1);let r=window.location.origin,a=new lS.ZP.OpenAI({apiKey:s,baseURL:r,dangerouslyAllowBrowser:!0});try{for await(let s of(await a.chat.completions.create({model:t,stream:!0,messages:[{role:"user",content:e}]})))console.log(s),s.choices[0].delta.content&&l(s.choices[0].delta.content)}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lU=e=>{let{accessToken:l,token:t,userRole:s,userID:r}=e,[o,i]=(0,n.useState)(""),[c,d]=(0,n.useState)(""),[m,h]=(0,n.useState)([]),[u,x]=(0,n.useState)(void 0),[p,j]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{let e=await P(l,r,s);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));console.log(l),j(l),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,r,s]);let g=(e,l)=>{h(t=>{let s=t[t.length-1];return s&&s.role===e?[...t.slice(0,t.length-1),{role:e,content:s.content+l}]:[...t,{role:e,content:l}]})},y=async()=>{if(""!==c.trim()&&o&&t&&s&&r){h(e=>[...e,{role:"user",content:c}]);try{u&&await lL(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsx)(e$.Z,{children:(0,a.jsx)(eY.Z,{children:"Chat"})}),(0,a.jsx)(eQ.Z,{children:(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"API Key"}),(0,a.jsx)(ec.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,a.jsxs)(en.Z,{className:"mx-2",children:[(0,a.jsx)(eu.Z,{children:"Select Model:"}),(0,a.jsx)(ej.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,a.jsxs)(eI.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{})})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(ec.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,a.jsx)(ei.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]})})]})})})})},lD=t(33509),lB=t(95781);let{Sider:lz}=lD.default;var lK=e=>{let{setPage:l,userRole:t,defaultSelectedKey:s}=e;return"Admin Viewer"==t?(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(lz,{width:120,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(lz,{width:145,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(eu.Z,{children:"API Keys"})},"1"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(eu.Z,{children:"Test Key"})},"3"),"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(eu.Z,{children:"Models"})},"2"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(eu.Z,{children:"Usage"})},"4"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(eu.Z,{children:"Teams"})},"6"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(eu.Z,{children:"Users"})},"5"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(eu.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(eu.Z,{children:"Rate Limits"})},"9"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(eu.Z,{children:"Router Settings"})},"10"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(eu.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(eu.Z,{children:"API Reference"})},"12"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(eu.Z,{children:"Model Hub"})},"14")]})})})},lG=t(67989),lq=t(49167),lV=t(52703),lW=e=>{let{accessToken:l,token:t,userRole:s,userID:r,keys:o,premiumUser:i}=e,c=new Date,[d,m]=(0,n.useState)([]),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)([]),[j,g]=(0,n.useState)([]),[y,f]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[w,b]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)({}),[I,C]=(0,n.useState)([]),[T,P]=(0,n.useState)(""),[q,V]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),W=new Date(c.getFullYear(),c.getMonth(),1),H=new Date(c.getFullYear(),c.getMonth()+1,0),Y=Q(W),J=Q(H);console.log("keys in usage",o),console.log("premium user in usage",i);let $=async(e,t,s)=>{if(!e||!t||!l)return;t.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",s);let r=await U(l,s,e.toISOString(),t.toISOString());console.log("End user data updated successfully",r),g(r)},X=async(e,t)=>{e&&t&&l&&(t.setHours(23,59,59,999),e.setHours(0,0,0,0),_((await O(l,e.toISOString(),t.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function Q(e){let l=e.getFullYear(),t=e.getMonth()+1,s=e.getDate();return"".concat(l,"-").concat(t<10?"0"+t:t,"-").concat(s<10?"0"+s:s)}return console.log("Start date is ".concat(Y)),console.log("End date is ".concat(J)),(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{if(console.log("user role: ".concat(s)),"Admin"==s||"Admin Viewer"==s){var e,a;let s=await M(l);m(s);let r=await D(l,t,Y,J);console.log("provider_spend",r),N(r);let n=(await L(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));u(n);let o=(await K(l)).map(e=>({key:e.model,spend:e.total_spend}));p(o);let i=await F(l);console.log("teamSpend",i),f(i.daily_spend),b(i.teams);let c=i.total_spend_per_team;c=c.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),v(c);let d=await O(l,null===(e=q.from)||void 0===e?void 0:e.toISOString(),null===(a=q.to)||void 0===a?void 0:a.toISOString());_(d.spend_per_tag);let h=await U(l,null,void 0,void 0);g(h),console.log("spend/user result",h);let x=await B(l,Y,J);E(x);let j=await z(l,Y,J);console.log("global activity per model",j),C(j)}else"App Owner"==s&&await R(l,t,s,r,Y,J).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let t=e.top_api_keys;u(t)}else{let t=(await G(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[t,s]=e;"spend"!==t&&"startTime"!==t&&"models"!==t&&"users"!==t&&l.push({key:t,spend:s})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let t=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(t[0]))),t}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));u(t),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,t,s,r,Y,J]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(ez,{userID:r,userRole:s,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{className:"mt-2",children:[(0,a.jsx)(eY.Z,{children:"All Up"}),(0,a.jsx)(eY.Z,{children:"Team Based Usage"}),(0,a.jsx)(eY.Z,{children:"End User Usage"}),(0,a.jsx)(eY.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eY.Z,{children:"Cost"}),(0,a.jsx)(eY.Z,{children:"Activity"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Monthly Spend"}),(0,a.jsx)(e4.Z,{data:d,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top API Keys"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top Models"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:x,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1}),(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"✨ Spend by Provider"}),i?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(lV.Z,{className:"mt-4 h-40",variant:"pie",data:S,index:"provider",category:"spend"})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Provider"}),(0,a.jsx)(eF.Z,{children:"Spend"})]})}),(0,a.jsx)(eC.Z,{children:S.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.provider}),(0,a.jsx)(eT.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"All Up"}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",A.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",A.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),i?(0,a.jsx)(a.Fragment,{children:I.map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:I&&I.length>0&&I.slice(0,1).map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lG.Z,{data:k})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(e4.Z,{className:"h-72",data:y,showLegend:!0,index:"date",categories:w,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:q,onValueChange:e=>{V(e),$(e.from,e.to,null)}})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Key"}),(0,a.jsxs)(eR.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(eM.Z,{value:"all-keys",onClick:()=>{$(q.from,q.to,null)},children:"All Keys"},"all-keys"),null==o?void 0:o.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{$(q.from,q.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(eA.Z,{className:"mt-4",children:(0,a.jsxs)(eI.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"End User"}),(0,a.jsx)(eF.Z,{children:"Spend"}),(0,a.jsx)(eF.Z,{children:"Total Events"})]})}),(0,a.jsx)(eC.Z,{children:null==j?void 0:j.map((e,l)=>{var t;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.end_user}),(0,a.jsx)(eT.Z,{children:null===(t=e.total_spend)||void 0===t?void 0:t.toFixed(4)}),(0,a.jsx)(eT.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsx)(eH.Z,{className:"mb-4",enableSelect:!0,value:q,onValueChange:e=>{V(e),X(e.from,e.to)}}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(eu.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(e4.Z,{className:"h-72",data:Z,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})})]})]})]})},lH=()=>{let{Title:e,Paragraph:l}=eV.default,[t,s]=(0,n.useState)(""),[r,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!0),y=(0,o.useSearchParams)(),[f,Z]=(0,n.useState)({data:[]}),_=y.get("userID"),w=y.get("token"),[b,k]=(0,n.useState)("api-keys"),[v,S]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(w){let e=(0,eq.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),S(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),s(l),"Admin Viewer"==l&&k("usage")}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&i(e.premium_user)}}},[w]),(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:_,userRole:t,userEmail:c,showSSOBanner:j,premiumUser:r}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lK,{setPage:k,userRole:t,defaultSelectedKey:null})}),"api-keys"==b?(0,a.jsx)(eW,{userID:_,userRole:t,teams:h,keys:x,setUserRole:s,userEmail:c,setUserEmail:d,setTeams:u,setKeys:p}):"models"==b?(0,a.jsx)(lu,{userID:_,userRole:t,token:w,accessToken:v,modelData:f,setModelData:Z,premiumUser:r}):"llm-playground"==b?(0,a.jsx)(lU,{userID:_,userRole:t,token:w,accessToken:v}):"users"==b?(0,a.jsx)(lj,{userID:_,userRole:t,token:w,keys:x,teams:h,accessToken:v,setKeys:p}):"teams"==b?(0,a.jsx)(lg,{teams:h,setTeams:u,searchParams:y,accessToken:v,userID:_,userRole:t}):"admin-panel"==b?(0,a.jsx)(ly,{setTeams:u,searchParams:y,accessToken:v,showSSOBanner:j}):"api_ref"==b?(0,a.jsx)(lM,{}):"settings"==b?(0,a.jsx)(lb,{userID:_,userRole:t,accessToken:v,premiumUser:r}):"budgets"==b?(0,a.jsx)(lP,{accessToken:v}):"general-settings"==b?(0,a.jsx)(lI,{userID:_,userRole:t,accessToken:v,modelData:f}):"model-hub"==b?(0,a.jsx)(lR,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r}):(0,a.jsx)(lW,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r})]})]})})}}},function(e){e.O(0,[936,608,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/ui/litellm-dashboard/out/index.html b/ui/litellm-dashboard/out/index.html index 29cf19287..963865a00 100644 --- a/ui/litellm-dashboard/out/index.html +++ b/ui/litellm-dashboard/out/index.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/ui/litellm-dashboard/out/index.txt b/ui/litellm-dashboard/out/index.txt index ee14514d8..730ddfbc2 100644 --- a/ui/litellm-dashboard/out/index.txt +++ b/ui/litellm-dashboard/out/index.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[39712,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","608","static/chunks/608-d128caa3cfe973c1.js","931","static/chunks/app/page-e266cb0126026d40.js"],""] +3:I[39712,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","608","static/chunks/608-d128caa3cfe973c1.js","931","static/chunks/app/page-2421e763699a7dc4.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["dYIEEO-62OCgyckEhgBd-",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/5d93d4a9fa59d72f.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["N-Poqi-YBhDAzJSVSMX3L",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/5d93d4a9fa59d72f.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/src/components/model_hub.tsx b/ui/litellm-dashboard/src/components/model_hub.tsx index f64e20e3a..24d4bf045 100644 --- a/ui/litellm-dashboard/src/components/model_hub.tsx +++ b/ui/litellm-dashboard/src/components/model_hub.tsx @@ -202,7 +202,7 @@ print(response) { selectedModel?.supported_openai_params?.map((param) => ( -
+                             
                               {param}
                              
From f0f853b9411d7b1519e99d3492b8b0f629b062c0 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 27 May 2024 09:16:39 -0700 Subject: [PATCH 13/25] fix(utils.py): support deepinfra optional params Fixes https://github.com/BerriAI/litellm/issues/3855 --- litellm/__init__.py | 7 ++- litellm/llms/openai.py | 97 ++++++++++++++++++++++++++++++++++++++++++ litellm/utils.py | 43 +++---------------- 3 files changed, 109 insertions(+), 38 deletions(-) diff --git a/litellm/__init__.py b/litellm/__init__.py index d11242b1c..3c78c9b27 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -766,7 +766,12 @@ from .llms.bedrock import ( AmazonMistralConfig, AmazonBedrockGlobalConfig, ) -from .llms.openai import OpenAIConfig, OpenAITextCompletionConfig, MistralConfig +from .llms.openai import ( + OpenAIConfig, + OpenAITextCompletionConfig, + MistralConfig, + DeepInfraConfig, +) from .llms.azure import AzureOpenAIConfig, AzureOpenAIError from .llms.watsonx import IBMWatsonXAIConfig from .main import * # type: ignore diff --git a/litellm/llms/openai.py b/litellm/llms/openai.py index 2e0196faa..6197ec922 100644 --- a/litellm/llms/openai.py +++ b/litellm/llms/openai.py @@ -157,6 +157,101 @@ class MistralConfig: ) if param == "seed": optional_params["extra_body"] = {"random_seed": value} + if param == "response_format": + optional_params["response_format"] = value + return optional_params + + +class DeepInfraConfig: + """ + Reference: https://deepinfra.com/docs/advanced/openai_api + + The class `DeepInfra` provides configuration for the DeepInfra's Chat Completions API interface. Below are the parameters: + """ + + frequency_penalty: Optional[int] = None + function_call: Optional[Union[str, dict]] = None + functions: Optional[list] = None + logit_bias: Optional[dict] = None + max_tokens: Optional[int] = None + n: Optional[int] = None + presence_penalty: Optional[int] = None + stop: Optional[Union[str, list]] = None + temperature: Optional[int] = None + top_p: Optional[int] = None + response_format: Optional[dict] = None + tools: Optional[list] = None + tool_choice: Optional[Union[str, dict]] = None + + def __init__( + self, + frequency_penalty: Optional[int] = None, + function_call: Optional[Union[str, dict]] = None, + functions: Optional[list] = None, + logit_bias: Optional[dict] = None, + max_tokens: Optional[int] = None, + n: Optional[int] = None, + presence_penalty: Optional[int] = None, + stop: Optional[Union[str, list]] = None, + temperature: Optional[int] = None, + top_p: Optional[int] = None, + response_format: Optional[dict] = None, + tools: Optional[list] = None, + tool_choice: Optional[Union[str, dict]] = None, + ) -> None: + locals_ = locals().copy() + for key, value in locals_.items(): + if key != "self" and value is not None: + setattr(self.__class__, key, value) + + @classmethod + def get_config(cls): + return { + k: v + for k, v in cls.__dict__.items() + if not k.startswith("__") + and not isinstance( + v, + ( + types.FunctionType, + types.BuiltinFunctionType, + classmethod, + staticmethod, + ), + ) + and v is not None + } + + def get_supported_openai_params(self): + return [ + "frequency_penalty", + "function_call", + "functions", + "logit_bias", + "max_tokens", + "n", + "presence_penalty", + "stop", + "temperature", + "top_p", + "response_format", + "tools", + "tool_choice", + ] + + def map_openai_params( + self, non_default_params: dict, optional_params: dict, model: str + ): + supported_openai_params = self.get_supported_openai_params() + for param, value in non_default_params.items(): + if ( + param == "temperature" + and value == 0 + and model == "mistralai/Mistral-7B-Instruct-v0.1" + ): # this model does no support temperature == 0 + value = 0.0001 # close to 0 + if param in supported_openai_params: + optional_params[param] = value return optional_params @@ -197,6 +292,7 @@ class OpenAIConfig: stop: Optional[Union[str, list]] = None temperature: Optional[int] = None top_p: Optional[int] = None + response_format: Optional[dict] = None def __init__( self, @@ -210,6 +306,7 @@ class OpenAIConfig: stop: Optional[Union[str, list]] = None, temperature: Optional[int] = None, top_p: Optional[int] = None, + response_format: Optional[dict] = None, ) -> None: locals_ = locals().copy() for key, value in locals_.items(): diff --git a/litellm/utils.py b/litellm/utils.py index b777819e5..08822692c 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -5797,30 +5797,11 @@ def get_optional_params( model=model, custom_llm_provider=custom_llm_provider ) _check_valid_arg(supported_params=supported_params) - if temperature is not None: - if ( - temperature == 0 and model == "mistralai/Mistral-7B-Instruct-v0.1" - ): # this model does no support temperature == 0 - temperature = 0.0001 # close to 0 - optional_params["temperature"] = temperature - if top_p: - optional_params["top_p"] = top_p - if n: - optional_params["n"] = n - if stream: - optional_params["stream"] = stream - if stop: - optional_params["stop"] = stop - if max_tokens: - optional_params["max_tokens"] = max_tokens - if presence_penalty: - optional_params["presence_penalty"] = presence_penalty - if frequency_penalty: - optional_params["frequency_penalty"] = frequency_penalty - if logit_bias: - optional_params["logit_bias"] = logit_bias - if user: - optional_params["user"] = user + optional_params = litellm.DeepInfraConfig().map_openai_params( + non_default_params=non_default_params, + optional_params=optional_params, + model=model, + ) elif custom_llm_provider == "perplexity": supported_params = get_supported_openai_params( model=model, custom_llm_provider=custom_llm_provider @@ -6604,19 +6585,7 @@ def get_supported_openai_params( elif custom_llm_provider == "petals": return ["max_tokens", "temperature", "top_p", "stream"] elif custom_llm_provider == "deepinfra": - return [ - "temperature", - "top_p", - "n", - "stream", - "stop", - "max_tokens", - "presence_penalty", - "frequency_penalty", - "logit_bias", - "user", - "response_format", - ] + return litellm.DeepInfraConfig().get_supported_openai_params() elif custom_llm_provider == "perplexity": return [ "temperature", From 1e877d18a91f87f4ef42da174a1902381cd62fae Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 27 May 2024 09:18:07 -0700 Subject: [PATCH 14/25] =?UTF-8?q?bump:=20version=201.38.10=20=E2=86=92=201?= =?UTF-8?q?.38.11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7419a5d40..8b59ca297 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm" -version = "1.38.10" +version = "1.38.11" description = "Library to easily interface with LLM API providers" authors = ["BerriAI"] license = "MIT" @@ -79,7 +79,7 @@ requires = ["poetry-core", "wheel"] build-backend = "poetry.core.masonry.api" [tool.commitizen] -version = "1.38.10" +version = "1.38.11" version_files = [ "pyproject.toml:^version" ] From 8ff66cf4195d8231c5677c1bd414b03bef29c878 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 09:22:42 -0700 Subject: [PATCH 15/25] fix supported_openai_params --- .../src/components/model_hub.tsx | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_hub.tsx b/ui/litellm-dashboard/src/components/model_hub.tsx index 24d4bf045..a7359aea7 100644 --- a/ui/litellm-dashboard/src/components/model_hub.tsx +++ b/ui/litellm-dashboard/src/components/model_hub.tsx @@ -197,21 +197,10 @@ print(response) - - - { - selectedModel?.supported_openai_params?.map((param) => ( - -
-                              {param}
-                             
- - - )) - } - - -
+ + {`${selectedModel.supported_openai_params?.map((param) => `${param}\n`).join('')}`} + + {` From 3ed26d963b28e4a641fa4690b99bea33f14c927d Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 09:23:54 -0700 Subject: [PATCH 16/25] ui - new build --- litellm/proxy/_experimental/out/404.html | 2 +- .../_buildManifest.js | 0 .../_ssgManifest.js | 0 .../{page-2421e763699a7dc4.js => page-76d278f96a0e9768.js} | 2 +- litellm/proxy/_experimental/out/index.html | 2 +- litellm/proxy/_experimental/out/index.txt | 4 ++-- ui/litellm-dashboard/out/404.html | 2 +- .../_buildManifest.js | 0 .../_ssgManifest.js | 0 .../{page-2421e763699a7dc4.js => page-76d278f96a0e9768.js} | 2 +- ui/litellm-dashboard/out/index.html | 2 +- ui/litellm-dashboard/out/index.txt | 4 ++-- 12 files changed, 10 insertions(+), 10 deletions(-) rename litellm/proxy/_experimental/out/_next/static/{N-Poqi-YBhDAzJSVSMX3L => D_ZUmMtLMPSa4aQQUJtKt}/_buildManifest.js (100%) rename litellm/proxy/_experimental/out/_next/static/{N-Poqi-YBhDAzJSVSMX3L => D_ZUmMtLMPSa4aQQUJtKt}/_ssgManifest.js (100%) rename litellm/proxy/_experimental/out/_next/static/chunks/app/{page-2421e763699a7dc4.js => page-76d278f96a0e9768.js} (84%) rename ui/litellm-dashboard/out/_next/static/{N-Poqi-YBhDAzJSVSMX3L => D_ZUmMtLMPSa4aQQUJtKt}/_buildManifest.js (100%) rename ui/litellm-dashboard/out/_next/static/{N-Poqi-YBhDAzJSVSMX3L => D_ZUmMtLMPSa4aQQUJtKt}/_ssgManifest.js (100%) rename ui/litellm-dashboard/out/_next/static/chunks/app/{page-2421e763699a7dc4.js => page-76d278f96a0e9768.js} (84%) diff --git a/litellm/proxy/_experimental/out/404.html b/litellm/proxy/_experimental/out/404.html index dca0b9a75..14787d256 100644 --- a/litellm/proxy/_experimental/out/404.html +++ b/litellm/proxy/_experimental/out/404.html @@ -1 +1 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/D_ZUmMtLMPSa4aQQUJtKt/_buildManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_buildManifest.js rename to litellm/proxy/_experimental/out/_next/static/D_ZUmMtLMPSa4aQQUJtKt/_buildManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/D_ZUmMtLMPSa4aQQUJtKt/_ssgManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_ssgManifest.js rename to litellm/proxy/_experimental/out/_next/static/D_ZUmMtLMPSa4aQQUJtKt/_ssgManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-2421e763699a7dc4.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-76d278f96a0e9768.js similarity index 84% rename from litellm/proxy/_experimental/out/_next/static/chunks/app/page-2421e763699a7dc4.js rename to litellm/proxy/_experimental/out/_next/static/chunks/app/page-76d278f96a0e9768.js index ce8149624..e673e3c21 100644 --- a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-2421e763699a7dc4.js +++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-76d278f96a0e9768.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,t){Promise.resolve().then(t.bind(t,39712))},39712:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return lH}});var s,r,a=t(3827),n=t(64090),o=t(47907),i=t(8792),c=t(40491),d=t(65270),m=e=>{let{userID:l,userRole:t,userEmail:s,showSSOBanner:r,premiumUser:n}=e;console.log("User ID:",l),console.log("userEmail:",s),console.log("showSSOBanner:",r),console.log("premiumUser:",n);let o=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",t]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(i.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[r?(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(c.Z,{menu:{items:o},children:(0,a.jsx)(d.Z,{children:s})})})]})]})},h=t(80588);let u=async()=>{try{let e=await fetch("https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"),l=await e.json();return console.log("received data: ".concat(l)),l}catch(e){throw console.error("Failed to get model cost map:",e),e}},x=async(e,l)=>{try{let t=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),s}catch(e){throw console.error("Failed to create key:",e),e}},p=async e=>{try{let l=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},j=async(e,l)=>{console.log("model_id in model delete call: ".concat(l));try{let t=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model deleted successfully. Restart server to see this."),s}catch(e){throw console.error("Failed to create key:",e),e}},g=async(e,l)=>{if(console.log("budget_id in budget delete call: ".concat(l)),null!=e)try{let t=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,l)=>{try{console.log("Form Values in budgetCreateCall:",l),console.log("Form Values after check:",l);let t=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},f=async e=>{try{let l=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},Z=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,l)=>{try{console.log("in keyDeleteCall:",l);let t=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,l)=>{try{console.log("in teamDeleteCall:",l);let t=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,l,t){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;try{let n="/user/info";"App Owner"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),"App User"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),console.log("in userInfoCall viewAll=",s),s&&a&&null!=r&&void 0!=r&&(n="".concat(n,"?view_all=true&page=").concat(r,"&page_size=").concat(a));let o=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let i=await o.json();return console.log("API Response:",i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,l)=>{try{let t="/team/info";l&&(t="".concat(t,"?team_id=").concat(l)),console.log("in teamInfoCall");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},S=async e=>{try{let l=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,l,t)=>{try{let l=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelInfoCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,l,t)=>{try{let l=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelHubCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,l,t,s,r,a)=>{try{let l="/model/metrics";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},I=async(e,l,t,s)=>{try{let r="/model/streaming_metrics";l&&(r="".concat(r,"?_selected_model_group=").concat(l,"&startTime=").concat(t,"&endTime=").concat(s));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},C=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/slow_responses";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/exceptions";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,l,t)=>{try{let l=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},F=async e=>{try{let l="/global/spend/teams";console.log("in teamSpendLogsCall:",l);let t=await fetch("".concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=async(e,l,t)=>{try{let s="/global/spend/tags";l&&t&&(s="".concat(s,"?start_date=").concat(l,"&end_date=").concat(t)),console.log("in tagsSpendLogsCall:",s);let r=await fetch("".concat(s),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},R=async(e,l,t,s,r,a)=>{try{console.log("user role in spend logs call: ".concat(t));let l="/spend/logs";l="App Owner"==t?"".concat(l,"?user_id=").concat(s,"&start_date=").concat(r,"&end_date=").concat(a):"".concat(l,"?start_date=").concat(r,"&end_date=").concat(a);let n=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},M=async e=>{try{let l=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},L=async e=>{try{let l=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,l,t,s)=>{try{let r="";r=l?JSON.stringify({api_key:l,startTime:t,endTime:s}):JSON.stringify({startTime:t,endTime:s});let a={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};a.body=r;let n=await fetch("/global/spend/end_users",a);if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,l,t,s)=>{try{let r="/global/spend/provider";t&&s&&(r+="?start_date=".concat(t,"&end_date=").concat(s)),l&&(r+="&api_key=".concat(l));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log(n),n}catch(e){throw console.error("Failed to fetch spend data:",e),e}},B=async(e,l,t)=>{try{let s="/global/activity";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},z=async(e,l,t)=>{try{let s="/global/activity/model";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},K=async e=>{try{let l=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},G=async(e,l)=>{try{let t=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},q=async(e,l)=>{try{let t="/user/get_users?role=".concat(l);console.log("in userGetAllUsersCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let r=await s.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},V=async(e,l)=>{try{console.log("Form Values in teamCreateCall:",l);let t=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,l)=>{try{console.log("Form Values in keyUpdateCall:",l);let t=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},H=async(e,l)=>{try{console.log("Form Values in teamUpateCall:",l);let t=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},Y=async(e,l)=>{try{console.log("Form Values in modelUpateCall:",l);let t=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update model Response:",s),s}catch(e){throw console.error("Failed to update model:",e),e}},J=async(e,l,t)=>{try{console.log("Form Values in teamMemberAddCall:",t);let s=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:l,member:t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},$=async(e,l,t)=>{try{console.log("Form Values in userUpdateUserCall:",l);let s={...l};null!==t&&(s.user_role=t),s=JSON.stringify(s);let r=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:s});if(!r.ok){let e=await r.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await r.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,l)=>{try{let t="/health/services?service=".concat(l);console.log("Checking Slack Budget Alerts service health");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed ".concat(l," service health check ")+e),Error(e)}let r=await s.json();return h.ZP.success("Test request to ".concat(l," made - check logs/alerts on ").concat(l," to verify")),r}catch(e){throw console.error("Failed to perform health check:",e),e}},Q=async e=>{try{let l=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async(e,l,t)=>{try{let l=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},el=async e=>{try{let l=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,l,t)=>{try{let s=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,field_value:t,config_type:"general_settings"})});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return h.ZP.success("Successfully updated value!"),r}catch(e){throw console.error("Failed to set callbacks:",e),e}},es=async(e,l)=>{try{let t=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,config_type:"general_settings"})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return h.ZP.success("Field reset on proxy"),s}catch(e){throw console.error("Failed to get callbacks:",e),e}},er=async(e,l)=>{try{let t=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},ea=async e=>{try{let l=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to call /health:",e),e}};var en=t(10384),eo=t(46453),ei=t(16450),ec=t(52273),ed=t(26780),em=t(15595),eh=t(6698),eu=t(71801),ex=t(42440),ep=t(42308),ej=t(50670),eg=t(81583),ey=t(99129),ef=t(44839),eZ=t(88707),e_=t(1861);let{Option:ew}=ej.default;var eb=e=>{let{userID:l,team:t,userRole:s,accessToken:r,data:o,setData:i}=e,[c]=eg.Z.useForm(),[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(null),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,_]=(0,n.useState)([]),w=()=>{m(!1),c.resetFields()},b=()=>{m(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==r){let e=(await P(r,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,s]);let k=async e=>{try{var t,s,a;let n=null!==(t=null==e?void 0:e.key_alias)&&void 0!==t?t:"",d=null!==(s=null==e?void 0:e.team_id)&&void 0!==s?s:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===d).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(n))throw Error("Key alias ".concat(n," already exists for team with ID ").concat(d,", please provide another key alias"));h.ZP.info("Making API Call"),m(!0);let u=await Z(r,l,e);console.log("key create Response:",u),i(e=>e?[...e,u]:[u]),x(u.key),j(u.soft_budget),h.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.useEffect)(()=>{_(t&&t.models.length>0?t.models.includes("all-proxy-models")?g:t.models:g)},[t,g]),(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(ey.Z,{title:"Create Key",visible:d,width:800,footer:null,onOk:w,onCancel:b,children:(0,a.jsxs)(eg.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:t?t.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t?t.team_alias:"",disabled:!0})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(ew,{value:"all-team-models",children:"All Team Models"},"all-team-models"),f.map(e=>(0,a.jsx)(ew,{value:e,children:e},e))]})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==t?void 0:t.max_budget)!==null&&(null==t?void 0:t.max_budget)!==void 0?null==t?void 0:t.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.max_budget&&l>t.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(t.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==t?void 0:t.budget_duration)!==null&&(null==t?void 0:t.budget_duration)!==void 0?null==t?void 0:t.budget_duration:"None"),children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==t?void 0:t.tpm_limit)!==null&&(null==t?void 0:t.tpm_limit)!==void 0?null==t?void 0:t.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.tpm_limit&&l>t.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(t.tpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==t?void 0:t.rpm_limit)!==null&&(null==t?void 0:t.rpm_limit)!==void 0?null==t?void 0:t.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.rpm_limit&&l>t.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(t.rpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Key"})})]})}),u&&(0,a.jsx)(ey.Z,{visible:d,onOk:w,onCancel:b,footer:null,children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Save your Key"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:null!=u?(0,a.jsxs)("div",{children:[(0,a.jsx)(eu.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:u})}),(0,a.jsx)(ep.CopyToClipboard,{text:u,onCopy:()=>{h.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(ei.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(eu.Z,{children:"Key being created, this might take 30s"})})]})})]})},ek=t(9454),ev=t(98941),eS=t(33393),eN=t(5),eA=t(13810),eE=t(61244),eI=t(10827),eC=t(3851),eT=t(2044),eP=t(64167),eF=t(74480),eO=t(7178),eR=t(95093),eM=t(27166);let{Option:eL}=ej.default;var eU=e=>{let{userID:l,userRole:t,accessToken:s,selectedTeam:r,data:o,setData:i,teams:c}=e,[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(!1),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(""),[k,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(!1),[A,E]=(0,n.useState)(null),[I,C]=(0,n.useState)([]),T=new Set,[F,O]=(0,n.useState)(T);(0,n.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==s&&null!==t){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),C(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[s,l,t]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,t)=>{let s=l.team_id;e.add(s)}),O(e)}},[c]);let R=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),E(e),v(!0)},M=async e=>{if(null==s)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let t=await W(s,e);console.log("handleEditSubmit: newKeyValues",t),o&&i(o.map(e=>e.token===l?t:e)),h.ZP.success("Key updated successfully"),v(!1),E(null)},L=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+l),x(!0))},U=async()=>{if(null!=p&&null!=o){try{await w(s,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(eI.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Key Alias"}),(0,a.jsx)(eF.Z,{children:"Secret Key"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(eC.Z,{children:o.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(r){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(F.has(e.team_id),", selectedTeam id: ").concat(r.team_id)),(null!=r.team_id||null===e.team_id||F.has(e.team_id))&&e.team_id!=r.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(eu.Z,{children:e.key_alias}):(0,a.jsx)(eu.Z,{children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:e.key_name})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(eT.Z,{children:null!=e.max_budget?(0,a.jsx)(eu.Z,{children:e.max_budget}):(0,a.jsx)(eu.Z,{children:"Unlimited"})}),(0,a.jsx)(eT.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:r&&r.models&&r.models.length>0?r.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{onClick:()=>{E(e),N(!0)},icon:ek.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:S,onCancel:()=>{N(!1),E(null)},footer:null,width:800,children:A&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(A.spend).toFixed(4)}catch(e){return A.spend}})()})})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.max_budget?(0,a.jsx)(a.Fragment,{children:A.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.expires?(0,a.jsx)(a.Fragment,{children:new Date(A.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(eA.Z,{className:"my-4",children:[(0,a.jsx)(ex.Z,{children:"Token Name"}),(0,a.jsx)(eu.Z,{className:"my-1",children:A.key_alias?A.key_alias:A.key_name}),(0,a.jsx)(ex.Z,{children:"Token ID"}),(0,a.jsx)(eu.Z,{className:"my-1 text-[12px]",children:A.token}),(0,a.jsx)(ex.Z,{children:"Metadata"}),(0,a.jsx)(eu.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(A.metadata)," "]})})]}),(0,a.jsx)(ei.Z,{className:"mx-auto flex items-center",onClick:()=>{N(!1),E(null)},children:"Close"})]})}),(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>R(e)}),(0,a.jsx)(eE.Z,{onClick:()=>L(e),icon:eS.Z,size:"sm"})]})]},e.token)})})]}),u&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{x(!1),j(null)},children:"Cancel"})]})]})]})})]}),A&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,token:s,onSubmit:o}=e,[i]=eg.Z.useForm(),[d,m]=(0,n.useState)(r),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1);return(0,a.jsx)(ey.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:i,onFinish:M,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let t=l.filter(e=>!d.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!d.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(t)),t.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(t,"Team models: ").concat(d.models)):Promise.resolve()}}],children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(eL,{value:"all-team-models",children:"All Team Models"},"all-team-models"),d&&d.models?d.models.includes("all-proxy-models")?I.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):d.models.map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):I.map(e=>(0,a.jsx)(eL,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==d?void 0:d.max_budget)!==null&&(null==d?void 0:d.max_budget)!==void 0?null==d?void 0:d.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&d&&null!==d.max_budget&&l>d.max_budget)throw console.log("keyTeam.max_budget: ".concat(d.max_budget)),Error("Budget cannot exceed team max budget: $".concat(d.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(eg.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(eR.Z,{value:s.team_alias,children:null==c?void 0:c.map((e,l)=>(0,a.jsx)(eM.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:k,onCancel:()=>{v(!1),E(null)},token:A,onSubmit:M})]})},eD=t(76032),eB=t(35152),ez=e=>{let{userID:l,userRole:t,accessToken:s,userSpend:r,selectedTeam:o}=e;console.log("userSpend: ".concat(r));let[i,c]=(0,n.useState)(null!==r?r:0),[d,m]=(0,n.useState)(0),[h,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(s&&l&&t&&"Admin"===t&&null==r)try{let e=await S(s);e&&(e.spend?c(e.spend):c(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(async()=>{try{if(null===l||null===t)return;if(null!==s){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),u(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,s,l]),(0,n.useEffect)(()=>{null!==r&&c(r)},[r]);let x=[];o&&o.models&&(x=o.models),x&&x.includes("all-proxy-models")?(console.log("user models:",h),x=h):x&&x.includes("all-team-models")?x=o.models:x&&0===x.length&&(x=h);let p=void 0!==i?i.toFixed(4):null;return console.log("spend in view user spend: ".concat(i)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:["Total Spend"," "]}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",p]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Team Models"})}),(0,a.jsx)(em.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(eD.Z,{children:x.map(e=>(0,a.jsx)(eB.Z,{children:(0,a.jsx)(eu.Z,{children:e})},e))})})]})})]})},eK=e=>{let{userID:l,userRole:t,selectedTeam:s,accessToken:r}=e,[o,i]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==r){let e=(await P(r,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),i(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,t]);let c=[];return s&&s.models&&(c=s.models),c&&c.includes("all-proxy-models")&&(console.log("user models:",o),c=o),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"mb-5",children:(0,a.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==s?void 0:s.team_alias})})})},eG=e=>{let l,{teams:t,setSelectedTeam:s,userRole:r}=e,o={models:[],team_id:null,team_alias:"Default Team"},[i,c]=(0,n.useState)(o);return(l="App User"===r?t:t?[...t,o]:[o],"App User"===r)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(ex.Z,{children:"Select Team"}),(0,a.jsx)(eu.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(eu.Z,{className:"mt-3 mb-3",children:[(0,a.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>s(e),children:e.team_alias},l))}):(0,a.jsxs)(eu.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},eq=t(37963),eV=t(97482);console.log("isLocal:",!1);var eW=e=>{let{userID:l,userRole:t,teams:s,keys:r,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,n.useState)(null),p=(0,o.useSearchParams)();p.get("viewSpend"),(0,o.useRouter)();let j=p.get("token"),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)([]),b={models:[],team_alias:"Default Team",team_id:null},[v,N]=(0,n.useState)(s?s[0]:b);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(j){let e=(0,eq.o)(j);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),i(l)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&g&&t&&!r&&!u){let e=sessionStorage.getItem("userModels"+l);e?w(JSON.parse(e)):(async()=>{try{let e=await k(g,l,t,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==t){let e=await S(g);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(e.teams);let s=[...e.teams];s.length>0?(console.log("response['teams']: ".concat(s)),N(s[0])):N(b),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let r=(await P(g,l,t)).data.map(e=>e.id);console.log("available_model_names:",r),w(r),console.log("userModels:",_),sessionStorage.setItem("userModels"+l,JSON.stringify(r))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,j,g,r,t]),(0,n.useEffect)(()=>{if(null!==r&&null!=v){let e=0;for(let l of r)v.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===v.team_id&&(e+=l.spend);Z(e)}else if(null!==r){let e=0;for(let l of r)e+=l.spend;Z(e)}},[v]),null==l||null==j){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==g)return null;if(null==t&&i("App Owner"),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",v),console.log("teamSpend: ".concat(f)),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eK,{userID:l,userRole:t,selectedTeam:v||null,accessToken:g}),(0,a.jsx)(ez,{userID:l,userRole:t,accessToken:g,userSpend:f,selectedTeam:v||null}),(0,a.jsx)(eU,{userID:l,userRole:t,accessToken:g,selectedTeam:v||null,data:r,setData:h,teams:s}),(0,a.jsx)(eb,{userID:l,team:v||null,userRole:t,accessToken:g,data:r,setData:h},v?v.team_id:null),(0,a.jsx)(eG,{teams:s,setSelectedTeam:N,userRole:t})]})})})},eH=t(35087),eY=t(92836),eJ=t(26734),e$=t(41608),eX=t(32126),eQ=t(23682),e0=t(47047),e1=t(76628),e2=t(25707),e4=t(44041),e5=t(38302),e8=t(28683),e3=t(1460),e6=t(78578),e7=t(63954),e9=t(90252),le=t(7905),ll=e=>{let{modelID:l,accessToken:t}=e,[s,r]=(0,n.useState)(!1),o=async()=>{try{h.ZP.info("Making API Call"),r(!0);let e=await j(t,l);console.log("model delete Response:",e),h.ZP.success("Model ".concat(l," deleted successfully")),r(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(eE.Z,{onClick:()=>r(!0),icon:eS.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:s,onOk:o,okType:"danger",onCancel:()=>r(!1),children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Delete Model"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},lt=t(97766),ls=t(46495),lr=t(18190),la=t(91118),ln=e=>{let{modelMetrics:l,modelMetricsCategories:t,customTooltip:s,premiumUser:r}=e;return r?(0,a.jsx)(la.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:t,colors:["indigo","rose"],connectNulls:!0,customTooltip:s}):(0,a.jsxs)("div",{children:[(0,a.jsx)(lr.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,a.jsx)(ei.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},lo=e=>{let{fields:l,selectedProvider:t}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,a.jsx)(ec.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})};let{Title:li,Link:lc}=eV.default;(s=r||(r={})).OpenAI="OpenAI",s.Azure="Azure",s.Anthropic="Anthropic",s.Google_AI_Studio="Google AI Studio",s.Bedrock="Amazon Bedrock",s.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",s.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",s.Databricks="Databricks";let ld={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},lm={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},lh=async(e,l,t)=>{try{let s=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(s)),console.log("received type of deployments: ".concat(typeof s)),s.forEach(async t=>{console.log("litellm_model: ".concat(t));let s={},r={};s.model=t;let a="";for(let[l,t]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==t){if("model_name"==l)a+=t;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)r[l]=t;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",t);let e={};if(t&&void 0!=t){try{e=JSON.parse(t)}catch(e){throw h.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,t]of Object.entries(e))s[l]=t}}else s[l]=t}let n={model_name:a,litellm_params:s,model_info:r},o=await x(l,n);console.log("response for model create call: ".concat(o.data))}),t.resetFields()}catch(e){h.ZP.error("Failed to create model: "+e,10)}};var lu=e=>{var l,t,s;let o,{accessToken:i,token:c,userRole:d,userID:m,modelData:x={data:[]},setModelData:j,premiumUser:g}=e,[y,f]=(0,n.useState)([]),[Z]=eg.Z.useForm(),[_,w]=(0,n.useState)(null),[b,k]=(0,n.useState)(""),[v,S]=(0,n.useState)([]),A=Object.values(r).filter(e=>isNaN(Number(e))),[P,F]=(0,n.useState)([]),[O,R]=(0,n.useState)("OpenAI"),[M,L]=(0,n.useState)(""),[U,D]=(0,n.useState)(!1),[B,z]=(0,n.useState)(null),[K,G]=(0,n.useState)([]),[q,V]=(0,n.useState)(null),[W,H]=(0,n.useState)([]),[J,$]=(0,n.useState)([]),[X,Q]=(0,n.useState)([]),[el,et]=(0,n.useState)([]),[es,en]=(0,n.useState)([]),[ep,ej]=(0,n.useState)([]),[ef,ew]=(0,n.useState)([]),[eb,ek]=(0,n.useState)([]),[eS,eL]=(0,n.useState)([]),[eU,eD]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eB,ez]=(0,n.useState)(null),[eK,eG]=(0,n.useState)(0),eq=e=>{z(e),D(!0)},eW=async e=>{if(console.log("handleEditSubmit:",e),null==i)return;let l={},t=null;for(let[s,r]of Object.entries(e))"model_id"!==s?l[s]=r:t=r;let s={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",s);try{await Y(i,s),h.ZP.success("Model updated successfully, restart server to see updates"),D(!1),z(null)}catch(e){console.log("Error occurred")}},lr=()=>{k(new Date().toLocaleString())},la=async()=>{if(!i){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eB);try{await er(i,{router_settings:{model_group_retry_policy:eB}}),h.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),h.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!i||!c||!d||!m)return;let e=async()=>{try{var e,l,t,s,r,a,n,o;let c=await p(i);F(c);let h=await N(i,m,d);console.log("Model data response:",h.data),j(h);let u=new Set;for(let e=0;e0&&(g=x[x.length-1],console.log("_initial_model_group:",g),V(g)),console.log("selectedModelGroup:",q);let y=await E(i,m,d,g,null===(e=eU.from)||void 0===e?void 0:e.toISOString(),null===(l=eU.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",y),$(y.data),Q(y.all_api_bases);let f=await I(i,g,null===(t=eU.from)||void 0===t?void 0:t.toISOString(),null===(s=eU.to)||void 0===s?void 0:s.toISOString());et(f.data),en(f.all_api_bases);let Z=await T(i,m,d,g,null===(r=eU.from)||void 0===r?void 0:r.toISOString(),null===(a=eU.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",Z),ej(Z.data),ew(Z.exception_types);let _=await C(i,m,d,g,null===(n=eU.from)||void 0===n?void 0:n.toISOString(),null===(o=eU.to)||void 0===o?void 0:o.toISOString());console.log("slowResponses:",_),eL(_);let w=(await ee(i,m,d)).router_settings;console.log("routerSettingsInfo:",w);let b=w.model_group_retry_policy,k=w.num_retries;console.log("model_group_retry_policy:",b),console.log("default_retries:",k),ez(b),eG(k)}catch(e){console.error("There was an error fetching the model data",e)}};i&&c&&d&&m&&e();let l=async()=>{let e=await u();console.log("received model cost map data: ".concat(Object.keys(e))),w(e)};null==_&&l(),lr()},[i,c,d,m,_,b]),!x||!i||!c||!d||!m)return(0,a.jsx)("div",{children:"Loading..."});let lu=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(_)),null!=_&&"object"==typeof _&&e in _)?_[e].litellm_provider:"openai";if(r){let e=r.split("/"),l=e[0];n=1===e.length?h(r):l}else n="openai";a&&(o=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,c=null==a?void 0:a.max_tokens,d=null==a?void 0:a.max_input_tokens),(null==s?void 0:s.litellm_params)&&(m=Object.fromEntries(Object.entries(null==s?void 0:s.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),x.data[e].provider=n,x.data[e].input_cost=o,x.data[e].output_cost=i,x.data[e].input_cost&&(x.data[e].input_cost=(1e6*Number(x.data[e].input_cost)).toFixed(2)),x.data[e].output_cost&&(x.data[e].output_cost=(1e6*Number(x.data[e].output_cost)).toFixed(2)),x.data[e].max_tokens=c,x.data[e].max_input_tokens=d,x.data[e].api_base=null==s?void 0:null===(t=s.litellm_params)||void 0===t?void 0:t.api_base,x.data[e].cleanedLitellmParams=m,lu.push(s.model_name),console.log(x.data[e])}if(d&&"Admin Viewer"==d){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lx=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(r).find(l=>r[l]===e);if(l){let e=ld[l];console.log("mappingResult: ".concat(e));let t=[];"object"==typeof _&&Object.entries(_).forEach(l=>{let[s,r]=l;null!==r&&"object"==typeof r&&"litellm_provider"in r&&(r.litellm_provider===e||r.litellm_provider.includes(e))&&t.push(s)}),S(t),console.log("providerModels: ".concat(v))}},lp=async()=>{try{h.ZP.info("Running health check..."),L("");let e=await ea(i);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lj=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),i&&m&&d&&l&&t){console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),V(e);try{let s=await E(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model metrics response:",s),$(s.data),Q(s.all_api_bases);let r=await I(i,e,l.toISOString(),t.toISOString());et(r.data),en(r.all_api_bases);let a=await T(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model exceptions response:",a),ej(a.data),ew(a.exception_types);let n=await C(i,m,d,e,l.toISOString(),t.toISOString());console.log("slowResponses:",n),eL(n)}catch(e){console.error("Failed to fetch model metrics",e)}}},lg=e=>{var l,t;let{payload:s,active:r}=e;if(!r||!s)return null;let n=null===(t=s[0])||void 0===t?void 0:null===(l=t.payload)||void 0===l?void 0:l.date,o=s.sort((e,l)=>l.value-e.value);if(o.length>5){let e=o.length-5;(o=o.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:s.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,a.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[n&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),o.map((e,l)=>{let t=parseFloat(e.value.toFixed(5)),s=0===t&&e.value>0?"<0.00001":t.toFixed(5);return(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:s})]},l)})]})};console.log("selectedProvider: ".concat(O)),console.log("providerModels.length: ".concat(v.length));let ly=Object.keys(r).find(e=>r[e]===O);return ly&&(o=P.find(e=>e.name===ld[ly])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eY.Z,{children:"All Models"}),(0,a.jsx)(eY.Z,{children:"Add Model"}),(0,a.jsx)(eY.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eY.Z,{children:"Model Analytics"}),(0,a.jsx)(eY.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[b&&(0,a.jsxs)(eu.Z,{children:["Last Refreshed: ",b]}),(0,a.jsx)(eE.Z,{icon:e7.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lr})]})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],onValueChange:e=>V("all"===e?"all":e),value:q||K[0],children:[(0,a.jsx)(eM.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))]})]}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"Public Model Name"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:"Provider"}),"Admin"===d&&(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"API Base"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:"Extra litellm Params"}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(eF.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:"Max Tokens"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word"},children:"Status"})]})}),(0,a.jsx)(eC.Z,{children:x.data.filter(e=>"all"===q||e.model_name===q||null==q||""===q).map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{children:e.model_name})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.provider}),"Admin"===d&&(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:e.api_base}),(0,a.jsx)(eT.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Litellm params"})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)("pre",{children:JSON.stringify(e.cleanedLitellmParams,null,2)})})]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.input_cost||e.litellm_params.input_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.output_cost||e.litellm_params.output_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)("p",{style:{fontSize:"10px"},children:["Max Tokens: ",e.max_tokens," ",(0,a.jsx)("br",{}),"Max Input Tokens: ",e.max_input_tokens]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(eN.Z,{icon:e9.Z,size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(eN.Z,{icon:le.Z,size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsxs)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>eq(e)}),(0,a.jsx)(ll,{modelID:e.model_info.id,accessToken:i})]})]},l))})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:t,model:s,onSubmit:r}=e,[n]=eg.Z.useForm(),o={},i="",c="";if(s){o=s.litellm_params,i=s.model_name;let e=s.model_info;e&&(c=e.id,console.log("model_id: ".concat(c)),o.model_id=c)}return(0,a.jsx)(ey.Z,{title:"Edit Model "+i,visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r(e),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:eW,initialValues:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:U,onCancel:()=>{D(!1),z(null)},model:B,onSubmit:eW})]}),(0,a.jsxs)(eX.Z,{className:"h-full",children:[(0,a.jsx)(li,{level:2,children:"Add new model"}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eg.Z,{form:Z,onFinish:()=>{Z.validateFields().then(e=>{lh(e,i,Z)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:O.toString(),children:A.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>{lx(e),R(e)},children:e},l))})}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(s=O.toString())?"gemini-pro":"Anthropic"==s?"claude-3-opus":"Amazon Bedrock"==s?"claude-3-opus":"Google AI Studio"==s?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===O?(0,a.jsx)(ec.Z,{placeholder:"Enter model name"}):v.length>0?(0,a.jsx)(e0.Z,{value:v,children:v.map((e,l)=>(0,a.jsx)(e1.Z,{value:e,children:e},l))}):(0,a.jsx)(ec.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==o&&o.fields.length>0&&(0,a.jsx)(lo,{fields:o.fields,selectedProvider:o.name}),"Amazon Bedrock"!=O&&"Vertex AI (Anthropic, Gemini, etc.)"!=O&&void 0===o&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(ec.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==O&&(0,a.jsx)(eg.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(ec.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(ec.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ls.Z,{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;Z.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?h.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&h.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(e_.ZP,{icon:(0,a.jsx)(lt.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==O||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==O)&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(ec.Z,{placeholder:"https://..."})}),"Azure"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(ec.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==O&&(0,a.jsxs)("div",{children:[(0,a.jsx)(eg.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(lc,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(eg.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,a.jsx)(e6.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(e3.Z,{title:"Get help on our github",children:(0,a.jsx)(eV.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(ei.Z,{onClick:lp,children:"Run `/health`"}),M&&(0,a.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:eU,onValueChange:e=>{eD(e),lj(q,e.from,e.to)}})]}),(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Model Group"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2",defaultValue:q||K[0],value:q||K[0],children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>lj(e,eU.from,eU.to),children:e},l))})]})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eY.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(eu.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),J&&X&&(0,a.jsx)(e2.Z,{title:"Model Latency",className:"h-72",data:J,showLegend:!1,index:"date",categories:X,connectNulls:!0,customTooltip:lg})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(ln,{modelMetrics:el,modelMetricsCategories:es,customTooltip:lg,premiumUser:g})})]})]})})}),(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Deployment"}),(0,a.jsx)(eF.Z,{children:"Success Responses"}),(0,a.jsxs)(eF.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(eC.Z,{children:eS.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.api_base}),(0,a.jsx)(eT.Z,{children:e.total_count}),(0,a.jsx)(eT.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(eA.Z,{className:"mt-4",children:[(0,a.jsx)(ex.Z,{children:"Exceptions per Model"}),(0,a.jsx)(e4.Z,{className:"h-72",data:ep,index:"model",categories:ef,stack:!0,colors:["indigo-300","rose-200","#ffcc33"],yAxisWidth:30})]})]}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],value:q||K[0],onValueChange:e=>V(e),children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))})]}),(0,a.jsxs)(ex.Z,{children:["Retry Policy for ",q]}),(0,a.jsx)(eu.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),lm&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(lm).map((e,l)=>{var t;let[s,r]=e,n=null==eB?void 0:null===(t=eB[q])||void 0===t?void 0:t[r];return null==n&&(n=eK),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)("td",{children:(0,a.jsx)(eZ.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{ez(l=>{var t;let s=null!==(t=null==l?void 0:l[q])&&void 0!==t?t:{};return{...null!=l?l:{},[q]:{...s,[r]:e}}})}})})]},l)})})}),(0,a.jsx)(ei.Z,{className:"mt-6 mr-8",onClick:la,children:"Save"})]})]})]})})};let{Option:lx}=ej.default;var lp=e=>{let{userID:l,accessToken:t,teams:s}=e,[r]=eg.Z.useForm(),[o,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[m,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{let e=await P(t,l,"any"),s=[];for(let l=0;l{i(!1),r.resetFields()},p=()=>{i(!1),d(null),r.resetFields()},j=async e=>{try{h.ZP.info("Making API Call"),i(!0),console.log("formValues in create user:",e);let s=await _(t,null,e);console.log("user create Response:",s),d(s.key),h.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-0",onClick:()=>i(!0),children:"+ Invite User"}),(0,a.jsxs)(ey.Z,{title:"Invite User",visible:o,width:800,footer:null,onOk:x,onCancel:p,children:[(0,a.jsx)(eu.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(eu.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(eg.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(eg.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(ej.default,{placeholder:"Select Team ID",style:{width:"100%"},children:s?s.map(e=>(0,a.jsx)(lx,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(lx,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create User"})})]})]}),c&&(0,a.jsxs)(ey.Z,{title:"User Created Successfully",visible:o,onOk:x,onCancel:p,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},lj=e=>{let{accessToken:l,token:t,keys:s,userRole:r,userID:o,teams:i,setKeys:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(0),[j,g]=n.useState(null),[y,f]=(0,n.useState)(null);return((0,n.useEffect)(()=>{if(!l||!t||!r||!o)return;let e=async()=>{try{let e=await k(l,null,r,!0,x,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&r&&o&&e()},[l,t,r,o,x]),d&&l&&t&&r&&o)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(eo.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(lp,{userID:o,accessToken:l,teams:i}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(eu.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(eJ.Z,{children:(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"User ID"}),(0,a.jsx)(eF.Z,{children:"User Email"}),(0,a.jsx)(eF.Z,{children:"User Models"}),(0,a.jsx)(eF.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User API Key Aliases"})]})}),(0,a.jsx)(eC.Z,{children:d.map(e=>{var l;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_id}),(0,a.jsx)(eT.Z,{children:e.user_email}),(0,a.jsx)(eT.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(eT.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eo.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsx)(eN.Z,{size:"xs",color:"indigo",children:e.key_aliases.filter(e=>null!==e).join(", ")}):(0,a.jsx)(eN.Z,{size:"xs",color:"gray",children:"No Keys"})})})]},e.user_id)})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})})]}),function(){if(!d)return null;let e=Math.ceil(d.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",x+1," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:0===x,onClick:()=>p(x-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",onClick:()=>{p(x+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},lg=e=>{let{teams:l,searchParams:t,accessToken:s,setTeams:r,userID:o,userRole:i}=e,[c]=eg.Z.useForm(),[d]=eg.Z.useForm(),{Title:m,Paragraph:u}=eV.default,[x,p]=(0,n.useState)(""),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(l?l[0]:null),[Z,_]=(0,n.useState)(!1),[w,k]=(0,n.useState)(!1),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)(!1),[I,C]=(0,n.useState)(null),[T,F]=(0,n.useState)({}),O=e=>{f(e),g(!0)},R=async e=>{let t=e.team_id;if(console.log("handleEditSubmit:",e),null==s)return;let a=await H(s,e);l&&r(l.map(e=>e.team_id===t?a.data:e)),h.ZP.success("Team updated successfully"),g(!1),f(null)},M=async e=>{C(e),E(!0)},L=async()=>{if(null!=I&&null!=l&&null!=s){try{await b(s,I);let e=l.filter(e=>e.team_id!==I);r(e)}catch(e){console.error("Error deleting the team:",e)}E(!1),C(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{if(null===o||null===i||null===s||null===l)return;console.log("fetching team info:");let e={};for(let t=0;t<(null==l?void 0:l.length);t++){let r=l[t].team_id,a=await v(s,r);console.log("teamInfo response:",a),null!==a&&(e={...e,[r]:a})}F(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===o||null===i)return;if(null!==s){let e=(await P(s,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,o,i,l]);let U=async e=>{try{if(null!=s){var t;let a=null==e?void 0:e.team_alias;if((null!==(t=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==t?t:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));h.ZP.info("Creating Team");let n=await V(s,e);null!==l?r([...l,n]):r([n]),console.log("response for team create call: ".concat(n)),h.ZP.success("Team created"),_(!1)}}catch(e){console.error("Error creating the team:",e),h.ZP.error("Error creating the team: "+e,20)}},D=async e=>{try{if(null!=s&&null!=l){h.ZP.info("Adding Member");let t={role:"user",user_email:e.user_email,user_id:e.user_id},a=await J(s,y.team_id,t);console.log("response for team create call: ".concat(a.data));let n=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(n)),-1!==n){let e=[...l];e[n]=a.data,r(e),f(a.data)}k(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Team Name"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(eF.Z,{children:"Info"})]})}),(0,a.jsx)(eC.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(eT.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].keys&&T[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].team_info&&T[e.team_id].team_info.members_with_roles&&T[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>O(e)}),(0,a.jsx)(eE.Z,{onClick:()=>M(e.team_id),icon:eS.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{E(!1),C(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>_(!0),children:"+ Create New Team"}),(0,a.jsx)(ey.Z,{title:"Create Team",visible:Z,width:800,footer:null,onOk:()=>{_(!1),c.resetFields()},onCancel:()=>{_(!1),c.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:U,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{f(e)},children:e.team_alias},l))}):(0,a.jsxs)(u,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:y?y.members_with_roles.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.role})]},l)):null})]})}),y&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,team:s,onSubmit:r}=e,[n]=eg.Z.useForm();return(0,a.jsx)(ey.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:s.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:R,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:j,onCancel:()=>{g(!1),f(null)},team:y,onSubmit:R})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-5",onClick:()=>k(!0),children:"+ Add member"}),(0,a.jsx)(ey.Z,{title:"Add member",visible:w,width:800,footer:null,onOk:()=>{k(!1),d.resetFields()},onCancel:()=>{k(!1),d.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:D,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},ly=e=>{let l,{searchParams:t,accessToken:s,showSSOBanner:r}=e,[o]=eg.Z.useForm(),[i]=eg.Z.useForm(),{Title:c,Paragraph:d}=eV.default,[m,u]=(0,n.useState)(""),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(!1),[Z,_]=(0,n.useState)(!1),[w,b]=(0,n.useState)(!1),[k,v]=(0,n.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let S=()=>{v(!1)},N=["proxy_admin","proxy_admin_viewer"];(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await q(s,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let t=await q(s,"proxy_admin");t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(t)),console.log("combinedList: ".concat(e)),p(e)}})()},[s]);let A=()=>{_(!1),i.resetFields()},E=()=>{_(!1),i.resetFields()},I=e=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]}),C=(e,l,t)=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:l,children:N.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:t,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update role"})})]}),T=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,null);console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),h.ZP.success("Refresh tab to see updated user role"),_(!1)}}catch(e){console.error("Error creating the key:",e)}},P=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),g(!1)}}catch(e){console.error("Error creating the key:",e)}},F=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await $(s,e,"proxy_admin");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),f(!1)}}catch(e){console.error("Error creating the key:",e)}},O=async e=>{null!=s&&er(s,{environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}})};return console.log("admins: ".concat(null==x?void 0:x.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(c,{level:4,children:"Admin Access "}),(0,a.jsxs)(d,{children:[r&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc. ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:x?x.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.user_role}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>_(!0)}),(0,a.jsx)(ey.Z,{title:"Update role",visible:Z,width:800,footer:null,onOk:A,onCancel:E,children:C(T,e.user_role,e.user_id)})]})]},l)):null})]})})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(ei.Z,{className:"mr-4 mb-5",onClick:()=>f(!0),children:"+ Add admin"}),(0,a.jsx)(ey.Z,{title:"Add admin",visible:y,width:800,footer:null,onOk:()=>{f(!1),i.resetFields()},onCancel:()=>{f(!1),i.resetFields()},children:I(F)}),(0,a.jsx)(ei.Z,{className:"mb-5",onClick:()=>g(!0),children:"+ Add viewer"}),(0,a.jsx)(ey.Z,{title:"Add viewer",visible:j,width:800,footer:null,onOk:()=>{g(!1),i.resetFields()},onCancel:()=>{g(!1),i.resetFields()},children:I(P)})]})})]}),(0,a.jsxs)(eo.Z,{children:[(0,a.jsx)(c,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(ei.Z,{onClick:()=>b(!0),children:"Add SSO"}),(0,a.jsx)(ey.Z,{title:"Add SSO",visible:w,width:800,footer:null,onOk:()=>{b(!1),o.resetFields()},onCancel:()=>{b(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{F(e),O(e),b(!1),v(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(ef.Z.Password,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(ef.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(ey.Z,{title:"SSO Setup Instructions",visible:k,width:800,footer:null,onOk:S,onCancel:()=>{v(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{onClick:S,children:"Done"})})]})]}),(0,a.jsxs)(lr.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},lf=t(42556),lZ=e=>{let{alertingSettings:l,handleInputChange:t,handleResetField:s,handleSubmit:r,premiumUser:n}=e,[o]=eg.Z.useForm();return(0,a.jsxs)(eg.Z,{form:o,onFinish:()=>{let e=o.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):r(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{align:"center",children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?n?(0,a.jsx)(eg.Z.Item,{name:e.field_name,children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l)}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}):(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(eg.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l),className:"p-0"}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>s(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update Settings"})})]})},l_=e=>{let{accessToken:l,premiumUser:t}=e,[s,r]=(0,n.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,n.useEffect)(()=>{l&&f(l).then(e=>{r(e)})},[l]),(0,a.jsx)(lZ,{alertingSettings:s,handleInputChange:(e,l)=>{r(s.map(t=>t.field_name===e?{...t,field_value:l}:t))},handleResetField:(e,t)=>{if(l)try{let l=s.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),r(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let t={};s.forEach(e=>{t[e.field_name]=e.field_value});let r={...e,...t};try{et(l,"alerting_args",r),h.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:t})};let lw=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var lb=e=>{let{accessToken:l,userRole:t,userID:s,premiumUser:r}=e,[o,i]=(0,n.useState)(lw),[c,d]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[x]=eg.Z.useForm(),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,Z]=(0,n.useState)(""),[_,w]=(0,n.useState)({}),[b,k]=(0,n.useState)([]),v=e=>{b.includes(e)?k(b.filter(l=>l!==e)):k([...b,e])},S={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,n.useEffect)(()=>{l&&t&&s&&ee(l,s,t).then(e=>{console.log("callbacks",e);let l=lw;i(l=l.map(l=>{let t=e.callbacks.find(e=>e.name===l.name);return t?{...l,variables:{...l.variables,...t.variables}}:l}));let t=e.alerts;if(console.log("alerts_data",t),t&&t.length>0){let e=t[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),k(e.active_alerts),Z(l),w(e.alerts_to_webhook)}d(t)})},[l,t,s]);let N=e=>b&&b.includes(e),A=e=>{if(!l)return;let t=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[t,s]=e;return[t,(null===(l=document.querySelector('input[name="'.concat(t,'"]')))||void 0===l?void 0:l.value)||s]}));console.log("updatedVariables",t),console.log("updateAlertTypes",g);let s={environment_variables:t,litellm_settings:{success_callback:[e.name]}};try{er(l,s)}catch(e){h.ZP.error("Failed to update callback: "+e,20)}h.ZP.success("Callback updated successfully")},E=()=>{l&&x.validateFields().then(e=>{if(console.log("Form values:",e),"langfuse"===e.callback){er(l,{environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),er(l,{general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}}),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),er(l,{environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};i(o?[...o,t]:[t])}u(!1),x.resetFields(),j(null)})};return l?(console.log("callbacks: ".concat(o)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(lr.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Settings"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Callback"}),(0,a.jsx)(eF.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(eC.Z,{children:o.filter(e=>"slack"!==e.name).map((e,t)=>{var s;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eN.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).filter(l=>{let[t,s]=l;return t.toLowerCase().includes(e.name)}).map(e=>{let[l,t]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(eu.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(ec.Z,{name:l,defaultValue:t,type:"password"})]},l)})}),(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(e),children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,e.name),className:"mx-2",children:"Test Callback"})]})]},t)})})]})})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eu.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(S).map((e,l)=>{let[t,s]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:"region_outage_alerts"==t?r?(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)}):(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:t,type:"password",defaultValue:_&&_[t]?_[t]:f})})]},l)})})]}),(0,a.jsx)(ei.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(S).forEach(l=>{let[t,s]=l,r=document.querySelector('input[name="'.concat(t,'"]'));console.log("key",t),console.log("webhookInput",r);let a=(null==r?void 0:r.value)||"";console.log("newWebhookValue",a),e[t]=a}),console.log("updatedAlertToWebhooks",e);let t={general_settings:{alert_to_webhook_url:e,alert_types:b}};console.log("payload",t);try{er(l,t)}catch(e){h.ZP.error("Failed to update alerts: "+e,20)}h.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(l_,{accessToken:l,premiumUser:r})})]})]})]}),(0,a.jsx)(ey.Z,{title:"Add Callback",visible:m,onOk:E,width:800,onCancel:()=>{u(!1),x.resetFields(),j(null)},footer:null,children:(0,a.jsxs)(eg.Z,{form:x,layout:"vertical",onFinish:E,children:[(0,a.jsx)(eg.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(ej.default,{onChange:e=>{j(e)},children:[(0,a.jsx)(ej.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(ej.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(ec.Z,{type:"password"})}),(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})]}),"openmeter"==p&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eg.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:lk}=ej.default;var lv=e=>{let{models:l,accessToken:t,routerSettings:s,setRouterSettings:r}=e,[o]=eg.Z.useForm(),[i,c]=(0,n.useState)(!1),[d,m]=(0,n.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>c(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(ey.Z,{title:"Add Fallbacks",visible:i,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,n=[...s.fallbacks||[],{[l]:a}],i={...s,fallbacks:n};console.log(i);try{er(t,{router_settings:i}),r(i)}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully"),c(!1),o.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(eR.Z,{defaultValue:d,children:l&&l.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(e0.Z,{value:l,children:l&&l.filter(e=>e!=d).map(e=>(0,a.jsx)(e1.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lS=t(12968);async function lN(e,l){console.log("isLocal:",!1);let t=window.location.origin,s=new lS.ZP.OpenAI({apiKey:l,baseURL:t,dangerouslyAllowBrowser:!0});try{let l=await s.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});h.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lA={ttl:3600,lowest_latency_buffer:0},lE=e=>{let{selectedStrategy:l,strategyArgs:t,paramExplanation:s}=e;return(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(em.Z,{children:"latency-based-routing"==l?(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(t).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:s[l]})]}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]})}):(0,a.jsx)(eu.Z,{children:"No specific settings"})})]})};var lI=e=>{let{accessToken:l,userRole:t,userID:s,modelData:r}=e,[o,i]=(0,n.useState)({}),[c,d]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1),[j]=eg.Z.useForm(),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)(null),b={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,n.useEffect)(()=>{l&&t&&s&&(ee(l,s,t).then(e=>{console.log("callbacks",e),i(e.router_settings)}),el(l).then(e=>{u(e)}))},[l,t,s]);let k=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(o.fallbacks)),o.fallbacks.map(l=>(e in l&&delete l[e],l));try{await er(l,{router_settings:o}),i({...o}),Z(o.routing_strategy),h.ZP.success("Router settings updated successfully")}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}}},v=(e,l)=>{u(m.map(t=>t.field_name===e?{...t,field_value:l}:t))},S=(e,t)=>{if(!l)return;let s=m[t].field_value;if(null!=s&&void 0!=s)try{et(l,e,s);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(t)}catch(e){}},N=(e,t)=>{if(l)try{es(l,e);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(t)}catch(e){}},A=e=>{if(!l)return;console.log("router_settings",e);let t=Object.fromEntries(Object.entries(e).map(e=>{let[l,t]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var s;return[l,(null===(s=document.querySelector('input[name="'.concat(l,'"]')))||void 0===s?void 0:s.value)||t]}if("routing_strategy"==l)return[l,f];if("routing_strategy_args"==l&&"latency-based-routing"==f){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),t=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==t?void 0:t.value)&&(e.ttl=Number(t.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",t);try{er(l,{router_settings:t})}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eY.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eY.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(ex.Z,{children:"Router Settings"}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(o).filter(e=>{let[l,t]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:b[l]})]}),(0,a.jsx)(eT.Z,{children:"routing_strategy"==l?(0,a.jsxs)(eR.Z,{defaultValue:t,className:"w-full max-w-md",onValueChange:Z,children:[(0,a.jsx)(eM.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(eM.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(eM.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]}),(0,a.jsx)(lE,{selectedStrategy:f,strategyArgs:o&&o.routing_strategy_args&&Object.keys(o.routing_strategy_args).length>0?o.routing_strategy_args:lA,paramExplanation:b})]}),(0,a.jsx)(en.Z,{children:(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(o),children:"Save Changes"})})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Model Name"}),(0,a.jsx)(eF.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(eC.Z,{children:o.fallbacks&&o.fallbacks.map((e,t)=>Object.entries(e).map(e=>{let[s,r]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:s}),(0,a.jsx)(eT.Z,{children:Array.isArray(r)?r.join(", "):r}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{onClick:()=>lN(s,l),children:"Test Fallback"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>k(s)})})]},t.toString()+s)}))})]}),(0,a.jsx)(lv,{models:(null==r?void 0:r.data)?r.data.map(e=>e.model_name):[],accessToken:l,routerSettings:o,setRouterSettings:i})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"}),(0,a.jsx)(eF.Z,{children:"Status"}),(0,a.jsx)(eF.Z,{children:"Action"})]})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(eT.Z,{children:"Integer"==e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>v(e.field_name,l)}):null}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(ei.Z,{onClick:()=>S(e.field_name,l),children:"Update"}),(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>N(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lC=e=>{let{isModalVisible:l,accessToken:t,setIsModalVisible:s,setBudgetList:r}=e,[n]=eg.Z.useForm(),o=async e=>{if(null!=t&&void 0!=t)try{h.ZP.info("Making API Call");let l=await y(t,e);console.log("key create Response:",l),r(e=>e?[...e,l]:[l]),h.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(ey.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{s(!1),n.resetFields()},onCancel:()=>{s(!1),n.resetFields()},children:(0,a.jsxs)(eg.Z,{form:n,onFinish:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lT=t(67951),lP=e=>{let{accessToken:l}=e,[t,s]=(0,n.useState)(!1),[r,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&Q(l).then(e=>{o(e)})},[l]);let i=async(e,t)=>{if(null==l)return;h.ZP.info("Request made"),await g(l,e);let s=[...r];s.splice(t,1),o(s),h.ZP.success("Budget Deleted.")};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(ei.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>s(!0),children:"+ Create Budget"}),(0,a.jsx)(lC,{accessToken:l,isModalVisible:t,setIsModalVisible:s,setBudgetList:o}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Budget ID"}),(0,a.jsx)(eF.Z,{children:"Max Budget"}),(0,a.jsx)(eF.Z,{children:"TPM"}),(0,a.jsx)(eF.Z,{children:"RPM"})]})}),(0,a.jsx)(eC.Z,{children:r.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.budget_id}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(eT.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(eT.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>i(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(eu.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eY.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eY.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{var l;let{userID:t,userRole:s,token:r,accessToken:o,keys:i,premiumUser:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);(0,n.useEffect)(()=>{o&&r&&s&&t&&(async()=>{try{let e=await A(o,t,s);console.log("ModelHubData:",e),m(e.data)}catch(e){console.error("There was an error fetching the model data",e)}})()},[o,r,s,t]);let j=e=>{p(e),u(!0)},g=e=>{navigator.clipboard.writeText(e)};return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)("div",{className:"relative w-full"}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(ex.Z,{className:"ml-8 text-center ",children:"Model Hub"}),(0,a.jsx)(ei.Z,{className:"ml-4",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4",children:d&&d.map(e=>(0,a.jsxs)(eA.Z,{className:"mt-5 mx-8",children:[(0,a.jsxs)("pre",{className:"flex justify-between",children:[(0,a.jsx)(ex.Z,{children:e.model_group}),(0,a.jsx)(e3.Z,{title:e.model_group,children:(0,a.jsx)(lF.Z,{onClick:()=>g(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,a.jsxs)("div",{className:"my-5",children:[(0,a.jsxs)(eu.Z,{children:["Mode: ",e.mode]}),(0,a.jsxs)(eu.Z,{children:["Supports Function Calling: ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Supports Vision: ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Max Input Tokens: ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,a.jsxs)(eu.Z,{children:["Max Output Tokens: ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,a.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,a.jsxs)("a",{href:"#",onClick:()=>j(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,a.jsx)(lO.Z,{})]})})]},e.model_group))})]}),(0,a.jsx)(ey.Z,{title:x&&x.model_group?x.model_group:"Unknown Model",width:800,visible:h,footer:null,onOk:()=>{u(!1),p(null)},onCancel:()=>{u(!1),p(null)},children:x&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-4",children:(0,a.jsx)("strong",{children:"Model Information & Usage"})}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"Supported OpenAI Params"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(x.model_group,'", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,a.jsx)(eX.Z,{children:null==x?void 0:null===(l=x.supported_openai_params)||void 0===l?void 0:l.map(e=>(0,a.jsx)("pre",{children:e},e))}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="'.concat(x.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "'.concat(x.model_group,'",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})]})},lM=e=>{let{}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(eu.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n '})})]})]})]})})})};async function lL(e,l,t,s){console.log("isLocal:",!1);let r=window.location.origin,a=new lS.ZP.OpenAI({apiKey:s,baseURL:r,dangerouslyAllowBrowser:!0});try{for await(let s of(await a.chat.completions.create({model:t,stream:!0,messages:[{role:"user",content:e}]})))console.log(s),s.choices[0].delta.content&&l(s.choices[0].delta.content)}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lU=e=>{let{accessToken:l,token:t,userRole:s,userID:r}=e,[o,i]=(0,n.useState)(""),[c,d]=(0,n.useState)(""),[m,h]=(0,n.useState)([]),[u,x]=(0,n.useState)(void 0),[p,j]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{let e=await P(l,r,s);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));console.log(l),j(l),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,r,s]);let g=(e,l)=>{h(t=>{let s=t[t.length-1];return s&&s.role===e?[...t.slice(0,t.length-1),{role:e,content:s.content+l}]:[...t,{role:e,content:l}]})},y=async()=>{if(""!==c.trim()&&o&&t&&s&&r){h(e=>[...e,{role:"user",content:c}]);try{u&&await lL(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsx)(e$.Z,{children:(0,a.jsx)(eY.Z,{children:"Chat"})}),(0,a.jsx)(eQ.Z,{children:(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"API Key"}),(0,a.jsx)(ec.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,a.jsxs)(en.Z,{className:"mx-2",children:[(0,a.jsx)(eu.Z,{children:"Select Model:"}),(0,a.jsx)(ej.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,a.jsxs)(eI.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{})})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(ec.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,a.jsx)(ei.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]})})]})})})})},lD=t(33509),lB=t(95781);let{Sider:lz}=lD.default;var lK=e=>{let{setPage:l,userRole:t,defaultSelectedKey:s}=e;return"Admin Viewer"==t?(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(lz,{width:120,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(lz,{width:145,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(eu.Z,{children:"API Keys"})},"1"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(eu.Z,{children:"Test Key"})},"3"),"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(eu.Z,{children:"Models"})},"2"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(eu.Z,{children:"Usage"})},"4"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(eu.Z,{children:"Teams"})},"6"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(eu.Z,{children:"Users"})},"5"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(eu.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(eu.Z,{children:"Rate Limits"})},"9"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(eu.Z,{children:"Router Settings"})},"10"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(eu.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(eu.Z,{children:"API Reference"})},"12"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(eu.Z,{children:"Model Hub"})},"14")]})})})},lG=t(67989),lq=t(49167),lV=t(52703),lW=e=>{let{accessToken:l,token:t,userRole:s,userID:r,keys:o,premiumUser:i}=e,c=new Date,[d,m]=(0,n.useState)([]),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)([]),[j,g]=(0,n.useState)([]),[y,f]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[w,b]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)({}),[I,C]=(0,n.useState)([]),[T,P]=(0,n.useState)(""),[q,V]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),W=new Date(c.getFullYear(),c.getMonth(),1),H=new Date(c.getFullYear(),c.getMonth()+1,0),Y=Q(W),J=Q(H);console.log("keys in usage",o),console.log("premium user in usage",i);let $=async(e,t,s)=>{if(!e||!t||!l)return;t.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",s);let r=await U(l,s,e.toISOString(),t.toISOString());console.log("End user data updated successfully",r),g(r)},X=async(e,t)=>{e&&t&&l&&(t.setHours(23,59,59,999),e.setHours(0,0,0,0),_((await O(l,e.toISOString(),t.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function Q(e){let l=e.getFullYear(),t=e.getMonth()+1,s=e.getDate();return"".concat(l,"-").concat(t<10?"0"+t:t,"-").concat(s<10?"0"+s:s)}return console.log("Start date is ".concat(Y)),console.log("End date is ".concat(J)),(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{if(console.log("user role: ".concat(s)),"Admin"==s||"Admin Viewer"==s){var e,a;let s=await M(l);m(s);let r=await D(l,t,Y,J);console.log("provider_spend",r),N(r);let n=(await L(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));u(n);let o=(await K(l)).map(e=>({key:e.model,spend:e.total_spend}));p(o);let i=await F(l);console.log("teamSpend",i),f(i.daily_spend),b(i.teams);let c=i.total_spend_per_team;c=c.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),v(c);let d=await O(l,null===(e=q.from)||void 0===e?void 0:e.toISOString(),null===(a=q.to)||void 0===a?void 0:a.toISOString());_(d.spend_per_tag);let h=await U(l,null,void 0,void 0);g(h),console.log("spend/user result",h);let x=await B(l,Y,J);E(x);let j=await z(l,Y,J);console.log("global activity per model",j),C(j)}else"App Owner"==s&&await R(l,t,s,r,Y,J).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let t=e.top_api_keys;u(t)}else{let t=(await G(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[t,s]=e;"spend"!==t&&"startTime"!==t&&"models"!==t&&"users"!==t&&l.push({key:t,spend:s})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let t=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(t[0]))),t}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));u(t),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,t,s,r,Y,J]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(ez,{userID:r,userRole:s,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{className:"mt-2",children:[(0,a.jsx)(eY.Z,{children:"All Up"}),(0,a.jsx)(eY.Z,{children:"Team Based Usage"}),(0,a.jsx)(eY.Z,{children:"End User Usage"}),(0,a.jsx)(eY.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eY.Z,{children:"Cost"}),(0,a.jsx)(eY.Z,{children:"Activity"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Monthly Spend"}),(0,a.jsx)(e4.Z,{data:d,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top API Keys"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top Models"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:x,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1}),(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"✨ Spend by Provider"}),i?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(lV.Z,{className:"mt-4 h-40",variant:"pie",data:S,index:"provider",category:"spend"})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Provider"}),(0,a.jsx)(eF.Z,{children:"Spend"})]})}),(0,a.jsx)(eC.Z,{children:S.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.provider}),(0,a.jsx)(eT.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"All Up"}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",A.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",A.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),i?(0,a.jsx)(a.Fragment,{children:I.map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:I&&I.length>0&&I.slice(0,1).map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lG.Z,{data:k})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(e4.Z,{className:"h-72",data:y,showLegend:!0,index:"date",categories:w,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:q,onValueChange:e=>{V(e),$(e.from,e.to,null)}})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Key"}),(0,a.jsxs)(eR.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(eM.Z,{value:"all-keys",onClick:()=>{$(q.from,q.to,null)},children:"All Keys"},"all-keys"),null==o?void 0:o.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{$(q.from,q.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(eA.Z,{className:"mt-4",children:(0,a.jsxs)(eI.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"End User"}),(0,a.jsx)(eF.Z,{children:"Spend"}),(0,a.jsx)(eF.Z,{children:"Total Events"})]})}),(0,a.jsx)(eC.Z,{children:null==j?void 0:j.map((e,l)=>{var t;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.end_user}),(0,a.jsx)(eT.Z,{children:null===(t=e.total_spend)||void 0===t?void 0:t.toFixed(4)}),(0,a.jsx)(eT.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsx)(eH.Z,{className:"mb-4",enableSelect:!0,value:q,onValueChange:e=>{V(e),X(e.from,e.to)}}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(eu.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(e4.Z,{className:"h-72",data:Z,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})})]})]})]})},lH=()=>{let{Title:e,Paragraph:l}=eV.default,[t,s]=(0,n.useState)(""),[r,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!0),y=(0,o.useSearchParams)(),[f,Z]=(0,n.useState)({data:[]}),_=y.get("userID"),w=y.get("token"),[b,k]=(0,n.useState)("api-keys"),[v,S]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(w){let e=(0,eq.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),S(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),s(l),"Admin Viewer"==l&&k("usage")}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&i(e.premium_user)}}},[w]),(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:_,userRole:t,userEmail:c,showSSOBanner:j,premiumUser:r}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lK,{setPage:k,userRole:t,defaultSelectedKey:null})}),"api-keys"==b?(0,a.jsx)(eW,{userID:_,userRole:t,teams:h,keys:x,setUserRole:s,userEmail:c,setUserEmail:d,setTeams:u,setKeys:p}):"models"==b?(0,a.jsx)(lu,{userID:_,userRole:t,token:w,accessToken:v,modelData:f,setModelData:Z,premiumUser:r}):"llm-playground"==b?(0,a.jsx)(lU,{userID:_,userRole:t,token:w,accessToken:v}):"users"==b?(0,a.jsx)(lj,{userID:_,userRole:t,token:w,keys:x,teams:h,accessToken:v,setKeys:p}):"teams"==b?(0,a.jsx)(lg,{teams:h,setTeams:u,searchParams:y,accessToken:v,userID:_,userRole:t}):"admin-panel"==b?(0,a.jsx)(ly,{setTeams:u,searchParams:y,accessToken:v,showSSOBanner:j}):"api_ref"==b?(0,a.jsx)(lM,{}):"settings"==b?(0,a.jsx)(lb,{userID:_,userRole:t,accessToken:v,premiumUser:r}):"budgets"==b?(0,a.jsx)(lP,{accessToken:v}):"general-settings"==b?(0,a.jsx)(lI,{userID:_,userRole:t,accessToken:v,modelData:f}):"model-hub"==b?(0,a.jsx)(lR,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r}):(0,a.jsx)(lW,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r})]})]})})}}},function(e){e.O(0,[936,608,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]); \ No newline at end of file +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,t){Promise.resolve().then(t.bind(t,39712))},39712:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return lH}});var s,r,a=t(3827),n=t(64090),o=t(47907),i=t(8792),c=t(40491),d=t(65270),m=e=>{let{userID:l,userRole:t,userEmail:s,showSSOBanner:r,premiumUser:n}=e;console.log("User ID:",l),console.log("userEmail:",s),console.log("showSSOBanner:",r),console.log("premiumUser:",n);let o=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",t]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(i.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[r?(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(c.Z,{menu:{items:o},children:(0,a.jsx)(d.Z,{children:s})})})]})]})},h=t(80588);let u=async()=>{try{let e=await fetch("https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"),l=await e.json();return console.log("received data: ".concat(l)),l}catch(e){throw console.error("Failed to get model cost map:",e),e}},x=async(e,l)=>{try{let t=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),s}catch(e){throw console.error("Failed to create key:",e),e}},p=async e=>{try{let l=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},j=async(e,l)=>{console.log("model_id in model delete call: ".concat(l));try{let t=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model deleted successfully. Restart server to see this."),s}catch(e){throw console.error("Failed to create key:",e),e}},g=async(e,l)=>{if(console.log("budget_id in budget delete call: ".concat(l)),null!=e)try{let t=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,l)=>{try{console.log("Form Values in budgetCreateCall:",l),console.log("Form Values after check:",l);let t=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},f=async e=>{try{let l=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},Z=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,l)=>{try{console.log("in keyDeleteCall:",l);let t=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,l)=>{try{console.log("in teamDeleteCall:",l);let t=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,l,t){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;try{let n="/user/info";"App Owner"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),"App User"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),console.log("in userInfoCall viewAll=",s),s&&a&&null!=r&&void 0!=r&&(n="".concat(n,"?view_all=true&page=").concat(r,"&page_size=").concat(a));let o=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let i=await o.json();return console.log("API Response:",i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,l)=>{try{let t="/team/info";l&&(t="".concat(t,"?team_id=").concat(l)),console.log("in teamInfoCall");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},S=async e=>{try{let l=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,l,t)=>{try{let l=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelInfoCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,l,t)=>{try{let l=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelHubCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,l,t,s,r,a)=>{try{let l="/model/metrics";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},I=async(e,l,t,s)=>{try{let r="/model/streaming_metrics";l&&(r="".concat(r,"?_selected_model_group=").concat(l,"&startTime=").concat(t,"&endTime=").concat(s));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},C=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/slow_responses";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/exceptions";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,l,t)=>{try{let l=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},F=async e=>{try{let l="/global/spend/teams";console.log("in teamSpendLogsCall:",l);let t=await fetch("".concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=async(e,l,t)=>{try{let s="/global/spend/tags";l&&t&&(s="".concat(s,"?start_date=").concat(l,"&end_date=").concat(t)),console.log("in tagsSpendLogsCall:",s);let r=await fetch("".concat(s),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},R=async(e,l,t,s,r,a)=>{try{console.log("user role in spend logs call: ".concat(t));let l="/spend/logs";l="App Owner"==t?"".concat(l,"?user_id=").concat(s,"&start_date=").concat(r,"&end_date=").concat(a):"".concat(l,"?start_date=").concat(r,"&end_date=").concat(a);let n=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},M=async e=>{try{let l=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},L=async e=>{try{let l=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,l,t,s)=>{try{let r="";r=l?JSON.stringify({api_key:l,startTime:t,endTime:s}):JSON.stringify({startTime:t,endTime:s});let a={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};a.body=r;let n=await fetch("/global/spend/end_users",a);if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,l,t,s)=>{try{let r="/global/spend/provider";t&&s&&(r+="?start_date=".concat(t,"&end_date=").concat(s)),l&&(r+="&api_key=".concat(l));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log(n),n}catch(e){throw console.error("Failed to fetch spend data:",e),e}},B=async(e,l,t)=>{try{let s="/global/activity";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},z=async(e,l,t)=>{try{let s="/global/activity/model";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},K=async e=>{try{let l=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},G=async(e,l)=>{try{let t=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},q=async(e,l)=>{try{let t="/user/get_users?role=".concat(l);console.log("in userGetAllUsersCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let r=await s.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},V=async(e,l)=>{try{console.log("Form Values in teamCreateCall:",l);let t=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,l)=>{try{console.log("Form Values in keyUpdateCall:",l);let t=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},H=async(e,l)=>{try{console.log("Form Values in teamUpateCall:",l);let t=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},Y=async(e,l)=>{try{console.log("Form Values in modelUpateCall:",l);let t=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update model Response:",s),s}catch(e){throw console.error("Failed to update model:",e),e}},J=async(e,l,t)=>{try{console.log("Form Values in teamMemberAddCall:",t);let s=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:l,member:t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},$=async(e,l,t)=>{try{console.log("Form Values in userUpdateUserCall:",l);let s={...l};null!==t&&(s.user_role=t),s=JSON.stringify(s);let r=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:s});if(!r.ok){let e=await r.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await r.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,l)=>{try{let t="/health/services?service=".concat(l);console.log("Checking Slack Budget Alerts service health");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed ".concat(l," service health check ")+e),Error(e)}let r=await s.json();return h.ZP.success("Test request to ".concat(l," made - check logs/alerts on ").concat(l," to verify")),r}catch(e){throw console.error("Failed to perform health check:",e),e}},Q=async e=>{try{let l=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async(e,l,t)=>{try{let l=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},el=async e=>{try{let l=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,l,t)=>{try{let s=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,field_value:t,config_type:"general_settings"})});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return h.ZP.success("Successfully updated value!"),r}catch(e){throw console.error("Failed to set callbacks:",e),e}},es=async(e,l)=>{try{let t=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,config_type:"general_settings"})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return h.ZP.success("Field reset on proxy"),s}catch(e){throw console.error("Failed to get callbacks:",e),e}},er=async(e,l)=>{try{let t=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},ea=async e=>{try{let l=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to call /health:",e),e}};var en=t(10384),eo=t(46453),ei=t(16450),ec=t(52273),ed=t(26780),em=t(15595),eh=t(6698),eu=t(71801),ex=t(42440),ep=t(42308),ej=t(50670),eg=t(81583),ey=t(99129),ef=t(44839),eZ=t(88707),e_=t(1861);let{Option:ew}=ej.default;var eb=e=>{let{userID:l,team:t,userRole:s,accessToken:r,data:o,setData:i}=e,[c]=eg.Z.useForm(),[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(null),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,_]=(0,n.useState)([]),w=()=>{m(!1),c.resetFields()},b=()=>{m(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==r){let e=(await P(r,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,s]);let k=async e=>{try{var t,s,a;let n=null!==(t=null==e?void 0:e.key_alias)&&void 0!==t?t:"",d=null!==(s=null==e?void 0:e.team_id)&&void 0!==s?s:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===d).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(n))throw Error("Key alias ".concat(n," already exists for team with ID ").concat(d,", please provide another key alias"));h.ZP.info("Making API Call"),m(!0);let u=await Z(r,l,e);console.log("key create Response:",u),i(e=>e?[...e,u]:[u]),x(u.key),j(u.soft_budget),h.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.useEffect)(()=>{_(t&&t.models.length>0?t.models.includes("all-proxy-models")?g:t.models:g)},[t,g]),(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(ey.Z,{title:"Create Key",visible:d,width:800,footer:null,onOk:w,onCancel:b,children:(0,a.jsxs)(eg.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:t?t.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t?t.team_alias:"",disabled:!0})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(ew,{value:"all-team-models",children:"All Team Models"},"all-team-models"),f.map(e=>(0,a.jsx)(ew,{value:e,children:e},e))]})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==t?void 0:t.max_budget)!==null&&(null==t?void 0:t.max_budget)!==void 0?null==t?void 0:t.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.max_budget&&l>t.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(t.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==t?void 0:t.budget_duration)!==null&&(null==t?void 0:t.budget_duration)!==void 0?null==t?void 0:t.budget_duration:"None"),children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==t?void 0:t.tpm_limit)!==null&&(null==t?void 0:t.tpm_limit)!==void 0?null==t?void 0:t.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.tpm_limit&&l>t.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(t.tpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==t?void 0:t.rpm_limit)!==null&&(null==t?void 0:t.rpm_limit)!==void 0?null==t?void 0:t.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.rpm_limit&&l>t.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(t.rpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Key"})})]})}),u&&(0,a.jsx)(ey.Z,{visible:d,onOk:w,onCancel:b,footer:null,children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Save your Key"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:null!=u?(0,a.jsxs)("div",{children:[(0,a.jsx)(eu.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:u})}),(0,a.jsx)(ep.CopyToClipboard,{text:u,onCopy:()=>{h.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(ei.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(eu.Z,{children:"Key being created, this might take 30s"})})]})})]})},ek=t(9454),ev=t(98941),eS=t(33393),eN=t(5),eA=t(13810),eE=t(61244),eI=t(10827),eC=t(3851),eT=t(2044),eP=t(64167),eF=t(74480),eO=t(7178),eR=t(95093),eM=t(27166);let{Option:eL}=ej.default;var eU=e=>{let{userID:l,userRole:t,accessToken:s,selectedTeam:r,data:o,setData:i,teams:c}=e,[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(!1),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(""),[k,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(!1),[A,E]=(0,n.useState)(null),[I,C]=(0,n.useState)([]),T=new Set,[F,O]=(0,n.useState)(T);(0,n.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==s&&null!==t){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),C(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[s,l,t]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,t)=>{let s=l.team_id;e.add(s)}),O(e)}},[c]);let R=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),E(e),v(!0)},M=async e=>{if(null==s)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let t=await W(s,e);console.log("handleEditSubmit: newKeyValues",t),o&&i(o.map(e=>e.token===l?t:e)),h.ZP.success("Key updated successfully"),v(!1),E(null)},L=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+l),x(!0))},U=async()=>{if(null!=p&&null!=o){try{await w(s,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(eI.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Key Alias"}),(0,a.jsx)(eF.Z,{children:"Secret Key"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(eC.Z,{children:o.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(r){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(F.has(e.team_id),", selectedTeam id: ").concat(r.team_id)),(null!=r.team_id||null===e.team_id||F.has(e.team_id))&&e.team_id!=r.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(eu.Z,{children:e.key_alias}):(0,a.jsx)(eu.Z,{children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:e.key_name})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(eT.Z,{children:null!=e.max_budget?(0,a.jsx)(eu.Z,{children:e.max_budget}):(0,a.jsx)(eu.Z,{children:"Unlimited"})}),(0,a.jsx)(eT.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:r&&r.models&&r.models.length>0?r.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{onClick:()=>{E(e),N(!0)},icon:ek.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:S,onCancel:()=>{N(!1),E(null)},footer:null,width:800,children:A&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(A.spend).toFixed(4)}catch(e){return A.spend}})()})})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.max_budget?(0,a.jsx)(a.Fragment,{children:A.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.expires?(0,a.jsx)(a.Fragment,{children:new Date(A.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(eA.Z,{className:"my-4",children:[(0,a.jsx)(ex.Z,{children:"Token Name"}),(0,a.jsx)(eu.Z,{className:"my-1",children:A.key_alias?A.key_alias:A.key_name}),(0,a.jsx)(ex.Z,{children:"Token ID"}),(0,a.jsx)(eu.Z,{className:"my-1 text-[12px]",children:A.token}),(0,a.jsx)(ex.Z,{children:"Metadata"}),(0,a.jsx)(eu.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(A.metadata)," "]})})]}),(0,a.jsx)(ei.Z,{className:"mx-auto flex items-center",onClick:()=>{N(!1),E(null)},children:"Close"})]})}),(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>R(e)}),(0,a.jsx)(eE.Z,{onClick:()=>L(e),icon:eS.Z,size:"sm"})]})]},e.token)})})]}),u&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{x(!1),j(null)},children:"Cancel"})]})]})]})})]}),A&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,token:s,onSubmit:o}=e,[i]=eg.Z.useForm(),[d,m]=(0,n.useState)(r),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1);return(0,a.jsx)(ey.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:i,onFinish:M,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let t=l.filter(e=>!d.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!d.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(t)),t.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(t,"Team models: ").concat(d.models)):Promise.resolve()}}],children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(eL,{value:"all-team-models",children:"All Team Models"},"all-team-models"),d&&d.models?d.models.includes("all-proxy-models")?I.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):d.models.map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):I.map(e=>(0,a.jsx)(eL,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==d?void 0:d.max_budget)!==null&&(null==d?void 0:d.max_budget)!==void 0?null==d?void 0:d.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&d&&null!==d.max_budget&&l>d.max_budget)throw console.log("keyTeam.max_budget: ".concat(d.max_budget)),Error("Budget cannot exceed team max budget: $".concat(d.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(eg.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(eR.Z,{value:s.team_alias,children:null==c?void 0:c.map((e,l)=>(0,a.jsx)(eM.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:k,onCancel:()=>{v(!1),E(null)},token:A,onSubmit:M})]})},eD=t(76032),eB=t(35152),ez=e=>{let{userID:l,userRole:t,accessToken:s,userSpend:r,selectedTeam:o}=e;console.log("userSpend: ".concat(r));let[i,c]=(0,n.useState)(null!==r?r:0),[d,m]=(0,n.useState)(0),[h,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(s&&l&&t&&"Admin"===t&&null==r)try{let e=await S(s);e&&(e.spend?c(e.spend):c(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(async()=>{try{if(null===l||null===t)return;if(null!==s){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),u(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,s,l]),(0,n.useEffect)(()=>{null!==r&&c(r)},[r]);let x=[];o&&o.models&&(x=o.models),x&&x.includes("all-proxy-models")?(console.log("user models:",h),x=h):x&&x.includes("all-team-models")?x=o.models:x&&0===x.length&&(x=h);let p=void 0!==i?i.toFixed(4):null;return console.log("spend in view user spend: ".concat(i)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:["Total Spend"," "]}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",p]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Team Models"})}),(0,a.jsx)(em.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(eD.Z,{children:x.map(e=>(0,a.jsx)(eB.Z,{children:(0,a.jsx)(eu.Z,{children:e})},e))})})]})})]})},eK=e=>{let{userID:l,userRole:t,selectedTeam:s,accessToken:r}=e,[o,i]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==r){let e=(await P(r,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),i(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,t]);let c=[];return s&&s.models&&(c=s.models),c&&c.includes("all-proxy-models")&&(console.log("user models:",o),c=o),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"mb-5",children:(0,a.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==s?void 0:s.team_alias})})})},eG=e=>{let l,{teams:t,setSelectedTeam:s,userRole:r}=e,o={models:[],team_id:null,team_alias:"Default Team"},[i,c]=(0,n.useState)(o);return(l="App User"===r?t:t?[...t,o]:[o],"App User"===r)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(ex.Z,{children:"Select Team"}),(0,a.jsx)(eu.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(eu.Z,{className:"mt-3 mb-3",children:[(0,a.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>s(e),children:e.team_alias},l))}):(0,a.jsxs)(eu.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},eq=t(37963),eV=t(97482);console.log("isLocal:",!1);var eW=e=>{let{userID:l,userRole:t,teams:s,keys:r,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,n.useState)(null),p=(0,o.useSearchParams)();p.get("viewSpend"),(0,o.useRouter)();let j=p.get("token"),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)([]),b={models:[],team_alias:"Default Team",team_id:null},[v,N]=(0,n.useState)(s?s[0]:b);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(j){let e=(0,eq.o)(j);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),i(l)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&g&&t&&!r&&!u){let e=sessionStorage.getItem("userModels"+l);e?w(JSON.parse(e)):(async()=>{try{let e=await k(g,l,t,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==t){let e=await S(g);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(e.teams);let s=[...e.teams];s.length>0?(console.log("response['teams']: ".concat(s)),N(s[0])):N(b),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let r=(await P(g,l,t)).data.map(e=>e.id);console.log("available_model_names:",r),w(r),console.log("userModels:",_),sessionStorage.setItem("userModels"+l,JSON.stringify(r))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,j,g,r,t]),(0,n.useEffect)(()=>{if(null!==r&&null!=v){let e=0;for(let l of r)v.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===v.team_id&&(e+=l.spend);Z(e)}else if(null!==r){let e=0;for(let l of r)e+=l.spend;Z(e)}},[v]),null==l||null==j){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==g)return null;if(null==t&&i("App Owner"),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",v),console.log("teamSpend: ".concat(f)),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eK,{userID:l,userRole:t,selectedTeam:v||null,accessToken:g}),(0,a.jsx)(ez,{userID:l,userRole:t,accessToken:g,userSpend:f,selectedTeam:v||null}),(0,a.jsx)(eU,{userID:l,userRole:t,accessToken:g,selectedTeam:v||null,data:r,setData:h,teams:s}),(0,a.jsx)(eb,{userID:l,team:v||null,userRole:t,accessToken:g,data:r,setData:h},v?v.team_id:null),(0,a.jsx)(eG,{teams:s,setSelectedTeam:N,userRole:t})]})})})},eH=t(35087),eY=t(92836),eJ=t(26734),e$=t(41608),eX=t(32126),eQ=t(23682),e0=t(47047),e1=t(76628),e2=t(25707),e4=t(44041),e5=t(38302),e8=t(28683),e3=t(1460),e6=t(78578),e7=t(63954),e9=t(90252),le=t(7905),ll=e=>{let{modelID:l,accessToken:t}=e,[s,r]=(0,n.useState)(!1),o=async()=>{try{h.ZP.info("Making API Call"),r(!0);let e=await j(t,l);console.log("model delete Response:",e),h.ZP.success("Model ".concat(l," deleted successfully")),r(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(eE.Z,{onClick:()=>r(!0),icon:eS.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:s,onOk:o,okType:"danger",onCancel:()=>r(!1),children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Delete Model"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},lt=t(97766),ls=t(46495),lr=t(18190),la=t(91118),ln=e=>{let{modelMetrics:l,modelMetricsCategories:t,customTooltip:s,premiumUser:r}=e;return r?(0,a.jsx)(la.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:t,colors:["indigo","rose"],connectNulls:!0,customTooltip:s}):(0,a.jsxs)("div",{children:[(0,a.jsx)(lr.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,a.jsx)(ei.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},lo=e=>{let{fields:l,selectedProvider:t}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,a.jsx)(ec.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})};let{Title:li,Link:lc}=eV.default;(s=r||(r={})).OpenAI="OpenAI",s.Azure="Azure",s.Anthropic="Anthropic",s.Google_AI_Studio="Google AI Studio",s.Bedrock="Amazon Bedrock",s.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",s.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",s.Databricks="Databricks";let ld={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},lm={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},lh=async(e,l,t)=>{try{let s=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(s)),console.log("received type of deployments: ".concat(typeof s)),s.forEach(async t=>{console.log("litellm_model: ".concat(t));let s={},r={};s.model=t;let a="";for(let[l,t]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==t){if("model_name"==l)a+=t;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)r[l]=t;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",t);let e={};if(t&&void 0!=t){try{e=JSON.parse(t)}catch(e){throw h.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,t]of Object.entries(e))s[l]=t}}else s[l]=t}let n={model_name:a,litellm_params:s,model_info:r},o=await x(l,n);console.log("response for model create call: ".concat(o.data))}),t.resetFields()}catch(e){h.ZP.error("Failed to create model: "+e,10)}};var lu=e=>{var l,t,s;let o,{accessToken:i,token:c,userRole:d,userID:m,modelData:x={data:[]},setModelData:j,premiumUser:g}=e,[y,f]=(0,n.useState)([]),[Z]=eg.Z.useForm(),[_,w]=(0,n.useState)(null),[b,k]=(0,n.useState)(""),[v,S]=(0,n.useState)([]),A=Object.values(r).filter(e=>isNaN(Number(e))),[P,F]=(0,n.useState)([]),[O,R]=(0,n.useState)("OpenAI"),[M,L]=(0,n.useState)(""),[U,D]=(0,n.useState)(!1),[B,z]=(0,n.useState)(null),[K,G]=(0,n.useState)([]),[q,V]=(0,n.useState)(null),[W,H]=(0,n.useState)([]),[J,$]=(0,n.useState)([]),[X,Q]=(0,n.useState)([]),[el,et]=(0,n.useState)([]),[es,en]=(0,n.useState)([]),[ep,ej]=(0,n.useState)([]),[ef,ew]=(0,n.useState)([]),[eb,ek]=(0,n.useState)([]),[eS,eL]=(0,n.useState)([]),[eU,eD]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eB,ez]=(0,n.useState)(null),[eK,eG]=(0,n.useState)(0),eq=e=>{z(e),D(!0)},eW=async e=>{if(console.log("handleEditSubmit:",e),null==i)return;let l={},t=null;for(let[s,r]of Object.entries(e))"model_id"!==s?l[s]=r:t=r;let s={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",s);try{await Y(i,s),h.ZP.success("Model updated successfully, restart server to see updates"),D(!1),z(null)}catch(e){console.log("Error occurred")}},lr=()=>{k(new Date().toLocaleString())},la=async()=>{if(!i){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eB);try{await er(i,{router_settings:{model_group_retry_policy:eB}}),h.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),h.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!i||!c||!d||!m)return;let e=async()=>{try{var e,l,t,s,r,a,n,o;let c=await p(i);F(c);let h=await N(i,m,d);console.log("Model data response:",h.data),j(h);let u=new Set;for(let e=0;e0&&(g=x[x.length-1],console.log("_initial_model_group:",g),V(g)),console.log("selectedModelGroup:",q);let y=await E(i,m,d,g,null===(e=eU.from)||void 0===e?void 0:e.toISOString(),null===(l=eU.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",y),$(y.data),Q(y.all_api_bases);let f=await I(i,g,null===(t=eU.from)||void 0===t?void 0:t.toISOString(),null===(s=eU.to)||void 0===s?void 0:s.toISOString());et(f.data),en(f.all_api_bases);let Z=await T(i,m,d,g,null===(r=eU.from)||void 0===r?void 0:r.toISOString(),null===(a=eU.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",Z),ej(Z.data),ew(Z.exception_types);let _=await C(i,m,d,g,null===(n=eU.from)||void 0===n?void 0:n.toISOString(),null===(o=eU.to)||void 0===o?void 0:o.toISOString());console.log("slowResponses:",_),eL(_);let w=(await ee(i,m,d)).router_settings;console.log("routerSettingsInfo:",w);let b=w.model_group_retry_policy,k=w.num_retries;console.log("model_group_retry_policy:",b),console.log("default_retries:",k),ez(b),eG(k)}catch(e){console.error("There was an error fetching the model data",e)}};i&&c&&d&&m&&e();let l=async()=>{let e=await u();console.log("received model cost map data: ".concat(Object.keys(e))),w(e)};null==_&&l(),lr()},[i,c,d,m,_,b]),!x||!i||!c||!d||!m)return(0,a.jsx)("div",{children:"Loading..."});let lu=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(_)),null!=_&&"object"==typeof _&&e in _)?_[e].litellm_provider:"openai";if(r){let e=r.split("/"),l=e[0];n=1===e.length?h(r):l}else n="openai";a&&(o=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,c=null==a?void 0:a.max_tokens,d=null==a?void 0:a.max_input_tokens),(null==s?void 0:s.litellm_params)&&(m=Object.fromEntries(Object.entries(null==s?void 0:s.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),x.data[e].provider=n,x.data[e].input_cost=o,x.data[e].output_cost=i,x.data[e].input_cost&&(x.data[e].input_cost=(1e6*Number(x.data[e].input_cost)).toFixed(2)),x.data[e].output_cost&&(x.data[e].output_cost=(1e6*Number(x.data[e].output_cost)).toFixed(2)),x.data[e].max_tokens=c,x.data[e].max_input_tokens=d,x.data[e].api_base=null==s?void 0:null===(t=s.litellm_params)||void 0===t?void 0:t.api_base,x.data[e].cleanedLitellmParams=m,lu.push(s.model_name),console.log(x.data[e])}if(d&&"Admin Viewer"==d){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lx=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(r).find(l=>r[l]===e);if(l){let e=ld[l];console.log("mappingResult: ".concat(e));let t=[];"object"==typeof _&&Object.entries(_).forEach(l=>{let[s,r]=l;null!==r&&"object"==typeof r&&"litellm_provider"in r&&(r.litellm_provider===e||r.litellm_provider.includes(e))&&t.push(s)}),S(t),console.log("providerModels: ".concat(v))}},lp=async()=>{try{h.ZP.info("Running health check..."),L("");let e=await ea(i);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lj=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),i&&m&&d&&l&&t){console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),V(e);try{let s=await E(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model metrics response:",s),$(s.data),Q(s.all_api_bases);let r=await I(i,e,l.toISOString(),t.toISOString());et(r.data),en(r.all_api_bases);let a=await T(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model exceptions response:",a),ej(a.data),ew(a.exception_types);let n=await C(i,m,d,e,l.toISOString(),t.toISOString());console.log("slowResponses:",n),eL(n)}catch(e){console.error("Failed to fetch model metrics",e)}}},lg=e=>{var l,t;let{payload:s,active:r}=e;if(!r||!s)return null;let n=null===(t=s[0])||void 0===t?void 0:null===(l=t.payload)||void 0===l?void 0:l.date,o=s.sort((e,l)=>l.value-e.value);if(o.length>5){let e=o.length-5;(o=o.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:s.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,a.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[n&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),o.map((e,l)=>{let t=parseFloat(e.value.toFixed(5)),s=0===t&&e.value>0?"<0.00001":t.toFixed(5);return(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:s})]},l)})]})};console.log("selectedProvider: ".concat(O)),console.log("providerModels.length: ".concat(v.length));let ly=Object.keys(r).find(e=>r[e]===O);return ly&&(o=P.find(e=>e.name===ld[ly])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eY.Z,{children:"All Models"}),(0,a.jsx)(eY.Z,{children:"Add Model"}),(0,a.jsx)(eY.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eY.Z,{children:"Model Analytics"}),(0,a.jsx)(eY.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[b&&(0,a.jsxs)(eu.Z,{children:["Last Refreshed: ",b]}),(0,a.jsx)(eE.Z,{icon:e7.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lr})]})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],onValueChange:e=>V("all"===e?"all":e),value:q||K[0],children:[(0,a.jsx)(eM.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))]})]}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"Public Model Name"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:"Provider"}),"Admin"===d&&(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"API Base"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:"Extra litellm Params"}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(eF.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:"Max Tokens"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word"},children:"Status"})]})}),(0,a.jsx)(eC.Z,{children:x.data.filter(e=>"all"===q||e.model_name===q||null==q||""===q).map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{children:e.model_name})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.provider}),"Admin"===d&&(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:e.api_base}),(0,a.jsx)(eT.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Litellm params"})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)("pre",{children:JSON.stringify(e.cleanedLitellmParams,null,2)})})]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.input_cost||e.litellm_params.input_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.output_cost||e.litellm_params.output_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)("p",{style:{fontSize:"10px"},children:["Max Tokens: ",e.max_tokens," ",(0,a.jsx)("br",{}),"Max Input Tokens: ",e.max_input_tokens]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(eN.Z,{icon:e9.Z,size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(eN.Z,{icon:le.Z,size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsxs)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>eq(e)}),(0,a.jsx)(ll,{modelID:e.model_info.id,accessToken:i})]})]},l))})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:t,model:s,onSubmit:r}=e,[n]=eg.Z.useForm(),o={},i="",c="";if(s){o=s.litellm_params,i=s.model_name;let e=s.model_info;e&&(c=e.id,console.log("model_id: ".concat(c)),o.model_id=c)}return(0,a.jsx)(ey.Z,{title:"Edit Model "+i,visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r(e),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:eW,initialValues:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:U,onCancel:()=>{D(!1),z(null)},model:B,onSubmit:eW})]}),(0,a.jsxs)(eX.Z,{className:"h-full",children:[(0,a.jsx)(li,{level:2,children:"Add new model"}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eg.Z,{form:Z,onFinish:()=>{Z.validateFields().then(e=>{lh(e,i,Z)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:O.toString(),children:A.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>{lx(e),R(e)},children:e},l))})}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(s=O.toString())?"gemini-pro":"Anthropic"==s?"claude-3-opus":"Amazon Bedrock"==s?"claude-3-opus":"Google AI Studio"==s?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===O?(0,a.jsx)(ec.Z,{placeholder:"Enter model name"}):v.length>0?(0,a.jsx)(e0.Z,{value:v,children:v.map((e,l)=>(0,a.jsx)(e1.Z,{value:e,children:e},l))}):(0,a.jsx)(ec.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==o&&o.fields.length>0&&(0,a.jsx)(lo,{fields:o.fields,selectedProvider:o.name}),"Amazon Bedrock"!=O&&"Vertex AI (Anthropic, Gemini, etc.)"!=O&&void 0===o&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(ec.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==O&&(0,a.jsx)(eg.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(ec.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(ec.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ls.Z,{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;Z.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?h.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&h.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(e_.ZP,{icon:(0,a.jsx)(lt.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==O||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==O)&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(ec.Z,{placeholder:"https://..."})}),"Azure"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(ec.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==O&&(0,a.jsxs)("div",{children:[(0,a.jsx)(eg.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(lc,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(eg.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,a.jsx)(e6.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(e3.Z,{title:"Get help on our github",children:(0,a.jsx)(eV.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(ei.Z,{onClick:lp,children:"Run `/health`"}),M&&(0,a.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:eU,onValueChange:e=>{eD(e),lj(q,e.from,e.to)}})]}),(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Model Group"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2",defaultValue:q||K[0],value:q||K[0],children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>lj(e,eU.from,eU.to),children:e},l))})]})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eY.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(eu.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),J&&X&&(0,a.jsx)(e2.Z,{title:"Model Latency",className:"h-72",data:J,showLegend:!1,index:"date",categories:X,connectNulls:!0,customTooltip:lg})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(ln,{modelMetrics:el,modelMetricsCategories:es,customTooltip:lg,premiumUser:g})})]})]})})}),(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Deployment"}),(0,a.jsx)(eF.Z,{children:"Success Responses"}),(0,a.jsxs)(eF.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(eC.Z,{children:eS.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.api_base}),(0,a.jsx)(eT.Z,{children:e.total_count}),(0,a.jsx)(eT.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(eA.Z,{className:"mt-4",children:[(0,a.jsx)(ex.Z,{children:"Exceptions per Model"}),(0,a.jsx)(e4.Z,{className:"h-72",data:ep,index:"model",categories:ef,stack:!0,colors:["indigo-300","rose-200","#ffcc33"],yAxisWidth:30})]})]}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],value:q||K[0],onValueChange:e=>V(e),children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))})]}),(0,a.jsxs)(ex.Z,{children:["Retry Policy for ",q]}),(0,a.jsx)(eu.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),lm&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(lm).map((e,l)=>{var t;let[s,r]=e,n=null==eB?void 0:null===(t=eB[q])||void 0===t?void 0:t[r];return null==n&&(n=eK),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)("td",{children:(0,a.jsx)(eZ.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{ez(l=>{var t;let s=null!==(t=null==l?void 0:l[q])&&void 0!==t?t:{};return{...null!=l?l:{},[q]:{...s,[r]:e}}})}})})]},l)})})}),(0,a.jsx)(ei.Z,{className:"mt-6 mr-8",onClick:la,children:"Save"})]})]})]})})};let{Option:lx}=ej.default;var lp=e=>{let{userID:l,accessToken:t,teams:s}=e,[r]=eg.Z.useForm(),[o,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[m,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{let e=await P(t,l,"any"),s=[];for(let l=0;l{i(!1),r.resetFields()},p=()=>{i(!1),d(null),r.resetFields()},j=async e=>{try{h.ZP.info("Making API Call"),i(!0),console.log("formValues in create user:",e);let s=await _(t,null,e);console.log("user create Response:",s),d(s.key),h.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-0",onClick:()=>i(!0),children:"+ Invite User"}),(0,a.jsxs)(ey.Z,{title:"Invite User",visible:o,width:800,footer:null,onOk:x,onCancel:p,children:[(0,a.jsx)(eu.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(eu.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(eg.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(eg.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(ej.default,{placeholder:"Select Team ID",style:{width:"100%"},children:s?s.map(e=>(0,a.jsx)(lx,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(lx,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create User"})})]})]}),c&&(0,a.jsxs)(ey.Z,{title:"User Created Successfully",visible:o,onOk:x,onCancel:p,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},lj=e=>{let{accessToken:l,token:t,keys:s,userRole:r,userID:o,teams:i,setKeys:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(0),[j,g]=n.useState(null),[y,f]=(0,n.useState)(null);return((0,n.useEffect)(()=>{if(!l||!t||!r||!o)return;let e=async()=>{try{let e=await k(l,null,r,!0,x,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&r&&o&&e()},[l,t,r,o,x]),d&&l&&t&&r&&o)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(eo.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(lp,{userID:o,accessToken:l,teams:i}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(eu.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(eJ.Z,{children:(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"User ID"}),(0,a.jsx)(eF.Z,{children:"User Email"}),(0,a.jsx)(eF.Z,{children:"User Models"}),(0,a.jsx)(eF.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User API Key Aliases"})]})}),(0,a.jsx)(eC.Z,{children:d.map(e=>{var l;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_id}),(0,a.jsx)(eT.Z,{children:e.user_email}),(0,a.jsx)(eT.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(eT.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eo.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsx)(eN.Z,{size:"xs",color:"indigo",children:e.key_aliases.filter(e=>null!==e).join(", ")}):(0,a.jsx)(eN.Z,{size:"xs",color:"gray",children:"No Keys"})})})]},e.user_id)})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})})]}),function(){if(!d)return null;let e=Math.ceil(d.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",x+1," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:0===x,onClick:()=>p(x-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",onClick:()=>{p(x+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},lg=e=>{let{teams:l,searchParams:t,accessToken:s,setTeams:r,userID:o,userRole:i}=e,[c]=eg.Z.useForm(),[d]=eg.Z.useForm(),{Title:m,Paragraph:u}=eV.default,[x,p]=(0,n.useState)(""),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(l?l[0]:null),[Z,_]=(0,n.useState)(!1),[w,k]=(0,n.useState)(!1),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)(!1),[I,C]=(0,n.useState)(null),[T,F]=(0,n.useState)({}),O=e=>{f(e),g(!0)},R=async e=>{let t=e.team_id;if(console.log("handleEditSubmit:",e),null==s)return;let a=await H(s,e);l&&r(l.map(e=>e.team_id===t?a.data:e)),h.ZP.success("Team updated successfully"),g(!1),f(null)},M=async e=>{C(e),E(!0)},L=async()=>{if(null!=I&&null!=l&&null!=s){try{await b(s,I);let e=l.filter(e=>e.team_id!==I);r(e)}catch(e){console.error("Error deleting the team:",e)}E(!1),C(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{if(null===o||null===i||null===s||null===l)return;console.log("fetching team info:");let e={};for(let t=0;t<(null==l?void 0:l.length);t++){let r=l[t].team_id,a=await v(s,r);console.log("teamInfo response:",a),null!==a&&(e={...e,[r]:a})}F(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===o||null===i)return;if(null!==s){let e=(await P(s,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,o,i,l]);let U=async e=>{try{if(null!=s){var t;let a=null==e?void 0:e.team_alias;if((null!==(t=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==t?t:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));h.ZP.info("Creating Team");let n=await V(s,e);null!==l?r([...l,n]):r([n]),console.log("response for team create call: ".concat(n)),h.ZP.success("Team created"),_(!1)}}catch(e){console.error("Error creating the team:",e),h.ZP.error("Error creating the team: "+e,20)}},D=async e=>{try{if(null!=s&&null!=l){h.ZP.info("Adding Member");let t={role:"user",user_email:e.user_email,user_id:e.user_id},a=await J(s,y.team_id,t);console.log("response for team create call: ".concat(a.data));let n=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(n)),-1!==n){let e=[...l];e[n]=a.data,r(e),f(a.data)}k(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Team Name"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(eF.Z,{children:"Info"})]})}),(0,a.jsx)(eC.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(eT.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].keys&&T[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].team_info&&T[e.team_id].team_info.members_with_roles&&T[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>O(e)}),(0,a.jsx)(eE.Z,{onClick:()=>M(e.team_id),icon:eS.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{E(!1),C(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>_(!0),children:"+ Create New Team"}),(0,a.jsx)(ey.Z,{title:"Create Team",visible:Z,width:800,footer:null,onOk:()=>{_(!1),c.resetFields()},onCancel:()=>{_(!1),c.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:U,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{f(e)},children:e.team_alias},l))}):(0,a.jsxs)(u,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:y?y.members_with_roles.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.role})]},l)):null})]})}),y&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,team:s,onSubmit:r}=e,[n]=eg.Z.useForm();return(0,a.jsx)(ey.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:s.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:R,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:j,onCancel:()=>{g(!1),f(null)},team:y,onSubmit:R})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-5",onClick:()=>k(!0),children:"+ Add member"}),(0,a.jsx)(ey.Z,{title:"Add member",visible:w,width:800,footer:null,onOk:()=>{k(!1),d.resetFields()},onCancel:()=>{k(!1),d.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:D,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},ly=e=>{let l,{searchParams:t,accessToken:s,showSSOBanner:r}=e,[o]=eg.Z.useForm(),[i]=eg.Z.useForm(),{Title:c,Paragraph:d}=eV.default,[m,u]=(0,n.useState)(""),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(!1),[Z,_]=(0,n.useState)(!1),[w,b]=(0,n.useState)(!1),[k,v]=(0,n.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let S=()=>{v(!1)},N=["proxy_admin","proxy_admin_viewer"];(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await q(s,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let t=await q(s,"proxy_admin");t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(t)),console.log("combinedList: ".concat(e)),p(e)}})()},[s]);let A=()=>{_(!1),i.resetFields()},E=()=>{_(!1),i.resetFields()},I=e=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]}),C=(e,l,t)=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:l,children:N.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:t,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update role"})})]}),T=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,null);console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),h.ZP.success("Refresh tab to see updated user role"),_(!1)}}catch(e){console.error("Error creating the key:",e)}},P=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),g(!1)}}catch(e){console.error("Error creating the key:",e)}},F=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await $(s,e,"proxy_admin");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),f(!1)}}catch(e){console.error("Error creating the key:",e)}},O=async e=>{null!=s&&er(s,{environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}})};return console.log("admins: ".concat(null==x?void 0:x.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(c,{level:4,children:"Admin Access "}),(0,a.jsxs)(d,{children:[r&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc. ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:x?x.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.user_role}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>_(!0)}),(0,a.jsx)(ey.Z,{title:"Update role",visible:Z,width:800,footer:null,onOk:A,onCancel:E,children:C(T,e.user_role,e.user_id)})]})]},l)):null})]})})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(ei.Z,{className:"mr-4 mb-5",onClick:()=>f(!0),children:"+ Add admin"}),(0,a.jsx)(ey.Z,{title:"Add admin",visible:y,width:800,footer:null,onOk:()=>{f(!1),i.resetFields()},onCancel:()=>{f(!1),i.resetFields()},children:I(F)}),(0,a.jsx)(ei.Z,{className:"mb-5",onClick:()=>g(!0),children:"+ Add viewer"}),(0,a.jsx)(ey.Z,{title:"Add viewer",visible:j,width:800,footer:null,onOk:()=>{g(!1),i.resetFields()},onCancel:()=>{g(!1),i.resetFields()},children:I(P)})]})})]}),(0,a.jsxs)(eo.Z,{children:[(0,a.jsx)(c,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(ei.Z,{onClick:()=>b(!0),children:"Add SSO"}),(0,a.jsx)(ey.Z,{title:"Add SSO",visible:w,width:800,footer:null,onOk:()=>{b(!1),o.resetFields()},onCancel:()=>{b(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{F(e),O(e),b(!1),v(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(ef.Z.Password,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(ef.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(ey.Z,{title:"SSO Setup Instructions",visible:k,width:800,footer:null,onOk:S,onCancel:()=>{v(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{onClick:S,children:"Done"})})]})]}),(0,a.jsxs)(lr.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},lf=t(42556),lZ=e=>{let{alertingSettings:l,handleInputChange:t,handleResetField:s,handleSubmit:r,premiumUser:n}=e,[o]=eg.Z.useForm();return(0,a.jsxs)(eg.Z,{form:o,onFinish:()=>{let e=o.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):r(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{align:"center",children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?n?(0,a.jsx)(eg.Z.Item,{name:e.field_name,children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l)}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}):(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(eg.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l),className:"p-0"}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>s(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update Settings"})})]})},l_=e=>{let{accessToken:l,premiumUser:t}=e,[s,r]=(0,n.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,n.useEffect)(()=>{l&&f(l).then(e=>{r(e)})},[l]),(0,a.jsx)(lZ,{alertingSettings:s,handleInputChange:(e,l)=>{r(s.map(t=>t.field_name===e?{...t,field_value:l}:t))},handleResetField:(e,t)=>{if(l)try{let l=s.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),r(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let t={};s.forEach(e=>{t[e.field_name]=e.field_value});let r={...e,...t};try{et(l,"alerting_args",r),h.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:t})};let lw=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var lb=e=>{let{accessToken:l,userRole:t,userID:s,premiumUser:r}=e,[o,i]=(0,n.useState)(lw),[c,d]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[x]=eg.Z.useForm(),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,Z]=(0,n.useState)(""),[_,w]=(0,n.useState)({}),[b,k]=(0,n.useState)([]),v=e=>{b.includes(e)?k(b.filter(l=>l!==e)):k([...b,e])},S={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,n.useEffect)(()=>{l&&t&&s&&ee(l,s,t).then(e=>{console.log("callbacks",e);let l=lw;i(l=l.map(l=>{let t=e.callbacks.find(e=>e.name===l.name);return t?{...l,variables:{...l.variables,...t.variables}}:l}));let t=e.alerts;if(console.log("alerts_data",t),t&&t.length>0){let e=t[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),k(e.active_alerts),Z(l),w(e.alerts_to_webhook)}d(t)})},[l,t,s]);let N=e=>b&&b.includes(e),A=e=>{if(!l)return;let t=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[t,s]=e;return[t,(null===(l=document.querySelector('input[name="'.concat(t,'"]')))||void 0===l?void 0:l.value)||s]}));console.log("updatedVariables",t),console.log("updateAlertTypes",g);let s={environment_variables:t,litellm_settings:{success_callback:[e.name]}};try{er(l,s)}catch(e){h.ZP.error("Failed to update callback: "+e,20)}h.ZP.success("Callback updated successfully")},E=()=>{l&&x.validateFields().then(e=>{if(console.log("Form values:",e),"langfuse"===e.callback){er(l,{environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),er(l,{general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}}),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),er(l,{environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};i(o?[...o,t]:[t])}u(!1),x.resetFields(),j(null)})};return l?(console.log("callbacks: ".concat(o)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(lr.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Settings"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Callback"}),(0,a.jsx)(eF.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(eC.Z,{children:o.filter(e=>"slack"!==e.name).map((e,t)=>{var s;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eN.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).filter(l=>{let[t,s]=l;return t.toLowerCase().includes(e.name)}).map(e=>{let[l,t]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(eu.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(ec.Z,{name:l,defaultValue:t,type:"password"})]},l)})}),(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(e),children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,e.name),className:"mx-2",children:"Test Callback"})]})]},t)})})]})})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eu.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(S).map((e,l)=>{let[t,s]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:"region_outage_alerts"==t?r?(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)}):(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:t,type:"password",defaultValue:_&&_[t]?_[t]:f})})]},l)})})]}),(0,a.jsx)(ei.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(S).forEach(l=>{let[t,s]=l,r=document.querySelector('input[name="'.concat(t,'"]'));console.log("key",t),console.log("webhookInput",r);let a=(null==r?void 0:r.value)||"";console.log("newWebhookValue",a),e[t]=a}),console.log("updatedAlertToWebhooks",e);let t={general_settings:{alert_to_webhook_url:e,alert_types:b}};console.log("payload",t);try{er(l,t)}catch(e){h.ZP.error("Failed to update alerts: "+e,20)}h.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(l_,{accessToken:l,premiumUser:r})})]})]})]}),(0,a.jsx)(ey.Z,{title:"Add Callback",visible:m,onOk:E,width:800,onCancel:()=>{u(!1),x.resetFields(),j(null)},footer:null,children:(0,a.jsxs)(eg.Z,{form:x,layout:"vertical",onFinish:E,children:[(0,a.jsx)(eg.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(ej.default,{onChange:e=>{j(e)},children:[(0,a.jsx)(ej.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(ej.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(ec.Z,{type:"password"})}),(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})]}),"openmeter"==p&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eg.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:lk}=ej.default;var lv=e=>{let{models:l,accessToken:t,routerSettings:s,setRouterSettings:r}=e,[o]=eg.Z.useForm(),[i,c]=(0,n.useState)(!1),[d,m]=(0,n.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>c(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(ey.Z,{title:"Add Fallbacks",visible:i,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,n=[...s.fallbacks||[],{[l]:a}],i={...s,fallbacks:n};console.log(i);try{er(t,{router_settings:i}),r(i)}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully"),c(!1),o.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(eR.Z,{defaultValue:d,children:l&&l.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(e0.Z,{value:l,children:l&&l.filter(e=>e!=d).map(e=>(0,a.jsx)(e1.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lS=t(12968);async function lN(e,l){console.log("isLocal:",!1);let t=window.location.origin,s=new lS.ZP.OpenAI({apiKey:l,baseURL:t,dangerouslyAllowBrowser:!0});try{let l=await s.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});h.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lA={ttl:3600,lowest_latency_buffer:0},lE=e=>{let{selectedStrategy:l,strategyArgs:t,paramExplanation:s}=e;return(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(em.Z,{children:"latency-based-routing"==l?(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(t).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:s[l]})]}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]})}):(0,a.jsx)(eu.Z,{children:"No specific settings"})})]})};var lI=e=>{let{accessToken:l,userRole:t,userID:s,modelData:r}=e,[o,i]=(0,n.useState)({}),[c,d]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1),[j]=eg.Z.useForm(),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)(null),b={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,n.useEffect)(()=>{l&&t&&s&&(ee(l,s,t).then(e=>{console.log("callbacks",e),i(e.router_settings)}),el(l).then(e=>{u(e)}))},[l,t,s]);let k=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(o.fallbacks)),o.fallbacks.map(l=>(e in l&&delete l[e],l));try{await er(l,{router_settings:o}),i({...o}),Z(o.routing_strategy),h.ZP.success("Router settings updated successfully")}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}}},v=(e,l)=>{u(m.map(t=>t.field_name===e?{...t,field_value:l}:t))},S=(e,t)=>{if(!l)return;let s=m[t].field_value;if(null!=s&&void 0!=s)try{et(l,e,s);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(t)}catch(e){}},N=(e,t)=>{if(l)try{es(l,e);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(t)}catch(e){}},A=e=>{if(!l)return;console.log("router_settings",e);let t=Object.fromEntries(Object.entries(e).map(e=>{let[l,t]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var s;return[l,(null===(s=document.querySelector('input[name="'.concat(l,'"]')))||void 0===s?void 0:s.value)||t]}if("routing_strategy"==l)return[l,f];if("routing_strategy_args"==l&&"latency-based-routing"==f){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),t=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==t?void 0:t.value)&&(e.ttl=Number(t.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",t);try{er(l,{router_settings:t})}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eY.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eY.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(ex.Z,{children:"Router Settings"}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(o).filter(e=>{let[l,t]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:b[l]})]}),(0,a.jsx)(eT.Z,{children:"routing_strategy"==l?(0,a.jsxs)(eR.Z,{defaultValue:t,className:"w-full max-w-md",onValueChange:Z,children:[(0,a.jsx)(eM.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(eM.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(eM.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]}),(0,a.jsx)(lE,{selectedStrategy:f,strategyArgs:o&&o.routing_strategy_args&&Object.keys(o.routing_strategy_args).length>0?o.routing_strategy_args:lA,paramExplanation:b})]}),(0,a.jsx)(en.Z,{children:(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(o),children:"Save Changes"})})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Model Name"}),(0,a.jsx)(eF.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(eC.Z,{children:o.fallbacks&&o.fallbacks.map((e,t)=>Object.entries(e).map(e=>{let[s,r]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:s}),(0,a.jsx)(eT.Z,{children:Array.isArray(r)?r.join(", "):r}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{onClick:()=>lN(s,l),children:"Test Fallback"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>k(s)})})]},t.toString()+s)}))})]}),(0,a.jsx)(lv,{models:(null==r?void 0:r.data)?r.data.map(e=>e.model_name):[],accessToken:l,routerSettings:o,setRouterSettings:i})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"}),(0,a.jsx)(eF.Z,{children:"Status"}),(0,a.jsx)(eF.Z,{children:"Action"})]})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(eT.Z,{children:"Integer"==e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>v(e.field_name,l)}):null}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(ei.Z,{onClick:()=>S(e.field_name,l),children:"Update"}),(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>N(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lC=e=>{let{isModalVisible:l,accessToken:t,setIsModalVisible:s,setBudgetList:r}=e,[n]=eg.Z.useForm(),o=async e=>{if(null!=t&&void 0!=t)try{h.ZP.info("Making API Call");let l=await y(t,e);console.log("key create Response:",l),r(e=>e?[...e,l]:[l]),h.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(ey.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{s(!1),n.resetFields()},onCancel:()=>{s(!1),n.resetFields()},children:(0,a.jsxs)(eg.Z,{form:n,onFinish:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lT=t(67951),lP=e=>{let{accessToken:l}=e,[t,s]=(0,n.useState)(!1),[r,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&Q(l).then(e=>{o(e)})},[l]);let i=async(e,t)=>{if(null==l)return;h.ZP.info("Request made"),await g(l,e);let s=[...r];s.splice(t,1),o(s),h.ZP.success("Budget Deleted.")};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(ei.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>s(!0),children:"+ Create Budget"}),(0,a.jsx)(lC,{accessToken:l,isModalVisible:t,setIsModalVisible:s,setBudgetList:o}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Budget ID"}),(0,a.jsx)(eF.Z,{children:"Max Budget"}),(0,a.jsx)(eF.Z,{children:"TPM"}),(0,a.jsx)(eF.Z,{children:"RPM"})]})}),(0,a.jsx)(eC.Z,{children:r.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.budget_id}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(eT.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(eT.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>i(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(eu.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eY.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eY.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{var l;let{userID:t,userRole:s,token:r,accessToken:o,keys:i,premiumUser:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);(0,n.useEffect)(()=>{o&&r&&s&&t&&(async()=>{try{let e=await A(o,t,s);console.log("ModelHubData:",e),m(e.data)}catch(e){console.error("There was an error fetching the model data",e)}})()},[o,r,s,t]);let j=e=>{p(e),u(!0)},g=e=>{navigator.clipboard.writeText(e)};return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)("div",{className:"relative w-full"}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(ex.Z,{className:"ml-8 text-center ",children:"Model Hub"}),(0,a.jsx)(ei.Z,{className:"ml-4",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4",children:d&&d.map(e=>(0,a.jsxs)(eA.Z,{className:"mt-5 mx-8",children:[(0,a.jsxs)("pre",{className:"flex justify-between",children:[(0,a.jsx)(ex.Z,{children:e.model_group}),(0,a.jsx)(e3.Z,{title:e.model_group,children:(0,a.jsx)(lF.Z,{onClick:()=>g(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,a.jsxs)("div",{className:"my-5",children:[(0,a.jsxs)(eu.Z,{children:["Mode: ",e.mode]}),(0,a.jsxs)(eu.Z,{children:["Supports Function Calling: ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Supports Vision: ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Max Input Tokens: ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,a.jsxs)(eu.Z,{children:["Max Output Tokens: ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,a.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,a.jsxs)("a",{href:"#",onClick:()=>j(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,a.jsx)(lO.Z,{})]})})]},e.model_group))})]}),(0,a.jsx)(ey.Z,{title:x&&x.model_group?x.model_group:"Unknown Model",width:800,visible:h,footer:null,onOk:()=>{u(!1),p(null)},onCancel:()=>{u(!1),p(null)},children:x&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-4",children:(0,a.jsx)("strong",{children:"Model Information & Usage"})}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"Supported OpenAI Params"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(x.model_group,'", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:"".concat(null===(l=x.supported_openai_params)||void 0===l?void 0:l.map(e=>"".concat(e,"\n")).join(""))})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="'.concat(x.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "'.concat(x.model_group,'",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})]})},lM=e=>{let{}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(eu.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n '})})]})]})]})})})};async function lL(e,l,t,s){console.log("isLocal:",!1);let r=window.location.origin,a=new lS.ZP.OpenAI({apiKey:s,baseURL:r,dangerouslyAllowBrowser:!0});try{for await(let s of(await a.chat.completions.create({model:t,stream:!0,messages:[{role:"user",content:e}]})))console.log(s),s.choices[0].delta.content&&l(s.choices[0].delta.content)}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lU=e=>{let{accessToken:l,token:t,userRole:s,userID:r}=e,[o,i]=(0,n.useState)(""),[c,d]=(0,n.useState)(""),[m,h]=(0,n.useState)([]),[u,x]=(0,n.useState)(void 0),[p,j]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{let e=await P(l,r,s);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));console.log(l),j(l),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,r,s]);let g=(e,l)=>{h(t=>{let s=t[t.length-1];return s&&s.role===e?[...t.slice(0,t.length-1),{role:e,content:s.content+l}]:[...t,{role:e,content:l}]})},y=async()=>{if(""!==c.trim()&&o&&t&&s&&r){h(e=>[...e,{role:"user",content:c}]);try{u&&await lL(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsx)(e$.Z,{children:(0,a.jsx)(eY.Z,{children:"Chat"})}),(0,a.jsx)(eQ.Z,{children:(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"API Key"}),(0,a.jsx)(ec.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,a.jsxs)(en.Z,{className:"mx-2",children:[(0,a.jsx)(eu.Z,{children:"Select Model:"}),(0,a.jsx)(ej.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,a.jsxs)(eI.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{})})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(ec.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,a.jsx)(ei.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]})})]})})})})},lD=t(33509),lB=t(95781);let{Sider:lz}=lD.default;var lK=e=>{let{setPage:l,userRole:t,defaultSelectedKey:s}=e;return"Admin Viewer"==t?(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(lz,{width:120,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(lz,{width:145,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(eu.Z,{children:"API Keys"})},"1"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(eu.Z,{children:"Test Key"})},"3"),"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(eu.Z,{children:"Models"})},"2"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(eu.Z,{children:"Usage"})},"4"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(eu.Z,{children:"Teams"})},"6"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(eu.Z,{children:"Users"})},"5"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(eu.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(eu.Z,{children:"Rate Limits"})},"9"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(eu.Z,{children:"Router Settings"})},"10"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(eu.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(eu.Z,{children:"API Reference"})},"12"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(eu.Z,{children:"Model Hub"})},"14")]})})})},lG=t(67989),lq=t(49167),lV=t(52703),lW=e=>{let{accessToken:l,token:t,userRole:s,userID:r,keys:o,premiumUser:i}=e,c=new Date,[d,m]=(0,n.useState)([]),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)([]),[j,g]=(0,n.useState)([]),[y,f]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[w,b]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)({}),[I,C]=(0,n.useState)([]),[T,P]=(0,n.useState)(""),[q,V]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),W=new Date(c.getFullYear(),c.getMonth(),1),H=new Date(c.getFullYear(),c.getMonth()+1,0),Y=Q(W),J=Q(H);console.log("keys in usage",o),console.log("premium user in usage",i);let $=async(e,t,s)=>{if(!e||!t||!l)return;t.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",s);let r=await U(l,s,e.toISOString(),t.toISOString());console.log("End user data updated successfully",r),g(r)},X=async(e,t)=>{e&&t&&l&&(t.setHours(23,59,59,999),e.setHours(0,0,0,0),_((await O(l,e.toISOString(),t.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function Q(e){let l=e.getFullYear(),t=e.getMonth()+1,s=e.getDate();return"".concat(l,"-").concat(t<10?"0"+t:t,"-").concat(s<10?"0"+s:s)}return console.log("Start date is ".concat(Y)),console.log("End date is ".concat(J)),(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{if(console.log("user role: ".concat(s)),"Admin"==s||"Admin Viewer"==s){var e,a;let s=await M(l);m(s);let r=await D(l,t,Y,J);console.log("provider_spend",r),N(r);let n=(await L(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));u(n);let o=(await K(l)).map(e=>({key:e.model,spend:e.total_spend}));p(o);let i=await F(l);console.log("teamSpend",i),f(i.daily_spend),b(i.teams);let c=i.total_spend_per_team;c=c.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),v(c);let d=await O(l,null===(e=q.from)||void 0===e?void 0:e.toISOString(),null===(a=q.to)||void 0===a?void 0:a.toISOString());_(d.spend_per_tag);let h=await U(l,null,void 0,void 0);g(h),console.log("spend/user result",h);let x=await B(l,Y,J);E(x);let j=await z(l,Y,J);console.log("global activity per model",j),C(j)}else"App Owner"==s&&await R(l,t,s,r,Y,J).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let t=e.top_api_keys;u(t)}else{let t=(await G(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[t,s]=e;"spend"!==t&&"startTime"!==t&&"models"!==t&&"users"!==t&&l.push({key:t,spend:s})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let t=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(t[0]))),t}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));u(t),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,t,s,r,Y,J]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(ez,{userID:r,userRole:s,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{className:"mt-2",children:[(0,a.jsx)(eY.Z,{children:"All Up"}),(0,a.jsx)(eY.Z,{children:"Team Based Usage"}),(0,a.jsx)(eY.Z,{children:"End User Usage"}),(0,a.jsx)(eY.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eY.Z,{children:"Cost"}),(0,a.jsx)(eY.Z,{children:"Activity"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Monthly Spend"}),(0,a.jsx)(e4.Z,{data:d,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top API Keys"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top Models"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:x,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1}),(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"✨ Spend by Provider"}),i?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(lV.Z,{className:"mt-4 h-40",variant:"pie",data:S,index:"provider",category:"spend"})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Provider"}),(0,a.jsx)(eF.Z,{children:"Spend"})]})}),(0,a.jsx)(eC.Z,{children:S.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.provider}),(0,a.jsx)(eT.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"All Up"}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",A.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",A.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),i?(0,a.jsx)(a.Fragment,{children:I.map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:I&&I.length>0&&I.slice(0,1).map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lG.Z,{data:k})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(e4.Z,{className:"h-72",data:y,showLegend:!0,index:"date",categories:w,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:q,onValueChange:e=>{V(e),$(e.from,e.to,null)}})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Key"}),(0,a.jsxs)(eR.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(eM.Z,{value:"all-keys",onClick:()=>{$(q.from,q.to,null)},children:"All Keys"},"all-keys"),null==o?void 0:o.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{$(q.from,q.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(eA.Z,{className:"mt-4",children:(0,a.jsxs)(eI.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"End User"}),(0,a.jsx)(eF.Z,{children:"Spend"}),(0,a.jsx)(eF.Z,{children:"Total Events"})]})}),(0,a.jsx)(eC.Z,{children:null==j?void 0:j.map((e,l)=>{var t;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.end_user}),(0,a.jsx)(eT.Z,{children:null===(t=e.total_spend)||void 0===t?void 0:t.toFixed(4)}),(0,a.jsx)(eT.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsx)(eH.Z,{className:"mb-4",enableSelect:!0,value:q,onValueChange:e=>{V(e),X(e.from,e.to)}}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(eu.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(e4.Z,{className:"h-72",data:Z,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})})]})]})]})},lH=()=>{let{Title:e,Paragraph:l}=eV.default,[t,s]=(0,n.useState)(""),[r,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!0),y=(0,o.useSearchParams)(),[f,Z]=(0,n.useState)({data:[]}),_=y.get("userID"),w=y.get("token"),[b,k]=(0,n.useState)("api-keys"),[v,S]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(w){let e=(0,eq.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),S(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),s(l),"Admin Viewer"==l&&k("usage")}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&i(e.premium_user)}}},[w]),(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:_,userRole:t,userEmail:c,showSSOBanner:j,premiumUser:r}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lK,{setPage:k,userRole:t,defaultSelectedKey:null})}),"api-keys"==b?(0,a.jsx)(eW,{userID:_,userRole:t,teams:h,keys:x,setUserRole:s,userEmail:c,setUserEmail:d,setTeams:u,setKeys:p}):"models"==b?(0,a.jsx)(lu,{userID:_,userRole:t,token:w,accessToken:v,modelData:f,setModelData:Z,premiumUser:r}):"llm-playground"==b?(0,a.jsx)(lU,{userID:_,userRole:t,token:w,accessToken:v}):"users"==b?(0,a.jsx)(lj,{userID:_,userRole:t,token:w,keys:x,teams:h,accessToken:v,setKeys:p}):"teams"==b?(0,a.jsx)(lg,{teams:h,setTeams:u,searchParams:y,accessToken:v,userID:_,userRole:t}):"admin-panel"==b?(0,a.jsx)(ly,{setTeams:u,searchParams:y,accessToken:v,showSSOBanner:j}):"api_ref"==b?(0,a.jsx)(lM,{}):"settings"==b?(0,a.jsx)(lb,{userID:_,userRole:t,accessToken:v,premiumUser:r}):"budgets"==b?(0,a.jsx)(lP,{accessToken:v}):"general-settings"==b?(0,a.jsx)(lI,{userID:_,userRole:t,accessToken:v,modelData:f}):"model-hub"==b?(0,a.jsx)(lR,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r}):(0,a.jsx)(lW,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r})]})]})})}}},function(e){e.O(0,[936,608,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/index.html b/litellm/proxy/_experimental/out/index.html index 963865a00..54a25805a 100644 --- a/litellm/proxy/_experimental/out/index.html +++ b/litellm/proxy/_experimental/out/index.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/index.txt b/litellm/proxy/_experimental/out/index.txt index 730ddfbc2..fbe813922 100644 --- a/litellm/proxy/_experimental/out/index.txt +++ b/litellm/proxy/_experimental/out/index.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[39712,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","608","static/chunks/608-d128caa3cfe973c1.js","931","static/chunks/app/page-2421e763699a7dc4.js"],""] +3:I[39712,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","608","static/chunks/608-d128caa3cfe973c1.js","931","static/chunks/app/page-76d278f96a0e9768.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["N-Poqi-YBhDAzJSVSMX3L",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/5d93d4a9fa59d72f.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["D_ZUmMtLMPSa4aQQUJtKt",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/5d93d4a9fa59d72f.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null diff --git a/ui/litellm-dashboard/out/404.html b/ui/litellm-dashboard/out/404.html index dca0b9a75..14787d256 100644 --- a/ui/litellm-dashboard/out/404.html +++ b/ui/litellm-dashboard/out/404.html @@ -1 +1 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file diff --git a/ui/litellm-dashboard/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_buildManifest.js b/ui/litellm-dashboard/out/_next/static/D_ZUmMtLMPSa4aQQUJtKt/_buildManifest.js similarity index 100% rename from ui/litellm-dashboard/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_buildManifest.js rename to ui/litellm-dashboard/out/_next/static/D_ZUmMtLMPSa4aQQUJtKt/_buildManifest.js diff --git a/ui/litellm-dashboard/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_ssgManifest.js b/ui/litellm-dashboard/out/_next/static/D_ZUmMtLMPSa4aQQUJtKt/_ssgManifest.js similarity index 100% rename from ui/litellm-dashboard/out/_next/static/N-Poqi-YBhDAzJSVSMX3L/_ssgManifest.js rename to ui/litellm-dashboard/out/_next/static/D_ZUmMtLMPSa4aQQUJtKt/_ssgManifest.js diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/page-2421e763699a7dc4.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-76d278f96a0e9768.js similarity index 84% rename from ui/litellm-dashboard/out/_next/static/chunks/app/page-2421e763699a7dc4.js rename to ui/litellm-dashboard/out/_next/static/chunks/app/page-76d278f96a0e9768.js index ce8149624..e673e3c21 100644 --- a/ui/litellm-dashboard/out/_next/static/chunks/app/page-2421e763699a7dc4.js +++ b/ui/litellm-dashboard/out/_next/static/chunks/app/page-76d278f96a0e9768.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,t){Promise.resolve().then(t.bind(t,39712))},39712:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return lH}});var s,r,a=t(3827),n=t(64090),o=t(47907),i=t(8792),c=t(40491),d=t(65270),m=e=>{let{userID:l,userRole:t,userEmail:s,showSSOBanner:r,premiumUser:n}=e;console.log("User ID:",l),console.log("userEmail:",s),console.log("showSSOBanner:",r),console.log("premiumUser:",n);let o=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",t]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(i.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[r?(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(c.Z,{menu:{items:o},children:(0,a.jsx)(d.Z,{children:s})})})]})]})},h=t(80588);let u=async()=>{try{let e=await fetch("https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"),l=await e.json();return console.log("received data: ".concat(l)),l}catch(e){throw console.error("Failed to get model cost map:",e),e}},x=async(e,l)=>{try{let t=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),s}catch(e){throw console.error("Failed to create key:",e),e}},p=async e=>{try{let l=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},j=async(e,l)=>{console.log("model_id in model delete call: ".concat(l));try{let t=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model deleted successfully. Restart server to see this."),s}catch(e){throw console.error("Failed to create key:",e),e}},g=async(e,l)=>{if(console.log("budget_id in budget delete call: ".concat(l)),null!=e)try{let t=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,l)=>{try{console.log("Form Values in budgetCreateCall:",l),console.log("Form Values after check:",l);let t=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},f=async e=>{try{let l=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},Z=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,l)=>{try{console.log("in keyDeleteCall:",l);let t=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,l)=>{try{console.log("in teamDeleteCall:",l);let t=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,l,t){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;try{let n="/user/info";"App Owner"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),"App User"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),console.log("in userInfoCall viewAll=",s),s&&a&&null!=r&&void 0!=r&&(n="".concat(n,"?view_all=true&page=").concat(r,"&page_size=").concat(a));let o=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let i=await o.json();return console.log("API Response:",i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,l)=>{try{let t="/team/info";l&&(t="".concat(t,"?team_id=").concat(l)),console.log("in teamInfoCall");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},S=async e=>{try{let l=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,l,t)=>{try{let l=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelInfoCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,l,t)=>{try{let l=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelHubCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,l,t,s,r,a)=>{try{let l="/model/metrics";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},I=async(e,l,t,s)=>{try{let r="/model/streaming_metrics";l&&(r="".concat(r,"?_selected_model_group=").concat(l,"&startTime=").concat(t,"&endTime=").concat(s));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},C=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/slow_responses";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/exceptions";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,l,t)=>{try{let l=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},F=async e=>{try{let l="/global/spend/teams";console.log("in teamSpendLogsCall:",l);let t=await fetch("".concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=async(e,l,t)=>{try{let s="/global/spend/tags";l&&t&&(s="".concat(s,"?start_date=").concat(l,"&end_date=").concat(t)),console.log("in tagsSpendLogsCall:",s);let r=await fetch("".concat(s),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},R=async(e,l,t,s,r,a)=>{try{console.log("user role in spend logs call: ".concat(t));let l="/spend/logs";l="App Owner"==t?"".concat(l,"?user_id=").concat(s,"&start_date=").concat(r,"&end_date=").concat(a):"".concat(l,"?start_date=").concat(r,"&end_date=").concat(a);let n=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},M=async e=>{try{let l=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},L=async e=>{try{let l=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,l,t,s)=>{try{let r="";r=l?JSON.stringify({api_key:l,startTime:t,endTime:s}):JSON.stringify({startTime:t,endTime:s});let a={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};a.body=r;let n=await fetch("/global/spend/end_users",a);if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,l,t,s)=>{try{let r="/global/spend/provider";t&&s&&(r+="?start_date=".concat(t,"&end_date=").concat(s)),l&&(r+="&api_key=".concat(l));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log(n),n}catch(e){throw console.error("Failed to fetch spend data:",e),e}},B=async(e,l,t)=>{try{let s="/global/activity";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},z=async(e,l,t)=>{try{let s="/global/activity/model";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},K=async e=>{try{let l=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},G=async(e,l)=>{try{let t=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},q=async(e,l)=>{try{let t="/user/get_users?role=".concat(l);console.log("in userGetAllUsersCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let r=await s.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},V=async(e,l)=>{try{console.log("Form Values in teamCreateCall:",l);let t=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,l)=>{try{console.log("Form Values in keyUpdateCall:",l);let t=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},H=async(e,l)=>{try{console.log("Form Values in teamUpateCall:",l);let t=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},Y=async(e,l)=>{try{console.log("Form Values in modelUpateCall:",l);let t=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update model Response:",s),s}catch(e){throw console.error("Failed to update model:",e),e}},J=async(e,l,t)=>{try{console.log("Form Values in teamMemberAddCall:",t);let s=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:l,member:t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},$=async(e,l,t)=>{try{console.log("Form Values in userUpdateUserCall:",l);let s={...l};null!==t&&(s.user_role=t),s=JSON.stringify(s);let r=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:s});if(!r.ok){let e=await r.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await r.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,l)=>{try{let t="/health/services?service=".concat(l);console.log("Checking Slack Budget Alerts service health");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed ".concat(l," service health check ")+e),Error(e)}let r=await s.json();return h.ZP.success("Test request to ".concat(l," made - check logs/alerts on ").concat(l," to verify")),r}catch(e){throw console.error("Failed to perform health check:",e),e}},Q=async e=>{try{let l=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async(e,l,t)=>{try{let l=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},el=async e=>{try{let l=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,l,t)=>{try{let s=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,field_value:t,config_type:"general_settings"})});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return h.ZP.success("Successfully updated value!"),r}catch(e){throw console.error("Failed to set callbacks:",e),e}},es=async(e,l)=>{try{let t=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,config_type:"general_settings"})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return h.ZP.success("Field reset on proxy"),s}catch(e){throw console.error("Failed to get callbacks:",e),e}},er=async(e,l)=>{try{let t=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},ea=async e=>{try{let l=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to call /health:",e),e}};var en=t(10384),eo=t(46453),ei=t(16450),ec=t(52273),ed=t(26780),em=t(15595),eh=t(6698),eu=t(71801),ex=t(42440),ep=t(42308),ej=t(50670),eg=t(81583),ey=t(99129),ef=t(44839),eZ=t(88707),e_=t(1861);let{Option:ew}=ej.default;var eb=e=>{let{userID:l,team:t,userRole:s,accessToken:r,data:o,setData:i}=e,[c]=eg.Z.useForm(),[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(null),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,_]=(0,n.useState)([]),w=()=>{m(!1),c.resetFields()},b=()=>{m(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==r){let e=(await P(r,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,s]);let k=async e=>{try{var t,s,a;let n=null!==(t=null==e?void 0:e.key_alias)&&void 0!==t?t:"",d=null!==(s=null==e?void 0:e.team_id)&&void 0!==s?s:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===d).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(n))throw Error("Key alias ".concat(n," already exists for team with ID ").concat(d,", please provide another key alias"));h.ZP.info("Making API Call"),m(!0);let u=await Z(r,l,e);console.log("key create Response:",u),i(e=>e?[...e,u]:[u]),x(u.key),j(u.soft_budget),h.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.useEffect)(()=>{_(t&&t.models.length>0?t.models.includes("all-proxy-models")?g:t.models:g)},[t,g]),(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(ey.Z,{title:"Create Key",visible:d,width:800,footer:null,onOk:w,onCancel:b,children:(0,a.jsxs)(eg.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:t?t.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t?t.team_alias:"",disabled:!0})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(ew,{value:"all-team-models",children:"All Team Models"},"all-team-models"),f.map(e=>(0,a.jsx)(ew,{value:e,children:e},e))]})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==t?void 0:t.max_budget)!==null&&(null==t?void 0:t.max_budget)!==void 0?null==t?void 0:t.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.max_budget&&l>t.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(t.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==t?void 0:t.budget_duration)!==null&&(null==t?void 0:t.budget_duration)!==void 0?null==t?void 0:t.budget_duration:"None"),children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==t?void 0:t.tpm_limit)!==null&&(null==t?void 0:t.tpm_limit)!==void 0?null==t?void 0:t.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.tpm_limit&&l>t.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(t.tpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==t?void 0:t.rpm_limit)!==null&&(null==t?void 0:t.rpm_limit)!==void 0?null==t?void 0:t.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.rpm_limit&&l>t.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(t.rpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Key"})})]})}),u&&(0,a.jsx)(ey.Z,{visible:d,onOk:w,onCancel:b,footer:null,children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Save your Key"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:null!=u?(0,a.jsxs)("div",{children:[(0,a.jsx)(eu.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:u})}),(0,a.jsx)(ep.CopyToClipboard,{text:u,onCopy:()=>{h.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(ei.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(eu.Z,{children:"Key being created, this might take 30s"})})]})})]})},ek=t(9454),ev=t(98941),eS=t(33393),eN=t(5),eA=t(13810),eE=t(61244),eI=t(10827),eC=t(3851),eT=t(2044),eP=t(64167),eF=t(74480),eO=t(7178),eR=t(95093),eM=t(27166);let{Option:eL}=ej.default;var eU=e=>{let{userID:l,userRole:t,accessToken:s,selectedTeam:r,data:o,setData:i,teams:c}=e,[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(!1),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(""),[k,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(!1),[A,E]=(0,n.useState)(null),[I,C]=(0,n.useState)([]),T=new Set,[F,O]=(0,n.useState)(T);(0,n.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==s&&null!==t){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),C(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[s,l,t]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,t)=>{let s=l.team_id;e.add(s)}),O(e)}},[c]);let R=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),E(e),v(!0)},M=async e=>{if(null==s)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let t=await W(s,e);console.log("handleEditSubmit: newKeyValues",t),o&&i(o.map(e=>e.token===l?t:e)),h.ZP.success("Key updated successfully"),v(!1),E(null)},L=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+l),x(!0))},U=async()=>{if(null!=p&&null!=o){try{await w(s,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(eI.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Key Alias"}),(0,a.jsx)(eF.Z,{children:"Secret Key"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(eC.Z,{children:o.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(r){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(F.has(e.team_id),", selectedTeam id: ").concat(r.team_id)),(null!=r.team_id||null===e.team_id||F.has(e.team_id))&&e.team_id!=r.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(eu.Z,{children:e.key_alias}):(0,a.jsx)(eu.Z,{children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:e.key_name})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(eT.Z,{children:null!=e.max_budget?(0,a.jsx)(eu.Z,{children:e.max_budget}):(0,a.jsx)(eu.Z,{children:"Unlimited"})}),(0,a.jsx)(eT.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:r&&r.models&&r.models.length>0?r.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{onClick:()=>{E(e),N(!0)},icon:ek.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:S,onCancel:()=>{N(!1),E(null)},footer:null,width:800,children:A&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(A.spend).toFixed(4)}catch(e){return A.spend}})()})})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.max_budget?(0,a.jsx)(a.Fragment,{children:A.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.expires?(0,a.jsx)(a.Fragment,{children:new Date(A.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(eA.Z,{className:"my-4",children:[(0,a.jsx)(ex.Z,{children:"Token Name"}),(0,a.jsx)(eu.Z,{className:"my-1",children:A.key_alias?A.key_alias:A.key_name}),(0,a.jsx)(ex.Z,{children:"Token ID"}),(0,a.jsx)(eu.Z,{className:"my-1 text-[12px]",children:A.token}),(0,a.jsx)(ex.Z,{children:"Metadata"}),(0,a.jsx)(eu.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(A.metadata)," "]})})]}),(0,a.jsx)(ei.Z,{className:"mx-auto flex items-center",onClick:()=>{N(!1),E(null)},children:"Close"})]})}),(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>R(e)}),(0,a.jsx)(eE.Z,{onClick:()=>L(e),icon:eS.Z,size:"sm"})]})]},e.token)})})]}),u&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{x(!1),j(null)},children:"Cancel"})]})]})]})})]}),A&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,token:s,onSubmit:o}=e,[i]=eg.Z.useForm(),[d,m]=(0,n.useState)(r),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1);return(0,a.jsx)(ey.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:i,onFinish:M,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let t=l.filter(e=>!d.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!d.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(t)),t.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(t,"Team models: ").concat(d.models)):Promise.resolve()}}],children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(eL,{value:"all-team-models",children:"All Team Models"},"all-team-models"),d&&d.models?d.models.includes("all-proxy-models")?I.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):d.models.map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):I.map(e=>(0,a.jsx)(eL,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==d?void 0:d.max_budget)!==null&&(null==d?void 0:d.max_budget)!==void 0?null==d?void 0:d.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&d&&null!==d.max_budget&&l>d.max_budget)throw console.log("keyTeam.max_budget: ".concat(d.max_budget)),Error("Budget cannot exceed team max budget: $".concat(d.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(eg.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(eR.Z,{value:s.team_alias,children:null==c?void 0:c.map((e,l)=>(0,a.jsx)(eM.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:k,onCancel:()=>{v(!1),E(null)},token:A,onSubmit:M})]})},eD=t(76032),eB=t(35152),ez=e=>{let{userID:l,userRole:t,accessToken:s,userSpend:r,selectedTeam:o}=e;console.log("userSpend: ".concat(r));let[i,c]=(0,n.useState)(null!==r?r:0),[d,m]=(0,n.useState)(0),[h,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(s&&l&&t&&"Admin"===t&&null==r)try{let e=await S(s);e&&(e.spend?c(e.spend):c(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(async()=>{try{if(null===l||null===t)return;if(null!==s){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),u(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,s,l]),(0,n.useEffect)(()=>{null!==r&&c(r)},[r]);let x=[];o&&o.models&&(x=o.models),x&&x.includes("all-proxy-models")?(console.log("user models:",h),x=h):x&&x.includes("all-team-models")?x=o.models:x&&0===x.length&&(x=h);let p=void 0!==i?i.toFixed(4):null;return console.log("spend in view user spend: ".concat(i)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:["Total Spend"," "]}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",p]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Team Models"})}),(0,a.jsx)(em.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(eD.Z,{children:x.map(e=>(0,a.jsx)(eB.Z,{children:(0,a.jsx)(eu.Z,{children:e})},e))})})]})})]})},eK=e=>{let{userID:l,userRole:t,selectedTeam:s,accessToken:r}=e,[o,i]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==r){let e=(await P(r,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),i(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,t]);let c=[];return s&&s.models&&(c=s.models),c&&c.includes("all-proxy-models")&&(console.log("user models:",o),c=o),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"mb-5",children:(0,a.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==s?void 0:s.team_alias})})})},eG=e=>{let l,{teams:t,setSelectedTeam:s,userRole:r}=e,o={models:[],team_id:null,team_alias:"Default Team"},[i,c]=(0,n.useState)(o);return(l="App User"===r?t:t?[...t,o]:[o],"App User"===r)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(ex.Z,{children:"Select Team"}),(0,a.jsx)(eu.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(eu.Z,{className:"mt-3 mb-3",children:[(0,a.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>s(e),children:e.team_alias},l))}):(0,a.jsxs)(eu.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},eq=t(37963),eV=t(97482);console.log("isLocal:",!1);var eW=e=>{let{userID:l,userRole:t,teams:s,keys:r,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,n.useState)(null),p=(0,o.useSearchParams)();p.get("viewSpend"),(0,o.useRouter)();let j=p.get("token"),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)([]),b={models:[],team_alias:"Default Team",team_id:null},[v,N]=(0,n.useState)(s?s[0]:b);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(j){let e=(0,eq.o)(j);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),i(l)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&g&&t&&!r&&!u){let e=sessionStorage.getItem("userModels"+l);e?w(JSON.parse(e)):(async()=>{try{let e=await k(g,l,t,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==t){let e=await S(g);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(e.teams);let s=[...e.teams];s.length>0?(console.log("response['teams']: ".concat(s)),N(s[0])):N(b),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let r=(await P(g,l,t)).data.map(e=>e.id);console.log("available_model_names:",r),w(r),console.log("userModels:",_),sessionStorage.setItem("userModels"+l,JSON.stringify(r))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,j,g,r,t]),(0,n.useEffect)(()=>{if(null!==r&&null!=v){let e=0;for(let l of r)v.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===v.team_id&&(e+=l.spend);Z(e)}else if(null!==r){let e=0;for(let l of r)e+=l.spend;Z(e)}},[v]),null==l||null==j){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==g)return null;if(null==t&&i("App Owner"),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",v),console.log("teamSpend: ".concat(f)),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eK,{userID:l,userRole:t,selectedTeam:v||null,accessToken:g}),(0,a.jsx)(ez,{userID:l,userRole:t,accessToken:g,userSpend:f,selectedTeam:v||null}),(0,a.jsx)(eU,{userID:l,userRole:t,accessToken:g,selectedTeam:v||null,data:r,setData:h,teams:s}),(0,a.jsx)(eb,{userID:l,team:v||null,userRole:t,accessToken:g,data:r,setData:h},v?v.team_id:null),(0,a.jsx)(eG,{teams:s,setSelectedTeam:N,userRole:t})]})})})},eH=t(35087),eY=t(92836),eJ=t(26734),e$=t(41608),eX=t(32126),eQ=t(23682),e0=t(47047),e1=t(76628),e2=t(25707),e4=t(44041),e5=t(38302),e8=t(28683),e3=t(1460),e6=t(78578),e7=t(63954),e9=t(90252),le=t(7905),ll=e=>{let{modelID:l,accessToken:t}=e,[s,r]=(0,n.useState)(!1),o=async()=>{try{h.ZP.info("Making API Call"),r(!0);let e=await j(t,l);console.log("model delete Response:",e),h.ZP.success("Model ".concat(l," deleted successfully")),r(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(eE.Z,{onClick:()=>r(!0),icon:eS.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:s,onOk:o,okType:"danger",onCancel:()=>r(!1),children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Delete Model"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},lt=t(97766),ls=t(46495),lr=t(18190),la=t(91118),ln=e=>{let{modelMetrics:l,modelMetricsCategories:t,customTooltip:s,premiumUser:r}=e;return r?(0,a.jsx)(la.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:t,colors:["indigo","rose"],connectNulls:!0,customTooltip:s}):(0,a.jsxs)("div",{children:[(0,a.jsx)(lr.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,a.jsx)(ei.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},lo=e=>{let{fields:l,selectedProvider:t}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,a.jsx)(ec.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})};let{Title:li,Link:lc}=eV.default;(s=r||(r={})).OpenAI="OpenAI",s.Azure="Azure",s.Anthropic="Anthropic",s.Google_AI_Studio="Google AI Studio",s.Bedrock="Amazon Bedrock",s.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",s.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",s.Databricks="Databricks";let ld={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},lm={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},lh=async(e,l,t)=>{try{let s=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(s)),console.log("received type of deployments: ".concat(typeof s)),s.forEach(async t=>{console.log("litellm_model: ".concat(t));let s={},r={};s.model=t;let a="";for(let[l,t]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==t){if("model_name"==l)a+=t;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)r[l]=t;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",t);let e={};if(t&&void 0!=t){try{e=JSON.parse(t)}catch(e){throw h.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,t]of Object.entries(e))s[l]=t}}else s[l]=t}let n={model_name:a,litellm_params:s,model_info:r},o=await x(l,n);console.log("response for model create call: ".concat(o.data))}),t.resetFields()}catch(e){h.ZP.error("Failed to create model: "+e,10)}};var lu=e=>{var l,t,s;let o,{accessToken:i,token:c,userRole:d,userID:m,modelData:x={data:[]},setModelData:j,premiumUser:g}=e,[y,f]=(0,n.useState)([]),[Z]=eg.Z.useForm(),[_,w]=(0,n.useState)(null),[b,k]=(0,n.useState)(""),[v,S]=(0,n.useState)([]),A=Object.values(r).filter(e=>isNaN(Number(e))),[P,F]=(0,n.useState)([]),[O,R]=(0,n.useState)("OpenAI"),[M,L]=(0,n.useState)(""),[U,D]=(0,n.useState)(!1),[B,z]=(0,n.useState)(null),[K,G]=(0,n.useState)([]),[q,V]=(0,n.useState)(null),[W,H]=(0,n.useState)([]),[J,$]=(0,n.useState)([]),[X,Q]=(0,n.useState)([]),[el,et]=(0,n.useState)([]),[es,en]=(0,n.useState)([]),[ep,ej]=(0,n.useState)([]),[ef,ew]=(0,n.useState)([]),[eb,ek]=(0,n.useState)([]),[eS,eL]=(0,n.useState)([]),[eU,eD]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eB,ez]=(0,n.useState)(null),[eK,eG]=(0,n.useState)(0),eq=e=>{z(e),D(!0)},eW=async e=>{if(console.log("handleEditSubmit:",e),null==i)return;let l={},t=null;for(let[s,r]of Object.entries(e))"model_id"!==s?l[s]=r:t=r;let s={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",s);try{await Y(i,s),h.ZP.success("Model updated successfully, restart server to see updates"),D(!1),z(null)}catch(e){console.log("Error occurred")}},lr=()=>{k(new Date().toLocaleString())},la=async()=>{if(!i){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eB);try{await er(i,{router_settings:{model_group_retry_policy:eB}}),h.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),h.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!i||!c||!d||!m)return;let e=async()=>{try{var e,l,t,s,r,a,n,o;let c=await p(i);F(c);let h=await N(i,m,d);console.log("Model data response:",h.data),j(h);let u=new Set;for(let e=0;e0&&(g=x[x.length-1],console.log("_initial_model_group:",g),V(g)),console.log("selectedModelGroup:",q);let y=await E(i,m,d,g,null===(e=eU.from)||void 0===e?void 0:e.toISOString(),null===(l=eU.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",y),$(y.data),Q(y.all_api_bases);let f=await I(i,g,null===(t=eU.from)||void 0===t?void 0:t.toISOString(),null===(s=eU.to)||void 0===s?void 0:s.toISOString());et(f.data),en(f.all_api_bases);let Z=await T(i,m,d,g,null===(r=eU.from)||void 0===r?void 0:r.toISOString(),null===(a=eU.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",Z),ej(Z.data),ew(Z.exception_types);let _=await C(i,m,d,g,null===(n=eU.from)||void 0===n?void 0:n.toISOString(),null===(o=eU.to)||void 0===o?void 0:o.toISOString());console.log("slowResponses:",_),eL(_);let w=(await ee(i,m,d)).router_settings;console.log("routerSettingsInfo:",w);let b=w.model_group_retry_policy,k=w.num_retries;console.log("model_group_retry_policy:",b),console.log("default_retries:",k),ez(b),eG(k)}catch(e){console.error("There was an error fetching the model data",e)}};i&&c&&d&&m&&e();let l=async()=>{let e=await u();console.log("received model cost map data: ".concat(Object.keys(e))),w(e)};null==_&&l(),lr()},[i,c,d,m,_,b]),!x||!i||!c||!d||!m)return(0,a.jsx)("div",{children:"Loading..."});let lu=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(_)),null!=_&&"object"==typeof _&&e in _)?_[e].litellm_provider:"openai";if(r){let e=r.split("/"),l=e[0];n=1===e.length?h(r):l}else n="openai";a&&(o=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,c=null==a?void 0:a.max_tokens,d=null==a?void 0:a.max_input_tokens),(null==s?void 0:s.litellm_params)&&(m=Object.fromEntries(Object.entries(null==s?void 0:s.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),x.data[e].provider=n,x.data[e].input_cost=o,x.data[e].output_cost=i,x.data[e].input_cost&&(x.data[e].input_cost=(1e6*Number(x.data[e].input_cost)).toFixed(2)),x.data[e].output_cost&&(x.data[e].output_cost=(1e6*Number(x.data[e].output_cost)).toFixed(2)),x.data[e].max_tokens=c,x.data[e].max_input_tokens=d,x.data[e].api_base=null==s?void 0:null===(t=s.litellm_params)||void 0===t?void 0:t.api_base,x.data[e].cleanedLitellmParams=m,lu.push(s.model_name),console.log(x.data[e])}if(d&&"Admin Viewer"==d){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lx=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(r).find(l=>r[l]===e);if(l){let e=ld[l];console.log("mappingResult: ".concat(e));let t=[];"object"==typeof _&&Object.entries(_).forEach(l=>{let[s,r]=l;null!==r&&"object"==typeof r&&"litellm_provider"in r&&(r.litellm_provider===e||r.litellm_provider.includes(e))&&t.push(s)}),S(t),console.log("providerModels: ".concat(v))}},lp=async()=>{try{h.ZP.info("Running health check..."),L("");let e=await ea(i);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lj=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),i&&m&&d&&l&&t){console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),V(e);try{let s=await E(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model metrics response:",s),$(s.data),Q(s.all_api_bases);let r=await I(i,e,l.toISOString(),t.toISOString());et(r.data),en(r.all_api_bases);let a=await T(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model exceptions response:",a),ej(a.data),ew(a.exception_types);let n=await C(i,m,d,e,l.toISOString(),t.toISOString());console.log("slowResponses:",n),eL(n)}catch(e){console.error("Failed to fetch model metrics",e)}}},lg=e=>{var l,t;let{payload:s,active:r}=e;if(!r||!s)return null;let n=null===(t=s[0])||void 0===t?void 0:null===(l=t.payload)||void 0===l?void 0:l.date,o=s.sort((e,l)=>l.value-e.value);if(o.length>5){let e=o.length-5;(o=o.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:s.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,a.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[n&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),o.map((e,l)=>{let t=parseFloat(e.value.toFixed(5)),s=0===t&&e.value>0?"<0.00001":t.toFixed(5);return(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:s})]},l)})]})};console.log("selectedProvider: ".concat(O)),console.log("providerModels.length: ".concat(v.length));let ly=Object.keys(r).find(e=>r[e]===O);return ly&&(o=P.find(e=>e.name===ld[ly])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eY.Z,{children:"All Models"}),(0,a.jsx)(eY.Z,{children:"Add Model"}),(0,a.jsx)(eY.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eY.Z,{children:"Model Analytics"}),(0,a.jsx)(eY.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[b&&(0,a.jsxs)(eu.Z,{children:["Last Refreshed: ",b]}),(0,a.jsx)(eE.Z,{icon:e7.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lr})]})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],onValueChange:e=>V("all"===e?"all":e),value:q||K[0],children:[(0,a.jsx)(eM.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))]})]}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"Public Model Name"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:"Provider"}),"Admin"===d&&(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"API Base"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:"Extra litellm Params"}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(eF.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:"Max Tokens"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word"},children:"Status"})]})}),(0,a.jsx)(eC.Z,{children:x.data.filter(e=>"all"===q||e.model_name===q||null==q||""===q).map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{children:e.model_name})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.provider}),"Admin"===d&&(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:e.api_base}),(0,a.jsx)(eT.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Litellm params"})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)("pre",{children:JSON.stringify(e.cleanedLitellmParams,null,2)})})]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.input_cost||e.litellm_params.input_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.output_cost||e.litellm_params.output_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)("p",{style:{fontSize:"10px"},children:["Max Tokens: ",e.max_tokens," ",(0,a.jsx)("br",{}),"Max Input Tokens: ",e.max_input_tokens]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(eN.Z,{icon:e9.Z,size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(eN.Z,{icon:le.Z,size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsxs)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>eq(e)}),(0,a.jsx)(ll,{modelID:e.model_info.id,accessToken:i})]})]},l))})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:t,model:s,onSubmit:r}=e,[n]=eg.Z.useForm(),o={},i="",c="";if(s){o=s.litellm_params,i=s.model_name;let e=s.model_info;e&&(c=e.id,console.log("model_id: ".concat(c)),o.model_id=c)}return(0,a.jsx)(ey.Z,{title:"Edit Model "+i,visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r(e),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:eW,initialValues:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:U,onCancel:()=>{D(!1),z(null)},model:B,onSubmit:eW})]}),(0,a.jsxs)(eX.Z,{className:"h-full",children:[(0,a.jsx)(li,{level:2,children:"Add new model"}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eg.Z,{form:Z,onFinish:()=>{Z.validateFields().then(e=>{lh(e,i,Z)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:O.toString(),children:A.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>{lx(e),R(e)},children:e},l))})}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(s=O.toString())?"gemini-pro":"Anthropic"==s?"claude-3-opus":"Amazon Bedrock"==s?"claude-3-opus":"Google AI Studio"==s?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===O?(0,a.jsx)(ec.Z,{placeholder:"Enter model name"}):v.length>0?(0,a.jsx)(e0.Z,{value:v,children:v.map((e,l)=>(0,a.jsx)(e1.Z,{value:e,children:e},l))}):(0,a.jsx)(ec.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==o&&o.fields.length>0&&(0,a.jsx)(lo,{fields:o.fields,selectedProvider:o.name}),"Amazon Bedrock"!=O&&"Vertex AI (Anthropic, Gemini, etc.)"!=O&&void 0===o&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(ec.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==O&&(0,a.jsx)(eg.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(ec.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(ec.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ls.Z,{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;Z.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?h.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&h.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(e_.ZP,{icon:(0,a.jsx)(lt.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==O||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==O)&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(ec.Z,{placeholder:"https://..."})}),"Azure"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(ec.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==O&&(0,a.jsxs)("div",{children:[(0,a.jsx)(eg.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(lc,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(eg.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,a.jsx)(e6.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(e3.Z,{title:"Get help on our github",children:(0,a.jsx)(eV.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(ei.Z,{onClick:lp,children:"Run `/health`"}),M&&(0,a.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:eU,onValueChange:e=>{eD(e),lj(q,e.from,e.to)}})]}),(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Model Group"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2",defaultValue:q||K[0],value:q||K[0],children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>lj(e,eU.from,eU.to),children:e},l))})]})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eY.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(eu.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),J&&X&&(0,a.jsx)(e2.Z,{title:"Model Latency",className:"h-72",data:J,showLegend:!1,index:"date",categories:X,connectNulls:!0,customTooltip:lg})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(ln,{modelMetrics:el,modelMetricsCategories:es,customTooltip:lg,premiumUser:g})})]})]})})}),(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Deployment"}),(0,a.jsx)(eF.Z,{children:"Success Responses"}),(0,a.jsxs)(eF.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(eC.Z,{children:eS.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.api_base}),(0,a.jsx)(eT.Z,{children:e.total_count}),(0,a.jsx)(eT.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(eA.Z,{className:"mt-4",children:[(0,a.jsx)(ex.Z,{children:"Exceptions per Model"}),(0,a.jsx)(e4.Z,{className:"h-72",data:ep,index:"model",categories:ef,stack:!0,colors:["indigo-300","rose-200","#ffcc33"],yAxisWidth:30})]})]}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],value:q||K[0],onValueChange:e=>V(e),children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))})]}),(0,a.jsxs)(ex.Z,{children:["Retry Policy for ",q]}),(0,a.jsx)(eu.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),lm&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(lm).map((e,l)=>{var t;let[s,r]=e,n=null==eB?void 0:null===(t=eB[q])||void 0===t?void 0:t[r];return null==n&&(n=eK),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)("td",{children:(0,a.jsx)(eZ.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{ez(l=>{var t;let s=null!==(t=null==l?void 0:l[q])&&void 0!==t?t:{};return{...null!=l?l:{},[q]:{...s,[r]:e}}})}})})]},l)})})}),(0,a.jsx)(ei.Z,{className:"mt-6 mr-8",onClick:la,children:"Save"})]})]})]})})};let{Option:lx}=ej.default;var lp=e=>{let{userID:l,accessToken:t,teams:s}=e,[r]=eg.Z.useForm(),[o,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[m,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{let e=await P(t,l,"any"),s=[];for(let l=0;l{i(!1),r.resetFields()},p=()=>{i(!1),d(null),r.resetFields()},j=async e=>{try{h.ZP.info("Making API Call"),i(!0),console.log("formValues in create user:",e);let s=await _(t,null,e);console.log("user create Response:",s),d(s.key),h.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-0",onClick:()=>i(!0),children:"+ Invite User"}),(0,a.jsxs)(ey.Z,{title:"Invite User",visible:o,width:800,footer:null,onOk:x,onCancel:p,children:[(0,a.jsx)(eu.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(eu.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(eg.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(eg.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(ej.default,{placeholder:"Select Team ID",style:{width:"100%"},children:s?s.map(e=>(0,a.jsx)(lx,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(lx,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create User"})})]})]}),c&&(0,a.jsxs)(ey.Z,{title:"User Created Successfully",visible:o,onOk:x,onCancel:p,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},lj=e=>{let{accessToken:l,token:t,keys:s,userRole:r,userID:o,teams:i,setKeys:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(0),[j,g]=n.useState(null),[y,f]=(0,n.useState)(null);return((0,n.useEffect)(()=>{if(!l||!t||!r||!o)return;let e=async()=>{try{let e=await k(l,null,r,!0,x,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&r&&o&&e()},[l,t,r,o,x]),d&&l&&t&&r&&o)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(eo.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(lp,{userID:o,accessToken:l,teams:i}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(eu.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(eJ.Z,{children:(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"User ID"}),(0,a.jsx)(eF.Z,{children:"User Email"}),(0,a.jsx)(eF.Z,{children:"User Models"}),(0,a.jsx)(eF.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User API Key Aliases"})]})}),(0,a.jsx)(eC.Z,{children:d.map(e=>{var l;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_id}),(0,a.jsx)(eT.Z,{children:e.user_email}),(0,a.jsx)(eT.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(eT.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eo.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsx)(eN.Z,{size:"xs",color:"indigo",children:e.key_aliases.filter(e=>null!==e).join(", ")}):(0,a.jsx)(eN.Z,{size:"xs",color:"gray",children:"No Keys"})})})]},e.user_id)})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})})]}),function(){if(!d)return null;let e=Math.ceil(d.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",x+1," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:0===x,onClick:()=>p(x-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",onClick:()=>{p(x+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},lg=e=>{let{teams:l,searchParams:t,accessToken:s,setTeams:r,userID:o,userRole:i}=e,[c]=eg.Z.useForm(),[d]=eg.Z.useForm(),{Title:m,Paragraph:u}=eV.default,[x,p]=(0,n.useState)(""),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(l?l[0]:null),[Z,_]=(0,n.useState)(!1),[w,k]=(0,n.useState)(!1),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)(!1),[I,C]=(0,n.useState)(null),[T,F]=(0,n.useState)({}),O=e=>{f(e),g(!0)},R=async e=>{let t=e.team_id;if(console.log("handleEditSubmit:",e),null==s)return;let a=await H(s,e);l&&r(l.map(e=>e.team_id===t?a.data:e)),h.ZP.success("Team updated successfully"),g(!1),f(null)},M=async e=>{C(e),E(!0)},L=async()=>{if(null!=I&&null!=l&&null!=s){try{await b(s,I);let e=l.filter(e=>e.team_id!==I);r(e)}catch(e){console.error("Error deleting the team:",e)}E(!1),C(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{if(null===o||null===i||null===s||null===l)return;console.log("fetching team info:");let e={};for(let t=0;t<(null==l?void 0:l.length);t++){let r=l[t].team_id,a=await v(s,r);console.log("teamInfo response:",a),null!==a&&(e={...e,[r]:a})}F(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===o||null===i)return;if(null!==s){let e=(await P(s,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,o,i,l]);let U=async e=>{try{if(null!=s){var t;let a=null==e?void 0:e.team_alias;if((null!==(t=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==t?t:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));h.ZP.info("Creating Team");let n=await V(s,e);null!==l?r([...l,n]):r([n]),console.log("response for team create call: ".concat(n)),h.ZP.success("Team created"),_(!1)}}catch(e){console.error("Error creating the team:",e),h.ZP.error("Error creating the team: "+e,20)}},D=async e=>{try{if(null!=s&&null!=l){h.ZP.info("Adding Member");let t={role:"user",user_email:e.user_email,user_id:e.user_id},a=await J(s,y.team_id,t);console.log("response for team create call: ".concat(a.data));let n=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(n)),-1!==n){let e=[...l];e[n]=a.data,r(e),f(a.data)}k(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Team Name"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(eF.Z,{children:"Info"})]})}),(0,a.jsx)(eC.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(eT.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].keys&&T[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].team_info&&T[e.team_id].team_info.members_with_roles&&T[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>O(e)}),(0,a.jsx)(eE.Z,{onClick:()=>M(e.team_id),icon:eS.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{E(!1),C(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>_(!0),children:"+ Create New Team"}),(0,a.jsx)(ey.Z,{title:"Create Team",visible:Z,width:800,footer:null,onOk:()=>{_(!1),c.resetFields()},onCancel:()=>{_(!1),c.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:U,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{f(e)},children:e.team_alias},l))}):(0,a.jsxs)(u,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:y?y.members_with_roles.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.role})]},l)):null})]})}),y&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,team:s,onSubmit:r}=e,[n]=eg.Z.useForm();return(0,a.jsx)(ey.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:s.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:R,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:j,onCancel:()=>{g(!1),f(null)},team:y,onSubmit:R})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-5",onClick:()=>k(!0),children:"+ Add member"}),(0,a.jsx)(ey.Z,{title:"Add member",visible:w,width:800,footer:null,onOk:()=>{k(!1),d.resetFields()},onCancel:()=>{k(!1),d.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:D,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},ly=e=>{let l,{searchParams:t,accessToken:s,showSSOBanner:r}=e,[o]=eg.Z.useForm(),[i]=eg.Z.useForm(),{Title:c,Paragraph:d}=eV.default,[m,u]=(0,n.useState)(""),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(!1),[Z,_]=(0,n.useState)(!1),[w,b]=(0,n.useState)(!1),[k,v]=(0,n.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let S=()=>{v(!1)},N=["proxy_admin","proxy_admin_viewer"];(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await q(s,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let t=await q(s,"proxy_admin");t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(t)),console.log("combinedList: ".concat(e)),p(e)}})()},[s]);let A=()=>{_(!1),i.resetFields()},E=()=>{_(!1),i.resetFields()},I=e=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]}),C=(e,l,t)=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:l,children:N.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:t,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update role"})})]}),T=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,null);console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),h.ZP.success("Refresh tab to see updated user role"),_(!1)}}catch(e){console.error("Error creating the key:",e)}},P=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),g(!1)}}catch(e){console.error("Error creating the key:",e)}},F=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await $(s,e,"proxy_admin");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),f(!1)}}catch(e){console.error("Error creating the key:",e)}},O=async e=>{null!=s&&er(s,{environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}})};return console.log("admins: ".concat(null==x?void 0:x.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(c,{level:4,children:"Admin Access "}),(0,a.jsxs)(d,{children:[r&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc. ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:x?x.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.user_role}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>_(!0)}),(0,a.jsx)(ey.Z,{title:"Update role",visible:Z,width:800,footer:null,onOk:A,onCancel:E,children:C(T,e.user_role,e.user_id)})]})]},l)):null})]})})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(ei.Z,{className:"mr-4 mb-5",onClick:()=>f(!0),children:"+ Add admin"}),(0,a.jsx)(ey.Z,{title:"Add admin",visible:y,width:800,footer:null,onOk:()=>{f(!1),i.resetFields()},onCancel:()=>{f(!1),i.resetFields()},children:I(F)}),(0,a.jsx)(ei.Z,{className:"mb-5",onClick:()=>g(!0),children:"+ Add viewer"}),(0,a.jsx)(ey.Z,{title:"Add viewer",visible:j,width:800,footer:null,onOk:()=>{g(!1),i.resetFields()},onCancel:()=>{g(!1),i.resetFields()},children:I(P)})]})})]}),(0,a.jsxs)(eo.Z,{children:[(0,a.jsx)(c,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(ei.Z,{onClick:()=>b(!0),children:"Add SSO"}),(0,a.jsx)(ey.Z,{title:"Add SSO",visible:w,width:800,footer:null,onOk:()=>{b(!1),o.resetFields()},onCancel:()=>{b(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{F(e),O(e),b(!1),v(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(ef.Z.Password,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(ef.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(ey.Z,{title:"SSO Setup Instructions",visible:k,width:800,footer:null,onOk:S,onCancel:()=>{v(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{onClick:S,children:"Done"})})]})]}),(0,a.jsxs)(lr.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},lf=t(42556),lZ=e=>{let{alertingSettings:l,handleInputChange:t,handleResetField:s,handleSubmit:r,premiumUser:n}=e,[o]=eg.Z.useForm();return(0,a.jsxs)(eg.Z,{form:o,onFinish:()=>{let e=o.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):r(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{align:"center",children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?n?(0,a.jsx)(eg.Z.Item,{name:e.field_name,children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l)}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}):(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(eg.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l),className:"p-0"}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>s(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update Settings"})})]})},l_=e=>{let{accessToken:l,premiumUser:t}=e,[s,r]=(0,n.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,n.useEffect)(()=>{l&&f(l).then(e=>{r(e)})},[l]),(0,a.jsx)(lZ,{alertingSettings:s,handleInputChange:(e,l)=>{r(s.map(t=>t.field_name===e?{...t,field_value:l}:t))},handleResetField:(e,t)=>{if(l)try{let l=s.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),r(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let t={};s.forEach(e=>{t[e.field_name]=e.field_value});let r={...e,...t};try{et(l,"alerting_args",r),h.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:t})};let lw=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var lb=e=>{let{accessToken:l,userRole:t,userID:s,premiumUser:r}=e,[o,i]=(0,n.useState)(lw),[c,d]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[x]=eg.Z.useForm(),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,Z]=(0,n.useState)(""),[_,w]=(0,n.useState)({}),[b,k]=(0,n.useState)([]),v=e=>{b.includes(e)?k(b.filter(l=>l!==e)):k([...b,e])},S={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,n.useEffect)(()=>{l&&t&&s&&ee(l,s,t).then(e=>{console.log("callbacks",e);let l=lw;i(l=l.map(l=>{let t=e.callbacks.find(e=>e.name===l.name);return t?{...l,variables:{...l.variables,...t.variables}}:l}));let t=e.alerts;if(console.log("alerts_data",t),t&&t.length>0){let e=t[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),k(e.active_alerts),Z(l),w(e.alerts_to_webhook)}d(t)})},[l,t,s]);let N=e=>b&&b.includes(e),A=e=>{if(!l)return;let t=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[t,s]=e;return[t,(null===(l=document.querySelector('input[name="'.concat(t,'"]')))||void 0===l?void 0:l.value)||s]}));console.log("updatedVariables",t),console.log("updateAlertTypes",g);let s={environment_variables:t,litellm_settings:{success_callback:[e.name]}};try{er(l,s)}catch(e){h.ZP.error("Failed to update callback: "+e,20)}h.ZP.success("Callback updated successfully")},E=()=>{l&&x.validateFields().then(e=>{if(console.log("Form values:",e),"langfuse"===e.callback){er(l,{environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),er(l,{general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}}),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),er(l,{environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};i(o?[...o,t]:[t])}u(!1),x.resetFields(),j(null)})};return l?(console.log("callbacks: ".concat(o)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(lr.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Settings"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Callback"}),(0,a.jsx)(eF.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(eC.Z,{children:o.filter(e=>"slack"!==e.name).map((e,t)=>{var s;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eN.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).filter(l=>{let[t,s]=l;return t.toLowerCase().includes(e.name)}).map(e=>{let[l,t]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(eu.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(ec.Z,{name:l,defaultValue:t,type:"password"})]},l)})}),(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(e),children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,e.name),className:"mx-2",children:"Test Callback"})]})]},t)})})]})})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eu.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(S).map((e,l)=>{let[t,s]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:"region_outage_alerts"==t?r?(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)}):(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:t,type:"password",defaultValue:_&&_[t]?_[t]:f})})]},l)})})]}),(0,a.jsx)(ei.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(S).forEach(l=>{let[t,s]=l,r=document.querySelector('input[name="'.concat(t,'"]'));console.log("key",t),console.log("webhookInput",r);let a=(null==r?void 0:r.value)||"";console.log("newWebhookValue",a),e[t]=a}),console.log("updatedAlertToWebhooks",e);let t={general_settings:{alert_to_webhook_url:e,alert_types:b}};console.log("payload",t);try{er(l,t)}catch(e){h.ZP.error("Failed to update alerts: "+e,20)}h.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(l_,{accessToken:l,premiumUser:r})})]})]})]}),(0,a.jsx)(ey.Z,{title:"Add Callback",visible:m,onOk:E,width:800,onCancel:()=>{u(!1),x.resetFields(),j(null)},footer:null,children:(0,a.jsxs)(eg.Z,{form:x,layout:"vertical",onFinish:E,children:[(0,a.jsx)(eg.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(ej.default,{onChange:e=>{j(e)},children:[(0,a.jsx)(ej.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(ej.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(ec.Z,{type:"password"})}),(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})]}),"openmeter"==p&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eg.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:lk}=ej.default;var lv=e=>{let{models:l,accessToken:t,routerSettings:s,setRouterSettings:r}=e,[o]=eg.Z.useForm(),[i,c]=(0,n.useState)(!1),[d,m]=(0,n.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>c(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(ey.Z,{title:"Add Fallbacks",visible:i,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,n=[...s.fallbacks||[],{[l]:a}],i={...s,fallbacks:n};console.log(i);try{er(t,{router_settings:i}),r(i)}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully"),c(!1),o.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(eR.Z,{defaultValue:d,children:l&&l.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(e0.Z,{value:l,children:l&&l.filter(e=>e!=d).map(e=>(0,a.jsx)(e1.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lS=t(12968);async function lN(e,l){console.log("isLocal:",!1);let t=window.location.origin,s=new lS.ZP.OpenAI({apiKey:l,baseURL:t,dangerouslyAllowBrowser:!0});try{let l=await s.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});h.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lA={ttl:3600,lowest_latency_buffer:0},lE=e=>{let{selectedStrategy:l,strategyArgs:t,paramExplanation:s}=e;return(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(em.Z,{children:"latency-based-routing"==l?(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(t).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:s[l]})]}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]})}):(0,a.jsx)(eu.Z,{children:"No specific settings"})})]})};var lI=e=>{let{accessToken:l,userRole:t,userID:s,modelData:r}=e,[o,i]=(0,n.useState)({}),[c,d]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1),[j]=eg.Z.useForm(),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)(null),b={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,n.useEffect)(()=>{l&&t&&s&&(ee(l,s,t).then(e=>{console.log("callbacks",e),i(e.router_settings)}),el(l).then(e=>{u(e)}))},[l,t,s]);let k=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(o.fallbacks)),o.fallbacks.map(l=>(e in l&&delete l[e],l));try{await er(l,{router_settings:o}),i({...o}),Z(o.routing_strategy),h.ZP.success("Router settings updated successfully")}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}}},v=(e,l)=>{u(m.map(t=>t.field_name===e?{...t,field_value:l}:t))},S=(e,t)=>{if(!l)return;let s=m[t].field_value;if(null!=s&&void 0!=s)try{et(l,e,s);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(t)}catch(e){}},N=(e,t)=>{if(l)try{es(l,e);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(t)}catch(e){}},A=e=>{if(!l)return;console.log("router_settings",e);let t=Object.fromEntries(Object.entries(e).map(e=>{let[l,t]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var s;return[l,(null===(s=document.querySelector('input[name="'.concat(l,'"]')))||void 0===s?void 0:s.value)||t]}if("routing_strategy"==l)return[l,f];if("routing_strategy_args"==l&&"latency-based-routing"==f){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),t=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==t?void 0:t.value)&&(e.ttl=Number(t.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",t);try{er(l,{router_settings:t})}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eY.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eY.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(ex.Z,{children:"Router Settings"}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(o).filter(e=>{let[l,t]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:b[l]})]}),(0,a.jsx)(eT.Z,{children:"routing_strategy"==l?(0,a.jsxs)(eR.Z,{defaultValue:t,className:"w-full max-w-md",onValueChange:Z,children:[(0,a.jsx)(eM.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(eM.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(eM.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]}),(0,a.jsx)(lE,{selectedStrategy:f,strategyArgs:o&&o.routing_strategy_args&&Object.keys(o.routing_strategy_args).length>0?o.routing_strategy_args:lA,paramExplanation:b})]}),(0,a.jsx)(en.Z,{children:(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(o),children:"Save Changes"})})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Model Name"}),(0,a.jsx)(eF.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(eC.Z,{children:o.fallbacks&&o.fallbacks.map((e,t)=>Object.entries(e).map(e=>{let[s,r]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:s}),(0,a.jsx)(eT.Z,{children:Array.isArray(r)?r.join(", "):r}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{onClick:()=>lN(s,l),children:"Test Fallback"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>k(s)})})]},t.toString()+s)}))})]}),(0,a.jsx)(lv,{models:(null==r?void 0:r.data)?r.data.map(e=>e.model_name):[],accessToken:l,routerSettings:o,setRouterSettings:i})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"}),(0,a.jsx)(eF.Z,{children:"Status"}),(0,a.jsx)(eF.Z,{children:"Action"})]})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(eT.Z,{children:"Integer"==e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>v(e.field_name,l)}):null}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(ei.Z,{onClick:()=>S(e.field_name,l),children:"Update"}),(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>N(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lC=e=>{let{isModalVisible:l,accessToken:t,setIsModalVisible:s,setBudgetList:r}=e,[n]=eg.Z.useForm(),o=async e=>{if(null!=t&&void 0!=t)try{h.ZP.info("Making API Call");let l=await y(t,e);console.log("key create Response:",l),r(e=>e?[...e,l]:[l]),h.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(ey.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{s(!1),n.resetFields()},onCancel:()=>{s(!1),n.resetFields()},children:(0,a.jsxs)(eg.Z,{form:n,onFinish:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lT=t(67951),lP=e=>{let{accessToken:l}=e,[t,s]=(0,n.useState)(!1),[r,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&Q(l).then(e=>{o(e)})},[l]);let i=async(e,t)=>{if(null==l)return;h.ZP.info("Request made"),await g(l,e);let s=[...r];s.splice(t,1),o(s),h.ZP.success("Budget Deleted.")};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(ei.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>s(!0),children:"+ Create Budget"}),(0,a.jsx)(lC,{accessToken:l,isModalVisible:t,setIsModalVisible:s,setBudgetList:o}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Budget ID"}),(0,a.jsx)(eF.Z,{children:"Max Budget"}),(0,a.jsx)(eF.Z,{children:"TPM"}),(0,a.jsx)(eF.Z,{children:"RPM"})]})}),(0,a.jsx)(eC.Z,{children:r.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.budget_id}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(eT.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(eT.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>i(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(eu.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eY.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eY.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{var l;let{userID:t,userRole:s,token:r,accessToken:o,keys:i,premiumUser:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);(0,n.useEffect)(()=>{o&&r&&s&&t&&(async()=>{try{let e=await A(o,t,s);console.log("ModelHubData:",e),m(e.data)}catch(e){console.error("There was an error fetching the model data",e)}})()},[o,r,s,t]);let j=e=>{p(e),u(!0)},g=e=>{navigator.clipboard.writeText(e)};return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)("div",{className:"relative w-full"}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(ex.Z,{className:"ml-8 text-center ",children:"Model Hub"}),(0,a.jsx)(ei.Z,{className:"ml-4",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4",children:d&&d.map(e=>(0,a.jsxs)(eA.Z,{className:"mt-5 mx-8",children:[(0,a.jsxs)("pre",{className:"flex justify-between",children:[(0,a.jsx)(ex.Z,{children:e.model_group}),(0,a.jsx)(e3.Z,{title:e.model_group,children:(0,a.jsx)(lF.Z,{onClick:()=>g(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,a.jsxs)("div",{className:"my-5",children:[(0,a.jsxs)(eu.Z,{children:["Mode: ",e.mode]}),(0,a.jsxs)(eu.Z,{children:["Supports Function Calling: ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Supports Vision: ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Max Input Tokens: ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,a.jsxs)(eu.Z,{children:["Max Output Tokens: ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,a.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,a.jsxs)("a",{href:"#",onClick:()=>j(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,a.jsx)(lO.Z,{})]})})]},e.model_group))})]}),(0,a.jsx)(ey.Z,{title:x&&x.model_group?x.model_group:"Unknown Model",width:800,visible:h,footer:null,onOk:()=>{u(!1),p(null)},onCancel:()=>{u(!1),p(null)},children:x&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-4",children:(0,a.jsx)("strong",{children:"Model Information & Usage"})}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"Supported OpenAI Params"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(x.model_group,'", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,a.jsx)(eX.Z,{children:null==x?void 0:null===(l=x.supported_openai_params)||void 0===l?void 0:l.map(e=>(0,a.jsx)("pre",{children:e},e))}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="'.concat(x.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "'.concat(x.model_group,'",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})]})},lM=e=>{let{}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(eu.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n '})})]})]})]})})})};async function lL(e,l,t,s){console.log("isLocal:",!1);let r=window.location.origin,a=new lS.ZP.OpenAI({apiKey:s,baseURL:r,dangerouslyAllowBrowser:!0});try{for await(let s of(await a.chat.completions.create({model:t,stream:!0,messages:[{role:"user",content:e}]})))console.log(s),s.choices[0].delta.content&&l(s.choices[0].delta.content)}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lU=e=>{let{accessToken:l,token:t,userRole:s,userID:r}=e,[o,i]=(0,n.useState)(""),[c,d]=(0,n.useState)(""),[m,h]=(0,n.useState)([]),[u,x]=(0,n.useState)(void 0),[p,j]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{let e=await P(l,r,s);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));console.log(l),j(l),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,r,s]);let g=(e,l)=>{h(t=>{let s=t[t.length-1];return s&&s.role===e?[...t.slice(0,t.length-1),{role:e,content:s.content+l}]:[...t,{role:e,content:l}]})},y=async()=>{if(""!==c.trim()&&o&&t&&s&&r){h(e=>[...e,{role:"user",content:c}]);try{u&&await lL(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsx)(e$.Z,{children:(0,a.jsx)(eY.Z,{children:"Chat"})}),(0,a.jsx)(eQ.Z,{children:(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"API Key"}),(0,a.jsx)(ec.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,a.jsxs)(en.Z,{className:"mx-2",children:[(0,a.jsx)(eu.Z,{children:"Select Model:"}),(0,a.jsx)(ej.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,a.jsxs)(eI.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{})})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(ec.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,a.jsx)(ei.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]})})]})})})})},lD=t(33509),lB=t(95781);let{Sider:lz}=lD.default;var lK=e=>{let{setPage:l,userRole:t,defaultSelectedKey:s}=e;return"Admin Viewer"==t?(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(lz,{width:120,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(lz,{width:145,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(eu.Z,{children:"API Keys"})},"1"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(eu.Z,{children:"Test Key"})},"3"),"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(eu.Z,{children:"Models"})},"2"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(eu.Z,{children:"Usage"})},"4"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(eu.Z,{children:"Teams"})},"6"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(eu.Z,{children:"Users"})},"5"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(eu.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(eu.Z,{children:"Rate Limits"})},"9"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(eu.Z,{children:"Router Settings"})},"10"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(eu.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(eu.Z,{children:"API Reference"})},"12"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(eu.Z,{children:"Model Hub"})},"14")]})})})},lG=t(67989),lq=t(49167),lV=t(52703),lW=e=>{let{accessToken:l,token:t,userRole:s,userID:r,keys:o,premiumUser:i}=e,c=new Date,[d,m]=(0,n.useState)([]),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)([]),[j,g]=(0,n.useState)([]),[y,f]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[w,b]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)({}),[I,C]=(0,n.useState)([]),[T,P]=(0,n.useState)(""),[q,V]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),W=new Date(c.getFullYear(),c.getMonth(),1),H=new Date(c.getFullYear(),c.getMonth()+1,0),Y=Q(W),J=Q(H);console.log("keys in usage",o),console.log("premium user in usage",i);let $=async(e,t,s)=>{if(!e||!t||!l)return;t.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",s);let r=await U(l,s,e.toISOString(),t.toISOString());console.log("End user data updated successfully",r),g(r)},X=async(e,t)=>{e&&t&&l&&(t.setHours(23,59,59,999),e.setHours(0,0,0,0),_((await O(l,e.toISOString(),t.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function Q(e){let l=e.getFullYear(),t=e.getMonth()+1,s=e.getDate();return"".concat(l,"-").concat(t<10?"0"+t:t,"-").concat(s<10?"0"+s:s)}return console.log("Start date is ".concat(Y)),console.log("End date is ".concat(J)),(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{if(console.log("user role: ".concat(s)),"Admin"==s||"Admin Viewer"==s){var e,a;let s=await M(l);m(s);let r=await D(l,t,Y,J);console.log("provider_spend",r),N(r);let n=(await L(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));u(n);let o=(await K(l)).map(e=>({key:e.model,spend:e.total_spend}));p(o);let i=await F(l);console.log("teamSpend",i),f(i.daily_spend),b(i.teams);let c=i.total_spend_per_team;c=c.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),v(c);let d=await O(l,null===(e=q.from)||void 0===e?void 0:e.toISOString(),null===(a=q.to)||void 0===a?void 0:a.toISOString());_(d.spend_per_tag);let h=await U(l,null,void 0,void 0);g(h),console.log("spend/user result",h);let x=await B(l,Y,J);E(x);let j=await z(l,Y,J);console.log("global activity per model",j),C(j)}else"App Owner"==s&&await R(l,t,s,r,Y,J).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let t=e.top_api_keys;u(t)}else{let t=(await G(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[t,s]=e;"spend"!==t&&"startTime"!==t&&"models"!==t&&"users"!==t&&l.push({key:t,spend:s})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let t=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(t[0]))),t}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));u(t),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,t,s,r,Y,J]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(ez,{userID:r,userRole:s,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{className:"mt-2",children:[(0,a.jsx)(eY.Z,{children:"All Up"}),(0,a.jsx)(eY.Z,{children:"Team Based Usage"}),(0,a.jsx)(eY.Z,{children:"End User Usage"}),(0,a.jsx)(eY.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eY.Z,{children:"Cost"}),(0,a.jsx)(eY.Z,{children:"Activity"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Monthly Spend"}),(0,a.jsx)(e4.Z,{data:d,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top API Keys"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top Models"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:x,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1}),(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"✨ Spend by Provider"}),i?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(lV.Z,{className:"mt-4 h-40",variant:"pie",data:S,index:"provider",category:"spend"})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Provider"}),(0,a.jsx)(eF.Z,{children:"Spend"})]})}),(0,a.jsx)(eC.Z,{children:S.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.provider}),(0,a.jsx)(eT.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"All Up"}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",A.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",A.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),i?(0,a.jsx)(a.Fragment,{children:I.map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:I&&I.length>0&&I.slice(0,1).map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lG.Z,{data:k})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(e4.Z,{className:"h-72",data:y,showLegend:!0,index:"date",categories:w,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:q,onValueChange:e=>{V(e),$(e.from,e.to,null)}})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Key"}),(0,a.jsxs)(eR.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(eM.Z,{value:"all-keys",onClick:()=>{$(q.from,q.to,null)},children:"All Keys"},"all-keys"),null==o?void 0:o.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{$(q.from,q.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(eA.Z,{className:"mt-4",children:(0,a.jsxs)(eI.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"End User"}),(0,a.jsx)(eF.Z,{children:"Spend"}),(0,a.jsx)(eF.Z,{children:"Total Events"})]})}),(0,a.jsx)(eC.Z,{children:null==j?void 0:j.map((e,l)=>{var t;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.end_user}),(0,a.jsx)(eT.Z,{children:null===(t=e.total_spend)||void 0===t?void 0:t.toFixed(4)}),(0,a.jsx)(eT.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsx)(eH.Z,{className:"mb-4",enableSelect:!0,value:q,onValueChange:e=>{V(e),X(e.from,e.to)}}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(eu.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(e4.Z,{className:"h-72",data:Z,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})})]})]})]})},lH=()=>{let{Title:e,Paragraph:l}=eV.default,[t,s]=(0,n.useState)(""),[r,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!0),y=(0,o.useSearchParams)(),[f,Z]=(0,n.useState)({data:[]}),_=y.get("userID"),w=y.get("token"),[b,k]=(0,n.useState)("api-keys"),[v,S]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(w){let e=(0,eq.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),S(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),s(l),"Admin Viewer"==l&&k("usage")}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&i(e.premium_user)}}},[w]),(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:_,userRole:t,userEmail:c,showSSOBanner:j,premiumUser:r}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lK,{setPage:k,userRole:t,defaultSelectedKey:null})}),"api-keys"==b?(0,a.jsx)(eW,{userID:_,userRole:t,teams:h,keys:x,setUserRole:s,userEmail:c,setUserEmail:d,setTeams:u,setKeys:p}):"models"==b?(0,a.jsx)(lu,{userID:_,userRole:t,token:w,accessToken:v,modelData:f,setModelData:Z,premiumUser:r}):"llm-playground"==b?(0,a.jsx)(lU,{userID:_,userRole:t,token:w,accessToken:v}):"users"==b?(0,a.jsx)(lj,{userID:_,userRole:t,token:w,keys:x,teams:h,accessToken:v,setKeys:p}):"teams"==b?(0,a.jsx)(lg,{teams:h,setTeams:u,searchParams:y,accessToken:v,userID:_,userRole:t}):"admin-panel"==b?(0,a.jsx)(ly,{setTeams:u,searchParams:y,accessToken:v,showSSOBanner:j}):"api_ref"==b?(0,a.jsx)(lM,{}):"settings"==b?(0,a.jsx)(lb,{userID:_,userRole:t,accessToken:v,premiumUser:r}):"budgets"==b?(0,a.jsx)(lP,{accessToken:v}):"general-settings"==b?(0,a.jsx)(lI,{userID:_,userRole:t,accessToken:v,modelData:f}):"model-hub"==b?(0,a.jsx)(lR,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r}):(0,a.jsx)(lW,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r})]})]})})}}},function(e){e.O(0,[936,608,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]); \ No newline at end of file +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,t){Promise.resolve().then(t.bind(t,39712))},39712:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return lH}});var s,r,a=t(3827),n=t(64090),o=t(47907),i=t(8792),c=t(40491),d=t(65270),m=e=>{let{userID:l,userRole:t,userEmail:s,showSSOBanner:r,premiumUser:n}=e;console.log("User ID:",l),console.log("userEmail:",s),console.log("showSSOBanner:",r),console.log("premiumUser:",n);let o=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",t]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(n)]})]})}];return(0,a.jsxs)("nav",{className:"left-0 right-0 top-0 flex justify-between items-center h-12 mb-4",children:[(0,a.jsx)("div",{className:"text-left my-2 absolute top-0 left-0",children:(0,a.jsx)("div",{className:"flex flex-col items-center",children:(0,a.jsx)(i.default,{href:"/",children:(0,a.jsx)("button",{className:"text-gray-800 rounded text-center",children:(0,a.jsx)("img",{src:"/get_image",width:160,height:160,alt:"LiteLLM Brand",className:"mr-2"})})})})}),(0,a.jsxs)("div",{className:"text-right mx-4 my-2 absolute top-0 right-0 flex items-center justify-end space-x-2",children:[r?(0,a.jsx)("div",{style:{padding:"6px",borderRadius:"8px"},children:(0,a.jsx)("a",{href:"https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat",target:"_blank",style:{fontSize:"14px",textDecoration:"underline"},children:"Get enterpise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(c.Z,{menu:{items:o},children:(0,a.jsx)(d.Z,{children:s})})})]})]})},h=t(80588);let u=async()=>{try{let e=await fetch("https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"),l=await e.json();return console.log("received data: ".concat(l)),l}catch(e){throw console.error("Failed to get model cost map:",e),e}},x=async(e,l)=>{try{let t=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),s}catch(e){throw console.error("Failed to create key:",e),e}},p=async e=>{try{let l=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},j=async(e,l)=>{console.log("model_id in model delete call: ".concat(l));try{let t=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),h.ZP.success("Model deleted successfully. Restart server to see this."),s}catch(e){throw console.error("Failed to create key:",e),e}},g=async(e,l)=>{if(console.log("budget_id in budget delete call: ".concat(l)),null!=e)try{let t=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,l)=>{try{console.log("Form Values in budgetCreateCall:",l),console.log("Form Values after check:",l);let t=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},f=async e=>{try{let l=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},Z=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,l,t)=>{try{if(console.log("Form Values in keyCreateCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw h.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",t);let s=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:l,...t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},w=async(e,l)=>{try{console.log("in keyDeleteCall:",l);let t=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,l)=>{try{console.log("in teamDeleteCall:",l);let t=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[l]})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,l,t){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;try{let n="/user/info";"App Owner"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),"App User"==t&&l&&(n="".concat(n,"?user_id=").concat(l)),console.log("in userInfoCall viewAll=",s),s&&a&&null!=r&&void 0!=r&&(n="".concat(n,"?view_all=true&page=").concat(r,"&page_size=").concat(a));let o=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let i=await o.json();return console.log("API Response:",i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,l)=>{try{let t="/team/info";l&&(t="".concat(t,"?team_id=").concat(l)),console.log("in teamInfoCall");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},S=async e=>{try{let l=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,l,t)=>{try{let l=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelInfoCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,l,t)=>{try{let l=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log("modelHubCall:",t),t}catch(e){throw console.error("Failed to create key:",e),e}},E=async(e,l,t,s,r,a)=>{try{let l="/model/metrics";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},I=async(e,l,t,s)=>{try{let r="/model/streaming_metrics";l&&(r="".concat(r,"?_selected_model_group=").concat(l,"&startTime=").concat(t,"&endTime=").concat(s));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},C=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/slow_responses";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,l,t,s,r,a)=>{try{let l="/model/metrics/exceptions";s&&(l="".concat(l,"?_selected_model_group=").concat(s,"&startTime=").concat(r,"&endTime=").concat(a));let t=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,l,t)=>{try{let l=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},F=async e=>{try{let l="/global/spend/teams";console.log("in teamSpendLogsCall:",l);let t=await fetch("".concat(l),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},O=async(e,l,t)=>{try{let s="/global/spend/tags";l&&t&&(s="".concat(s,"?start_date=").concat(l,"&end_date=").concat(t)),console.log("in tagsSpendLogsCall:",s);let r=await fetch("".concat(s),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},R=async(e,l,t,s,r,a)=>{try{console.log("user role in spend logs call: ".concat(t));let l="/spend/logs";l="App Owner"==t?"".concat(l,"?user_id=").concat(s,"&start_date=").concat(r,"&end_date=").concat(a):"".concat(l,"?start_date=").concat(r,"&end_date=").concat(a);let n=await fetch(l,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},M=async e=>{try{let l=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},L=async e=>{try{let l=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,l,t,s)=>{try{let r="";r=l?JSON.stringify({api_key:l,startTime:t,endTime:s}):JSON.stringify({startTime:t,endTime:s});let a={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};a.body=r;let n=await fetch("/global/spend/end_users",a);if(!n.ok){let e=await n.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let o=await n.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,l,t,s)=>{try{let r="/global/spend/provider";t&&s&&(r+="?start_date=".concat(t,"&end_date=").concat(s)),l&&(r+="&api_key=".concat(l));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok){let e=await a.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log(n),n}catch(e){throw console.error("Failed to fetch spend data:",e),e}},B=async(e,l,t)=>{try{let s="/global/activity";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},z=async(e,l,t)=>{try{let s="/global/activity/model";l&&t&&(s+="?start_date=".concat(l,"&end_date=").concat(t));let r=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok)throw await r.text(),Error("Network response was not ok");let a=await r.json();return console.log(a),a}catch(e){throw console.error("Failed to fetch spend data:",e),e}},K=async e=>{try{let l=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let t=await l.json();return console.log(t),t}catch(e){throw console.error("Failed to create key:",e),e}},G=async(e,l)=>{try{let t=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},q=async(e,l)=>{try{let t="/user/get_users?role=".concat(l);console.log("in userGetAllUsersCall:",t);let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let r=await s.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},V=async(e,l)=>{try{console.log("Form Values in teamCreateCall:",l);let t=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,l)=>{try{console.log("Form Values in keyUpdateCall:",l);let t=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update key Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},H=async(e,l)=>{try{console.log("Form Values in teamUpateCall:",l);let t=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update Team Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},Y=async(e,l)=>{try{console.log("Form Values in modelUpateCall:",l);let t=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let s=await t.json();return console.log("Update model Response:",s),s}catch(e){throw console.error("Failed to update model:",e),e}},J=async(e,l,t)=>{try{console.log("Form Values in teamMemberAddCall:",t);let s=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:l,member:t})});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await s.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},$=async(e,l,t)=>{try{console.log("Form Values in userUpdateUserCall:",l);let s={...l};null!==t&&(s.user_role=t),s=JSON.stringify(s);let r=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:s});if(!r.ok){let e=await r.text();throw h.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await r.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,l)=>{try{let t="/health/services?service=".concat(l);console.log("Checking Slack Budget Alerts service health");let s=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw h.ZP.error("Failed ".concat(l," service health check ")+e),Error(e)}let r=await s.json();return h.ZP.success("Test request to ".concat(l," made - check logs/alerts on ").concat(l," to verify")),r}catch(e){throw console.error("Failed to perform health check:",e),e}},Q=async e=>{try{let l=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async(e,l,t)=>{try{let l=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},el=async e=>{try{let l=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,l,t)=>{try{let s=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,field_value:t,config_type:"general_settings"})});if(!s.ok){let e=await s.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let r=await s.json();return h.ZP.success("Successfully updated value!"),r}catch(e){throw console.error("Failed to set callbacks:",e),e}},es=async(e,l)=>{try{let t=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:l,config_type:"general_settings"})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}let s=await t.json();return h.ZP.success("Field reset on proxy"),s}catch(e){throw console.error("Failed to get callbacks:",e),e}},er=async(e,l)=>{try{let t=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...l})});if(!t.ok){let e=await t.text();throw h.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},ea=async e=>{try{let l=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw h.ZP.error(e),Error("Network response was not ok")}return await l.json()}catch(e){throw console.error("Failed to call /health:",e),e}};var en=t(10384),eo=t(46453),ei=t(16450),ec=t(52273),ed=t(26780),em=t(15595),eh=t(6698),eu=t(71801),ex=t(42440),ep=t(42308),ej=t(50670),eg=t(81583),ey=t(99129),ef=t(44839),eZ=t(88707),e_=t(1861);let{Option:ew}=ej.default;var eb=e=>{let{userID:l,team:t,userRole:s,accessToken:r,data:o,setData:i}=e,[c]=eg.Z.useForm(),[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(null),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,_]=(0,n.useState)([]),w=()=>{m(!1),c.resetFields()},b=()=>{m(!1),x(null),c.resetFields()};(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==r){let e=(await P(r,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),y(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,s]);let k=async e=>{try{var t,s,a;let n=null!==(t=null==e?void 0:e.key_alias)&&void 0!==t?t:"",d=null!==(s=null==e?void 0:e.team_id)&&void 0!==s?s:null;if((null!==(a=null==o?void 0:o.filter(e=>e.team_id===d).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(n))throw Error("Key alias ".concat(n," already exists for team with ID ").concat(d,", please provide another key alias"));h.ZP.info("Making API Call"),m(!0);let u=await Z(r,l,e);console.log("key create Response:",u),i(e=>e?[...e,u]:[u]),x(u.key),j(u.soft_budget),h.ZP.success("API Key Created"),c.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,n.useEffect)(()=>{_(t&&t.models.length>0?t.models.includes("all-proxy-models")?g:t.models:g)},[t,g]),(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(ey.Z,{title:"Create Key",visible:d,width:800,footer:null,onOk:w,onCancel:b,children:(0,a.jsxs)(eg.Z,{form:c,onFinish:k,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:t?t.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t?t.team_alias:"",disabled:!0})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&c.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(ew,{value:"all-team-models",children:"All Team Models"},"all-team-models"),f.map(e=>(0,a.jsx)(ew,{value:e,children:e},e))]})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==t?void 0:t.max_budget)!==null&&(null==t?void 0:t.max_budget)!==void 0?null==t?void 0:t.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.max_budget&&l>t.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(t.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==t?void 0:t.budget_duration)!==null&&(null==t?void 0:t.budget_duration)!==void 0?null==t?void 0:t.budget_duration:"None"),children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==t?void 0:t.tpm_limit)!==null&&(null==t?void 0:t.tpm_limit)!==void 0?null==t?void 0:t.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.tpm_limit&&l>t.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(t.tpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==t?void 0:t.rpm_limit)!==null&&(null==t?void 0:t.rpm_limit)!==void 0?null==t?void 0:t.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.rpm_limit&&l>t.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(t.rpm_limit))}}],children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Key"})})]})}),u&&(0,a.jsx)(ey.Z,{visible:d,onOk:w,onCancel:b,footer:null,children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Save your Key"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons, ",(0,a.jsx)("b",{children:"you will not be able to view it again"})," ","through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:null!=u?(0,a.jsxs)("div",{children:[(0,a.jsx)(eu.Z,{className:"mt-3",children:"API Key:"}),(0,a.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,a.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:u})}),(0,a.jsx)(ep.CopyToClipboard,{text:u,onCopy:()=>{h.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(ei.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(eu.Z,{children:"Key being created, this might take 30s"})})]})})]})},ek=t(9454),ev=t(98941),eS=t(33393),eN=t(5),eA=t(13810),eE=t(61244),eI=t(10827),eC=t(3851),eT=t(2044),eP=t(64167),eF=t(74480),eO=t(7178),eR=t(95093),eM=t(27166);let{Option:eL}=ej.default;var eU=e=>{let{userID:l,userRole:t,accessToken:s,selectedTeam:r,data:o,setData:i,teams:c}=e,[d,m]=(0,n.useState)(!1),[u,x]=(0,n.useState)(!1),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,b]=(0,n.useState)(""),[k,v]=(0,n.useState)(!1),[S,N]=(0,n.useState)(!1),[A,E]=(0,n.useState)(null),[I,C]=(0,n.useState)([]),T=new Set,[F,O]=(0,n.useState)(T);(0,n.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==s&&null!==t){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),C(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[s,l,t]),(0,n.useEffect)(()=>{if(c){let e=new Set;c.forEach((l,t)=>{let s=l.team_id;e.add(s)}),O(e)}},[c]);let R=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),E(e),v(!0)},M=async e=>{if(null==s)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let t=await W(s,e);console.log("handleEditSubmit: newKeyValues",t),o&&i(o.map(e=>e.token===l?t:e)),h.ZP.success("Key updated successfully"),v(!1),E(null)},L=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=o&&(j(e.token),localStorage.removeItem("userData"+l),x(!0))},U=async()=>{if(null!=p&&null!=o){try{await w(s,p);let e=o.filter(e=>e.token!==p);i(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),j(null)}};if(null!=o)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(eI.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Key Alias"}),(0,a.jsx)(eF.Z,{children:"Secret Key"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(eC.Z,{children:o.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(r){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(F.has(e.team_id),", selectedTeam id: ").concat(r.team_id)),(null!=r.team_id||null===e.team_id||F.has(e.team_id))&&e.team_id!=r.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(eu.Z,{children:e.key_alias}):(0,a.jsx)(eu.Z,{children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:e.key_name})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(eT.Z,{children:null!=e.max_budget?(0,a.jsx)(eu.Z,{children:e.max_budget}):(0,a.jsx)(eu.Z,{children:"Unlimited"})}),(0,a.jsx)(eT.Z,{children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(a.Fragment,{children:r&&r.models&&r.models.length>0?r.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Team Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{})," RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{onClick:()=>{E(e),N(!0)},icon:ek.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:S,onCancel:()=>{N(!1),E(null)},footer:null,width:800,children:A&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 mt-8",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Spend"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:(()=>{try{return parseFloat(A.spend).toFixed(4)}catch(e){return A.spend}})()})})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Budget"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.max_budget?(0,a.jsx)(a.Fragment,{children:A.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)("p",{className:"text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content",children:"Expires"}),(0,a.jsx)("div",{className:"mt-2 flex items-baseline space-x-2.5",children:(0,a.jsx)("p",{className:"text-tremor-default font-small text-tremor-content-strong dark:text-dark-tremor-content-strong",children:null!=A.expires?(0,a.jsx)(a.Fragment,{children:new Date(A.expires).toLocaleString(void 0,{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}):(0,a.jsx)(a.Fragment,{children:"Never"})})})]},e.name)]}),(0,a.jsxs)(eA.Z,{className:"my-4",children:[(0,a.jsx)(ex.Z,{children:"Token Name"}),(0,a.jsx)(eu.Z,{className:"my-1",children:A.key_alias?A.key_alias:A.key_name}),(0,a.jsx)(ex.Z,{children:"Token ID"}),(0,a.jsx)(eu.Z,{className:"my-1 text-[12px]",children:A.token}),(0,a.jsx)(ex.Z,{children:"Metadata"}),(0,a.jsx)(eu.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify(A.metadata)," "]})})]}),(0,a.jsx)(ei.Z,{className:"mx-auto flex items-center",onClick:()=>{N(!1),E(null)},children:"Close"})]})}),(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>R(e)}),(0,a.jsx)(eE.Z,{onClick:()=>L(e),icon:eS.Z,size:"sm"})]})]},e.token)})})]}),u&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Key"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this key ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:U,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{x(!1),j(null)},children:"Cancel"})]})]})]})})]}),A&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,token:s,onSubmit:o}=e,[i]=eg.Z.useForm(),[d,m]=(0,n.useState)(r),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1);return(0,a.jsx)(ey.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{i.validateFields().then(e=>{i.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:i,onFinish:M,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let t=l.filter(e=>!d.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!d.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(t)),t.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(t,"Team models: ").concat(d.models)):Promise.resolve()}}],children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(eL,{value:"all-team-models",children:"All Team Models"},"all-team-models"),d&&d.models?d.models.includes("all-proxy-models")?I.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):d.models.map(e=>(0,a.jsx)(eL,{value:e,children:e},e)):I.map(e=>(0,a.jsx)(eL,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==d?void 0:d.max_budget)!==null&&(null==d?void 0:d.max_budget)!==void 0?null==d?void 0:d.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&d&&null!==d.max_budget&&l>d.max_budget)throw console.log("keyTeam.max_budget: ".concat(d.max_budget)),Error("Budget cannot exceed team max budget: $".concat(d.max_budget))}}],children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(eg.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(eR.Z,{value:s.team_alias,children:null==c?void 0:c.map((e,l)=>(0,a.jsx)(eM.Z,{value:e.team_id,onClick:()=>m(e),children:e.team_alias},l))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:k,onCancel:()=>{v(!1),E(null)},token:A,onSubmit:M})]})},eD=t(76032),eB=t(35152),ez=e=>{let{userID:l,userRole:t,accessToken:s,userSpend:r,selectedTeam:o}=e;console.log("userSpend: ".concat(r));let[i,c]=(0,n.useState)(null!==r?r:0),[d,m]=(0,n.useState)(0),[h,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{let e=async()=>{if(s&&l&&t&&"Admin"===t&&null==r)try{let e=await S(s);e&&(e.spend?c(e.spend):c(0),e.max_budget?m(e.max_budget):m(0))}catch(e){console.error("Error fetching global spend data:",e)}};(async()=>{try{if(null===l||null===t)return;if(null!==s){let e=(await P(s,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),u(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,s,l]),(0,n.useEffect)(()=>{null!==r&&c(r)},[r]);let x=[];o&&o.models&&(x=o.models),x&&x.includes("all-proxy-models")?(console.log("user models:",h),x=h):x&&x.includes("all-team-models")?x=o.models:x&&0===x.length&&(x=h);let p=void 0!==i?i.toFixed(4):null;return console.log("spend in view user spend: ".concat(i)),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-tremor-default text-tremor-content dark:text-dark-tremor-content",children:["Total Spend"," "]}),(0,a.jsxs)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:["$",p]})]}),(0,a.jsx)("div",{className:"ml-auto",children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Team Models"})}),(0,a.jsx)(em.Z,{className:"absolute right-0 z-10 bg-white p-2 shadow-lg max-w-xs",children:(0,a.jsx)(eD.Z,{children:x.map(e=>(0,a.jsx)(eB.Z,{children:(0,a.jsx)(eu.Z,{children:e})},e))})})]})})]})},eK=e=>{let{userID:l,userRole:t,selectedTeam:s,accessToken:r}=e,[o,i]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==r){let e=(await P(r,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),i(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[r,l,t]);let c=[];return s&&s.models&&(c=s.models),c&&c.includes("all-proxy-models")&&(console.log("user models:",o),c=o),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"mb-5",children:(0,a.jsx)("p",{className:"text-3xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:null==s?void 0:s.team_alias})})})},eG=e=>{let l,{teams:t,setSelectedTeam:s,userRole:r}=e,o={models:[],team_id:null,team_alias:"Default Team"},[i,c]=(0,n.useState)(o);return(l="App User"===r?t:t?[...t,o]:[o],"App User"===r)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(ex.Z,{children:"Select Team"}),(0,a.jsx)(eu.Z,{children:"If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys."}),(0,a.jsxs)(eu.Z,{className:"mt-3 mb-3",children:[(0,a.jsx)("b",{children:"Default Team:"})," If no team_id is set for a key, it will be grouped under here."]}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>s(e),children:e.team_alias},l))}):(0,a.jsxs)(eu.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},eq=t(37963),eV=t(97482);console.log("isLocal:",!1);var eW=e=>{let{userID:l,userRole:t,teams:s,keys:r,setUserRole:i,userEmail:c,setUserEmail:d,setTeams:m,setKeys:h}=e,[u,x]=(0,n.useState)(null),p=(0,o.useSearchParams)();p.get("viewSpend"),(0,o.useRouter)();let j=p.get("token"),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)([]),b={models:[],team_alias:"Default Team",team_id:null},[v,N]=(0,n.useState)(s?s[0]:b);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,n.useEffect)(()=>{if(j){let e=(0,eq.o)(j);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),y(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),i(l)}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&g&&t&&!r&&!u){let e=sessionStorage.getItem("userModels"+l);e?w(JSON.parse(e)):(async()=>{try{let e=await k(g,l,t,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(e),"; team values: ").concat(Object.entries(e.teams))),"Admin"==t){let e=await S(g);x(e),console.log("globalSpend:",e)}else x(e.user_info);h(e.keys),m(e.teams);let s=[...e.teams];s.length>0?(console.log("response['teams']: ".concat(s)),N(s[0])):N(b),sessionStorage.setItem("userData"+l,JSON.stringify(e.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(e.user_info));let r=(await P(g,l,t)).data.map(e=>e.id);console.log("available_model_names:",r),w(r),console.log("userModels:",_),sessionStorage.setItem("userModels"+l,JSON.stringify(r))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,j,g,r,t]),(0,n.useEffect)(()=>{if(null!==r&&null!=v){let e=0;for(let l of r)v.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===v.team_id&&(e+=l.spend);Z(e)}else if(null!==r){let e=0;for(let l of r)e+=l.spend;Z(e)}},[v]),null==l||null==j){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==g)return null;if(null==t&&i("App Owner"),t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to create keys"})]})}return console.log("inside user dashboard, selected team",v),console.log("teamSpend: ".concat(f)),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eK,{userID:l,userRole:t,selectedTeam:v||null,accessToken:g}),(0,a.jsx)(ez,{userID:l,userRole:t,accessToken:g,userSpend:f,selectedTeam:v||null}),(0,a.jsx)(eU,{userID:l,userRole:t,accessToken:g,selectedTeam:v||null,data:r,setData:h,teams:s}),(0,a.jsx)(eb,{userID:l,team:v||null,userRole:t,accessToken:g,data:r,setData:h},v?v.team_id:null),(0,a.jsx)(eG,{teams:s,setSelectedTeam:N,userRole:t})]})})})},eH=t(35087),eY=t(92836),eJ=t(26734),e$=t(41608),eX=t(32126),eQ=t(23682),e0=t(47047),e1=t(76628),e2=t(25707),e4=t(44041),e5=t(38302),e8=t(28683),e3=t(1460),e6=t(78578),e7=t(63954),e9=t(90252),le=t(7905),ll=e=>{let{modelID:l,accessToken:t}=e,[s,r]=(0,n.useState)(!1),o=async()=>{try{h.ZP.info("Making API Call"),r(!0);let e=await j(t,l);console.log("model delete Response:",e),h.ZP.success("Model ".concat(l," deleted successfully")),r(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(eE.Z,{onClick:()=>r(!0),icon:eS.Z,size:"sm"}),(0,a.jsx)(ey.Z,{open:s,onOk:o,okType:"danger",onCancel:()=>r(!1),children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(ex.Z,{children:"Delete Model"}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)("p",{children:"Are you sure you want to delete this model? This action is irreversible."})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},lt=t(97766),ls=t(46495),lr=t(18190),la=t(91118),ln=e=>{let{modelMetrics:l,modelMetricsCategories:t,customTooltip:s,premiumUser:r}=e;return r?(0,a.jsx)(la.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:t,colors:["indigo","rose"],connectNulls:!0,customTooltip:s}):(0,a.jsxs)("div",{children:[(0,a.jsx)(lr.Z,{title:"✨ Enterprise Feature",color:"teal",className:"mt-2 mb-4",children:"Enterprise features are available for users with a specific license, please contact LiteLLM to unlock this limitation."}),(0,a.jsx)(ei.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},lo=e=>{let{fields:l,selectedProvider:t}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:e.field_name.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),name:e.field_name,tooltip:e.field_description,className:"mb-2",children:(0,a.jsx)(ec.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})};let{Title:li,Link:lc}=eV.default;(s=r||(r={})).OpenAI="OpenAI",s.Azure="Azure",s.Anthropic="Anthropic",s.Google_AI_Studio="Google AI Studio",s.Bedrock="Amazon Bedrock",s.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",s.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",s.Databricks="Databricks";let ld={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks"},lm={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},lh=async(e,l,t)=>{try{let s=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(s)),console.log("received type of deployments: ".concat(typeof s)),s.forEach(async t=>{console.log("litellm_model: ".concat(t));let s={},r={};s.model=t;let a="";for(let[l,t]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==t){if("model_name"==l)a+=t;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)r[l]=t;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",t);let e={};if(t&&void 0!=t){try{e=JSON.parse(t)}catch(e){throw h.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,t]of Object.entries(e))s[l]=t}}else s[l]=t}let n={model_name:a,litellm_params:s,model_info:r},o=await x(l,n);console.log("response for model create call: ".concat(o.data))}),t.resetFields()}catch(e){h.ZP.error("Failed to create model: "+e,10)}};var lu=e=>{var l,t,s;let o,{accessToken:i,token:c,userRole:d,userID:m,modelData:x={data:[]},setModelData:j,premiumUser:g}=e,[y,f]=(0,n.useState)([]),[Z]=eg.Z.useForm(),[_,w]=(0,n.useState)(null),[b,k]=(0,n.useState)(""),[v,S]=(0,n.useState)([]),A=Object.values(r).filter(e=>isNaN(Number(e))),[P,F]=(0,n.useState)([]),[O,R]=(0,n.useState)("OpenAI"),[M,L]=(0,n.useState)(""),[U,D]=(0,n.useState)(!1),[B,z]=(0,n.useState)(null),[K,G]=(0,n.useState)([]),[q,V]=(0,n.useState)(null),[W,H]=(0,n.useState)([]),[J,$]=(0,n.useState)([]),[X,Q]=(0,n.useState)([]),[el,et]=(0,n.useState)([]),[es,en]=(0,n.useState)([]),[ep,ej]=(0,n.useState)([]),[ef,ew]=(0,n.useState)([]),[eb,ek]=(0,n.useState)([]),[eS,eL]=(0,n.useState)([]),[eU,eD]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[eB,ez]=(0,n.useState)(null),[eK,eG]=(0,n.useState)(0),eq=e=>{z(e),D(!0)},eW=async e=>{if(console.log("handleEditSubmit:",e),null==i)return;let l={},t=null;for(let[s,r]of Object.entries(e))"model_id"!==s?l[s]=r:t=r;let s={litellm_params:l,model_info:{id:t}};console.log("handleEditSubmit payload:",s);try{await Y(i,s),h.ZP.success("Model updated successfully, restart server to see updates"),D(!1),z(null)}catch(e){console.log("Error occurred")}},lr=()=>{k(new Date().toLocaleString())},la=async()=>{if(!i){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",eB);try{await er(i,{router_settings:{model_group_retry_policy:eB}}),h.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),h.ZP.error("Failed to save retry settings")}};if((0,n.useEffect)(()=>{if(!i||!c||!d||!m)return;let e=async()=>{try{var e,l,t,s,r,a,n,o;let c=await p(i);F(c);let h=await N(i,m,d);console.log("Model data response:",h.data),j(h);let u=new Set;for(let e=0;e0&&(g=x[x.length-1],console.log("_initial_model_group:",g),V(g)),console.log("selectedModelGroup:",q);let y=await E(i,m,d,g,null===(e=eU.from)||void 0===e?void 0:e.toISOString(),null===(l=eU.to)||void 0===l?void 0:l.toISOString());console.log("Model metrics response:",y),$(y.data),Q(y.all_api_bases);let f=await I(i,g,null===(t=eU.from)||void 0===t?void 0:t.toISOString(),null===(s=eU.to)||void 0===s?void 0:s.toISOString());et(f.data),en(f.all_api_bases);let Z=await T(i,m,d,g,null===(r=eU.from)||void 0===r?void 0:r.toISOString(),null===(a=eU.to)||void 0===a?void 0:a.toISOString());console.log("Model exceptions response:",Z),ej(Z.data),ew(Z.exception_types);let _=await C(i,m,d,g,null===(n=eU.from)||void 0===n?void 0:n.toISOString(),null===(o=eU.to)||void 0===o?void 0:o.toISOString());console.log("slowResponses:",_),eL(_);let w=(await ee(i,m,d)).router_settings;console.log("routerSettingsInfo:",w);let b=w.model_group_retry_policy,k=w.num_retries;console.log("model_group_retry_policy:",b),console.log("default_retries:",k),ez(b),eG(k)}catch(e){console.error("There was an error fetching the model data",e)}};i&&c&&d&&m&&e();let l=async()=>{let e=await u();console.log("received model cost map data: ".concat(Object.keys(e))),w(e)};null==_&&l(),lr()},[i,c,d,m,_,b]),!x||!i||!c||!d||!m)return(0,a.jsx)("div",{children:"Loading..."});let lu=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(_)),null!=_&&"object"==typeof _&&e in _)?_[e].litellm_provider:"openai";if(r){let e=r.split("/"),l=e[0];n=1===e.length?h(r):l}else n="openai";a&&(o=null==a?void 0:a.input_cost_per_token,i=null==a?void 0:a.output_cost_per_token,c=null==a?void 0:a.max_tokens,d=null==a?void 0:a.max_input_tokens),(null==s?void 0:s.litellm_params)&&(m=Object.fromEntries(Object.entries(null==s?void 0:s.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),x.data[e].provider=n,x.data[e].input_cost=o,x.data[e].output_cost=i,x.data[e].input_cost&&(x.data[e].input_cost=(1e6*Number(x.data[e].input_cost)).toFixed(2)),x.data[e].output_cost&&(x.data[e].output_cost=(1e6*Number(x.data[e].output_cost)).toFixed(2)),x.data[e].max_tokens=c,x.data[e].max_input_tokens=d,x.data[e].api_base=null==s?void 0:null===(t=s.litellm_params)||void 0===t?void 0:t.api_base,x.data[e].cleanedLitellmParams=m,lu.push(s.model_name),console.log(x.data[e])}if(d&&"Admin Viewer"==d){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let lx=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(r).find(l=>r[l]===e);if(l){let e=ld[l];console.log("mappingResult: ".concat(e));let t=[];"object"==typeof _&&Object.entries(_).forEach(l=>{let[s,r]=l;null!==r&&"object"==typeof r&&"litellm_provider"in r&&(r.litellm_provider===e||r.litellm_provider.includes(e))&&t.push(s)}),S(t),console.log("providerModels: ".concat(v))}},lp=async()=>{try{h.ZP.info("Running health check..."),L("");let e=await ea(i);L(e)}catch(e){console.error("Error running health check:",e),L("Error running health check")}},lj=async(e,l,t)=>{if(console.log("Updating model metrics for group:",e),i&&m&&d&&l&&t){console.log("inside updateModelMetrics - startTime:",l,"endTime:",t),V(e);try{let s=await E(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model metrics response:",s),$(s.data),Q(s.all_api_bases);let r=await I(i,e,l.toISOString(),t.toISOString());et(r.data),en(r.all_api_bases);let a=await T(i,m,d,e,l.toISOString(),t.toISOString());console.log("Model exceptions response:",a),ej(a.data),ew(a.exception_types);let n=await C(i,m,d,e,l.toISOString(),t.toISOString());console.log("slowResponses:",n),eL(n)}catch(e){console.error("Failed to fetch model metrics",e)}}},lg=e=>{var l,t;let{payload:s,active:r}=e;if(!r||!s)return null;let n=null===(t=s[0])||void 0===t?void 0:null===(l=t.payload)||void 0===l?void 0:l.date,o=s.sort((e,l)=>l.value-e.value);if(o.length>5){let e=o.length-5;(o=o.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:s.slice(5).reduce((e,l)=>e+l.value,0),color:"gray"})}return(0,a.jsxs)("div",{className:"w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown",children:[n&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",n]}),o.map((e,l)=>{let t=parseFloat(e.value.toFixed(5)),s=0===t&&e.value>0?"<0.00001":t.toFixed(5);return(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 mt-1 rounded-full bg-".concat(e.color,"-500")}),(0,a.jsx)("p",{className:"text-tremor-content",children:e.dataKey})]}),(0,a.jsx)("p",{className:"font-medium text-tremor-content-emphasis text-righ ml-2",children:s})]},l)})]})};console.log("selectedProvider: ".concat(O)),console.log("providerModels.length: ".concat(v.length));let ly=Object.keys(r).find(e=>r[e]===O);return ly&&(o=P.find(e=>e.name===ld[ly])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(eY.Z,{children:"All Models"}),(0,a.jsx)(eY.Z,{children:"Add Model"}),(0,a.jsx)(eY.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(eY.Z,{children:"Model Analytics"}),(0,a.jsx)(eY.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[b&&(0,a.jsxs)(eu.Z,{children:["Last Refreshed: ",b]}),(0,a.jsx)(eE.Z,{icon:e7.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lr})]})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],onValueChange:e=>V("all"===e?"all":e),value:q||K[0],children:[(0,a.jsx)(eM.Z,{value:"all",children:"All Models"}),K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))]})]}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"Public Model Name"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:"Provider"}),"Admin"===d&&(0,a.jsx)(eF.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:"API Base"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:"Extra litellm Params"}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(eF.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(eF.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:"Max Tokens"}),(0,a.jsx)(eF.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word"},children:"Status"})]})}),(0,a.jsx)(eC.Z,{children:x.data.filter(e=>"all"===q||e.model_name===q||null==q||""===q).map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(eu.Z,{children:e.model_name})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.provider}),"Admin"===d&&(0,a.jsx)(eT.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:e.api_base}),(0,a.jsx)(eT.Z,{style:{maxWidth:"200px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)(eu.Z,{children:"Litellm params"})}),(0,a.jsx)(em.Z,{children:(0,a.jsx)("pre",{children:JSON.stringify(e.cleanedLitellmParams,null,2)})})]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.input_cost||e.litellm_params.input_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:e.output_cost||e.litellm_params.output_cost_per_token||null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"120px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)("p",{style:{fontSize:"10px"},children:["Max Tokens: ",e.max_tokens," ",(0,a.jsx)("br",{}),"Max Input Tokens: ",e.max_input_tokens]})}),(0,a.jsx)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(eN.Z,{icon:e9.Z,size:"xs",className:"text-white",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"DB Model"})}):(0,a.jsx)(eN.Z,{icon:le.Z,size:"xs",className:"text-black",children:(0,a.jsx)("p",{style:{fontSize:"10px"},children:"Config Model"})})}),(0,a.jsxs)(eT.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>eq(e)}),(0,a.jsx)(ll,{modelID:e.model_info.id,accessToken:i})]})]},l))})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:t,model:s,onSubmit:r}=e,[n]=eg.Z.useForm(),o={},i="",c="";if(s){o=s.litellm_params,i=s.model_name;let e=s.model_info;e&&(c=e.id,console.log("model_id: ".concat(c)),o.model_id=c)}return(0,a.jsx)(ey.Z,{title:"Edit Model "+i,visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r(e),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:eW,initialValues:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"tpm",name:"tpm",tooltip:"int (optional) - Tokens limit for this deployment: in tokens per minute (tpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"rpm",name:"rpm",tooltip:"int (optional) - Rate limit for this deployment: in requests per minute (rpm). Find this information on your model/providers website",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(eZ.Z,{min:0,step:1})}),(0,a.jsx)(eg.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(eZ.Z,{min:0,step:1e-4})}),(0,a.jsx)(eg.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:U,onCancel:()=>{D(!1),z(null)},model:B,onSubmit:eW})]}),(0,a.jsxs)(eX.Z,{className:"h-full",children:[(0,a.jsx)(li,{level:2,children:"Add new model"}),(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eg.Z,{form:Z,onFinish:()=>{Z.validateFields().then(e=>{lh(e,i,Z)}).catch(e=>{console.error("Validation failed:",e)})},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:O.toString(),children:A.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>{lx(e),R(e)},children:e},l))})}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Public Model Name",name:"model_name",tooltip:"Model name your users will pass in. Also used for load-balancing, LiteLLM will load balance between all models with this public name.",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(s=O.toString())?"gemini-pro":"Anthropic"==s?"claude-3-opus":"Amazon Bedrock"==s?"claude-3-opus":"Google AI Studio"==s?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"LiteLLM Model Name(s)",name:"model",tooltip:"Actual model name used for making litellm.completion() call.",className:"mb-0",children:"Azure"===O?(0,a.jsx)(ec.Z,{placeholder:"Enter model name"}):v.length>0?(0,a.jsx)(e0.Z,{value:v,children:v.map((e,l)=>(0,a.jsx)(e1.Z,{value:e,children:e},l))}):(0,a.jsx)(ec.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/proxy/reliability#step-1---set-deployments-on-config",target:"_blank",children:"loadbalance"})," ","models with the same 'public name'"]})})]}),void 0!==o&&o.fields.length>0&&(0,a.jsx)(lo,{fields:o.fields,selectedProvider:o.name}),"Amazon Bedrock"!=O&&"Vertex AI (Anthropic, Gemini, etc.)"!=O&&void 0===o&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(ec.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==O&&(0,a.jsx)(eg.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(ec.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(ec.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(ls.Z,{name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;Z.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"uploading"!==e.file.status&&console.log(e.file,e.fileList),"done"===e.file.status?h.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&h.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(e_.ZP,{icon:(0,a.jsx)(lt.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==O&&(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsx)(eu.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==O||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==O)&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(ec.Z,{placeholder:"https://..."})}),"Azure"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(ec.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==O&&(0,a.jsxs)("div",{children:[(0,a.jsx)(eg.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(ec.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(lc,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Access Key ID",name:"aws_access_key_id",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Secret Access Key",name:"aws_secret_access_key",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:""})}),"Amazon Bedrock"==O&&(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"AWS Region Name",name:"aws_region_name",tooltip:"You can provide the raw key or the environment variable (e.g. `os.environ/MY_SECRET_KEY`).",children:(0,a.jsx)(ec.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(eg.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-0",children:(0,a.jsx)(e6.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(e5.Z,{children:[(0,a.jsx)(e8.Z,{span:10}),(0,a.jsx)(e8.Z,{span:10,children:(0,a.jsxs)(eu.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(lc,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]})]}),(0,a.jsx)("div",{style:{textAlign:"center",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(e3.Z,{title:"Get help on our github",children:(0,a.jsx)(eV.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(ei.Z,{onClick:lp,children:"Run `/health`"}),M&&(0,a.jsx)("pre",{children:JSON.stringify(M,null,2)})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eo.Z,{numItems:2,className:"mt-2",children:[(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:eU,onValueChange:e=>{eD(e),lj(q,e.from,e.to)}})]}),(0,a.jsxs)(e8.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Model Group"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2",defaultValue:q||K[0],value:q||K[0],children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>lj(e,eU.from,eU.to),children:e},l))})]})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(eY.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(eu.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),J&&X&&(0,a.jsx)(e2.Z,{title:"Model Latency",className:"h-72",data:J,showLegend:!1,index:"date",categories:X,connectNulls:!0,customTooltip:lg})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(ln,{modelMetrics:el,modelMetricsCategories:es,customTooltip:lg,premiumUser:g})})]})]})})}),(0,a.jsx)(e8.Z,{children:(0,a.jsx)(eA.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Deployment"}),(0,a.jsx)(eF.Z,{children:"Success Responses"}),(0,a.jsxs)(eF.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(eC.Z,{children:eS.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.api_base}),(0,a.jsx)(eT.Z,{children:e.total_count}),(0,a.jsx)(eT.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(eA.Z,{className:"mt-4",children:[(0,a.jsx)(ex.Z,{children:"Exceptions per Model"}),(0,a.jsx)(e4.Z,{className:"h-72",data:ep,index:"model",categories:ef,stack:!0,colors:["indigo-300","rose-200","#ffcc33"],yAxisWidth:30})]})]}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(eu.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(eR.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:q||K[0],value:q||K[0],onValueChange:e=>V(e),children:K.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>V(e),children:e},l))})]}),(0,a.jsxs)(ex.Z,{children:["Retry Policy for ",q]}),(0,a.jsx)(eu.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),lm&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(lm).map((e,l)=>{var t;let[s,r]=e,n=null==eB?void 0:null===(t=eB[q])||void 0===t?void 0:t[r];return null==n&&(n=eK),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)("td",{children:(0,a.jsx)(eZ.Z,{className:"ml-5",value:n,min:0,step:1,onChange:e=>{ez(l=>{var t;let s=null!==(t=null==l?void 0:l[q])&&void 0!==t?t:{};return{...null!=l?l:{},[q]:{...s,[r]:e}}})}})})]},l)})})}),(0,a.jsx)(ei.Z,{className:"mt-6 mr-8",onClick:la,children:"Save"})]})]})]})})};let{Option:lx}=ej.default;var lp=e=>{let{userID:l,accessToken:t,teams:s}=e,[r]=eg.Z.useForm(),[o,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[m,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{let e=await P(t,l,"any"),s=[];for(let l=0;l{i(!1),r.resetFields()},p=()=>{i(!1),d(null),r.resetFields()},j=async e=>{try{h.ZP.info("Making API Call"),i(!0),console.log("formValues in create user:",e);let s=await _(t,null,e);console.log("user create Response:",s),d(s.key),h.ZP.success("API user Created"),r.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-0",onClick:()=>i(!0),children:"+ Invite User"}),(0,a.jsxs)(ey.Z,{title:"Invite User",visible:o,width:800,footer:null,onOk:x,onCancel:p,children:[(0,a.jsx)(eu.Z,{className:"mb-1",children:"Invite a user to login to the Admin UI and create Keys"}),(0,a.jsx)(eu.Z,{className:"mb-6",children:(0,a.jsx)("b",{children:"Note: SSO Setup Required for this"})}),(0,a.jsxs)(eg.Z,{form:r,onFinish:j,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(eg.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(ej.default,{placeholder:"Select Team ID",style:{width:"100%"},children:s?s.map(e=>(0,a.jsx)(lx,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(lx,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(eg.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(ef.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create User"})})]})]}),c&&(0,a.jsxs)(ey.Z,{title:"User Created Successfully",visible:o,onOk:x,onCancel:p,footer:null,children:[(0,a.jsx)("p",{children:"User has been created to access your proxy. Please Ask them to Log In."}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{children:(0,a.jsx)("b",{children:"Note: This Feature is only supported through SSO on the Admin UI"})})]})]})},lj=e=>{let{accessToken:l,token:t,keys:s,userRole:r,userID:o,teams:i,setKeys:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(0),[j,g]=n.useState(null),[y,f]=(0,n.useState)(null);return((0,n.useEffect)(()=>{if(!l||!t||!r||!o)return;let e=async()=>{try{let e=await k(l,null,r,!0,x,25);console.log("user data response:",e),m(e)}catch(e){console.error("There was an error fetching the model data",e)}};l&&t&&r&&o&&e()},[l,t,r,o,x]),d&&l&&t&&r&&o)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(eo.Z,{className:"gap-2 p-2 h-[80vh] w-full mt-8",children:[(0,a.jsx)(lp,{userID:o,accessToken:l,teams:i}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[80vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1",children:(0,a.jsx)(eu.Z,{children:"These are Users on LiteLLM that created API Keys. Automatically tracked by LiteLLM"})}),(0,a.jsx)(eJ.Z,{children:(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eI.Z,{className:"mt-5",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"User ID"}),(0,a.jsx)(eF.Z,{children:"User Email"}),(0,a.jsx)(eF.Z,{children:"User Models"}),(0,a.jsx)(eF.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(eF.Z,{children:"User API Key Aliases"})]})}),(0,a.jsx)(eC.Z,{children:d.map(e=>{var l;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_id}),(0,a.jsx)(eT.Z,{children:e.user_email}),(0,a.jsx)(eT.Z,{children:e.models&&e.models.length>0?e.models:"All Models"}),(0,a.jsx)(eT.Z,{children:e.spend?null===(l=e.spend)||void 0===l?void 0:l.toFixed(2):0}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eo.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsx)(eN.Z,{size:"xs",color:"indigo",children:e.key_aliases.filter(e=>null!==e).join(", ")}):(0,a.jsx)(eN.Z,{size:"xs",color:"gray",children:"No Keys"})})})]},e.user_id)})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("div",{className:"flex-1 flex justify-between items-center"})]})})]})})]}),function(){if(!d)return null;let e=Math.ceil(d.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",x+1," of ",e]}),(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none",disabled:0===x,onClick:()=>p(x-1),children:"← Prev"}),(0,a.jsx)("button",{className:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-r focus:outline-none",onClick:()=>{p(x+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},lg=e=>{let{teams:l,searchParams:t,accessToken:s,setTeams:r,userID:o,userRole:i}=e,[c]=eg.Z.useForm(),[d]=eg.Z.useForm(),{Title:m,Paragraph:u}=eV.default,[x,p]=(0,n.useState)(""),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(l?l[0]:null),[Z,_]=(0,n.useState)(!1),[w,k]=(0,n.useState)(!1),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)(!1),[I,C]=(0,n.useState)(null),[T,F]=(0,n.useState)({}),O=e=>{f(e),g(!0)},R=async e=>{let t=e.team_id;if(console.log("handleEditSubmit:",e),null==s)return;let a=await H(s,e);l&&r(l.map(e=>e.team_id===t?a.data:e)),h.ZP.success("Team updated successfully"),g(!1),f(null)},M=async e=>{C(e),E(!0)},L=async()=>{if(null!=I&&null!=l&&null!=s){try{await b(s,I);let e=l.filter(e=>e.team_id!==I);r(e)}catch(e){console.error("Error deleting the team:",e)}E(!1),C(null)}};(0,n.useEffect)(()=>{let e=async()=>{try{if(null===o||null===i||null===s||null===l)return;console.log("fetching team info:");let e={};for(let t=0;t<(null==l?void 0:l.length);t++){let r=l[t].team_id,a=await v(s,r);console.log("teamInfo response:",a),null!==a&&(e={...e,[r]:a})}F(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===o||null===i)return;if(null!==s){let e=(await P(s,o,i)).data.map(e=>e.id);console.log("available_model_names:",e),N(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,o,i,l]);let U=async e=>{try{if(null!=s){var t;let a=null==e?void 0:e.team_alias;if((null!==(t=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==t?t:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));h.ZP.info("Creating Team");let n=await V(s,e);null!==l?r([...l,n]):r([n]),console.log("response for team create call: ".concat(n)),h.ZP.success("Team created"),_(!1)}}catch(e){console.error("Error creating the team:",e),h.ZP.error("Error creating the team: "+e,20)}},D=async e=>{try{if(null!=s&&null!=l){h.ZP.info("Adding Member");let t={role:"user",user_email:e.user_email,user_id:e.user_id},a=await J(s,y.team_id,t);console.log("response for team create call: ".concat(a.data));let n=l.findIndex(e=>(console.log("team.team_id=".concat(e.team_id,"; response.data.team_id=").concat(a.data.team_id)),e.team_id===a.data.team_id));if(console.log("foundIndex: ".concat(n)),-1!==n){let e=[...l];e[n]=a.data,r(e),f(a.data)}k(!1)}}catch(e){console.error("Error creating the team:",e)}};return console.log("received teams ".concat(JSON.stringify(l))),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Team Name"}),(0,a.jsx)(eF.Z,{children:"Spend (USD)"}),(0,a.jsx)(eF.Z,{children:"Budget (USD)"}),(0,a.jsx)(eF.Z,{children:"Models"}),(0,a.jsx)(eF.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(eF.Z,{children:"Info"})]})}),(0,a.jsx)(eC.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(eT.Z,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},children:Array.isArray(e.models)?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:0===e.models.length?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(eu.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(eN.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(eu.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(eT.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(eu.Z,{children:["TPM: ",e.tpm_limit?e.tpm_limit:"Unlimited"," ",(0,a.jsx)("br",{}),"RPM:"," ",e.rpm_limit?e.rpm_limit:"Unlimited"]})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].keys&&T[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(eu.Z,{children:[T&&e.team_id&&T[e.team_id]&&T[e.team_id].team_info&&T[e.team_id].team_info.members_with_roles&&T[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>O(e)}),(0,a.jsx)(eE.Z,{onClick:()=>M(e.team_id),icon:eS.Z,size:"sm"})]})]},e.team_id)):null})]}),A&&(0,a.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,a.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,a.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,a.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,a.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,a.jsx)("div",{className:"sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,a.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Team"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this team ?"})})]})})}),(0,a.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,a.jsx)(ei.Z,{onClick:L,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(ei.Z,{onClick:()=>{E(!1),C(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>_(!0),children:"+ Create New Team"}),(0,a.jsx)(ey.Z,{title:"Create Team",visible:Z,width:800,footer:null,onOk:()=>{_(!1),c.resetFields()},onCancel:()=>{_(!1),c.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:U,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(u,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(eR.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{f(e)},children:e.team_alias},l))}):(0,a.jsxs)(u,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:y?y.members_with_roles.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.role})]},l)):null})]})}),y&&(0,a.jsx)(e=>{let{visible:l,onCancel:t,team:s,onSubmit:r}=e,[n]=eg.Z.useForm();return(0,a.jsx)(ey.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{n.validateFields().then(e=>{r({...e,team_id:s.team_id}),n.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:t,children:(0,a.jsxs)(eg.Z,{form:n,onFinish:R,initialValues:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(ec.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(ej.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(ej.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),S&&S.map(e=>(0,a.jsx)(ej.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(eZ.Z,{step:1,width:400})}),(0,a.jsx)(eg.Z.Item,{label:"Requests per minute Limit (RPM)",name:"team_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:j,onCancel:()=>{g(!1),f(null)},team:y,onSubmit:R})]}),(0,a.jsxs)(en.Z,{numColSpan:1,children:[(0,a.jsx)(ei.Z,{className:"mx-auto mb-5",onClick:()=>k(!0),children:"+ Add member"}),(0,a.jsx)(ey.Z,{title:"Add member",visible:w,width:800,footer:null,onOk:()=>{k(!1),d.resetFields()},onCancel:()=>{k(!1),d.resetFields()},children:(0,a.jsxs)(eg.Z,{form:c,onFinish:D,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},ly=e=>{let l,{searchParams:t,accessToken:s,showSSOBanner:r}=e,[o]=eg.Z.useForm(),[i]=eg.Z.useForm(),{Title:c,Paragraph:d}=eV.default,[m,u]=(0,n.useState)(""),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!1),[y,f]=(0,n.useState)(!1),[Z,_]=(0,n.useState)(!1),[w,b]=(0,n.useState)(!1),[k,v]=(0,n.useState)(!1);try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let S=()=>{v(!1)},N=["proxy_admin","proxy_admin_viewer"];(0,n.useEffect)(()=>{(async()=>{if(null!=s){let e=[],l=await q(s,"proxy_admin_viewer");l.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy viewers: ".concat(l));let t=await q(s,"proxy_admin");t.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(t)),console.log("combinedList: ".concat(e)),p(e)}})()},[s]);let A=()=>{_(!1),i.resetFields()},E=()=>{_(!1),i.resetFields()},I=e=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})}),(0,a.jsx)("div",{className:"text-center mb-4",children:"OR"}),(0,a.jsx)(eg.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(ef.Z,{name:"user_id",className:"px-3 py-2 border rounded-md w-full"})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add member"})})]}),C=(e,l,t)=>(0,a.jsxs)(eg.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(eR.Z,{value:l,children:N.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:t,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(ef.Z,{value:t,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update role"})})]}),T=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,null);console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),h.ZP.success("Refresh tab to see updated user role"),_(!1)}}catch(e){console.error("Error creating the key:",e)}},P=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call");let l=await $(s,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),g(!1)}}catch(e){console.error("Error creating the key:",e)}},F=async e=>{try{if(null!=s&&null!=x){h.ZP.info("Making API Call"),e.user_email,e.user_id;let l=await $(s,e,"proxy_admin");console.log("response for team create call: ".concat(l));let t=x.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(l.user_id)),e.user_id===l.user_id));console.log("foundIndex: ".concat(t)),-1==t&&(console.log("updates admin with new user"),x.push(l),p(x)),f(!1)}}catch(e){console.error("Error creating the key:",e)}},O=async e=>{null!=s&&er(s,{environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}})};return console.log("admins: ".concat(null==x?void 0:x.length)),(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)(c,{level:4,children:"Admin Access "}),(0,a.jsxs)(d,{children:[r&&(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/ui#restrict-ui-access",children:"Requires SSO Setup"}),(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin: "})," Can create keys, teams, users, add models, etc. ",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Proxy Admin Viewer: "}),"Can just view spend. They cannot create keys, teams or grant users access to new models."," "]}),(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(eA.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Member Name"}),(0,a.jsx)(eF.Z,{children:"Role"})]})}),(0,a.jsx)(eC.Z,{children:x?x.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(eT.Z,{children:e.user_role}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eE.Z,{icon:ev.Z,size:"sm",onClick:()=>_(!0)}),(0,a.jsx)(ey.Z,{title:"Update role",visible:Z,width:800,footer:null,onOk:A,onCancel:E,children:C(T,e.user_role,e.user_id)})]})]},l)):null})]})})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(ei.Z,{className:"mr-4 mb-5",onClick:()=>f(!0),children:"+ Add admin"}),(0,a.jsx)(ey.Z,{title:"Add admin",visible:y,width:800,footer:null,onOk:()=>{f(!1),i.resetFields()},onCancel:()=>{f(!1),i.resetFields()},children:I(F)}),(0,a.jsx)(ei.Z,{className:"mb-5",onClick:()=>g(!0),children:"+ Add viewer"}),(0,a.jsx)(ey.Z,{title:"Add viewer",visible:j,width:800,footer:null,onOk:()=>{g(!1),i.resetFields()},onCancel:()=>{g(!1),i.resetFields()},children:I(P)})]})})]}),(0,a.jsxs)(eo.Z,{children:[(0,a.jsx)(c,{level:4,children:"Add SSO"}),(0,a.jsxs)("div",{className:"flex justify-start mb-4",children:[(0,a.jsx)(ei.Z,{onClick:()=>b(!0),children:"Add SSO"}),(0,a.jsx)(ey.Z,{title:"Add SSO",visible:w,width:800,footer:null,onOk:()=>{b(!1),o.resetFields()},onCancel:()=>{b(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{F(e),O(e),b(!1),v(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(ef.Z,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(ef.Z.Password,{})}),(0,a.jsx)(eg.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(ef.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(ey.Z,{title:"SSO Setup Instructions",visible:k,width:800,footer:null,onOk:S,onCancel:()=>{v(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(eu.Z,{className:"mt-2",children:"4. If Step 3 is successful, you can close this tab"}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{onClick:S,children:"Done"})})]})]}),(0,a.jsxs)(lr.Z,{title:"Login without SSO",color:"teal",children:["If you need to login without sso, you can access ",(0,a.jsxs)("a",{href:l,target:"_blank",children:[(0,a.jsx)("b",{children:l})," "]})]})]})]})},lf=t(42556),lZ=e=>{let{alertingSettings:l,handleInputChange:t,handleResetField:s,handleSubmit:r,premiumUser:n}=e,[o]=eg.Z.useForm();return(0,a.jsxs)(eg.Z,{form:o,onFinish:()=>{let e=o.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):r(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{align:"center",children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),e.premium_field?n?(0,a.jsx)(eg.Z.Item,{name:e.field_name,children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l)}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}):(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})})}):(0,a.jsx)(eg.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(eT.Z,{children:"Integer"===e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>t(e.field_name,l),className:"p-0"}):(0,a.jsx)(ef.Z,{value:e.field_value,onChange:l=>t(e.field_name,l)})})}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>s(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Update Settings"})})]})},l_=e=>{let{accessToken:l,premiumUser:t}=e,[s,r]=(0,n.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,n.useEffect)(()=>{l&&f(l).then(e=>{r(e)})},[l]),(0,a.jsx)(lZ,{alertingSettings:s,handleInputChange:(e,l)=>{r(s.map(t=>t.field_name===e?{...t,field_value:l}:t))},handleResetField:(e,t)=>{if(l)try{let l=s.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),r(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let t={};s.forEach(e=>{t[e.field_name]=e.field_value});let r={...e,...t};try{et(l,"alerting_args",r),h.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:t})};let lw=[{name:"slack",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"langfuse",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}},{name:"openmeter",variables:{LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null,SLACK_WEBHOOK_URL:null}}];var lb=e=>{let{accessToken:l,userRole:t,userID:s,premiumUser:r}=e,[o,i]=(0,n.useState)(lw),[c,d]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[x]=eg.Z.useForm(),[p,j]=(0,n.useState)(null),[g,y]=(0,n.useState)([]),[f,Z]=(0,n.useState)(""),[_,w]=(0,n.useState)({}),[b,k]=(0,n.useState)([]),v=e=>{b.includes(e)?k(b.filter(l=>l!==e)):k([...b,e])},S={llm_exceptions:"LLM Exceptions",llm_too_slow:"LLM Responses Too Slow",llm_requests_hanging:"LLM Requests Hanging",budget_alerts:"Budget Alerts (API Keys, Users)",db_exceptions:"Database Exceptions (Read/Write)",daily_reports:"Weekly/Monthly Spend Reports",outage_alerts:"Outage Alerts",region_outage_alerts:"Region Outage Alerts"};(0,n.useEffect)(()=>{l&&t&&s&&ee(l,s,t).then(e=>{console.log("callbacks",e);let l=lw;i(l=l.map(l=>{let t=e.callbacks.find(e=>e.name===l.name);return t?{...l,variables:{...l.variables,...t.variables}}:l}));let t=e.alerts;if(console.log("alerts_data",t),t&&t.length>0){let e=t[0];console.log("_alert_info",e);let l=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",l),k(e.active_alerts),Z(l),w(e.alerts_to_webhook)}d(t)})},[l,t,s]);let N=e=>b&&b.includes(e),A=e=>{if(!l)return;let t=Object.fromEntries(Object.entries(e.variables).map(e=>{var l;let[t,s]=e;return[t,(null===(l=document.querySelector('input[name="'.concat(t,'"]')))||void 0===l?void 0:l.value)||s]}));console.log("updatedVariables",t),console.log("updateAlertTypes",g);let s={environment_variables:t,litellm_settings:{success_callback:[e.name]}};try{er(l,s)}catch(e){h.ZP.error("Failed to update callback: "+e,20)}h.ZP.success("Callback updated successfully")},E=()=>{l&&x.validateFields().then(e=>{if(console.log("Form values:",e),"langfuse"===e.callback){er(l,{environment_variables:{LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:e.langfusePublicKey,LANGFUSE_SECRET_KEY:e.langfusePrivateKey,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("slack"===e.callback){console.log("values.slackWebhookUrl: ".concat(e.slackWebhookUrl)),er(l,{general_settings:{alerting:["slack"],alerting_threshold:300},environment_variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl}}),console.log("values.callback: ".concat(e.callback));let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:e.slackWebhookUrl,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:null}};i(o?[...o,t]:[t])}else if("openmeter"==e.callback){console.log("values.openMeterApiKey: ".concat(e.openMeterApiKey)),er(l,{environment_variables:{OPENMETER_API_KEY:e.openMeterApiKey},litellm_settings:{success_callback:[e.callback]}});let t={name:e.callback,variables:{SLACK_WEBHOOK_URL:null,LANGFUSE_HOST:null,LANGFUSE_PUBLIC_KEY:null,LANGFUSE_SECRET_KEY:null,OPENMETER_API_KEY:e.openMeterAPIKey}};i(o?[...o,t]:[t])}u(!1),x.resetFields(),j(null)})};return l?(console.log("callbacks: ".concat(o)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(lr.Z,{title:"[UI] Presidio PII + Guardrails Coming Soon. https://docs.litellm.ai/docs/proxy/pii_masking",color:"sky"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(eY.Z,{value:"2",children:"Alerting Settings"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Callback"}),(0,a.jsx)(eF.Z,{children:"Callback Env Vars"})]})}),(0,a.jsx)(eC.Z,{children:o.filter(e=>"slack"!==e.name).map((e,t)=>{var s;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eN.Z,{color:"emerald",children:e.name})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)("ul",{children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).filter(l=>{let[t,s]=l;return t.toLowerCase().includes(e.name)}).map(e=>{let[l,t]=e;return(0,a.jsxs)("li",{children:[(0,a.jsx)(eu.Z,{className:"mt-2",children:l}),"LANGFUSE_HOST"===l?(0,a.jsx)("p",{children:"default value=https://cloud.langfuse.com"}):(0,a.jsx)("div",{}),(0,a.jsx)(ec.Z,{name:l,defaultValue:t,type:"password"})]},l)})}),(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(e),children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,e.name),className:"mx-2",children:"Test Callback"})]})]},t)})})]})})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eu.Z,{className:"my-2",children:["Alerts are only supported for Slack Webhook URLs. Get your webhook urls from"," ",(0,a.jsx)("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",style:{color:"blue"},children:"here"})]}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{}),(0,a.jsx)(eF.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(S).map((e,l)=>{let[t,s]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:"region_outage_alerts"==t?r?(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)}):(0,a.jsx)(ei.Z,{className:"flex items-center justify-center",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Enterprise Feature"})}):(0,a.jsx)(lf.Z,{id:"switch",name:"switch",checked:N(t),onChange:()=>v(t)})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eu.Z,{children:s})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:t,type:"password",defaultValue:_&&_[t]?_[t]:f})})]},l)})})]}),(0,a.jsx)(ei.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(S).forEach(l=>{let[t,s]=l,r=document.querySelector('input[name="'.concat(t,'"]'));console.log("key",t),console.log("webhookInput",r);let a=(null==r?void 0:r.value)||"";console.log("newWebhookValue",a),e[t]=a}),console.log("updatedAlertToWebhooks",e);let t={general_settings:{alert_to_webhook_url:e,alert_types:b}};console.log("payload",t);try{er(l,t)}catch(e){h.ZP.error("Failed to update alerts: "+e,20)}h.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(ei.Z,{onClick:()=>X(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(l_,{accessToken:l,premiumUser:r})})]})]})]}),(0,a.jsx)(ey.Z,{title:"Add Callback",visible:m,onOk:E,width:800,onCancel:()=>{u(!1),x.resetFields(),j(null)},footer:null,children:(0,a.jsxs)(eg.Z,{form:x,layout:"vertical",onFinish:E,children:[(0,a.jsx)(eg.Z.Item,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsxs)(ej.default,{onChange:e=>{j(e)},children:[(0,a.jsx)(ej.default.Option,{value:"langfuse",children:"langfuse"}),(0,a.jsx)(ej.default.Option,{value:"openmeter",children:"openmeter"})]})}),"langfuse"===p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PUBLIC_KEY",name:"langfusePublicKey",rules:[{required:!0,message:"Please enter the public key"}],children:(0,a.jsx)(ec.Z,{type:"password"})}),(0,a.jsx)(eg.Z.Item,{label:"LANGFUSE_PRIVATE_KEY",name:"langfusePrivateKey",rules:[{required:!0,message:"Please enter the private key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})]}),"openmeter"==p&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eg.Z.Item,{label:"OPENMETER_API_KEY",name:"openMeterApiKey",rules:[{required:!0,message:"Please enter the openmeter api key"}],children:(0,a.jsx)(ec.Z,{type:"password"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:lk}=ej.default;var lv=e=>{let{models:l,accessToken:t,routerSettings:s,setRouterSettings:r}=e,[o]=eg.Z.useForm(),[i,c]=(0,n.useState)(!1),[d,m]=(0,n.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(ei.Z,{className:"mx-auto",onClick:()=>c(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(ey.Z,{title:"Add Fallbacks",visible:i,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),o.resetFields()},children:(0,a.jsxs)(eg.Z,{form:o,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,n=[...s.fallbacks||[],{[l]:a}],i={...s,fallbacks:n};console.log(i);try{er(t,{router_settings:i}),r(i)}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully"),c(!1),o.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Public Model Name",name:"model_name",rules:[{required:!0,message:"Set the model to fallback for"}],help:"required",children:(0,a.jsx)(eR.Z,{defaultValue:d,children:l&&l.map((e,l)=>(0,a.jsx)(eM.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(eg.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(e0.Z,{value:l,children:l&&l.filter(e=>e!=d).map(e=>(0,a.jsx)(e1.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},lS=t(12968);async function lN(e,l){console.log("isLocal:",!1);let t=window.location.origin,s=new lS.ZP.OpenAI({apiKey:l,baseURL:t,dangerouslyAllowBrowser:!0});try{let l=await s.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});h.ZP.success((0,a.jsxs)("span",{children:["Test model=",(0,a.jsx)("strong",{children:e}),", received model=",(0,a.jsx)("strong",{children:l.model}),". See"," ",(0,a.jsx)("a",{href:"#",onClick:()=>window.open("https://docs.litellm.ai/docs/proxy/reliability","_blank"),style:{textDecoration:"underline",color:"blue"},children:"curl"})]}))}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let lA={ttl:3600,lowest_latency_buffer:0},lE=e=>{let{selectedStrategy:l,strategyArgs:t,paramExplanation:s}=e;return(0,a.jsxs)(ed.Z,{children:[(0,a.jsx)(eh.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(em.Z,{children:"latency-based-routing"==l?(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(t).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:s[l]})]}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]})}):(0,a.jsx)(eu.Z,{children:"No specific settings"})})]})};var lI=e=>{let{accessToken:l,userRole:t,userID:s,modelData:r}=e,[o,i]=(0,n.useState)({}),[c,d]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[x,p]=(0,n.useState)(!1),[j]=eg.Z.useForm(),[g,y]=(0,n.useState)(null),[f,Z]=(0,n.useState)(null),[_,w]=(0,n.useState)(null),b={routing_strategy_args:"(dict) Arguments to pass to the routing strategy",routing_strategy:"(string) Routing strategy to use",allowed_fails:"(int) Number of times a deployment can fail before being added to cooldown",cooldown_time:"(int) time in seconds to cooldown a deployment after failure",num_retries:"(int) Number of retries for failed requests. Defaults to 0.",timeout:"(float) Timeout for requests. Defaults to None.",retry_after:"(int) Minimum time to wait before retrying a failed request",ttl:"(int) Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"(float) Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};(0,n.useEffect)(()=>{l&&t&&s&&(ee(l,s,t).then(e=>{console.log("callbacks",e),i(e.router_settings)}),el(l).then(e=>{u(e)}))},[l,t,s]);let k=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(o.fallbacks)),o.fallbacks.map(l=>(e in l&&delete l[e],l));try{await er(l,{router_settings:o}),i({...o}),Z(o.routing_strategy),h.ZP.success("Router settings updated successfully")}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}}},v=(e,l)=>{u(m.map(t=>t.field_name===e?{...t,field_value:l}:t))},S=(e,t)=>{if(!l)return;let s=m[t].field_value;if(null!=s&&void 0!=s)try{et(l,e,s);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);u(t)}catch(e){}},N=(e,t)=>{if(l)try{es(l,e);let t=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);u(t)}catch(e){}},A=e=>{if(!l)return;console.log("router_settings",e);let t=Object.fromEntries(Object.entries(e).map(e=>{let[l,t]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var s;return[l,(null===(s=document.querySelector('input[name="'.concat(l,'"]')))||void 0===s?void 0:s.value)||t]}if("routing_strategy"==l)return[l,f];if("routing_strategy_args"==l&&"latency-based-routing"==f){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),t=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==t?void 0:t.value)&&(e.ttl=Number(t.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",t);try{er(l,{router_settings:t})}catch(e){h.ZP.error("Failed to update router settings: "+e,20)}h.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(eJ.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(e$.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(eY.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(eY.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(eY.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(ex.Z,{children:"Router Settings"}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"})]})}),(0,a.jsx)(eC.Z,{children:Object.entries(o).filter(e=>{let[l,t]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,t]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:b[l]})]}),(0,a.jsx)(eT.Z,{children:"routing_strategy"==l?(0,a.jsxs)(eR.Z,{defaultValue:t,className:"w-full max-w-md",onValueChange:Z,children:[(0,a.jsx)(eM.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(eM.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(eM.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(ec.Z,{name:l,defaultValue:"object"==typeof t?JSON.stringify(t,null,2):t.toString()})})]},l)})})]}),(0,a.jsx)(lE,{selectedStrategy:f,strategyArgs:o&&o.routing_strategy_args&&Object.keys(o.routing_strategy_args).length>0?o.routing_strategy_args:lA,paramExplanation:b})]}),(0,a.jsx)(en.Z,{children:(0,a.jsx)(ei.Z,{className:"mt-2",onClick:()=>A(o),children:"Save Changes"})})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Model Name"}),(0,a.jsx)(eF.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(eC.Z,{children:o.fallbacks&&o.fallbacks.map((e,t)=>Object.entries(e).map(e=>{let[s,r]=e;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:s}),(0,a.jsx)(eT.Z,{children:Array.isArray(r)?r.join(", "):r}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(ei.Z,{onClick:()=>lN(s,l),children:"Test Fallback"})}),(0,a.jsx)(eT.Z,{children:(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>k(s)})})]},t.toString()+s)}))})]}),(0,a.jsx)(lv,{models:(null==r?void 0:r.data)?r.data.map(e=>e.model_name):[],accessToken:l,routerSettings:o,setRouterSettings:i})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Setting"}),(0,a.jsx)(eF.Z,{children:"Value"}),(0,a.jsx)(eF.Z,{children:"Status"}),(0,a.jsx)(eF.Z,{children:"Action"})]})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(eu.Z,{children:e.field_name}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:e.field_description})]}),(0,a.jsx)(eT.Z,{children:"Integer"==e.field_type?(0,a.jsx)(eZ.Z,{step:1,value:e.field_value,onChange:l=>v(e.field_name,l)}):null}),(0,a.jsx)(eT.Z,{children:!0==e.stored_in_db?(0,a.jsx)(eN.Z,{icon:e9.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(eN.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(eT.Z,{children:[(0,a.jsx)(ei.Z,{onClick:()=>S(e.field_name,l),children:"Update"}),(0,a.jsx)(eE.Z,{icon:eS.Z,color:"red",onClick:()=>N(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},lC=e=>{let{isModalVisible:l,accessToken:t,setIsModalVisible:s,setBudgetList:r}=e,[n]=eg.Z.useForm(),o=async e=>{if(null!=t&&void 0!=t)try{h.ZP.info("Making API Call");let l=await y(t,e);console.log("key create Response:",l),r(e=>e?[...e,l]:[l]),h.ZP.success("API Key Created"),n.resetFields()}catch(e){console.error("Error creating the key:",e),h.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(ey.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{s(!1),n.resetFields()},onCancel:()=>{s(!1),n.resetFields()},children:(0,a.jsxs)(eg.Z,{form:n,onFinish:o,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.Z.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,a.jsx)(ec.Z,{placeholder:""})}),(0,a.jsx)(eg.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(eZ.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(ed.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(eh.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(em.Z,{children:[(0,a.jsx)(eg.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(eZ.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(eg.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(ej.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(ej.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(ej.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(e_.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},lT=t(67951),lP=e=>{let{accessToken:l}=e,[t,s]=(0,n.useState)(!1),[r,o]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&Q(l).then(e=>{o(e)})},[l]);let i=async(e,t)=>{if(null==l)return;h.ZP.info("Request made"),await g(l,e);let s=[...r];s.splice(t,1),o(s),h.ZP.success("Budget Deleted.")};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsx)(ei.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>s(!0),children:"+ Create Budget"}),(0,a.jsx)(lC,{accessToken:l,isModalVisible:t,setIsModalVisible:s,setBudgetList:o}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(eu.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Budget ID"}),(0,a.jsx)(eF.Z,{children:"Max Budget"}),(0,a.jsx)(eF.Z,{children:"TPM"}),(0,a.jsx)(eF.Z,{children:"RPM"})]})}),(0,a.jsx)(eC.Z,{children:r.map((e,l)=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.budget_id}),(0,a.jsx)(eT.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(eT.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(eT.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(eE.Z,{icon:eS.Z,size:"sm",onClick:()=>i(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(eu.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(eY.Z,{children:"Test it (Curl)"}),(0,a.jsx)(eY.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:"\ncurl -X POST --location '/end_user/new' \n-H 'Authorization: Bearer ' \n-H 'Content-Type: application/json' \n-d '{\"user_id\": \"my-customer-id', \"budget_id\": \"\"}' # \uD83D\uDC48 KEY CHANGE\n\n "})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"bash",children:'\ncurl -X POST --location \'/chat/completions\' \n-H \'Authorization: Bearer \' \n-H \'Content-Type: application/json\' \n-d \'{\n "model": "gpt-3.5-turbo\', \n "messages":[{"role": "user", "content": "Hey, how\'s it going?"}],\n "user": "my-customer-id"\n}\' # \uD83D\uDC48 KEY CHANGE\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{var l;let{userID:t,userRole:s,token:r,accessToken:o,keys:i,premiumUser:c}=e,[d,m]=(0,n.useState)(null),[h,u]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);(0,n.useEffect)(()=>{o&&r&&s&&t&&(async()=>{try{let e=await A(o,t,s);console.log("ModelHubData:",e),m(e.data)}catch(e){console.error("There was an error fetching the model data",e)}})()},[o,r,s,t]);let j=e=>{p(e),u(!0)},g=e=>{navigator.clipboard.writeText(e)};return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,a.jsx)("div",{className:"relative w-full"}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(ex.Z,{className:"ml-8 text-center ",children:"Model Hub"}),(0,a.jsx)(ei.Z,{className:"ml-4",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4",children:d&&d.map(e=>(0,a.jsxs)(eA.Z,{className:"mt-5 mx-8",children:[(0,a.jsxs)("pre",{className:"flex justify-between",children:[(0,a.jsx)(ex.Z,{children:e.model_group}),(0,a.jsx)(e3.Z,{title:e.model_group,children:(0,a.jsx)(lF.Z,{onClick:()=>g(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,a.jsxs)("div",{className:"my-5",children:[(0,a.jsxs)(eu.Z,{children:["Mode: ",e.mode]}),(0,a.jsxs)(eu.Z,{children:["Supports Function Calling: ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Supports Vision: ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,a.jsxs)(eu.Z,{children:["Max Input Tokens: ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,a.jsxs)(eu.Z,{children:["Max Output Tokens: ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,a.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,a.jsxs)("a",{href:"#",onClick:()=>j(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,a.jsx)(lO.Z,{})]})})]},e.model_group))})]}),(0,a.jsx)(ey.Z,{title:x&&x.model_group?x.model_group:"Unknown Model",width:800,visible:h,footer:null,onOk:()=>{u(!1),p(null)},onCancel:()=>{u(!1),p(null)},children:x&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-4",children:(0,a.jsx)("strong",{children:"Model Information & Usage"})}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"Supported OpenAI Params"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(x.model_group,'", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:"".concat(null===(l=x.supported_openai_params)||void 0===l?void 0:l.map(e=>"".concat(e,"\n")).join(""))})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="'.concat(x.model_group,'", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n ')})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "'.concat(x.model_group,'",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n ')})})]})]})]})})]})},lM=e=>{let{}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("p",{className:"text-2xl text-tremor-content-strong dark:text-dark-tremor-content-strong font-semibold",children:"OpenAI Compatible Proxy: API Reference"}),(0,a.jsx)(eu.Z,{className:"mt-2 mb-2",children:"LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below "}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{children:[(0,a.jsx)(eY.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(eY.Z,{children:"LlamaIndex"}),(0,a.jsx)(eY.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys\n)\n\nresponse = client.chat.completions.create(\n model="gpt-3.5-turbo", # model to send to the proxy\n messages = [\n {\n "role": "user",\n "content": "this is a test request, write a short poem"\n }\n ]\n)\n\nprint(response)\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nimport os, dotenv\n\nfrom llama_index.llms import AzureOpenAI\nfrom llama_index.embeddings import AzureOpenAIEmbedding\nfrom llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\nllm = AzureOpenAI(\n engine="azure-gpt-3.5", # model_name on litellm proxy\n temperature=0.0,\n azure_endpoint="http://0.0.0.0:4000", # litellm proxy endpoint\n api_key="sk-1234", # litellm proxy API Key\n api_version="2023-07-01-preview",\n)\n\nembed_model = AzureOpenAIEmbedding(\n deployment_name="azure-embedding-model",\n azure_endpoint="http://0.0.0.0:4000",\n api_key="sk-1234",\n api_version="2023-07-01-preview",\n)\n\n\ndocuments = SimpleDirectoryReader("llama_index_data").load_data()\nservice_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)\nindex = VectorStoreIndex.from_documents(documents, service_context=service_context)\n\nquery_engine = index.as_query_engine()\nresponse = query_engine.query("What did the author do growing up?")\nprint(response)\n\n '})}),(0,a.jsx)(eX.Z,{children:(0,a.jsx)(lT.Z,{language:"python",children:'\nfrom langchain.chat_models import ChatOpenAI\nfrom langchain.prompts.chat import (\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n SystemMessagePromptTemplate,\n)\nfrom langchain.schema import HumanMessage, SystemMessage\n\nchat = ChatOpenAI(\n openai_api_base="http://0.0.0.0:4000",\n model = "gpt-3.5-turbo",\n temperature=0.1\n)\n\nmessages = [\n SystemMessage(\n content="You are a helpful assistant that im using to make a test request to."\n ),\n HumanMessage(\n content="test from litellm. tell me why it\'s amazing in 1 sentence"\n ),\n]\nresponse = chat(messages)\n\nprint(response)\n\n '})})]})]})]})})})};async function lL(e,l,t,s){console.log("isLocal:",!1);let r=window.location.origin,a=new lS.ZP.OpenAI({apiKey:s,baseURL:r,dangerouslyAllowBrowser:!0});try{for await(let s of(await a.chat.completions.create({model:t,stream:!0,messages:[{role:"user",content:e}]})))console.log(s),s.choices[0].delta.content&&l(s.choices[0].delta.content)}catch(e){h.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var lU=e=>{let{accessToken:l,token:t,userRole:s,userID:r}=e,[o,i]=(0,n.useState)(""),[c,d]=(0,n.useState)(""),[m,h]=(0,n.useState)([]),[u,x]=(0,n.useState)(void 0),[p,j]=(0,n.useState)([]);(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{let e=await P(l,r,s);if(console.log("model_info:",e),(null==e?void 0:e.data.length)>0){let l=e.data.map(e=>({value:e.id,label:e.id}));console.log(l),j(l),x(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,r,s]);let g=(e,l)=>{h(t=>{let s=t[t.length-1];return s&&s.role===e?[...t.slice(0,t.length-1),{role:e,content:s.content+l}]:[...t,{role:e,content:l}]})},y=async()=>{if(""!==c.trim()&&o&&t&&s&&r){h(e=>[...e,{role:"user",content:c}]);try{u&&await lL(c,e=>g("assistant",e),u,o)}catch(e){console.error("Error fetching model response",e),g("assistant","Error fetching model response")}d("")}};if(s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=eV.default;return(0,a.jsxs)("div",{children:[(0,a.jsx)(e,{level:1,children:"Access Denied"}),(0,a.jsx)(l,{children:"Ask your proxy admin for access to test models"})]})}return(0,a.jsx)("div",{style:{width:"100%",position:"relative"},children:(0,a.jsx)(eo.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(eA.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsx)(e$.Z,{children:(0,a.jsx)(eY.Z,{children:"Chat"})}),(0,a.jsx)(eQ.Z,{children:(0,a.jsxs)(eX.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"API Key"}),(0,a.jsx)(ec.Z,{placeholder:"Type API Key here",type:"password",onValueChange:i,value:o})]}),(0,a.jsxs)(en.Z,{className:"mx-2",children:[(0,a.jsx)(eu.Z,{children:"Select Model:"}),(0,a.jsx)(ej.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),x(e)},options:p,style:{width:"200px"}})]})]})}),(0,a.jsxs)(eI.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(eP.Z,{children:(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{})})}),(0,a.jsx)(eC.Z,{children:m.map((e,l)=>(0,a.jsx)(eO.Z,{children:(0,a.jsx)(eT.Z,{children:"".concat(e.role,": ").concat(e.content)})},l))})]}),(0,a.jsx)("div",{className:"mt-3",style:{position:"absolute",bottom:5,width:"95%"},children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(ec.Z,{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Type your message..."}),(0,a.jsx)(ei.Z,{onClick:y,className:"ml-2",children:"Send"})]})})]})})]})})})})},lD=t(33509),lB=t(95781);let{Sider:lz}=lD.default;var lK=e=>{let{setPage:l,userRole:t,defaultSelectedKey:s}=e;return"Admin Viewer"==t?(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(lz,{width:120,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["4"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:"API Keys"},"4"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:"Models"},"2"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:"Chat UI"},"3"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")]})})}):(0,a.jsx)(lD.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(lz,{width:145,children:(0,a.jsxs)(lB.Z,{mode:"inline",defaultSelectedKeys:s||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(eu.Z,{children:"API Keys"})},"1"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(eu.Z,{children:"Test Key"})},"3"),"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(eu.Z,{children:"Models"})},"2"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(eu.Z,{children:"Usage"})},"4"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(eu.Z,{children:"Teams"})},"6"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(eu.Z,{children:"Users"})},"5"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(eu.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(eu.Z,{children:"Rate Limits"})},"9"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(eu.Z,{children:"Router Settings"})},"10"):null,"Admin"==t?(0,a.jsx)(lB.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(eu.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(lB.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(eu.Z,{children:"API Reference"})},"12"),(0,a.jsx)(lB.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(eu.Z,{children:"Model Hub"})},"14")]})})})},lG=t(67989),lq=t(49167),lV=t(52703),lW=e=>{let{accessToken:l,token:t,userRole:s,userID:r,keys:o,premiumUser:i}=e,c=new Date,[d,m]=(0,n.useState)([]),[h,u]=(0,n.useState)([]),[x,p]=(0,n.useState)([]),[j,g]=(0,n.useState)([]),[y,f]=(0,n.useState)([]),[Z,_]=(0,n.useState)([]),[w,b]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),[S,N]=(0,n.useState)([]),[A,E]=(0,n.useState)({}),[I,C]=(0,n.useState)([]),[T,P]=(0,n.useState)(""),[q,V]=(0,n.useState)({from:new Date(Date.now()-6048e5),to:new Date}),W=new Date(c.getFullYear(),c.getMonth(),1),H=new Date(c.getFullYear(),c.getMonth()+1,0),Y=Q(W),J=Q(H);console.log("keys in usage",o),console.log("premium user in usage",i);let $=async(e,t,s)=>{if(!e||!t||!l)return;t.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",s);let r=await U(l,s,e.toISOString(),t.toISOString());console.log("End user data updated successfully",r),g(r)},X=async(e,t)=>{e&&t&&l&&(t.setHours(23,59,59,999),e.setHours(0,0,0,0),_((await O(l,e.toISOString(),t.toISOString())).spend_per_tag),console.log("Tag spend data updated successfully"))};function Q(e){let l=e.getFullYear(),t=e.getMonth()+1,s=e.getDate();return"".concat(l,"-").concat(t<10?"0"+t:t,"-").concat(s<10?"0"+s:s)}return console.log("Start date is ".concat(Y)),console.log("End date is ".concat(J)),(0,n.useEffect)(()=>{l&&t&&s&&r&&(async()=>{try{if(console.log("user role: ".concat(s)),"Admin"==s||"Admin Viewer"==s){var e,a;let s=await M(l);m(s);let r=await D(l,t,Y,J);console.log("provider_spend",r),N(r);let n=(await L(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));u(n);let o=(await K(l)).map(e=>({key:e.model,spend:e.total_spend}));p(o);let i=await F(l);console.log("teamSpend",i),f(i.daily_spend),b(i.teams);let c=i.total_spend_per_team;c=c.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),v(c);let d=await O(l,null===(e=q.from)||void 0===e?void 0:e.toISOString(),null===(a=q.to)||void 0===a?void 0:a.toISOString());_(d.spend_per_tag);let h=await U(l,null,void 0,void 0);g(h),console.log("spend/user result",h);let x=await B(l,Y,J);E(x);let j=await z(l,Y,J);console.log("global activity per model",j),C(j)}else"App Owner"==s&&await R(l,t,s,r,Y,J).then(async e=>{if(console.log("result from spend logs call",e),"daily_spend"in e){let l=e.daily_spend;console.log("daily spend",l),m(l);let t=e.top_api_keys;u(t)}else{let t=(await G(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[t,s]=e;"spend"!==t&&"startTime"!==t&&"models"!==t&&"users"!==t&&l.push({key:t,spend:s})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let t=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(t[0]))),t}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));u(t),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,t,s,r,Y,J]),(0,a.jsxs)("div",{style:{width:"100%"},className:"p-8",children:[(0,a.jsx)(ez,{userID:r,userRole:s,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{className:"mt-2",children:[(0,a.jsx)(eY.Z,{children:"All Up"}),(0,a.jsx)(eY.Z,{children:"Team Based Usage"}),(0,a.jsx)(eY.Z,{children:"End User Usage"}),(0,a.jsx)(eY.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eJ.Z,{children:[(0,a.jsxs)(e$.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(eY.Z,{children:"Cost"}),(0,a.jsx)(eY.Z,{children:"Activity"})]}),(0,a.jsxs)(eQ.Z,{children:[(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Monthly Spend"}),(0,a.jsx)(e4.Z,{data:d,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top API Keys"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:h,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Top Models"}),(0,a.jsx)(e4.Z,{className:"mt-4 h-40",data:x,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(en.Z,{numColSpan:1}),(0,a.jsx)(en.Z,{numColSpan:2,children:(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"✨ Spend by Provider"}),i?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsx)(lV.Z,{className:"mt-4 h-40",variant:"pie",data:S,index:"provider",category:"spend"})}),(0,a.jsx)(en.Z,{numColSpan:1,children:(0,a.jsxs)(eI.Z,{children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"Provider"}),(0,a.jsx)(eF.Z,{children:"Spend"})]})}),(0,a.jsx)(eC.Z,{children:S.map(e=>(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.provider}),(0,a.jsx)(eT.Z,{children:1e-5>parseFloat(e.spend.toFixed(2))?"less than 0.00":e.spend.toFixed(2)})]},e.provider))})]})})]})}):(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to use this feature"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})})]})]})})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"All Up"}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",A.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",A.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:A.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),i?(0,a.jsx)(a.Fragment,{children:I.map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:I&&I.length>0&&I.slice(0,1).map((e,l)=>(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"✨ Activity by Model"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see analytics for all models"}),(0,a.jsx)(ei.Z,{variant:"primary",className:"mb-2",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get Free Trial"})}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:e.model}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",e.sum_api_requests]}),(0,a.jsx)(e2.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsxs)(lq.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",e.sum_total_tokens]}),(0,a.jsx)(e4.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsxs)(eA.Z,{className:"mb-2",children:[(0,a.jsx)(ex.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(lG.Z,{data:k})]}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(e4.Z,{className:"h-72",data:y,showLegend:!0,index:"date",categories:w,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})}),(0,a.jsxs)(eX.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["End-Users of your LLM API calls. Tracked when a `user` param is passed in your LLM calls ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/users",target:"_blank",children:"docs here"})]}),(0,a.jsxs)(eo.Z,{numItems:2,children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Time Range"}),(0,a.jsx)(eH.Z,{enableSelect:!0,value:q,onValueChange:e=>{V(e),$(e.from,e.to,null)}})]}),(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(eu.Z,{children:"Select Key"}),(0,a.jsxs)(eR.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(eM.Z,{value:"all-keys",onClick:()=>{$(q.from,q.to,null)},children:"All Keys"},"all-keys"),null==o?void 0:o.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(eM.Z,{value:String(l),onClick:()=>{$(q.from,q.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(eA.Z,{className:"mt-4",children:(0,a.jsxs)(eI.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(eP.Z,{children:(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eF.Z,{children:"End User"}),(0,a.jsx)(eF.Z,{children:"Spend"}),(0,a.jsx)(eF.Z,{children:"Total Events"})]})}),(0,a.jsx)(eC.Z,{children:null==j?void 0:j.map((e,l)=>{var t;return(0,a.jsxs)(eO.Z,{children:[(0,a.jsx)(eT.Z,{children:e.end_user}),(0,a.jsx)(eT.Z,{children:null===(t=e.total_spend)||void 0===t?void 0:t.toFixed(4)}),(0,a.jsx)(eT.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsx)(eX.Z,{children:(0,a.jsxs)(eo.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsxs)(en.Z,{numColSpan:2,children:[(0,a.jsx)(eH.Z,{className:"mb-4",enableSelect:!0,value:q,onValueChange:e=>{V(e),X(e.from,e.to)}}),(0,a.jsxs)(eA.Z,{children:[(0,a.jsx)(ex.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(eu.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/enterprise#tracking-spend-for-custom-tags",target:"_blank",children:"here"})]}),(0,a.jsx)(e4.Z,{className:"h-72",data:Z,index:"name",categories:["spend"],colors:["blue"]})]})]}),(0,a.jsx)(en.Z,{numColSpan:2})]})})]})]})]})},lH=()=>{let{Title:e,Paragraph:l}=eV.default,[t,s]=(0,n.useState)(""),[r,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[h,u]=(0,n.useState)(null),[x,p]=(0,n.useState)(null),[j,g]=(0,n.useState)(!0),y=(0,o.useSearchParams)(),[f,Z]=(0,n.useState)({data:[]}),_=y.get("userID"),w=y.get("token"),[b,k]=(0,n.useState)("api-keys"),[v,S]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(w){let e=(0,eq.o)(w);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),S(e.key),e.user_role){let l=function(e){if(!e)return"Undefined Role";switch(console.log("Received user role: ".concat(e.toLowerCase())),console.log("Received user role length: ".concat(e.toLowerCase().length)),e.toLowerCase()){case"app_owner":case"demo_app_owner":return"App Owner";case"app_admin":case"proxy_admin":return"Admin";case"proxy_admin_viewer":return"Admin Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),s(l),"Admin Viewer"==l&&k("usage")}else console.log("User role not defined");e.user_email?d(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?g("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&i(e.premium_user)}}},[w]),(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)("div",{children:"Loading..."}),children:(0,a.jsxs)("div",{className:"flex flex-col min-h-screen",children:[(0,a.jsx)(m,{userID:_,userRole:t,userEmail:c,showSSOBanner:j,premiumUser:r}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(lK,{setPage:k,userRole:t,defaultSelectedKey:null})}),"api-keys"==b?(0,a.jsx)(eW,{userID:_,userRole:t,teams:h,keys:x,setUserRole:s,userEmail:c,setUserEmail:d,setTeams:u,setKeys:p}):"models"==b?(0,a.jsx)(lu,{userID:_,userRole:t,token:w,accessToken:v,modelData:f,setModelData:Z,premiumUser:r}):"llm-playground"==b?(0,a.jsx)(lU,{userID:_,userRole:t,token:w,accessToken:v}):"users"==b?(0,a.jsx)(lj,{userID:_,userRole:t,token:w,keys:x,teams:h,accessToken:v,setKeys:p}):"teams"==b?(0,a.jsx)(lg,{teams:h,setTeams:u,searchParams:y,accessToken:v,userID:_,userRole:t}):"admin-panel"==b?(0,a.jsx)(ly,{setTeams:u,searchParams:y,accessToken:v,showSSOBanner:j}):"api_ref"==b?(0,a.jsx)(lM,{}):"settings"==b?(0,a.jsx)(lb,{userID:_,userRole:t,accessToken:v,premiumUser:r}):"budgets"==b?(0,a.jsx)(lP,{accessToken:v}):"general-settings"==b?(0,a.jsx)(lI,{userID:_,userRole:t,accessToken:v,modelData:f}):"model-hub"==b?(0,a.jsx)(lR,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r}):(0,a.jsx)(lW,{userID:_,userRole:t,token:w,accessToken:v,keys:x,premiumUser:r})]})]})})}}},function(e){e.O(0,[936,608,971,69,744],function(){return e(e.s=20661)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/ui/litellm-dashboard/out/index.html b/ui/litellm-dashboard/out/index.html index 963865a00..54a25805a 100644 --- a/ui/litellm-dashboard/out/index.html +++ b/ui/litellm-dashboard/out/index.html @@ -1 +1 @@ -LiteLLM Dashboard \ No newline at end of file +LiteLLM Dashboard \ No newline at end of file diff --git a/ui/litellm-dashboard/out/index.txt b/ui/litellm-dashboard/out/index.txt index 730ddfbc2..fbe813922 100644 --- a/ui/litellm-dashboard/out/index.txt +++ b/ui/litellm-dashboard/out/index.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[39712,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","608","static/chunks/608-d128caa3cfe973c1.js","931","static/chunks/app/page-2421e763699a7dc4.js"],""] +3:I[39712,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","608","static/chunks/608-d128caa3cfe973c1.js","931","static/chunks/app/page-76d278f96a0e9768.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["N-Poqi-YBhDAzJSVSMX3L",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/5d93d4a9fa59d72f.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["D_ZUmMtLMPSa4aQQUJtKt",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c23dc8","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"styles":null}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/ui/_next/static/css/5d93d4a9fa59d72f.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"LiteLLM Dashboard"}],["$","meta","3",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","4",{"rel":"icon","href":"/ui/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null From 1f12874eb4eeaa3bb925fab47c29fbf3bc901ec5 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 27 May 2024 09:51:31 -0700 Subject: [PATCH 17/25] docs(troubleshoot.md): cleanup docs --- docs/my-website/docs/troubleshoot.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/docs/my-website/docs/troubleshoot.md b/docs/my-website/docs/troubleshoot.md index 75a610e0c..3ca57a570 100644 --- a/docs/my-website/docs/troubleshoot.md +++ b/docs/my-website/docs/troubleshoot.md @@ -9,12 +9,3 @@ Our emails ✉️ ishaan@berri.ai / krrish@berri.ai [![Chat on WhatsApp](https://img.shields.io/static/v1?label=Chat%20on&message=WhatsApp&color=success&logo=WhatsApp&style=flat-square)](https://wa.link/huol9n) [![Chat on Discord](https://img.shields.io/static/v1?label=Chat%20on&message=Discord&color=blue&logo=Discord&style=flat-square)](https://discord.gg/wuPM9dRgDw) -## Stable Version - -If you're running into problems with installation / Usage -Use the stable version of litellm - -```shell -pip install litellm==0.1.819 -``` - From 54e4a2f7ac72be299b7a0583d1175b2a0e5a6abf Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 27 May 2024 11:07:57 -0700 Subject: [PATCH 18/25] build(ui): user_dashboard.tsx fix default team spend calc --- .../src/components/user_dashboard.tsx | 66 ++++++++++++------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/ui/litellm-dashboard/src/components/user_dashboard.tsx b/ui/litellm-dashboard/src/components/user_dashboard.tsx index c55e42424..587719b0a 100644 --- a/ui/litellm-dashboard/src/components/user_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/user_dashboard.tsx @@ -1,6 +1,10 @@ "use client"; import React, { useState, useEffect } from "react"; -import { userInfoCall, modelAvailableCall, getTotalSpendCall } from "./networking"; +import { + userInfoCall, + modelAvailableCall, + getTotalSpendCall, +} from "./networking"; import { Grid, Col, Card, Text, Title } from "@tremor/react"; import CreateKey from "./create_key_button"; import ViewKeyTable from "./view_key_table"; @@ -19,7 +23,6 @@ type UserSpendData = { max_budget?: number | null; }; - interface UserDashboardProps { userID: string | null; userRole: string | null; @@ -35,8 +38,8 @@ interface UserDashboardProps { type TeamInterface = { models: any[]; team_id: null; - team_alias: String -} + team_alias: String; +}; const UserDashboard: React.FC = ({ userID, @@ -63,10 +66,10 @@ const UserDashboard: React.FC = ({ const [teamSpend, setTeamSpend] = useState(null); const [userModels, setUserModels] = useState([]); const defaultTeam: TeamInterface = { - "models": [], - "team_alias": "Default Team", - "team_id": null - } + models: [], + team_alias: "Default Team", + team_id: null, + }; const [selectedTeam, setSelectedTeam] = useState( teams ? teams[0] : defaultTeam ); @@ -137,7 +140,14 @@ const UserDashboard: React.FC = ({ } else { const fetchData = async () => { try { - const response = await userInfoCall(accessToken, userID, userRole, false, null, null); + const response = await userInfoCall( + accessToken, + userID, + userRole, + false, + null, + null + ); console.log( `received teams in user dashboard: ${Object.keys( response @@ -152,12 +162,12 @@ const UserDashboard: React.FC = ({ } setKeys(response["keys"]); // Assuming this is the correct path to your data setTeams(response["teams"]); - const teamsArray = [...response['teams']]; + const teamsArray = [...response["teams"]]; if (teamsArray.length > 0) { - console.log(`response['teams']: ${teamsArray}`); - setSelectedTeam(teamsArray[0]); + console.log(`response['teams']: ${teamsArray}`); + setSelectedTeam(teamsArray[0]); } else { - setSelectedTeam(defaultTeam); + setSelectedTeam(defaultTeam); } sessionStorage.setItem( "userData" + userID, @@ -194,22 +204,30 @@ const UserDashboard: React.FC = ({ fetchData(); } } - }, [userID, token, accessToken, keys, userRole]); useEffect(() => { // This code will run every time selectedTeam changes - if (keys !== null && selectedTeam !== null && selectedTeam !== undefined) { + if ( + keys !== null && + selectedTeam !== null && + selectedTeam !== undefined && + selectedTeam.team_id !== null + ) { let sum = 0; for (const key of keys) { - if (selectedTeam.hasOwnProperty('team_id') && key.team_id !== null && key.team_id === selectedTeam.team_id) { + if ( + selectedTeam.hasOwnProperty("team_id") && + key.team_id !== null && + key.team_id === selectedTeam.team_id + ) { sum += key.spend; } } setTeamSpend(sum); } else if (keys !== null) { // sum the keys which don't have team-id set (default team) - let sum = 0 + let sum = 0; for (const key of keys) { sum += key.spend; } @@ -245,9 +263,8 @@ const UserDashboard: React.FC = ({ } console.log("inside user dashboard, selected team", selectedTeam); - console.log(`teamSpend: ${teamSpend}`) return ( -
+
= ({ userRole={userRole} accessToken={accessToken} userSpend={teamSpend} - selectedTeam = {selectedTeam ? selectedTeam : null} - + selectedTeam={selectedTeam ? selectedTeam : null} /> = ({ data={keys} setData={setKeys} /> - +
); }; -export default UserDashboard; \ No newline at end of file +export default UserDashboard; From ce41778b6f2acc6d049184d81054f835c960c173 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 11:25:16 -0700 Subject: [PATCH 19/25] fix - show activity by model_group --- litellm/proxy/proxy_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 1bdb5edba..8d58f6017 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -6094,7 +6094,7 @@ async def get_global_activity_model( sql_query = """ SELECT - model, + model_group AS model, date_trunc('day', "startTime") AS date, COUNT(*) AS api_requests, SUM(total_tokens) AS total_tokens From 67da24f1444e292553506ed2a581a4571d7ca949 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 27 May 2024 13:53:01 -0700 Subject: [PATCH 20/25] fix(fix-'get_model_group_info'-to-return-a-default-value-if-unmapped-model-group): allows model hub to return all model groupss --- litellm/router.py | 47 +++++++++++++++++++++++++++++++++--------- litellm/types/utils.py | 12 ++++++----- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/litellm/router.py b/litellm/router.py index 384c7f338..3e52acfdf 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -38,6 +38,7 @@ from litellm.utils import ( import copy from litellm._logging import verbose_router_logger import logging +from litellm.types.utils import ModelInfo as ModelMapInfo from litellm.types.router import ( Deployment, ModelInfo, @@ -3065,7 +3066,7 @@ class Router: try: model_info = litellm.get_model_info(model=litellm_params.model) except Exception as e: - continue + model_info = None # get llm provider try: model, llm_provider, _, _ = litellm.get_llm_provider( @@ -3075,6 +3076,21 @@ class Router: except litellm.exceptions.BadRequestError as e: continue + if model_info is None: + supported_openai_params = litellm.get_supported_openai_params( + model=model, custom_llm_provider=llm_provider + ) + model_info = ModelMapInfo( + max_tokens=None, + max_input_tokens=None, + max_output_tokens=None, + input_cost_per_token=0, + output_cost_per_token=0, + litellm_provider=llm_provider, + mode="chat", + supported_openai_params=supported_openai_params, + ) + if model_group_info is None: model_group_info = ModelGroupInfo( model_group=model_group, providers=[llm_provider], **model_info # type: ignore @@ -3089,18 +3105,26 @@ class Router: # supports_function_calling == True if llm_provider not in model_group_info.providers: model_group_info.providers.append(llm_provider) - if model_info.get("max_input_tokens", None) is not None and ( - model_group_info.max_input_tokens is None - or model_info["max_input_tokens"] - > model_group_info.max_input_tokens + if ( + model_info.get("max_input_tokens", None) is not None + and model_info["max_input_tokens"] is not None + and ( + model_group_info.max_input_tokens is None + or model_info["max_input_tokens"] + > model_group_info.max_input_tokens + ) ): model_group_info.max_input_tokens = model_info[ "max_input_tokens" ] - if model_info.get("max_output_tokens", None) is not None and ( - model_group_info.max_output_tokens is None - or model_info["max_output_tokens"] - > model_group_info.max_output_tokens + if ( + model_info.get("max_output_tokens", None) is not None + and model_info["max_output_tokens"] is not None + and ( + model_group_info.max_output_tokens is None + or model_info["max_output_tokens"] + > model_group_info.max_output_tokens + ) ): model_group_info.max_output_tokens = model_info[ "max_output_tokens" @@ -3137,7 +3161,10 @@ class Router: and model_info["supports_function_calling"] is True # type: ignore ): model_group_info.supports_function_calling = True - if model_info.get("supported_openai_params", None) is not None: + if ( + model_info.get("supported_openai_params", None) is not None + and model_info["supported_openai_params"] is not None + ): model_group_info.supported_openai_params = model_info[ "supported_openai_params" ] diff --git a/litellm/types/utils.py b/litellm/types/utils.py index cc0836132..7efc628ca 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -19,11 +19,13 @@ class ModelInfo(TypedDict): Model info for a given model, this is information found in litellm.model_prices_and_context_window.json """ - max_tokens: int - max_input_tokens: int - max_output_tokens: int + max_tokens: Optional[int] + max_input_tokens: Optional[int] + max_output_tokens: Optional[int] input_cost_per_token: float output_cost_per_token: float litellm_provider: str - mode: str - supported_openai_params: List[str] + mode: Literal[ + "completion", "embedding", "image_generation", "chat", "audio_transcription" + ] + supported_openai_params: Optional[List[str]] From 9198f003398e21d5470eb60e344ec563cbd1d89d Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 15:41:55 -0700 Subject: [PATCH 21/25] ui - show created at and updated at on models page --- .../src/components/model_dashboard.tsx | 153 ++++++++++++------ 1 file changed, 102 insertions(+), 51 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index 89061d916..18e29ebd8 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -86,6 +86,8 @@ import type { UploadProps } from "antd"; import { Upload } from "antd"; import TimeToFirstToken from "./model_metrics/time_to_first_token"; import DynamicFields from "./model_add/dynamic_form"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; + interface ModelDashboardProps { accessToken: string | null; token: string | null; @@ -269,6 +271,8 @@ const ModelDashboard: React.FC = ({ const [selectedProvider, setSelectedProvider] = useState("OpenAI"); const [healthCheckResponse, setHealthCheckResponse] = useState(""); const [editModalVisible, setEditModalVisible] = useState(false); + const [infoModalVisible, setInfoModalVisible] = useState(false); + const [selectedModel, setSelectedModel] = useState(null); const [availableModelGroups, setAvailableModelGroups] = useState< Array @@ -297,6 +301,15 @@ const ModelDashboard: React.FC = ({ useState(null); const [defaultRetry, setDefaultRetry] = useState(0); + function formatCreatedAt(createdAt: string | null) { + if (createdAt) { + const date = new Date(createdAt); + const options = { month: 'long', day: 'numeric', year: 'numeric' }; + return date.toLocaleDateString('en-US'); + } + return null; + } + const EditModelModal: React.FC = ({ visible, onCancel, @@ -423,11 +436,21 @@ const ModelDashboard: React.FC = ({ setEditModalVisible(true); }; + const handleInfoClick = (model: any) => { + setSelectedModel(model); + setInfoModalVisible(true); + }; + const handleEditCancel = () => { setEditModalVisible(false); setSelectedModel(null); }; + const handleInfoCancel = () => { + setInfoModalVisible(false); + setSelectedModel(null); + }; + const handleEditSubmit = async (formValues: Record) => { // Call API to update team with teamId and values @@ -1073,15 +1096,6 @@ const ModelDashboard: React.FC = ({ API Base )} - - Extra litellm Params - = ({ /1M Tokens ($)

+ - Max Tokens + Created At + + + Created By = ({ > Status + + + @@ -1140,12 +1167,14 @@ const ModelDashboard: React.FC = ({ - {model.model_name} +

+ {model.model_name} +

= ({ wordBreak: "break-word", }} > +

{model.provider} +

{userRole === "Admin" && ( - {model.api_base} - - )} - - - - Litellm params - - -
-                                  {JSON.stringify(
-                                    model.cleanedLitellmParams,
-                                    null,
-                                    2
-                                  )}
-                                
-
-
+ +
+                              {model && model.api_base ? model.api_base.slice(0, 20) : null}
+                            
+
+ + )} = ({ model.litellm_params.output_cost_per_token || null} - -

- Max Tokens: {model.max_tokens}

- Max Input Tokens: {model.max_input_tokens} + +

+ {formatCreatedAt(model.model_info.created_at)} +

+ +
+ +

+ {model.model_info.created_by}

= ({ size="xs" className="text-white" > -

DB Model

+

DB Model

) : ( = ({ size="xs" className="text-black" > -

Config Model

+

Config Model

)}
+ + + handleInfoClick(model)} + /> + + handleEditClick(model)} /> + + + + + + +
))} @@ -1277,6 +1314,20 @@ const ModelDashboard: React.FC = ({ model={selectedModel} onSubmit={handleEditSubmit} /> + + + Model Info + + {selectedModel && JSON.stringify(selectedModel, null, 2)} + + + Add new model From eccda76edc3c321c088aabe7628517f4c0e3b860 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 15:53:16 -0700 Subject: [PATCH 22/25] router - include updated at and created at in model info --- litellm/proxy/proxy_server.py | 8 ++++++-- litellm/types/router.py | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 1bdb5edba..19e68965f 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -2790,6 +2790,11 @@ class ProxyConfig: model.model_info["id"] = _id model.model_info["db_model"] = True + model.model_info["created_at"] = getattr(model, "created_at", None) + model.model_info["updated_at"] = getattr(model, "updated_at", None) + model.model_info["created_by"] = getattr(model, "created_by", None) + model.model_info["updated_by"] = getattr(model, "updated_by", None) + if model.model_info is not None and isinstance(model.model_info, dict): if "id" not in model.model_info: model.model_info["id"] = model.model_id @@ -3075,10 +3080,9 @@ class ProxyConfig: try: if master_key is None or not isinstance(master_key, str): - raise Exception( + raise ValueError( f"Master key is not initialized or formatted. master_key={master_key}" ) - verbose_proxy_logger.debug(f"llm_router: {llm_router}") new_models = await prisma_client.db.litellm_proxymodeltable.find_many() # update llm router await self._update_llm_router( diff --git a/litellm/types/router.py b/litellm/types/router.py index 93c65a1cf..75e792f4c 100644 --- a/litellm/types/router.py +++ b/litellm/types/router.py @@ -1,9 +1,15 @@ +""" + litellm.Router Types - includes RouterConfig, UpdateRouterConfig, ModelInfo etc +""" + from typing import List, Optional, Union, Dict, Tuple, Literal, TypedDict +import uuid +import enum import httpx -from pydantic import BaseModel, validator, Field +from pydantic import BaseModel, Field +import datetime from .completion import CompletionRequest from .embedding import EmbeddingRequest -import uuid, enum class ModelConfig(BaseModel): @@ -76,6 +82,12 @@ class ModelInfo(BaseModel): db_model: bool = ( False # used for proxy - to separate models which are stored in the db vs. config. ) + updated_at: Optional[datetime.datetime] = None + updated_by: Optional[str] = None + + created_at: Optional[datetime.datetime] = None + created_by: Optional[str] = None + base_model: Optional[str] = ( None # specify if the base model is azure/gpt-3.5-turbo etc for accurate cost tracking ) From 5fe6fea9c8a7ee32034d57ed0d1ecfec4510c53a Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 15:58:43 -0700 Subject: [PATCH 23/25] ui -clean up models default value --- .../src/components/model_dashboard.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index 18e29ebd8..9f383f4a7 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -1173,7 +1173,7 @@ const ModelDashboard: React.FC = ({ }} >

- {model.model_name} + {model.model_name || "-"}

= ({ }} >

- {model.provider} + {model.provider || "-"}

{userRole === "Admin" && ( @@ -1205,7 +1205,7 @@ const ModelDashboard: React.FC = ({ }} title={model && model.api_base ? model.api_base : ""} > - {model && model.api_base ? model.api_base.slice(0, 20) : null} + {model && model.api_base ? model.api_base.slice(0, 20) : "-"}
@@ -1218,9 +1218,11 @@ const ModelDashboard: React.FC = ({ wordBreak: "break-word", }} > +
                             {model.input_cost ||
                               model.litellm_params.input_cost_per_token ||
-                              null}
+                              "-"}
+                            
= ({ wordBreak: "break-word", }} > +
                             {model.output_cost ||
                               model.litellm_params.output_cost_per_token ||
-                              null}
+                              "-"}
+                            

- {formatCreatedAt(model.model_info.created_at)} + {formatCreatedAt(model.model_info.created_at) || "-"}

- {model.model_info.created_by} + {model.model_info.created_by || "-"}

Date: Mon, 27 May 2024 16:03:21 -0700 Subject: [PATCH 24/25] fix clean up models page --- .../src/components/model_dashboard.tsx | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index 9f383f4a7..a8a663733 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -1062,7 +1062,6 @@ const ModelDashboard: React.FC = ({
@@ -1072,6 +1071,7 @@ const ModelDashboard: React.FC = ({ maxWidth: "150px", whiteSpace: "normal", wordBreak: "break-word", + fontSize: "11px" }} > Public Model Name @@ -1081,6 +1081,7 @@ const ModelDashboard: React.FC = ({ maxWidth: "100px", whiteSpace: "normal", wordBreak: "break-word", + fontSize: "11px" }} > Provider @@ -1091,6 +1092,7 @@ const ModelDashboard: React.FC = ({ maxWidth: "150px", whiteSpace: "normal", wordBreak: "break-word", + fontSize: "11px" }} > API Base @@ -1101,6 +1103,7 @@ const ModelDashboard: React.FC = ({ maxWidth: "85px", whiteSpace: "normal", wordBreak: "break-word", + fontSize: "11px" }} > Input Price{" "} @@ -1113,6 +1116,7 @@ const ModelDashboard: React.FC = ({ maxWidth: "85px", whiteSpace: "normal", wordBreak: "break-word", + fontSize: "11px" }} > Output Price{" "} @@ -1123,27 +1127,30 @@ const ModelDashboard: React.FC = ({ - Created At - - - Created By + ✨ Created At + + + ✨ Created By Status From ef7f3bc4febb18b9146c1ef12eabfca6690322eb Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 27 May 2024 16:29:51 -0700 Subject: [PATCH 25/25] backend - add audit logs for adding models --- docs/my-website/docs/proxy/enterprise.md | 1 + litellm/proxy/proxy_server.py | 10 +++++---- .../src/components/model_dashboard.tsx | 21 +++++++++++++------ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/docs/my-website/docs/proxy/enterprise.md b/docs/my-website/docs/proxy/enterprise.md index c47589e8a..a8c84bf4f 100644 --- a/docs/my-website/docs/proxy/enterprise.md +++ b/docs/my-website/docs/proxy/enterprise.md @@ -21,6 +21,7 @@ Features: - ✅ Don't log/store specific requests to Langfuse, Sentry, etc. (eg confidential LLM requests) - ✅ Tracking Spend for Custom Tags - ✅ Custom Branding + Routes on Swagger Docs +- ✅ Audit Logs for `Created At, Created By` when Models Added ## Content Moderation diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 19e68965f..9eb0d2a15 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -2790,10 +2790,12 @@ class ProxyConfig: model.model_info["id"] = _id model.model_info["db_model"] = True - model.model_info["created_at"] = getattr(model, "created_at", None) - model.model_info["updated_at"] = getattr(model, "updated_at", None) - model.model_info["created_by"] = getattr(model, "created_by", None) - model.model_info["updated_by"] = getattr(model, "updated_by", None) + if premium_user is True: + # seeing "created_at", "updated_at", "created_by", "updated_by" is a LiteLLM Enterprise Feature + model.model_info["created_at"] = getattr(model, "created_at", None) + model.model_info["updated_at"] = getattr(model, "updated_at", None) + model.model_info["created_by"] = getattr(model, "created_by", None) + model.model_info["updated_by"] = getattr(model, "updated_by", None) if model.model_info is not None and isinstance(model.model_info, dict): if "id" not in model.model_info: diff --git a/ui/litellm-dashboard/src/components/model_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index a8a663733..2cb1c2cf0 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -1133,8 +1133,11 @@ const ModelDashboard: React.FC = ({ fontSize: "11px" }} > - ✨ Created At - + { + premiumUser ? "Created At" : ✨ Created At + } + + = ({ fontSize: "11px" }} > - ✨ Created By + { + premiumUser ? "Created By" : ✨ Created By + } = ({ selectedModelGroup === "" ) .map((model: any, index: number) => ( - + = ({

- {formatCreatedAt(model.model_info.created_at) || "-"} + { + premiumUser ? formatCreatedAt(model.model_info.created_at) || "-" : "-" + }

- {model.model_info.created_by || "-"} + { + premiumUser ? model.model_info.created_by || "-" : "-" + }