diff --git a/.circleci/config.yml b/.circleci/config.yml index 5f4628d26..736bb8e8a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -202,6 +202,7 @@ jobs: -e REDIS_PORT=$REDIS_PORT \ -e AZURE_FRANCE_API_KEY=$AZURE_FRANCE_API_KEY \ -e AZURE_EUROPE_API_KEY=$AZURE_EUROPE_API_KEY \ + -e MISTRAL_API_KEY=$MISTRAL_API_KEY \ -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \ -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \ -e AWS_REGION_NAME=$AWS_REGION_NAME \ diff --git a/docs/my-website/docs/providers/clarifai.md b/docs/my-website/docs/providers/clarifai.md index 085ab8ed9..cb4986503 100644 --- a/docs/my-website/docs/providers/clarifai.md +++ b/docs/my-website/docs/providers/clarifai.md @@ -1,10 +1,13 @@ # Clarifai Anthropic, OpenAI, Mistral, Llama and Gemini LLMs are Supported on Clarifai. +:::warning + +Streaming is not yet supported on using clarifai and litellm. Tracking support here: https://github.com/BerriAI/litellm/issues/4162 + +::: + ## Pre-Requisites - -`pip install clarifai` - `pip install litellm` ## Required Environment Variables @@ -12,6 +15,7 @@ To obtain your Clarifai Personal access token follow this [link](https://docs.cl ```python os.environ["CLARIFAI_API_KEY"] = "YOUR_CLARIFAI_PAT" # CLARIFAI_PAT + ``` ## Usage @@ -68,7 +72,7 @@ Example Usage - Note: liteLLM supports all models deployed on Clarifai | clarifai/meta.Llama-2.codeLlama-70b-Python | `completion('clarifai/meta.Llama-2.codeLlama-70b-Python', messages)`| | clarifai/meta.Llama-2.codeLlama-70b-Instruct | `completion('clarifai/meta.Llama-2.codeLlama-70b-Instruct', messages)` | -## Mistal LLMs +## Mistral LLMs | Model Name | Function Call | |---------------------------------------------|------------------------------------------------------------------------| | clarifai/mistralai.completion.mixtral-8x22B | `completion('clarifai/mistralai.completion.mixtral-8x22B', messages)` | diff --git a/docs/my-website/docs/providers/vertex.md b/docs/my-website/docs/providers/vertex.md index 3714265ac..a5c8e06c9 100644 --- a/docs/my-website/docs/providers/vertex.md +++ b/docs/my-website/docs/providers/vertex.md @@ -558,6 +558,29 @@ All models listed [here](https://github.com/BerriAI/litellm/blob/57f37f743886a02 | text-embedding-preview-0409 | `embedding(model="vertex_ai/text-embedding-preview-0409", input)` | | text-multilingual-embedding-preview-0409 | `embedding(model="vertex_ai/text-multilingual-embedding-preview-0409", input)` | +### Advanced Use `task_type` and `title` (Vertex Specific Params) + +👉 `task_type` and `title` are vertex specific params + +LiteLLM Supported Vertex Specific Params + +```python +auto_truncate: Optional[bool] = None +task_type: Optional[Literal["RETRIEVAL_QUERY","RETRIEVAL_DOCUMENT", "SEMANTIC_SIMILARITY", "CLASSIFICATION", "CLUSTERING", "QUESTION_ANSWERING", "FACT_VERIFICATION"]] = None +title: Optional[str] = None # The title of the document to be embedded. (only valid with task_type=RETRIEVAL_DOCUMENT). +``` + +**Example Usage with LiteLLM** +```python +response = litellm.embedding( + model="vertex_ai/text-embedding-004", + input=["good morning from litellm", "gm"] + task_type = "RETRIEVAL_DOCUMENT", + dimensions=1, + auto_truncate=True, +) +``` + ## Image Generation Models Usage diff --git a/docs/my-website/docs/proxy/deploy.md b/docs/my-website/docs/proxy/deploy.md index b756f56e2..a3c8590b5 100644 --- a/docs/my-website/docs/proxy/deploy.md +++ b/docs/my-website/docs/proxy/deploy.md @@ -1,5 +1,6 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; +import Image from '@theme/IdealImage'; # 🐳 Docker, Deploying LiteLLM Proxy @@ -537,7 +538,9 @@ ghcr.io/berriai/litellm-database:main-latest --config your_config.yaml ## Advanced Deployment Settings -### Customization of the server root path +### 1. Customization of the server root path (custom Proxy base url) + +💥 Use this when you want to serve LiteLLM on a custom base url path like `https://localhost:4000/api/v1` :::info @@ -548,9 +551,29 @@ In a Kubernetes deployment, it's possible to utilize a shared DNS to host multip Customize the root path to eliminate the need for employing multiple DNS configurations during deployment. 👉 Set `SERVER_ROOT_PATH` in your .env and this will be set as your server root path +``` +export SERVER_ROOT_PATH="/api/v1" +``` +**Step 1. Run Proxy with `SERVER_ROOT_PATH` set in your env ** -### Setting SSL Certification +```shell +docker run --name litellm-proxy \ +-e DATABASE_URL=postgresql://:@:/ \ +-e SERVER_ROOT_PATH="/api/v1" \ +-p 4000:4000 \ +ghcr.io/berriai/litellm-database:main-latest --config your_config.yaml +``` + +After running the proxy you can access it on `http://0.0.0.0:4000/api/v1/` (since we set `SERVER_ROOT_PATH="/api/v1"`) + +**Step 2. Verify Running on correct path** + + + +**That's it**, that's all you need to run the proxy on a custom root path + +### 2. Setting SSL Certification Use this, If you need to set ssl certificates for your on prem litellm proxy diff --git a/docs/my-website/img/custom_root_path.png b/docs/my-website/img/custom_root_path.png new file mode 100644 index 000000000..47de019eb Binary files /dev/null and b/docs/my-website/img/custom_root_path.png differ diff --git a/litellm/__init__.py b/litellm/__init__.py index 523ce4684..91fa253e7 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -766,8 +766,8 @@ from .llms.gemini import GeminiConfig from .llms.nlp_cloud import NLPCloudConfig from .llms.aleph_alpha import AlephAlphaConfig from .llms.petals import PetalsConfig -from .llms.vertex_ai import VertexAIConfig from .llms.vertex_httpx import VertexGeminiConfig +from .llms.vertex_ai import VertexAIConfig, VertexAITextEmbeddingConfig from .llms.vertex_ai_anthropic import VertexAIAnthropicConfig from .llms.sagemaker import SagemakerConfig from .llms.ollama import OllamaConfig @@ -789,7 +789,9 @@ from .llms.openai import ( OpenAIConfig, OpenAITextCompletionConfig, MistralConfig, + MistralEmbeddingConfig, DeepInfraConfig, + AzureAIStudioConfig, ) from .llms.azure import ( AzureOpenAIConfig, diff --git a/litellm/llms/azure.py b/litellm/llms/azure.py index 834fcbea9..46ab62a8d 100644 --- a/litellm/llms/azure.py +++ b/litellm/llms/azure.py @@ -36,6 +36,9 @@ from ..types.llms.openai import ( AsyncAssistantStreamManager, AssistantStreamManager, ) +from litellm.caching import DualCache + +azure_ad_cache = DualCache() class AzureOpenAIError(Exception): @@ -309,9 +312,10 @@ def select_azure_base_url_or_endpoint(azure_client_params: dict): def get_azure_ad_token_from_oidc(azure_ad_token: str): azure_client_id = os.getenv("AZURE_CLIENT_ID", None) - azure_tenant = os.getenv("AZURE_TENANT_ID", None) + azure_tenant_id = os.getenv("AZURE_TENANT_ID", None) + azure_authority_host = os.getenv("AZURE_AUTHORITY_HOST", "https://login.microsoftonline.com") - if azure_client_id is None or azure_tenant is None: + if azure_client_id is None or azure_tenant_id is None: raise AzureOpenAIError( status_code=422, message="AZURE_CLIENT_ID and AZURE_TENANT_ID must be set", @@ -325,8 +329,19 @@ def get_azure_ad_token_from_oidc(azure_ad_token: str): message="OIDC token could not be retrieved from secret manager.", ) + azure_ad_token_cache_key = json.dumps({ + "azure_client_id": azure_client_id, + "azure_tenant_id": azure_tenant_id, + "azure_authority_host": azure_authority_host, + "oidc_token": oidc_token, + }) + + azure_ad_token_access_token = azure_ad_cache.get_cache(azure_ad_token_cache_key) + if azure_ad_token_access_token is not None: + return azure_ad_token_access_token + req_token = httpx.post( - f"https://login.microsoftonline.com/{azure_tenant}/oauth2/v2.0/token", + f"{azure_authority_host}/{azure_tenant_id}/oauth2/v2.0/token", data={ "client_id": azure_client_id, "grant_type": "client_credentials", @@ -342,12 +357,23 @@ def get_azure_ad_token_from_oidc(azure_ad_token: str): message=req_token.text, ) - possible_azure_ad_token = req_token.json().get("access_token", None) + azure_ad_token_json = req_token.json() + azure_ad_token_access_token = azure_ad_token_json.get("access_token", None) + azure_ad_token_expires_in = azure_ad_token_json.get("expires_in", None) - if possible_azure_ad_token is None: - raise AzureOpenAIError(status_code=422, message="Azure AD Token not returned") + if azure_ad_token_access_token is None: + raise AzureOpenAIError( + status_code=422, message="Azure AD Token access_token not returned" + ) - return possible_azure_ad_token + if azure_ad_token_expires_in is None: + raise AzureOpenAIError( + status_code=422, message="Azure AD Token expires_in not returned" + ) + + azure_ad_cache.set_cache(key=azure_ad_token_cache_key, value=azure_ad_token_access_token, ttl=azure_ad_token_expires_in) + + return azure_ad_token_access_token class AzureChatCompletion(BaseLLM): diff --git a/litellm/llms/bedrock_httpx.py b/litellm/llms/bedrock_httpx.py index b011d9512..84b61d4cb 100644 --- a/litellm/llms/bedrock_httpx.py +++ b/litellm/llms/bedrock_httpx.py @@ -53,7 +53,9 @@ from litellm.types.llms.openai import ( ChatCompletionToolCallFunctionChunk, ChatCompletionDeltaChunk, ) +from litellm.caching import DualCache +iam_cache = DualCache() class AmazonCohereChatConfig: """ @@ -325,38 +327,53 @@ class BedrockLLM(BaseLLM): ) = params_to_check ### CHECK STS ### - if ( - aws_web_identity_token is not None - and aws_role_name is not None - and aws_session_name is not None - ): - oidc_token = get_secret(aws_web_identity_token) + if aws_web_identity_token is not None and aws_role_name is not None and aws_session_name is not None: + iam_creds_cache_key = json.dumps({ + "aws_web_identity_token": aws_web_identity_token, + "aws_role_name": aws_role_name, + "aws_session_name": aws_session_name, + "aws_region_name": aws_region_name, + }) - if oidc_token is None: - raise BedrockError( - message="OIDC token could not be retrieved from secret manager.", - status_code=401, + iam_creds_dict = iam_cache.get_cache(iam_creds_cache_key) + if iam_creds_dict is None: + oidc_token = get_secret(aws_web_identity_token) + + if oidc_token is None: + raise BedrockError( + message="OIDC token could not be retrieved from secret manager.", + status_code=401, + ) + + sts_client = boto3.client( + "sts", + region_name=aws_region_name, + endpoint_url=f"https://sts.{aws_region_name}.amazonaws.com" ) - sts_client = boto3.client("sts") + # https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html + # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sts/client/assume_role_with_web_identity.html + sts_response = sts_client.assume_role_with_web_identity( + RoleArn=aws_role_name, + RoleSessionName=aws_session_name, + WebIdentityToken=oidc_token, + DurationSeconds=3600, + ) - # https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html - # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sts/client/assume_role_with_web_identity.html - sts_response = sts_client.assume_role_with_web_identity( - RoleArn=aws_role_name, - RoleSessionName=aws_session_name, - WebIdentityToken=oidc_token, - DurationSeconds=3600, - ) + iam_creds_dict = { + "aws_access_key_id": sts_response["Credentials"]["AccessKeyId"], + "aws_secret_access_key": sts_response["Credentials"]["SecretAccessKey"], + "aws_session_token": sts_response["Credentials"]["SessionToken"], + "region_name": aws_region_name, + } - session = boto3.Session( - aws_access_key_id=sts_response["Credentials"]["AccessKeyId"], - aws_secret_access_key=sts_response["Credentials"]["SecretAccessKey"], - aws_session_token=sts_response["Credentials"]["SessionToken"], - region_name=aws_region_name, - ) + iam_cache.set_cache(key=iam_creds_cache_key, value=json.dumps(iam_creds_dict), ttl=3600 - 60) - return session.get_credentials() + session = boto3.Session(**iam_creds_dict) + + iam_creds = session.get_credentials() + + return iam_creds elif aws_role_name is not None and aws_session_name is not None: sts_client = boto3.client( "sts", @@ -1416,38 +1433,53 @@ class BedrockConverseLLM(BaseLLM): ) = params_to_check ### CHECK STS ### - if ( - aws_web_identity_token is not None - and aws_role_name is not None - and aws_session_name is not None - ): - oidc_token = get_secret(aws_web_identity_token) + if aws_web_identity_token is not None and aws_role_name is not None and aws_session_name is not None: + iam_creds_cache_key = json.dumps({ + "aws_web_identity_token": aws_web_identity_token, + "aws_role_name": aws_role_name, + "aws_session_name": aws_session_name, + "aws_region_name": aws_region_name, + }) - if oidc_token is None: - raise BedrockError( - message="OIDC token could not be retrieved from secret manager.", - status_code=401, + iam_creds_dict = iam_cache.get_cache(iam_creds_cache_key) + if iam_creds_dict is None: + oidc_token = get_secret(aws_web_identity_token) + + if oidc_token is None: + raise BedrockError( + message="OIDC token could not be retrieved from secret manager.", + status_code=401, + ) + + sts_client = boto3.client( + "sts", + region_name=aws_region_name, + endpoint_url=f"https://sts.{aws_region_name}.amazonaws.com" ) - sts_client = boto3.client("sts") + # https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html + # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sts/client/assume_role_with_web_identity.html + sts_response = sts_client.assume_role_with_web_identity( + RoleArn=aws_role_name, + RoleSessionName=aws_session_name, + WebIdentityToken=oidc_token, + DurationSeconds=3600, + ) - # https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html - # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sts/client/assume_role_with_web_identity.html - sts_response = sts_client.assume_role_with_web_identity( - RoleArn=aws_role_name, - RoleSessionName=aws_session_name, - WebIdentityToken=oidc_token, - DurationSeconds=3600, - ) + iam_creds_dict = { + "aws_access_key_id": sts_response["Credentials"]["AccessKeyId"], + "aws_secret_access_key": sts_response["Credentials"]["SecretAccessKey"], + "aws_session_token": sts_response["Credentials"]["SessionToken"], + "region_name": aws_region_name, + } - session = boto3.Session( - aws_access_key_id=sts_response["Credentials"]["AccessKeyId"], - aws_secret_access_key=sts_response["Credentials"]["SecretAccessKey"], - aws_session_token=sts_response["Credentials"]["SessionToken"], - region_name=aws_region_name, - ) + iam_cache.set_cache(key=iam_creds_cache_key, value=json.dumps(iam_creds_dict), ttl=3600 - 60) - return session.get_credentials() + session = boto3.Session(**iam_creds_dict) + + iam_creds = session.get_credentials() + + return iam_creds elif aws_role_name is not None and aws_session_name is not None: sts_client = boto3.client( "sts", diff --git a/litellm/llms/clarifai.py b/litellm/llms/clarifai.py index 4610911e1..785a7ad38 100644 --- a/litellm/llms/clarifai.py +++ b/litellm/llms/clarifai.py @@ -139,6 +139,7 @@ def process_response( def convert_model_to_url(model: str, api_base: str): user_id, app_id, model_id = model.split(".") + model_id = model_id.lower() return f"{api_base}/users/{user_id}/apps/{app_id}/models/{model_id}/outputs" @@ -171,19 +172,55 @@ async def async_completion( async_handler = AsyncHTTPHandler(timeout=httpx.Timeout(timeout=600.0, connect=5.0)) response = await async_handler.post( - api_base, headers=headers, data=json.dumps(data) + url=model, headers=headers, data=json.dumps(data) ) - return process_response( - model=model, - prompt=prompt, - response=response, - model_response=model_response, + logging_obj.post_call( + input=prompt, api_key=api_key, - data=data, - encoding=encoding, - logging_obj=logging_obj, + original_response=response.text, + additional_args={"complete_input_dict": data}, ) + ## RESPONSE OBJECT + try: + completion_response = response.json() + except Exception: + raise ClarifaiError( + message=response.text, status_code=response.status_code, url=model + ) + # print(completion_response) + try: + choices_list = [] + for idx, item in enumerate(completion_response["outputs"]): + if len(item["data"]["text"]["raw"]) > 0: + message_obj = Message(content=item["data"]["text"]["raw"]) + else: + message_obj = Message(content=None) + choice_obj = Choices( + finish_reason="stop", + index=idx + 1, # check + message=message_obj, + ) + choices_list.append(choice_obj) + model_response["choices"] = choices_list + + except Exception as e: + raise ClarifaiError( + message=traceback.format_exc(), status_code=response.status_code, url=model + ) + + # Calculate Usage + prompt_tokens = len(encoding.encode(prompt)) + completion_tokens = len( + encoding.encode(model_response["choices"][0]["message"].get("content")) + ) + model_response["model"] = model + model_response["usage"] = Usage( + prompt_tokens=prompt_tokens, + completion_tokens=completion_tokens, + total_tokens=prompt_tokens + completion_tokens, + ) + return model_response def completion( @@ -241,7 +278,7 @@ def completion( additional_args={ "complete_input_dict": data, "headers": headers, - "api_base": api_base, + "api_base": model, }, ) if acompletion == True: diff --git a/litellm/llms/openai.py b/litellm/llms/openai.py index dec86d35d..1f2b836c3 100644 --- a/litellm/llms/openai.py +++ b/litellm/llms/openai.py @@ -28,6 +28,7 @@ from .prompt_templates.factory import prompt_factory, custom_prompt from openai import OpenAI, AsyncOpenAI from ..types.llms.openai import * import openai +from litellm.types.utils import ProviderField class OpenAIError(Exception): @@ -164,6 +165,68 @@ class MistralConfig: return optional_params +class MistralEmbeddingConfig: + """ + Reference: https://docs.mistral.ai/api/#operation/createEmbedding + """ + + def __init__( + self, + ) -> 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 [ + "encoding_format", + ] + + def map_openai_params(self, non_default_params: dict, optional_params: dict): + for param, value in non_default_params.items(): + if param == "encoding_format": + optional_params["encoding_format"] = value + return optional_params + + +class AzureAIStudioConfig: + def get_required_params(self) -> List[ProviderField]: + """For a given provider, return it's required fields with a description""" + return [ + ProviderField( + field_name="api_key", + field_type="string", + field_description="Your Azure AI Studio API Key.", + field_value="zEJ...", + ), + ProviderField( + field_name="api_base", + field_type="string", + field_description="Your Azure AI Studio API Base.", + field_value="https://Mistral-serverless.", + ), + ] + + class DeepInfraConfig: """ Reference: https://deepinfra.com/docs/advanced/openai_api diff --git a/litellm/llms/vertex_ai.py b/litellm/llms/vertex_ai.py index ba16598be..67a8a4519 100644 --- a/litellm/llms/vertex_ai.py +++ b/litellm/llms/vertex_ai.py @@ -4,6 +4,7 @@ from enum import Enum import requests # type: ignore import time from typing import Callable, Optional, Union, List, Literal, Any +from pydantic import BaseModel from litellm.utils import ModelResponse, Usage, CustomStreamWrapper, map_finish_reason import litellm, uuid import httpx, inspect # type: ignore @@ -1298,6 +1299,95 @@ async def async_streaming( return streamwrapper +class VertexAITextEmbeddingConfig(BaseModel): + """ + Reference: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/text-embeddings-api#TextEmbeddingInput + + Args: + auto_truncate: Optional(bool) If True, will truncate input text to fit within the model's max input length. + task_type: Optional(str) The type of task to be performed. The default is "RETRIEVAL_QUERY". + title: Optional(str) The title of the document to be embedded. (only valid with task_type=RETRIEVAL_DOCUMENT). + """ + + auto_truncate: Optional[bool] = None + task_type: Optional[ + Literal[ + "RETRIEVAL_QUERY", + "RETRIEVAL_DOCUMENT", + "SEMANTIC_SIMILARITY", + "CLASSIFICATION", + "CLUSTERING", + "QUESTION_ANSWERING", + "FACT_VERIFICATION", + ] + ] = None + title: Optional[str] = None + + def __init__( + self, + auto_truncate: Optional[bool] = None, + task_type: Optional[ + Literal[ + "RETRIEVAL_QUERY", + "RETRIEVAL_DOCUMENT", + "SEMANTIC_SIMILARITY", + "CLASSIFICATION", + "CLUSTERING", + "QUESTION_ANSWERING", + "FACT_VERIFICATION", + ] + ] = None, + title: Optional[str] = None, + ) -> None: + locals_ = locals() + 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 [ + "dimensions", + ] + + def map_openai_params(self, non_default_params: dict, optional_params: dict): + for param, value in non_default_params.items(): + if param == "dimensions": + optional_params["output_dimensionality"] = value + return optional_params + + def get_mapped_special_auth_params(self) -> dict: + """ + Common auth params across bedrock/vertex_ai/azure/watsonx + """ + return {"project": "vertex_project", "region_name": "vertex_location"} + + def map_special_auth_params(self, non_default_params: dict, optional_params: dict): + mapped_params = self.get_mapped_special_auth_params() + + for param, value in non_default_params.items(): + if param in mapped_params: + optional_params[mapped_params[param]] = value + return optional_params + + def embedding( model: str, input: Union[list, str], @@ -1321,7 +1411,7 @@ def embedding( message="vertexai import failed please run `pip install google-cloud-aiplatform`", ) - from vertexai.language_models import TextEmbeddingModel + from vertexai.language_models import TextEmbeddingModel, TextEmbeddingInput import google.auth # type: ignore ## Load credentials with the correct quota project ref: https://github.com/googleapis/python-aiplatform/issues/2557#issuecomment-1709284744 @@ -1352,6 +1442,16 @@ def embedding( if isinstance(input, str): input = [input] + if optional_params is not None and isinstance(optional_params, dict): + if optional_params.get("task_type") or optional_params.get("title"): + # if user passed task_type or title, cast to TextEmbeddingInput + _task_type = optional_params.pop("task_type", None) + _title = optional_params.pop("title", None) + input = [ + TextEmbeddingInput(text=x, task_type=_task_type, title=_title) + for x in input + ] + try: llm_model = TextEmbeddingModel.from_pretrained(model) except Exception as e: @@ -1368,7 +1468,8 @@ def embedding( encoding=encoding, ) - request_str = f"""embeddings = llm_model.get_embeddings({input})""" + _input_dict = {"texts": input, **optional_params} + request_str = f"""embeddings = llm_model.get_embeddings({_input_dict})""" ## LOGGING PRE-CALL logging_obj.pre_call( input=input, @@ -1380,7 +1481,7 @@ def embedding( ) try: - embeddings = llm_model.get_embeddings(input) + embeddings = llm_model.get_embeddings(**_input_dict) except Exception as e: raise VertexAIError(status_code=500, message=str(e)) @@ -1388,6 +1489,7 @@ def embedding( logging_obj.post_call(input=input, api_key=None, original_response=embeddings) ## Populate OpenAI compliant dictionary embedding_response = [] + input_tokens: int = 0 for idx, embedding in enumerate(embeddings): embedding_response.append( { @@ -1396,14 +1498,10 @@ def embedding( "embedding": embedding.values, } ) + input_tokens += embedding.statistics.token_count model_response["object"] = "list" model_response["data"] = embedding_response model_response["model"] = model - input_tokens = 0 - - input_str = "".join(input) - - input_tokens += len(encoding.encode(input_str)) usage = Usage( prompt_tokens=input_tokens, completion_tokens=0, total_tokens=input_tokens @@ -1425,7 +1523,8 @@ async def async_embedding( """ Async embedding implementation """ - request_str = f"""embeddings = llm_model.get_embeddings({input})""" + _input_dict = {"texts": input, **optional_params} + request_str = f"""embeddings = llm_model.get_embeddings({_input_dict})""" ## LOGGING PRE-CALL logging_obj.pre_call( input=input, @@ -1437,7 +1536,7 @@ async def async_embedding( ) try: - embeddings = await client.get_embeddings_async(input) + embeddings = await client.get_embeddings_async(**_input_dict) except Exception as e: raise VertexAIError(status_code=500, message=str(e)) @@ -1445,6 +1544,7 @@ async def async_embedding( logging_obj.post_call(input=input, api_key=None, original_response=embeddings) ## Populate OpenAI compliant dictionary embedding_response = [] + input_tokens: int = 0 for idx, embedding in enumerate(embeddings): embedding_response.append( { @@ -1453,18 +1553,13 @@ async def async_embedding( "embedding": embedding.values, } ) + input_tokens += embedding.statistics.token_count + model_response["object"] = "list" model_response["data"] = embedding_response model_response["model"] = model - input_tokens = 0 - - input_str = "".join(input) - - input_tokens += len(encoding.encode(input_str)) - usage = Usage( prompt_tokens=input_tokens, completion_tokens=0, total_tokens=input_tokens ) model_response.usage = usage - return model_response diff --git a/litellm/main.py b/litellm/main.py index 83104290d..31cb8e364 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -336,6 +336,7 @@ async def acompletion( or custom_llm_provider == "predibase" or custom_llm_provider == "bedrock" or custom_llm_provider == "databricks" + or custom_llm_provider == "clarifai" or custom_llm_provider in litellm.openai_compatible_providers ): # currently implemented aiohttp calls for just azure, openai, hf, ollama, vertex ai soon all. init_response = await loop.run_in_executor(None, func_with_context) diff --git a/litellm/proxy/_experimental/out/404.html b/litellm/proxy/_experimental/out/404.html new file mode 100644 index 000000000..e97c72fc1 --- /dev/null +++ b/litellm/proxy/_experimental/out/404.html @@ -0,0 +1 @@ +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/48nWsJi-LJrUlOLzcK-Yz/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/Q9smtS3bJUKJtn7pvgodO/_buildManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/48nWsJi-LJrUlOLzcK-Yz/_buildManifest.js rename to litellm/proxy/_experimental/out/_next/static/Q9smtS3bJUKJtn7pvgodO/_buildManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/48nWsJi-LJrUlOLzcK-Yz/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/Q9smtS3bJUKJtn7pvgodO/_ssgManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/48nWsJi-LJrUlOLzcK-Yz/_ssgManifest.js rename to litellm/proxy/_experimental/out/_next/static/Q9smtS3bJUKJtn7pvgodO/_ssgManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/777-17b0c91edd3a24fe.js b/litellm/proxy/_experimental/out/_next/static/chunks/777-17b0c91edd3a24fe.js deleted file mode 100644 index f6e7b217f..000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/777-17b0c91edd3a24fe.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[777],{777:function(e,t,o){o.d(t,{AZ:function(){return j},Au:function(){return V},BL:function(){return $},Br:function(){return k},Dj:function(){return ec},E9:function(){return et},EY:function(){return en},FC:function(){return Z},Gh:function(){return K},HK:function(){return z},I1:function(){return u},J$:function(){return b},K_:function(){return ea},N8:function(){return N},NV:function(){return i},Nc:function(){return D},O3:function(){return Y},OU:function(){return v},Og:function(){return s},Ov:function(){return p},Qy:function(){return m},RQ:function(){return d},Rg:function(){return F},So:function(){return A},W_:function(){return g},X:function(){return x},XO:function(){return h},Xd:function(){return X},Xm:function(){return f},YU:function(){return ee},Zr:function(){return l},ao:function(){return er},b1:function(){return S},cu:function(){return H},e2:function(){return U},fP:function(){return P},hT:function(){return q},hy:function(){return c},j2:function(){return B},jA:function(){return eo},jE:function(){return W},kK:function(){return n},kn:function(){return E},lg:function(){return M},mR:function(){return C},m_:function(){return T},n$:function(){return I},o6:function(){return _},pf:function(){return Q},qm:function(){return a},rs:function(){return y},tN:function(){return O},um:function(){return L},v9:function(){return R},wX:function(){return w},wd:function(){return G},xA:function(){return J}});var r=o(80588);let a=async()=>{try{let e=await fetch("https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"),t=await e.json();return console.log("received data: ".concat(t)),t}catch(e){throw console.error("Failed to get model cost map:",e),e}},n=async(e,t)=>{try{let o=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),r.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),a}catch(e){throw console.error("Failed to create key:",e),e}},c=async e=>{try{let t=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},s=async(e,t)=>{console.log("model_id in model delete call: ".concat(t));try{let o=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),r.ZP.success("Model deleted successfully. Restart server to see this."),a}catch(e){throw console.error("Failed to create key:",e),e}},i=async(e,t)=>{if(console.log("budget_id in budget delete call: ".concat(t)),null!=e)try{let o=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},l=async(e,t)=>{try{console.log("Form Values in budgetCreateCall:",t),console.log("Form Values after check:",t);let o=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},h=async(e,t)=>{try{let o=await fetch("/invitation/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},d=async e=>{try{let t=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},w=async(e,t,o)=>{try{if(console.log("Form Values in keyCreateCall:",o),o.description&&(o.metadata||(o.metadata={}),o.metadata.description=o.description,delete o.description,o.metadata=JSON.stringify(o.metadata)),o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw r.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",o);let a=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},p=async(e,t,o)=>{try{if(console.log("Form Values in keyCreateCall:",o),o.description&&(o.metadata||(o.metadata={}),o.metadata.description=o.description,delete o.description,o.metadata=JSON.stringify(o.metadata)),o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw r.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",o);let a=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},u=async(e,t)=>{try{console.log("in keyDeleteCall:",t);let o=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[t]})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,t)=>{try{console.log("in teamDeleteCall:",t);let o=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[t]})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4?arguments[4]:void 0,c=arguments.length>5?arguments[5]:void 0;try{let s="/user/info";"App Owner"==o&&t&&(s="".concat(s,"?user_id=").concat(t)),"App User"==o&&t&&(s="".concat(s,"?user_id=").concat(t)),("Internal User"==o||"Internal Viewer"==o)&&t&&(s="".concat(s,"?user_id=").concat(t)),console.log("in userInfoCall viewAll=",a),a&&c&&null!=n&&void 0!=n&&(s="".concat(s,"?view_all=true&page=").concat(n,"&page_size=").concat(c));let i=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let l=await i.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},f=async(e,t)=>{try{let o="/team/info";t&&(o="".concat(o,"?team_id=").concat(t)),console.log("in teamInfoCall");let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},m=async e=>{try{let t=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.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}},g=async e=>{try{let t="/onboarding/get_token";t+="?invite_link=".concat(e);let o=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,t,o,a)=>{try{let n=await fetch("/onboarding/claim_token",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({invitation_link:t,user_id:o,password:a})});if(!n.ok){let e=await n.text();throw r.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to delete key:",e),e}},j=async(e,t,o)=>{try{let t=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log("modelInfoCall:",o),o}catch(e){throw console.error("Failed to create key:",e),e}},E=async e=>{try{let t=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log("modelHubCall:",o),o}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},F=async(e,t,o,a)=>{try{let n="/model/streaming_metrics";t&&(n="".concat(n,"?_selected_model_group=").concat(t,"&startTime=").concat(o,"&endTime=").concat(a));let c=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await c.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics/slow_responses";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics/exceptions";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,t,o)=>{try{let t=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.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}},C=async e=>{try{let t="/global/spend/teams";console.log("in teamSpendLogsCall:",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,t,o,r)=>{try{let a="/global/spend/tags";t&&o&&(a="".concat(a,"?start_date=").concat(t,"&end_date=").concat(o)),r&&(a+="".concat(a,"&tags=").concat(r.join(","))),console.log("in tagsSpendLogsCall:",a);let n=await fetch("".concat(a),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to create key:",e),e}},x=async e=>{try{let t="/global/spend/all_tag_names";console.log("in global/spend/all_tag_names call",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");let r=await o.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},B=async e=>{try{let t="/global/all_end_users";console.log("in global/all_end_users call",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");let r=await o.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},z=async(e,t,o,a,n,c)=>{try{console.log("user role in spend logs call: ".concat(o));let t="/spend/logs";t="App Owner"==o?"".concat(t,"?user_id=").concat(a,"&start_date=").concat(n,"&end_date=").concat(c):"".concat(t,"?start_date=").concat(n,"&end_date=").concat(c);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 r.ZP.error(e,10),Error("Network response was not ok")}let i=await s.json();return console.log(i),i}catch(e){throw console.error("Failed to create key:",e),e}},Z=async e=>{try{let t=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},O=async e=>{try{let t=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},S=async(e,t,o,a)=>{try{let n="";n=t?JSON.stringify({api_key:t,startTime:o,endTime:a}):JSON.stringify({startTime:o,endTime:a});let c={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};c.body=n;let s=await fetch("/global/spend/end_users",c);if(!s.ok){let e=await s.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let i=await s.json();return console.log(i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,t,o,a)=>{try{let n="/global/spend/provider";o&&a&&(n+="?start_date=".concat(o,"&end_date=").concat(a)),t&&(n+="&api_key=".concat(t));let c=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!c.ok){let e=await c.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let s=await c.json();return console.log(s),s}catch(e){throw console.error("Failed to fetch spend data:",e),e}},G=async(e,t,o)=>{try{let r="/global/activity";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok)throw await a.text(),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}},J=async(e,t,o)=>{try{let r="/global/activity/model";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok)throw await a.text(),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}},I=async(e,t,o,r)=>{try{let a="/global/activity/exceptions";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o)),r&&(a+="&model_group=".concat(r));let n=await fetch(a,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to fetch spend data:",e),e}},R=async(e,t,o,r)=>{try{let a="/global/activity/exceptions/deployment";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o)),r&&(a+="&model_group=".concat(r));let n=await fetch(a,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to fetch spend data:",e),e}},V=async e=>{try{let t=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,t)=>{try{let o=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:t})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,t)=>{try{let o="/user/get_users?role=".concat(t);console.log("in userGetAllUsersCall:",o);let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to delete key: "+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 get requested models:",e),e}},M=async e=>{try{let t=await fetch("/user/available_roles",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok)throw await t.text(),Error("Network response was not ok");let o=await t.json();return console.log("response from user/available_role",o),o}catch(e){throw e}},q=async(e,t)=>{try{console.log("Form Values in teamCreateCall:",t);let o=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,t)=>{try{console.log("Form Values in keyUpdateCall:",t);let o=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update key Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},K=async(e,t)=>{try{console.log("Form Values in teamUpateCall:",t);let o=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update Team Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},L=async(e,t)=>{try{console.log("Form Values in modelUpateCall:",t);let o=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update model Response:",a),a}catch(e){throw console.error("Failed to update model:",e),e}},H=async(e,t,o)=>{try{console.log("Form Values in teamMemberAddCall:",o);let a=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,member:o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},Q=async(e,t,o)=>{try{console.log("Form Values in userUpdateUserCall:",t);let a={...t};null!==o&&(a.user_role=o),a=JSON.stringify(a);let n=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:a});if(!n.ok){let e=await n.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let c=await n.json();return console.log("API Response:",c),c}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,t)=>{try{let o="/health/services?service=".concat(t);console.log("Checking Slack Budget Alerts service health");let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed ".concat(t," service health check ")+e),Error(e)}let n=await a.json();return r.ZP.success("Test request to ".concat(t," made - check logs/alerts on ").concat(t," to verify")),n}catch(e){throw console.error("Failed to perform health check:",e),e}},Y=async e=>{try{let t=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},$=async(e,t,o)=>{try{let t=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async e=>{try{let t=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,t)=>{try{let o=await fetch("/config/field/info?field_name=".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");return await o.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},eo=async(e,t,o)=>{try{let a=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,field_value:o,config_type:"general_settings"})});if(!a.ok){let e=await a.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return r.ZP.success("Successfully updated value!"),n}catch(e){throw console.error("Failed to set callbacks:",e),e}},er=async(e,t)=>{try{let o=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,config_type:"general_settings"})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return r.ZP.success("Field reset on proxy"),a}catch(e){throw console.error("Failed to get callbacks:",e),e}},ea=async(e,t)=>{try{let o=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},en=async e=>{try{let t=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to call /health:",e),e}},ec=async e=>{try{let t=await fetch("/sso/get/logout_url",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}}}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/777-71fb78fdb4897cc3.js b/litellm/proxy/_experimental/out/_next/static/chunks/777-71fb78fdb4897cc3.js new file mode 100644 index 000000000..371adff18 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/777-71fb78fdb4897cc3.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[777],{777:function(e,t,o){o.d(t,{AZ:function(){return j},Au:function(){return V},BL:function(){return $},Br:function(){return k},Dj:function(){return ec},E9:function(){return et},EY:function(){return en},FC:function(){return Z},Gh:function(){return K},HK:function(){return z},I1:function(){return u},J$:function(){return b},K_:function(){return ea},N8:function(){return P},NV:function(){return i},Nc:function(){return D},O3:function(){return Y},OU:function(){return v},Og:function(){return s},Ov:function(){return p},Qy:function(){return m},RQ:function(){return d},Rg:function(){return _},So:function(){return A},W_:function(){return g},X:function(){return x},XO:function(){return h},Xd:function(){return X},Xm:function(){return f},YU:function(){return ee},Zr:function(){return l},ao:function(){return er},b1:function(){return S},cu:function(){return H},e2:function(){return U},fP:function(){return N},hT:function(){return q},hy:function(){return c},j2:function(){return B},jA:function(){return eo},jE:function(){return W},kK:function(){return n},kn:function(){return E},lg:function(){return M},mR:function(){return C},m_:function(){return T},n$:function(){return R},o6:function(){return F},pf:function(){return Q},qm:function(){return a},rs:function(){return y},tN:function(){return O},um:function(){return L},v9:function(){return I},wX:function(){return w},wd:function(){return G},xA:function(){return J}});var r=o(80588);let a=async()=>{try{let e=await fetch("/get/litellm_model_cost_map"),t=await e.json();return console.log("received litellm model cost data: ".concat(t)),t}catch(e){throw console.error("Failed to get model cost map:",e),e}},n=async(e,t)=>{try{let o=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),r.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),a}catch(e){throw console.error("Failed to create key:",e),e}},c=async e=>{try{let t=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},s=async(e,t)=>{console.log("model_id in model delete call: ".concat(t));try{let o=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),r.ZP.success("Model deleted successfully. Restart server to see this."),a}catch(e){throw console.error("Failed to create key:",e),e}},i=async(e,t)=>{if(console.log("budget_id in budget delete call: ".concat(t)),null!=e)try{let o=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},l=async(e,t)=>{try{console.log("Form Values in budgetCreateCall:",t),console.log("Form Values after check:",t);let o=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},h=async(e,t)=>{try{let o=await fetch("/invitation/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},d=async e=>{try{let t=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},w=async(e,t,o)=>{try{if(console.log("Form Values in keyCreateCall:",o),o.description&&(o.metadata||(o.metadata={}),o.metadata.description=o.description,delete o.description,o.metadata=JSON.stringify(o.metadata)),o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw r.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",o);let a=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},p=async(e,t,o)=>{try{if(console.log("Form Values in keyCreateCall:",o),o.description&&(o.metadata||(o.metadata={}),o.metadata.description=o.description,delete o.description,o.metadata=JSON.stringify(o.metadata)),o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw r.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",o);let a=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},u=async(e,t)=>{try{console.log("in keyDeleteCall:",t);let o=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[t]})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,t)=>{try{console.log("in teamDeleteCall:",t);let o=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[t]})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4?arguments[4]:void 0,c=arguments.length>5?arguments[5]:void 0;try{let s="/user/info";"App Owner"==o&&t&&(s="".concat(s,"?user_id=").concat(t)),"App User"==o&&t&&(s="".concat(s,"?user_id=").concat(t)),("Internal User"==o||"Internal Viewer"==o)&&t&&(s="".concat(s,"?user_id=").concat(t)),console.log("in userInfoCall viewAll=",a),a&&c&&null!=n&&void 0!=n&&(s="".concat(s,"?view_all=true&page=").concat(n,"&page_size=").concat(c));let i=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let l=await i.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},f=async(e,t)=>{try{let o="/team/info";t&&(o="".concat(o,"?team_id=").concat(t)),console.log("in teamInfoCall");let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},m=async e=>{try{let t=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.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}},g=async e=>{try{let t="/onboarding/get_token";t+="?invite_link=".concat(e);let o=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,t,o,a)=>{try{let n=await fetch("/onboarding/claim_token",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({invitation_link:t,user_id:o,password:a})});if(!n.ok){let e=await n.text();throw r.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to delete key:",e),e}},j=async(e,t,o)=>{try{let t=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log("modelInfoCall:",o),o}catch(e){throw console.error("Failed to create key:",e),e}},E=async e=>{try{let t=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log("modelHubCall:",o),o}catch(e){throw console.error("Failed to create key:",e),e}},F=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,t,o,a)=>{try{let n="/model/streaming_metrics";t&&(n="".concat(n,"?_selected_model_group=").concat(t,"&startTime=").concat(o,"&endTime=").concat(a));let c=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await c.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics/slow_responses";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics/exceptions";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,t,o)=>{try{let t=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.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}},C=async e=>{try{let t="/global/spend/teams";console.log("in teamSpendLogsCall:",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,t,o,r)=>{try{let a="/global/spend/tags";t&&o&&(a="".concat(a,"?start_date=").concat(t,"&end_date=").concat(o)),r&&(a+="".concat(a,"&tags=").concat(r.join(","))),console.log("in tagsSpendLogsCall:",a);let n=await fetch("".concat(a),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to create key:",e),e}},x=async e=>{try{let t="/global/spend/all_tag_names";console.log("in global/spend/all_tag_names call",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");let r=await o.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},B=async e=>{try{let t="/global/all_end_users";console.log("in global/all_end_users call",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");let r=await o.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},z=async(e,t,o,a,n,c)=>{try{console.log("user role in spend logs call: ".concat(o));let t="/spend/logs";t="App Owner"==o?"".concat(t,"?user_id=").concat(a,"&start_date=").concat(n,"&end_date=").concat(c):"".concat(t,"?start_date=").concat(n,"&end_date=").concat(c);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 r.ZP.error(e,10),Error("Network response was not ok")}let i=await s.json();return console.log(i),i}catch(e){throw console.error("Failed to create key:",e),e}},Z=async e=>{try{let t=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},O=async e=>{try{let t=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},S=async(e,t,o,a)=>{try{let n="";n=t?JSON.stringify({api_key:t,startTime:o,endTime:a}):JSON.stringify({startTime:o,endTime:a});let c={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};c.body=n;let s=await fetch("/global/spend/end_users",c);if(!s.ok){let e=await s.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let i=await s.json();return console.log(i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,t,o,a)=>{try{let n="/global/spend/provider";o&&a&&(n+="?start_date=".concat(o,"&end_date=").concat(a)),t&&(n+="&api_key=".concat(t));let c=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!c.ok){let e=await c.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let s=await c.json();return console.log(s),s}catch(e){throw console.error("Failed to fetch spend data:",e),e}},G=async(e,t,o)=>{try{let r="/global/activity";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok)throw await a.text(),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}},J=async(e,t,o)=>{try{let r="/global/activity/model";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok)throw await a.text(),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}},R=async(e,t,o,r)=>{try{let a="/global/activity/exceptions";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o)),r&&(a+="&model_group=".concat(r));let n=await fetch(a,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to fetch spend data:",e),e}},I=async(e,t,o,r)=>{try{let a="/global/activity/exceptions/deployment";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o)),r&&(a+="&model_group=".concat(r));let n=await fetch(a,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to fetch spend data:",e),e}},V=async e=>{try{let t=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,t)=>{try{let o=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:t})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,t)=>{try{let o="/user/get_users?role=".concat(t);console.log("in userGetAllUsersCall:",o);let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to delete key: "+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 get requested models:",e),e}},M=async e=>{try{let t=await fetch("/user/available_roles",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok)throw await t.text(),Error("Network response was not ok");let o=await t.json();return console.log("response from user/available_role",o),o}catch(e){throw e}},q=async(e,t)=>{try{console.log("Form Values in teamCreateCall:",t);let o=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,t)=>{try{console.log("Form Values in keyUpdateCall:",t);let o=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update key Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},K=async(e,t)=>{try{console.log("Form Values in teamUpateCall:",t);let o=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update Team Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},L=async(e,t)=>{try{console.log("Form Values in modelUpateCall:",t);let o=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update model Response:",a),a}catch(e){throw console.error("Failed to update model:",e),e}},H=async(e,t,o)=>{try{console.log("Form Values in teamMemberAddCall:",o);let a=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,member:o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},Q=async(e,t,o)=>{try{console.log("Form Values in userUpdateUserCall:",t);let a={...t};null!==o&&(a.user_role=o),a=JSON.stringify(a);let n=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:a});if(!n.ok){let e=await n.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let c=await n.json();return console.log("API Response:",c),c}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,t)=>{try{let o="/health/services?service=".concat(t);console.log("Checking Slack Budget Alerts service health");let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed ".concat(t," service health check ")+e),Error(e)}let n=await a.json();return r.ZP.success("Test request to ".concat(t," made - check logs/alerts on ").concat(t," to verify")),n}catch(e){throw console.error("Failed to perform health check:",e),e}},Y=async e=>{try{let t=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},$=async(e,t,o)=>{try{let t=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async e=>{try{let t=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,t)=>{try{let o=await fetch("/config/field/info?field_name=".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");return await o.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},eo=async(e,t,o)=>{try{let a=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,field_value:o,config_type:"general_settings"})});if(!a.ok){let e=await a.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return r.ZP.success("Successfully updated value!"),n}catch(e){throw console.error("Failed to set callbacks:",e),e}},er=async(e,t)=>{try{let o=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,config_type:"general_settings"})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return r.ZP.success("Field reset on proxy"),a}catch(e){throw console.error("Failed to get callbacks:",e),e}},ea=async(e,t)=>{try{let o=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},en=async e=>{try{let t=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to call /health:",e),e}},ec=async e=>{try{let t=await fetch("/sso/get/logout_url",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok)throw await t.text(),Error("Network response was not ok");return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}}}}]); \ No newline at end of file diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/layout-cb827484903e98d8.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/layout-9bbef188642a56c0.js similarity index 54% rename from ui/litellm-dashboard/out/_next/static/chunks/app/layout-cb827484903e98d8.js rename to litellm/proxy/_experimental/out/_next/static/chunks/app/layout-9bbef188642a56c0.js index e261adc05..2fae6a1d3 100644 --- a/ui/litellm-dashboard/out/_next/static/chunks/app/layout-cb827484903e98d8.js +++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/layout-9bbef188642a56c0.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{87421:function(n,e,t){Promise.resolve().then(t.t.bind(t,99646,23)),Promise.resolve().then(t.t.bind(t,63385,23))},63385:function(){},99646:function(n){n.exports={style:{fontFamily:"'__Inter_c23dc8', '__Inter_Fallback_c23dc8'",fontStyle:"normal"},className:"__className_c23dc8"}}},function(n){n.O(0,[971,69,744],function(){return n(n.s=87421)}),_N_E=n.O()}]); \ No newline at end of file +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{87421:function(n,e,t){Promise.resolve().then(t.t.bind(t,99646,23)),Promise.resolve().then(t.t.bind(t,63385,23))},63385:function(){},99646:function(n){n.exports={style:{fontFamily:"'__Inter_12bbc4', '__Inter_Fallback_12bbc4'",fontStyle:"normal"},className:"__className_12bbc4"}}},function(n){n.O(0,[971,69,744],function(){return n(n.s=87421)}),_N_E=n.O()}]); \ No newline at end of file diff --git a/ui/litellm-dashboard/out/_next/static/chunks/app/page-bd882aee817406ff.js b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-d301c202a2cebcd3.js similarity index 82% rename from ui/litellm-dashboard/out/_next/static/chunks/app/page-bd882aee817406ff.js rename to litellm/proxy/_experimental/out/_next/static/chunks/app/page-d301c202a2cebcd3.js index a5a509e8f..0361a3c21 100644 --- a/ui/litellm-dashboard/out/_next/static/chunks/app/page-bd882aee817406ff.js +++ b/litellm/proxy/_experimental/out/_next/static/chunks/app/page-d301c202a2cebcd3.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,s){Promise.resolve().then(s.bind(s,45980))},45980:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return lt}});var t,n,a=s(3827),r=s(64090),i=s(47907),o=s(8792),d=s(40491),c=s(65270),m=e=>{let{userID:l,userRole:s,userEmail:t,showSSOBanner:n,premiumUser:r,setProxySettings:i,proxySettings:m}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("showSSOBanner:",n),console.log("premiumUser:",r);let u="";console.log("PROXY_settings=",m),m&&m.PROXY_LOGOUT_URL&&void 0!==m.PROXY_LOGOUT_URL&&(u=m.PROXY_LOGOUT_URL),console.log("logoutUrl=",u);let h=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",s]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(r)]})]})},{key:"2",label:(0,a.jsx)("a",{href:u,children:(0,a.jsx)("p",{children:"Logout"})})}];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)(o.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:[n?(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 enterprise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:h},children:(0,a.jsx)(c.Z,{children:t})})})]})]})},u=s(777),h=s(10384),x=s(46453),p=s(16450),j=s(52273),g=s(26780),Z=s(15595),f=s(6698),_=s(71801),y=s(42440),b=s(42308),v=s(50670),S=s(60620),k=s(80588),w=s(99129),N=s(44839),I=s(88707),A=s(1861);let{Option:C}=v.default;var P=e=>{let{userID:l,team:s,userRole:t,accessToken:n,data:i,setData:o}=e,[d]=S.Z.useForm(),[c,m]=(0,r.useState)(!1),[P,T]=(0,r.useState)(null),[E,O]=(0,r.useState)(null),[R,M]=(0,r.useState)([]),[F,L]=(0,r.useState)([]),D=()=>{m(!1),d.resetFields()},U=()=>{m(!1),T(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==n){let e=(await (0,u.So)(n,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),M(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let V=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",c=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(a=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));k.ZP.info("Making API Call"),m(!0);let h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),T(h.key),O(h.soft_budget),k.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.useEffect)(()=>{L(s&&s.models.length>0?s.models.includes("all-proxy-models")?R:s.models:R)},[s,R]),(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(w.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:D,onCancel:U,children:(0,a.jsxs)(S.Z,{form:d,onFinish:V,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(N.Z,{value:s?s.team_alias:"",disabled:!0})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(C,{value:"all-team-models",children:"All Team Models"},"all-team-models"),F.map(e=>(0,a.jsx)(C,{value:e,children:e},e))]})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==s?void 0:s.max_budget)!==null&&(null==s?void 0:s.max_budget)!==void 0?null==s?void 0:s.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.max_budget&&l>s.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(s.max_budget))}}],children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==s?void 0:s.budget_duration)!==null&&(null==s?void 0:s.budget_duration)!==void 0?null==s?void 0:s.budget_duration:"None"),children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==s?void 0:s.tpm_limit)!==null&&(null==s?void 0:s.tpm_limit)!==void 0?null==s?void 0:s.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.tpm_limit&&l>s.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(s.tpm_limit))}}],children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==s?void 0:s.rpm_limit)!==null&&(null==s?void 0:s.rpm_limit)!==void 0?null==s?void 0:s.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.rpm_limit&&l>s.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(s.rpm_limit))}}],children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Key"})})]})}),P&&(0,a.jsx)(w.Z,{visible:c,onOk:D,onCancel:U,footer:null,children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Save your Key"}),(0,a.jsx)(h.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)(h.Z,{numColSpan:1,children:null!=P?(0,a.jsxs)("div",{children:[(0,a.jsx)(_.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:P})}),(0,a.jsx)(b.CopyToClipboard,{text:P,onCopy:()=>{k.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(_.Z,{children:"Key being created, this might take 30s"})})]})})]})},T=s(9454),E=s(98941),O=s(33393),R=s(5),M=s(13810),F=s(61244),L=s(10827),D=s(3851),U=s(2044),V=s(64167),q=s(74480),z=s(7178),B=s(95093),K=s(27166);let{Option:W}=v.default;var G=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d}=e,[c,m]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)(null),[b,C]=(0,r.useState)(null),[P,G]=(0,r.useState)(""),[H,Y]=(0,r.useState)(!1),[J,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(null),[ee,el]=(0,r.useState)([]),es=new Set,[et,en]=(0,r.useState)(es);(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,u.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),el(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),en(e)}},[d]);let ea=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),Q(e),Y(!0)},er=async e=>{if(null==t)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let s=await (0,u.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),k.ZP.success("Key updated successfully"),Y(!1),Q(null)},ei=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(g(e.token),localStorage.removeItem("userData"+l),x(!0))},eo=async()=>{if(null!=j&&null!=i){try{await (0,u.I1)(t,j);let e=i.filter(e=>e.token!==j);o(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),g(null)}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(L.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Key Alias"}),(0,a.jsx)(q.Z,{children:"Secret Key"}),(0,a.jsx)(q.Z,{children:"Spend (USD)"}),(0,a.jsx)(q.Z,{children:"Budget (USD)"}),(0,a.jsx)(q.Z,{children:"Models"}),(0,a.jsx)(q.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(D.Z,{children:i.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(n){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(et.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||et.has(e.team_id))&&e.team_id!=n.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(_.Z,{children:e.key_alias}):(0,a.jsx)(_.Z,{children:"Not Set"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(U.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(U.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:n&&n.models&&n.models.length>0?n.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(_.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)(U.Z,{children:[(0,a.jsx)(F.Z,{onClick:()=>{Q(e),X(!0)},icon:T.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:J,onCancel:()=>{X(!1),Q(null)},footer:null,width:800,children:$&&(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)(M.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($.spend).toFixed(4)}catch(e){return $.spend}})()})})]}),(0,a.jsxs)(M.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!=$.max_budget?(0,a.jsx)(a.Fragment,{children:$.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(M.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!=$.expires?(0,a.jsx)(a.Fragment,{children:new Date($.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)(M.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:$.key_alias?$.key_alias:$.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:$.token}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify($.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{X(!1),Q(null)},children:"Close"})]})}),(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>ea(e)}),(0,a.jsx)(F.Z,{onClick:()=>ei(e),icon:O.Z,size:"sm"})]})]},e.token)})})]}),h&&(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)(p.Z,{onClick:eo,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{x(!1),g(null)},children:"Cancel"})]})]})]})})]}),$&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=S.Z.useForm(),[c,m]=(0,r.useState)(n),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(!1);return(0,a.jsx)(w.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:o,onFinish:er,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let s=l.filter(e=>!c.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!c.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(s)),s.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(s,"Team models: ").concat(c.models)):Promise.resolve()}}],children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(W,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ee.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(W,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(W,{value:e,children:e},e)):ee.map(e=>(0,a.jsx)(W,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==c?void 0:c.max_budget)!==null&&(null==c?void 0:c.max_budget)!==void 0?null==c?void 0:c.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.max_budget&&l>c.max_budget)throw console.log("keyTeam.max_budget: ".concat(c.max_budget)),Error("Budget cannot exceed team max budget: $".concat(c.max_budget))}}],children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(B.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(K.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)(A.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:H,onCancel:()=>{Y(!1),Q(null)},token:$,onSubmit:er})]})},H=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,selectedTeam:i}=e;console.log("userSpend: ".concat(n));let[o,d]=(0,r.useState)(null!==n?n:0),[c,m]=(0,r.useState)(0),[h,x]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(t&&l&&s&&"Admin"===s&&null==n)try{let e=await (0,u.Qy)(t);e&&(e.spend?d(e.spend):d(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===s)return;if(null!==t){let e=(await (0,u.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==n&&d(n)},[n]);let p=[];i&&i.models&&(p=i.models),p&&p.includes("all-proxy-models")?(console.log("user models:",h),p=h):p&&p.includes("all-team-models")?p=i.models:p&&0===p.length&&(p=h);let j=void 0!==o?o.toFixed(4):null;return console.log("spend in view user spend: ".concat(o)),(0,a.jsx)("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:["$",j]})]})})},Y=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==n){let e=(await (0,u.So)(n,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,s]);let d=[];return t&&t.models&&(d=t.models),d&&d.includes("all-proxy-models")&&(console.log("user models:",i),d=i),(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==t?void 0:t.team_alias})})})},J=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n}=e,i={models:[],team_id:null,team_alias:"Default Team"},[o,d]=(0,r.useState)(i);return(l="App User"===n?s:s?[...s,i]:[i],"App User"===n)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(y.Z,{children:"Select Team"}),(0,a.jsx)(_.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)(_.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)(B.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(K.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,a.jsxs)(_.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},X=s(37963),$=s(97482);console.log("isLocal:",!1);var Q=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p,setProxySettings:j,proxySettings:g}=e,[Z,f]=(0,r.useState)(null),_=(0,i.useSearchParams)();_.get("viewSpend"),(0,i.useRouter)();let y=_.get("token"),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)(null),[w,N]=(0,r.useState)([]),I={models:[],team_alias:"Default Team",team_id:null},[A,C]=(0,r.useState)(t?t[0]:I);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(y){let e=(0,X.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),v(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";case"internal_user":return"Internal User";case"internal_user_viewer":return"Internal Viewer";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),o(l)}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&b&&s&&!n&&!Z){let e=sessionStorage.getItem("userModels"+l);e?N(JSON.parse(e)):(async()=>{try{let e=await (0,u.Dj)(b);j(e);let t=await (0,u.Br)(b,l,s,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(t),"; team values: ").concat(Object.entries(t.teams))),"Admin"==s){let e=await (0,u.Qy)(b);f(e),console.log("globalSpend:",e)}else f(t.user_info);p(t.keys),m(t.teams);let n=[...t.teams];n.length>0?(console.log("response['teams']: ".concat(n)),C(n[0])):C(I),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,u.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),N(a),console.log("userModels:",w),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,y,b,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=A&&null!==A.team_id){let e=0;for(let l of n)A.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===A.team_id&&(e+=l.spend);k(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;k(e)}},[A]),null==l||null==y){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==b)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=$.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",A),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(Y,{userID:l,userRole:s,selectedTeam:A||null,accessToken:b}),(0,a.jsx)(H,{userID:l,userRole:s,accessToken:b,userSpend:S,selectedTeam:A||null}),(0,a.jsx)(G,{userID:l,userRole:s,accessToken:b,selectedTeam:A||null,data:n,setData:p,teams:t}),(0,a.jsx)(P,{userID:l,team:A||null,userRole:s,accessToken:b,data:n,setData:p},A?A.team_id:null),(0,a.jsx)(J,{teams:t,setSelectedTeam:C,userRole:s})]})})})},ee=s(49167),el=s(35087),es=s(92836),et=s(26734),en=s(41608),ea=s(32126),er=s(23682),ei=s(47047),eo=s(76628),ed=s(25707),ec=s(44041),em=s(6180),eu=s(28683),eh=s(38302),ex=s(66242),ep=s(78578),ej=s(63954),eg=s(34658),eZ=e=>{let{modelID:l,accessToken:s}=e,[t,n]=(0,r.useState)(!1),i=async()=>{try{k.ZP.info("Making API Call"),n(!0);let e=await (0,u.Og)(s,l);console.log("model delete Response:",e),k.ZP.success("Model ".concat(l," deleted successfully")),n(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(F.Z,{onClick:()=>n(!0),icon:O.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>n(!1),children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Delete Model"}),(0,a.jsx)(h.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)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},ef=s(97766),e_=s(46495),ey=s(18190),eb=s(91118),ev=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(eb.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:s,colors:["indigo","rose"],connectNulls:!0,customTooltip:t}):(0,a.jsxs)("div",{children:[(0,a.jsx)(ey.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)(p.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eS=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(S.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)(j.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},ek=s(67951);let{Title:ew,Link:eN}=$.default;(t=n||(n={})).OpenAI="OpenAI",t.Azure="Azure",t.Anthropic="Anthropic",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Databricks="Databricks",t.Ollama="Ollama";let eI={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks",Ollama:"ollama"},eA={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eC=async(e,l,s)=>{try{let t=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(t)),console.log("received type of deployments: ".concat(typeof t)),t.forEach(async s=>{console.log("litellm_model: ".concat(s));let t={},n={};t.model=s;let a="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)a+=s;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)n[l]=s;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw k.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else t[l]=s}let r={model_name:a,litellm_params:t,model_info:n},i=await (0,u.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){k.ZP.error("Failed to create model: "+e,10)}};var eP=e=>{var l,s,t;let i,{accessToken:o,token:d,userRole:c,userID:m,modelData:h={data:[]},keys:g,setModelData:Z,premiumUser:f}=e,[b,v]=(0,r.useState)([]),[N]=S.Z.useForm(),[C,P]=(0,r.useState)(null),[O,W]=(0,r.useState)(""),[G,H]=(0,r.useState)([]),Y=Object.values(n).filter(e=>isNaN(Number(e))),[J,X]=(0,r.useState)([]),[Q,ey]=(0,r.useState)("OpenAI"),[eb,eP]=(0,r.useState)(""),[eT,eE]=(0,r.useState)(!1),[eO,eR]=(0,r.useState)(!1),[eM,eF]=(0,r.useState)(null),[eL,eD]=(0,r.useState)([]),[eU,eV]=(0,r.useState)(null),[eq,ez]=(0,r.useState)([]),[eB,eK]=(0,r.useState)([]),[eW,eG]=(0,r.useState)([]),[eH,eY]=(0,r.useState)([]),[eJ,eX]=(0,r.useState)([]),[e$,eQ]=(0,r.useState)([]),[e0,e1]=(0,r.useState)([]),[e2,e4]=(0,r.useState)([]),[e5,e8]=(0,r.useState)([]),[e3,e6]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e9,e7]=(0,r.useState)(null),[le,ll]=(0,r.useState)(0),[ls,lt]=(0,r.useState)({}),[ln,la]=(0,r.useState)([]),[lr,li]=(0,r.useState)(!1),[lo,ld]=(0,r.useState)(null),[lc,lm]=(0,r.useState)(null),[lu,lh]=(0,r.useState)([]);(0,r.useEffect)(()=>{lb(eU,e3.from,e3.to)},[lo,lc]);let lx=e=>{eF(e),eE(!0)},lp=e=>{eF(e),eR(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==o)return;let l={},s=null;for(let[t,n]of Object.entries(e))"model_id"!==t?l[t]=n:s=n;let t={litellm_params:l,model_info:{id:s}};console.log("handleEditSubmit payload:",t);try{await (0,u.um)(o,t),k.ZP.success("Model updated successfully, restart server to see updates"),eE(!1),eF(null)}catch(e){console.log("Error occurred")}},lg=()=>{W(new Date().toLocaleString())},lZ=async()=>{if(!o){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e9);try{await (0,u.K_)(o,{router_settings:{model_group_retry_policy:e9}}),k.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),k.ZP.error("Failed to save retry settings")}};if((0,r.useEffect)(()=>{if(!o||!d||!c||!m)return;let e=async()=>{try{var e,l,s,t,n,a,r,i,d,h,x,p;let j=await (0,u.hy)(o);X(j);let g=await (0,u.AZ)(o,m,c);console.log("Model data response:",g.data),Z(g);let f=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y),eV(y)),console.log("selectedModelGroup:",eU);let b=await (0,u.o6)(o,m,c,y,null===(e=e3.from)||void 0===e?void 0:e.toISOString(),null===(l=e3.to)||void 0===l?void 0:l.toISOString(),null==lo?void 0:lo.token,lc);console.log("Model metrics response:",b),eK(b.data),eG(b.all_api_bases);let v=await (0,u.Rg)(o,y,null===(s=e3.from)||void 0===s?void 0:s.toISOString(),null===(t=e3.to)||void 0===t?void 0:t.toISOString());eY(v.data),eX(v.all_api_bases);let S=await (0,u.N8)(o,m,c,y,null===(n=e3.from)||void 0===n?void 0:n.toISOString(),null===(a=e3.to)||void 0===a?void 0:a.toISOString(),null==lo?void 0:lo.token,lc);console.log("Model exceptions response:",S),eQ(S.data),e1(S.exception_types);let k=await (0,u.fP)(o,m,c,y,null===(r=e3.from)||void 0===r?void 0:r.toISOString(),null===(i=e3.to)||void 0===i?void 0:i.toISOString(),null==lo?void 0:lo.token,lc),w=await (0,u.n$)(o,null===(d=e3.from)||void 0===d?void 0:d.toISOString().split("T")[0],null===(h=e3.to)||void 0===h?void 0:h.toISOString().split("T")[0],y);lt(w);let N=await (0,u.v9)(o,null===(x=e3.from)||void 0===x?void 0:x.toISOString().split("T")[0],null===(p=e3.to)||void 0===p?void 0:p.toISOString().split("T")[0],y);la(N),console.log("dailyExceptions:",w),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",k),e8(k);let I=await (0,u.j2)(o);lh(null==I?void 0:I.end_users);let A=(await (0,u.BL)(o,m,c)).router_settings;console.log("routerSettingsInfo:",A);let C=A.model_group_retry_policy,P=A.num_retries;console.log("model_group_retry_policy:",C),console.log("default_retries:",P),e7(C),ll(P)}catch(e){console.error("There was an error fetching the model data",e)}};o&&d&&c&&m&&e();let l=async()=>{let e=await (0,u.qm)();console.log("received model cost map data: ".concat(Object.keys(e))),P(e)};null==C&&l(),lg()},[o,d,c,m,C,O]),!h||!o||!d||!c||!m)return(0,a.jsx)("div",{children:"Loading..."});let lf=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(C)),null!=C&&"object"==typeof C&&e in C)?C[e].litellm_provider:"openai";if(n){let e=n.split("/"),l=e[0];r=1===e.length?u(n):l}else r="openai";a&&(i=null==a?void 0:a.input_cost_per_token,o=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==t?void 0:t.litellm_params)&&(m=Object.fromEntries(Object.entries(null==t?void 0:t.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),h.data[e].provider=r,h.data[e].input_cost=i,h.data[e].output_cost=o,h.data[e].input_cost&&(h.data[e].input_cost=(1e6*Number(h.data[e].input_cost)).toFixed(2)),h.data[e].output_cost&&(h.data[e].output_cost=(1e6*Number(h.data[e].output_cost)).toFixed(2)),h.data[e].max_tokens=d,h.data[e].max_input_tokens=c,h.data[e].api_base=null==t?void 0:null===(s=t.litellm_params)||void 0===s?void 0:s.api_base,h.data[e].cleanedLitellmParams=m,lf.push(t.model_name),console.log(h.data[e])}if(c&&"Admin Viewer"==c){let{Title:e,Paragraph:l}=$.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 l_=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eI[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof C&&Object.entries(C).forEach(l=>{let[t,n]=l;null!==n&&"object"==typeof n&&"litellm_provider"in n&&(n.litellm_provider===e||n.litellm_provider.includes(e))&&s.push(t)}),H(s),console.log("providerModels: ".concat(G))}},ly=async()=>{try{k.ZP.info("Running health check..."),eP("");let e=await (0,u.EY)(o);eP(e)}catch(e){console.error("Error running health check:",e),eP("Error running health check")}},lb=async(e,l,s)=>{if(console.log("Updating model metrics for group:",e),!o||!m||!c||!l||!s)return;console.log("inside updateModelMetrics - startTime:",l,"endTime:",s),eV(e);let t=null==lo?void 0:lo.token;void 0===t&&(t=null);let n=lc;void 0===n&&(n=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),s.setHours(23),s.setMinutes(59),s.setSeconds(59);try{let a=await (0,u.o6)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);console.log("Model metrics response:",a),eK(a.data),eG(a.all_api_bases);let r=await (0,u.Rg)(o,e,l.toISOString(),s.toISOString());eY(r.data),eX(r.all_api_bases);let i=await (0,u.N8)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);console.log("Model exceptions response:",i),eQ(i.data),e1(i.exception_types);let d=await (0,u.fP)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);if(console.log("slowResponses:",d),e8(d),e){let t=await (0,u.n$)(o,null==l?void 0:l.toISOString().split("T")[0],null==s?void 0:s.toISOString().split("T")[0],e);lt(t);let n=await (0,u.v9)(o,null==l?void 0:l.toISOString().split("T")[0],null==s?void 0:s.toISOString().split("T")[0],e);la(n)}}catch(e){console.error("Failed to fetch model metrics",e)}},lv=(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Select API Key Name"}),f?(0,a.jsxs)("div",{children:[(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{ld(null)},children:"All Keys"},"all-keys"),null==g?void 0:g.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{ld(e)},children:e.key_alias},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(B.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(K.Z,{value:"all-customers",onClick:()=>{lm(null)},children:"All Customers"},"all-customers"),null==lu?void 0:lu.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>{lm(e)},children:e},l))]})]}):(0,a.jsxs)("div",{children:[(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{ld(null)},children:"All Keys"},"all-keys"),null==g?void 0:g.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsxs)(K.Z,{value:String(l),disabled:!0,onClick:()=>{ld(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(B.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(K.Z,{value:"all-customers",onClick:()=>{lm(null)},children:"All Customers"},"all-customers"),null==lu?void 0:lu.map((e,l)=>(0,a.jsxs)(K.Z,{value:e,disabled:!0,onClick:()=>{lm(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lS=e=>{var l,s;let{payload:t,active:n}=e;if(!n||!t)return null;let r=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,i=t.sort((e,l)=>l.value-e.value);if(i.length>5){let e=i.length-5;(i=i.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:t.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:[r&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",r]}),i.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.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:t})]},l)})]})};console.log("selectedProvider: ".concat(Q)),console.log("providerModels.length: ".concat(G.length));let lk=Object.keys(n).find(e=>n[e]===Q);return lk&&(i=J.find(e=>e.name===eI[lk])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(et.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(es.Z,{children:"All Models"}),(0,a.jsx)(es.Z,{children:"Add Model"}),(0,a.jsx)(es.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(es.Z,{children:"Model Analytics"}),(0,a.jsx)(es.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[O&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",O]}),(0,a.jsx)(F.Z,{icon:ej.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(B.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eU||eL[0],onValueChange:e=>eV("all"===e?"all":e),value:eU||eL[0],children:[(0,a.jsx)(K.Z,{value:"all",children:"All Models"}),eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>eV(e),children:e},l))]})]}),(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),"Admin"===c&&(0,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:f?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:f?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(q.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(q.Z,{})]})}),(0,a.jsx)(D.Z,{children:h.data.filter(e=>"all"===eU||e.model_name===eU||null==eU||""===eU).map((e,l)=>{var s;return(0,a.jsxs)(z.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),"Admin"===c&&(0,a.jsx)(U.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(em.Z,{title:e&&e.api_base,children:(0,a.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,a.jsx)(U.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{className:"text-xs",children:e.input_cost?e.input_cost:e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(U.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{className:"text-xs",children:e.output_cost?e.output_cost:e.litellm_params.output_cost_per_token?(1e6*Number(e.litellm_params.output_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:f&&((s=e.model_info.created_at)?new Date(s).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:f&&e.model_info.created_by||"-"})}),(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(R.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,a.jsx)(R.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,a.jsx)(U.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eu.Z,{children:(0,a.jsx)(F.Z,{icon:T.Z,size:"sm",onClick:()=>lp(e)})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>lx(e)})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(eZ,{modelID:e.model_info.id,accessToken:o})})]})})]},l)})})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:n}=e,[r]=S.Z.useForm(),i={},o="",d="";if(t){i=t.litellm_params,o=t.model_name;let e=t.model_info;e&&(d=e.id,console.log("model_id: ".concat(d)),i.model_id=d)}return(0,a.jsx)(w.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.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)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(I.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(I.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:eT,onCancel:()=>{eE(!1),eF(null)},model:eM,onSubmit:lj}),(0,a.jsxs)(w.Z,{title:eM&&eM.model_name,visible:eO,width:800,footer:null,onCancel:()=>{eR(!1),eF(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(ek.Z,{language:"json",children:eM&&JSON.stringify(eM,null,2)})]})]}),(0,a.jsxs)(ea.Z,{className:"h-full",children:[(0,a.jsx)(ew,{level:2,children:"Add new model"}),(0,a.jsx)(M.Z,{children:(0,a.jsxs)(S.Z,{form:N,onFinish:()=>{N.validateFields().then(e=>{eC(e,o,N)}).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)(S.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)(B.Z,{value:Q.toString(),children:Y.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>{l_(e),ey(e)},children:e},l))})}),(0,a.jsx)(S.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)(j.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(t=Q.toString())?"gemini-pro":"Anthropic"==t?"claude-3-opus":"Amazon Bedrock"==t?"claude-3-opus":"Google AI Studio"==t?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(S.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"===Q?(0,a.jsx)(j.Z,{placeholder:"Enter model name"}):G.length>0?(0,a.jsx)(ei.Z,{value:G,children:G.map((e,l)=>(0,a.jsx)(eo.Z,{value:e,children:e},l))}):(0,a.jsx)(j.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(eN,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(eN,{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!==i&&i.fields.length>0&&(0,a.jsx)(eS,{fields:i.fields,selectedProvider:i.name}),"Amazon Bedrock"!=Q&&"Vertex AI (Anthropic, Gemini, etc.)"!=Q&&"Ollama"!=Q&&(void 0===i||0==i.fields.length)&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(j.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==Q&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(j.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(j.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(e_.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;N.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?k.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&k.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(A.ZP,{icon:(0,a.jsx)(ef.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==Q||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==Q)&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(j.Z,{placeholder:"https://..."})}),"Azure"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==Q&&(0,a.jsxs)("div",{children:[(0,a.jsx)(S.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(j.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(eN,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(S.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)(ep.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(eN,{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)(A.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(em.Z,{title:"Get help on our github",children:(0,a.jsx)($.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(_.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(p.Z,{onClick:ly,children:"Run `/health`"}),eb&&(0,a.jsx)("pre",{children:JSON.stringify(eb,null,2)})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(el.Z,{enableSelect:!0,value:e3,className:"mr-2",onValueChange:e=>{e6(e),lb(eU,e.from,e.to)}})]}),(0,a.jsxs)(eu.Z,{className:"ml-2",children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(B.Z,{defaultValue:eU||eL[0],value:eU||eL[0],children:eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>lb(e,e3.from,e3.to),children:e},l))})]}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(ex.Z,{trigger:"click",content:lv,overlayStyle:{width:"20vw"},children:(0,a.jsx)(p.Z,{icon:eg.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>li(!0)})})})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eu.Z,{children:(0,a.jsx)(M.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(es.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(_.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),eB&&eW&&(0,a.jsx)(ed.Z,{title:"Model Latency",className:"h-72",data:eB,showLegend:!1,index:"date",categories:eW,connectNulls:!0,customTooltip:lS})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ev,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lS,premiumUser:f})})]})]})})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(M.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Deployment"}),(0,a.jsx)(q.Z,{children:"Success Responses"}),(0,a.jsxs)(q.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(D.Z,{children:e5.map((e,l)=>(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.api_base}),(0,a.jsx)(U.Z,{children:e.total_count}),(0,a.jsx)(U.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eU]}),(0,a.jsxs)(x.Z,{numItems:1,children:[(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ls.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:ls.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,a.jsx)(eu.Z,{})]})]}),f?(0,a.jsx)(a.Fragment,{children:ln.map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,a.jsx)(a.Fragment,{children:ln&&ln.length>0&&ln.slice(0,1).map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,a.jsx)(p.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)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(B.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eU||eL[0],value:eU||eL[0],onValueChange:e=>eV(e),children:eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>eV(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eU]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eA&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eA).map((e,l)=>{var s;let[t,n]=e,r=null==e9?void 0:null===(s=e9[eU])||void 0===s?void 0:s[n];return null==r&&(r=le),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)("td",{children:(0,a.jsx)(I.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e7(l=>{var s;let t=null!==(s=null==l?void 0:l[eU])&&void 0!==s?s:{};return{...null!=l?l:{},[eU]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})},eT=e=>{let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:n}=e,{Title:r,Paragraph:i}=$.default;return(0,a.jsxs)(w.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,a.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"User ID"}),(0,a.jsx)(_.Z,{children:null==n?void 0:n.user_id})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{children:"Invitation Link"}),(0,a.jsxs)(_.Z,{children:[t,"/ui/onboarding?id=",null==n?void 0:n.id]})]}),(0,a.jsxs)("div",{className:"flex justify-end mt-5",children:[(0,a.jsx)("div",{}),(0,a.jsx)(b.CopyToClipboard,{text:"".concat(t,"/ui/onboarding?id=").concat(null==n?void 0:n.id),onCopy:()=>k.ZP.success("Copied!"),children:(0,a.jsx)(p.Z,{variant:"primary",children:"Copy invitation link"})})]})]})};let{Option:eE}=v.default;var eO=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:n}=e,[o]=S.Z.useForm(),[d,c]=(0,r.useState)(!1),[m,h]=(0,r.useState)(null),[x,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[y,b]=(0,r.useState)(null),I=(0,i.useRouter)(),[C,P]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{if(I){let{protocol:e,host:l}=window.location;P("".concat(e,"/").concat(l))}},[I]);let T=async e=>{try{var t;k.ZP.info("Making API Call"),c(!0),console.log("formValues in create user:",e);let n=await (0,u.Ov)(s,null,e);console.log("user create Response:",n),h(n.key);let a=(null===(t=n.data)||void 0===t?void 0:t.user_id)||n.user_id;(0,u.XO)(s,a).then(e=>{b(e),f(!0)}),k.ZP.success("API user Created"),o.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-0",onClick:()=>c(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:d,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),h(null),o.resetFields()},children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,a.jsxs)(S.Z,{form:o,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(S.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:n&&Object.entries(n).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(K.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(v.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,a.jsx)(eE,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eE,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create User"})})]})]}),m&&(0,a.jsx)(eT,{isInvitationLinkModalVisible:Z,setIsInvitationLinkModalVisible:f,baseUrl:C,invitationLinkData:y})]})},eR=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:n,onSubmit:i}=e,[o,d]=(0,r.useState)(n),[c]=S.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[n]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return n?(0,a.jsx)(w.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+n.user_id,width:1e3,children:(0,a.jsx)(S.Z,{form:c,onFinish:u,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(K.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})}):null},eM=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(0),[Z,f]=r.useState(null),[_,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(!1),[S,w]=(0,r.useState)(null),[N,I]=(0,r.useState)({}),A=async()=>{w(null),v(!1)},C=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&n&&i){try{await (0,u.pf)(l,e,null),k.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}c&&m(c.map(l=>l.user_id===e.user_id?e:l)),w(null),v(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=await (0,u.Br)(l,null,n,!0,j,25);console.log("user data response:",e),m(e);let s=await (0,u.lg)(l);I(s)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,j]),c&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,a.jsx)(eO,{userID:i,accessToken:l,teams:o,possibleUIRoles:N}),(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1"}),(0,a.jsx)(et.Z,{children:(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(L.Z,{className:"mt-5",children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"User ID"}),(0,a.jsx)(q.Z,{children:"User Email"}),(0,a.jsx)(q.Z,{children:"Role"}),(0,a.jsx)(q.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(q.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(q.Z,{children:"API Keys"}),(0,a.jsx)(q.Z,{})]})}),(0,a.jsx)(D.Z,{children:c.map(e=>{var l,s;return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_id||"-"}),(0,a.jsx)(U.Z,{children:e.user_email||"-"}),(0,a.jsx)(U.Z,{children:(null==N?void 0:null===(l=N[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,a.jsx)(U.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,a.jsx)(U.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsxs)(R.Z,{size:"xs",color:"indigo",children:[e.key_aliases.filter(e=>null!==e).length,"\xa0Keys"]}):(0,a.jsx)(R.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:E.Z,onClick:()=>{w(e),v(!0)},children:"View Keys"})})]},e.user_id)})})]})}),(0,a.jsx)(ea.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"})]})})]})}),(0,a.jsx)(eR,{visible:b,possibleUIRoles:N,onCancel:A,user:S,onSubmit:C})]}),function(){if(!c)return null;let e=Math.ceil(c.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",j+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===j,onClick:()=>g(j-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:()=>{g(j+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},eF=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,userID:i,userRole:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=$.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[C,P]=(0,r.useState)(l?l[0]:null),[T,W]=(0,r.useState)(!1),[G,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)([]),[X,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),[es,et]=(0,r.useState)({}),en=e=>{P(e),b(!0)},ea=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let a=await (0,u.Gh)(t,e);l&&n(l.map(e=>e.team_id===s?a.data:e)),k.ZP.success("Team updated successfully"),b(!1),P(null)},er=async e=>{el(e),Q(!0)},ei=async()=>{if(null!=ee&&null!=l&&null!=t){try{await (0,u.rs)(t,ee);let e=l.filter(e=>e.team_id!==ee);n(e)}catch(e){console.error("Error deleting the team:",e)}Q(!1),el(null)}};(0,r.useEffect)(()=>{let e=async()=>{try{if(null===i||null===o||null===t||null===l)return;console.log("fetching team info:");let e={};for(let s=0;s<(null==l?void 0:l.length);s++){let n=l[s].team_id,a=await (0,u.Xm)(t,n);console.log("teamInfo response:",a),null!==a&&(e={...e,[n]:a})}et(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,u.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),J(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eo=async e=>{try{if(null!=t){var s;let a=null==e?void 0:e.team_alias;if((null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));k.ZP.info("Creating Team");let r=await (0,u.hT)(t,e);null!==l?n([...l,r]):n([r]),console.log("response for team create call: ".concat(r)),k.ZP.success("Team created"),W(!1)}}catch(e){console.error("Error creating the team:",e),k.ZP.error("Error creating the team: "+e,20)}},ed=async e=>{try{if(null!=t&&null!=l){k.ZP.info("Adding Member");let s={role:"user",user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,C.team_id,s);console.log("response for team create call: ".concat(a.data));let r=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(r)),-1!==r){let e=[...l];e[r]=a.data,n(e),P(a.data)}H(!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)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Team Name"}),(0,a.jsx)(q.Z,{children:"Spend (USD)"}),(0,a.jsx)(q.Z,{children:"Budget (USD)"}),(0,a.jsx)(q.Z,{children:"Models"}),(0,a.jsx)(q.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(q.Z,{children:"Info"})]})}),(0,a.jsx)(D.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(U.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(_.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)(U.Z,{children:[(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].keys&&es[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].team_info&&es[e.team_id].team_info.members_with_roles&&es[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>en(e)}),(0,a.jsx)(F.Z,{onClick:()=>er(e.team_id),icon:O.Z,size:"sm"})]})]},e.team_id)):null})]}),X&&(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)(p.Z,{onClick:ei,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{Q(!1),el(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>W(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:T,width:800,footer:null,onOk:()=>{W(!1),d.resetFields()},onCancel:()=>{W(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:eo,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),Y.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(g,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(B.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{P(e)},children:e.team_alias},l))}):(0,a.jsxs)(g,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Member Name"}),(0,a.jsx)(q.Z,{children:"Role"})]})}),(0,a.jsx)(D.Z,{children:C?C.members_with_roles.map((e,l)=>(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(U.Z,{children:e.role})]},l)):null})]})}),C&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:n}=e,[r]=S.Z.useForm();return(0,a.jsx)(w.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:ea,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),Y&&Y.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.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)(A.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),P(null)},team:C,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-5",onClick:()=>H(!0),children:"+ Add member"}),(0,a.jsx)(w.Z,{title:"Add member",visible:G,width:800,footer:null,onOk:()=>{H(!1),c.resetFields()},onCancel:()=>{H(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(N.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)(S.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(N.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)(A.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eL=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n}=e,[o]=S.Z.useForm(),[d]=S.Z.useForm(),{Title:c,Paragraph:m}=$.default,[j,g]=(0,r.useState)(""),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)(null),[v,I]=(0,r.useState)(!1),[C,P]=(0,r.useState)(!1),[T,O]=(0,r.useState)(!1),[R,W]=(0,r.useState)(!1),[G,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)(!1),X=(0,i.useRouter)(),[Q,ee]=(0,r.useState)(null),[el,es]=(0,r.useState)("");try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let et=()=>{J(!1)},en=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{if(X){let{protocol:e,host:l}=window.location;es("".concat(e,"//").concat(l))}},[X]),(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,u.Xd)(t,"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 s=await (0,u.Xd)(t,"proxy_admin");s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(s)),console.log("combinedList: ".concat(e)),f(e),ee(await (0,u.lg)(t))}})()},[t]);let ea=()=>{W(!1),d.resetFields(),o.resetFields()},er=()=>{W(!1),d.resetFields(),o.resetFields()},ei=e=>(0,a.jsxs)(S.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,a.jsx)(N.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Add member"})})]}),eo=(e,l,s)=>(0,a.jsxs)(S.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(B.Z,{value:l,children:en.map((e,l)=>(0,a.jsx)(K.Z,{value:e,children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(N.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Update role"})})]}),ed=async e=>{try{if(null!=t&&null!=Z){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=Z.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(s)),-1==s&&(console.log("updates admin with new user"),Z.push(l),f(Z)),k.ZP.success("Refresh tab to see updated user role"),W(!1)}}catch(e){console.error("Error creating the key:",e)}},ec=async e=>{try{if(null!=t&&null!=Z){var l;k.ZP.info("Making API Call");let s=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{b(e),I(!0)});let a=Z.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(s.user_id)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),Z.push(s),f(Z)),o.resetFields(),P(!1)}}catch(e){console.error("Error creating the key:",e)}},em=async e=>{try{if(null!=t&&null!=Z){var l;k.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,u.pf)(t,e,"proxy_admin"),n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{b(e),I(!0)}),console.log("response for team create call: ".concat(s));let a=Z.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(n)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),Z.push(s),f(Z)),o.resetFields(),O(!1)}}catch(e){console.error("Error creating the key:",e)}},eu=async e=>{if(null==t)return;let l={environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}};(0,u.K_)(t,l)};return console.log("admins: ".concat(null==Z?void 0:Z.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)(m,{children:[n&&(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)(x.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Member Name"}),(0,a.jsx)(q.Z,{children:"Role"})]})}),(0,a.jsx)(D.Z,{children:Z?Z.map((e,l)=>{var s;return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsxs)(U.Z,{children:[" ",(null==Q?void 0:null===(s=Q[null==e?void 0:e.user_role])||void 0===s?void 0:s.ui_label)||"-"]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>W(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:R,width:800,footer:null,onOk:ea,onCancel:er,children:eo(ed,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(p.Z,{className:"mr-4 mb-5",onClick:()=>O(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:T,width:800,footer:null,onOk:()=>{O(!1),d.resetFields(),o.resetFields()},onCancel:()=>{O(!1),I(!1),d.resetFields(),o.resetFields()},children:ei(em)}),(0,a.jsx)(eT,{isInvitationLinkModalVisible:v,setIsInvitationLinkModalVisible:I,baseUrl:el,invitationLinkData:y}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>P(!0),children:"+ Add viewer"}),(0,a.jsx)(w.Z,{title:"Add viewer",visible:C,width:800,footer:null,onOk:()=>{P(!1),d.resetFields(),o.resetFields()},onCancel:()=>{P(!1),d.resetFields(),o.resetFields()},children:ei(ec)})]})})]}),(0,a.jsxs)(x.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)(p.Z,{onClick:()=>H(!0),children:"Add SSO"}),(0,a.jsx)(w.Z,{title:"Add SSO",visible:G,width:800,footer:null,onOk:()=>{H(!1),o.resetFields()},onCancel:()=>{H(!1),o.resetFields()},children:(0,a.jsxs)(S.Z,{form:o,onFinish:e=>{em(e),eu(e),H(!1),J(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(N.Z.Password,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(N.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:et,onCancel:()=>{J(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(_.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)(A.ZP,{onClick:et,children:"Done"})})]})]}),(0,a.jsxs)(ey.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})," "]})]})]})]})},eD=s(42556),eU=s(90252),eV=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:n,premiumUser:r}=e,[i]=S.Z.useForm();return(0,a.jsxs)(S.Z,{form:i,onFinish:()=>{let e=i.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(z.Z,{children:[(0,a.jsxs)(U.Z,{align:"center",children:[(0,a.jsx)(_.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?r?(0,a.jsx)(S.Z.Item,{name:e.field_name,children:(0,a.jsx)(U.Z,{children:"Integer"===e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(U.Z,{children:(0,a.jsx)(p.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)(S.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(U.Z,{children:"Integer"===e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(U.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eU.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:O.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eq=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(eV,{alertingSettings:t,handleInputChange:(e,l)=>{n(t.map(s=>s.field_name===e?{...s,field_value:l}:s))},handleResetField:(e,s)=>{if(l)try{let l=t.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),n(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let n={...e,...s};try{(0,u.jA)(l,"alerting_args",n),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},ez=s(84406);let{Title:eB,Paragraph:eK}=$.default;var eW=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g]=S.Z.useForm(),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[C,P]=(0,r.useState)({}),[T,O]=(0,r.useState)([]),[R,B]=(0,r.useState)(!1),[W,G]=(0,r.useState)([]),[H,Y]=(0,r.useState)(null),[J,X]=(0,r.useState)([]),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),ei=e=>{T.includes(e)?O(T.filter(l=>l!==e)):O([...T,e])},eo={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,r.useEffect)(()=>{l&&s&&t&&(0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),G(e.available_callbacks);let l=e.alerts;if(console.log("alerts_data",l),l&&l.length>0){let e=l[0];console.log("_alert_info",e);let s=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",s),O(e.active_alerts),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ed=e=>T&&T.includes(e),ec=()=>{if(!l)return;let e={};d.filter(e=>"email"===e.name).forEach(l=>{var s;Object.entries(null!==(s=l.variables)&&void 0!==s?s:{}).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));n&&n.value&&(e[s]=null==n?void 0:n.value)})}),console.log("updatedVariables",e);try{(0,u.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Email settings updated successfully")},em=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,u.K_)(l,{environment_variables:s}),k.ZP.success("Callback added successfully"),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eu=async e=>{if(!l)return;let s=null==e?void 0:e.callback,t={};Object.entries(e).forEach(e=>{let[l,s]=e;"callback"!==l&&(t[l]=s)});try{await (0,u.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),k.ZP.success("Callback ".concat(s," added successfully")),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),f(e.litellm_callback_name),console.log("all callbacks",W),e&&e.litellm_callback_params?(X(e.litellm_callback_params),console.log("selectedCallbackParams",J)):X([])};return l?(console.log("callbacks: ".concat(i)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(es.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(es.Z,{value:"3",children:"Alerting Settings"}),(0,a.jsx)(es.Z,{value:"4",children:"Email Alerts"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(eB,{level:4,children:"Active Logging Callbacks"}),(0,a.jsx)(x.Z,{numItems:2,children:(0,a.jsx)(M.Z,{className:"max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsx)(z.Z,{children:(0,a.jsx)(q.Z,{children:"Callback Name"})})}),(0,a.jsx)(D.Z,{children:i.map((e,s)=>(0,a.jsxs)(z.Z,{className:"flex justify-between",children:[(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:e.name})}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"flex justify-between",children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>B(!0),children:"Add Callback"})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(_.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)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{}),(0,a.jsx)(q.Z,{}),(0,a.jsx)(q.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(eo).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(eD.Z,{id:"switch",name:"switch",checked:ed(s),onChange:()=>ei(s)}):(0,a.jsx)(p.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)(eD.Z,{id:"switch",name:"switch",checked:ed(s),onChange:()=>ei(s)})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:C&&C[s]?C[s]:N})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(eo).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",n);let a=(null==n?void 0:n.value)||"";console.log("newWebhookValue",a),e[s]=a}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:T}};console.log("payload",s);try{(0,u.K_)(l,s)}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(eq,{accessToken:l,premiumUser:n})}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(eB,{level:4,children:"Email Settings"}),(0,a.jsxs)(_.Z,{children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,a.jsx)("br",{})]}),(0,a.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,a.jsx)(U.Z,{children:(0,a.jsx)("ul",{children:(0,a.jsx)(x.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{className:"mx-2 my-2",children:[!0!=n&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,a.jsxs)(_.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,a.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,a.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,a.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the Logo that appears in the email, pass a url to your logo"}),"EMAIL_SUPPORT_CONTACT"===l&&(0,a.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the support email address that appears in the email. Default is support@berri.ai"})]})]},l)})})})},l)})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>ec(),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,a.jsxs)(w.Z,{title:"Add Logging Callback",visible:R,width:800,onCancel:()=>B(!1),footer:null,children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/logging",className:"mb-8 mt-4",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: Logging"}),(0,a.jsx)(S.Z,{form:g,onFinish:eu,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ez.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsx)(v.default,{onChange:e=>{let l=W[e];l&&(console.log(l.ui_callback_name),eh(l))},children:W&&Object.values(W).map(e=>(0,a.jsx)(K.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),J&&J.map(e=>(0,a.jsx)(ez.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,a.jsx)(j.Z,{type:"password"})},e)),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,a.jsx)(w.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,a.jsxs)(S.Z,{form:g,onFinish:em,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,a.jsx)(ez.Z,{label:l,name:l,children:(0,a.jsx)(j.Z,{type:"password",defaultValue:s})},l)})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eG}=v.default;var eH=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:n}=e,[i]=S.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(w.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,r=[...t.fallbacks||[],{[l]:a}],o={...t,fallbacks:r};console.log(o);try{(0,u.K_)(s,{router_settings:o}),n(o)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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)(B.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(ei.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(eo.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},eY=s(12968);async function eJ(e,l){console.log("isLocal:",!1);let s=window.location.origin,t=new eY.ZP.OpenAI({apiKey:l,baseURL:s,dangerouslyAllowBrowser:!0});try{let l=await t.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});k.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){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let eX={ttl:3600,lowest_latency_buffer:0},e$=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(Z.Z,{children:"latency-based-routing"==l?(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Setting"}),(0,a.jsx)(q.Z,{children:"Value"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(z.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,a.jsx)(_.Z,{children:"No specific settings"})})]})};var eQ=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[b]=S.Z.useForm(),[v,w]=(0,r.useState)(null),[N,A]=(0,r.useState)(null),[C,P]=(0,r.useState)(null),T={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,r.useEffect)(()=>{l&&s&&t&&((0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.router_settings)}),(0,u.YU)(l).then(e=>{g(e)}))},[l,s,t]);let E=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks)),i.fallbacks.map(l=>(e in l&&delete l[e],l));try{await (0,u.K_)(l,{router_settings:i}),o({...i}),A(i.routing_strategy),k.ZP.success("Router settings updated successfully")}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}}},W=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},G=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,u.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},H=(e,s)=>{if(l)try{(0,u.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},Y=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,u.K_)(l,{router_settings:s})}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(et.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(es.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(es.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(y.Z,{children:"Router Settings"}),(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Setting"}),(0,a.jsx)(q.Z,{children:"Value"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(i).filter(e=>{let[l,s]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,s]=e;return(0,a.jsxs)(z.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:T[l]})]}),(0,a.jsx)(U.Z,{children:"routing_strategy"==l?(0,a.jsxs)(B.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:A,children:[(0,a.jsx)(K.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(K.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(K.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,a.jsx)(e$,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:eX,paramExplanation:T})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>Y(i),children:"Save Changes"})})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Model Name"}),(0,a.jsx)(q.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(D.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:t}),(0,a.jsx)(U.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>eJ(t,l),children:"Test Fallback"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:O.Z,size:"sm",onClick:()=>E(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(eH,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Setting"}),(0,a.jsx)(q.Z,{children:"Value"}),(0,a.jsx)(q.Z,{children:"Status"}),(0,a.jsx)(q.Z,{children:"Action"})]})}),(0,a.jsx)(D.Z,{children:m.map((e,l)=>(0,a.jsxs)(z.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.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)(U.Z,{children:"Integer"==e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>W(e.field_name,l)}):null}),(0,a.jsx)(U.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eU.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>G(e.field_name,l),children:"Update"}),(0,a.jsx)(F.Z,{icon:O.Z,color:"red",onClick:()=>H(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},e0=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n}=e,[r]=S.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call");let l=await (0,u.Zr)(s,e);console.log("key create Response:",l),n(e=>e?[...e,l]:[l]),k.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,a.jsxs)(S.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(I.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(I.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},e1=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{i(e)})},[l]);let o=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...n];t.splice(s,1),i(t),k.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)(p.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,a.jsx)(e0,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:i}),(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Budget ID"}),(0,a.jsx)(q.Z,{children:"Max Budget"}),(0,a.jsx)(q.Z,{children:"TPM"}),(0,a.jsx)(q.Z,{children:"RPM"})]})}),(0,a.jsx)(D.Z,{children:n.map((e,l)=>(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.budget_id}),(0,a.jsx)(U.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(U.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(U.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(F.Z,{icon:O.Z,size:"sm",onClick:()=>o(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(es.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(es.Z,{children:"Test it (Curl)"}),(0,a.jsx)(es.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ek.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)(ea.Z,{children:(0,a.jsx)(ek.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)(ea.Z,{children:(0,a.jsx)(ek.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{let{proxySettings:l}=e,s="http://localhost:4000";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(x.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)(_.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)(et.Z,{children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(es.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(es.Z,{children:"LlamaIndex"}),(0,a.jsx)(es.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ek.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="'.concat(s,'" # 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)(ea.Z,{children:(0,a.jsx)(ek.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="'.concat(s,'", # 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="').concat(s,'",\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)(ea.Z,{children:(0,a.jsx)(ek.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="'.concat(s,'",\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 e5(e,l,s,t){console.log("isLocal:",!1);let n=window.location.origin,a=new eY.ZP.OpenAI({apiKey:t,baseURL:n,dangerouslyAllowBrowser:!0});try{for await(let t of(await a.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content)}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var e8=e=>{let{accessToken:l,token:s,userRole:t,userID:n}=e,[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(""),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(void 0),[y,b]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{let e=await (0,u.So)(l,n,t);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}));if(console.log(l),l.length>0){let e=Array.from(new Set(l));console.log("Unique models:",e),e.sort((e,l)=>e.label.localeCompare(l.label)),console.log("Model info:",y),b(e)}f(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,n,t]);let S=(e,l)=>{g(s=>{let t=s[s.length-1];return t&&t.role===e?[...s.slice(0,s.length-1),{role:e,content:t.content+l}]:[...s,{role:e,content:l}]})},k=async()=>{if(""!==d.trim()&&i&&s&&t&&n){g(e=>[...e,{role:"user",content:d}]);try{Z&&await e5(d,e=>S("assistant",e),Z,i)}catch(e){console.error("Error fetching model response",e),S("assistant","Error fetching model response")}c("")}};if(t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=$.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)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(M.Z,{children:(0,a.jsxs)(et.Z,{children:[(0,a.jsx)(en.Z,{children:(0,a.jsx)(es.Z,{children:"Chat"})}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"API Key"}),(0,a.jsx)(j.Z,{placeholder:"Type API Key here",type:"password",onValueChange:o,value:i})]}),(0,a.jsxs)(h.Z,{className:"mx-2",children:[(0,a.jsx)(_.Z,{children:"Select Model:"}),(0,a.jsx)(v.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),f(e)},options:y,style:{width:"200px"}})]})]})}),(0,a.jsxs)(L.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(V.Z,{children:(0,a.jsx)(z.Z,{children:(0,a.jsx)(U.Z,{})})}),(0,a.jsx)(D.Z,{children:m.map((e,l)=>(0,a.jsx)(z.Z,{children:(0,a.jsx)(U.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)(j.Z,{type:"text",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},e3=s(33509),e6=s(95781);let{Sider:e9}=e3.default;var e7=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e;return"Admin Viewer"==s?(0,a.jsx)(e3.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(e9,{width:120,children:(0,a.jsx)(e6.Z,{mode:"inline",defaultSelectedKeys:t||["4"],style:{height:"100%",borderRight:0},children:(0,a.jsx)(e6.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")})})}):(0,a.jsx)(e3.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(e9,{width:145,children:(0,a.jsxs)(e6.Z,{mode:"inline",defaultSelectedKeys:t||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e6.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(_.Z,{children:"API Keys"})},"1"),(0,a.jsx)(e6.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(_.Z,{children:"Test Key"})},"3"),"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(_.Z,{children:"Models"})},"2"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(_.Z,{children:"Usage"})},"4"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(_.Z,{children:"Teams"})},"6"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(_.Z,{children:"Internal Users"})},"5"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(_.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(_.Z,{children:"Budgets"})},"9"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(_.Z,{children:"Router Settings"})},"10"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(_.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(e6.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(_.Z,{children:"API Reference"})},"12"),(0,a.jsx)(e6.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(_.Z,{children:"Model Hub"})},"14")]})})})},le=s(67989),ll=s(52703),ls=e=>{let{accessToken:l,token:s,userRole:t,userID:n,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[S,k]=(0,r.useState)([]),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)([]),[C,P]=(0,r.useState)([]),[T,E]=(0,r.useState)([]),[O,R]=(0,r.useState)([]),[F,W]=(0,r.useState)({}),[G,Y]=(0,r.useState)([]),[J,X]=(0,r.useState)(""),[$,Q]=(0,r.useState)(["all-tags"]),[em,eu]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),eh=new Date(d.getFullYear(),d.getMonth(),1),ex=new Date(d.getFullYear(),d.getMonth()+1,0),ep=e_(eh),ej=e_(ex);function eg(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}console.log("keys in usage",i),console.log("premium user in usage",o),(0,r.useEffect)(()=>{ef(em.from,em.to)},[em,$]);let eZ=async(e,s,t)=>{if(!e||!s||!l)return;s.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",t);let n=await (0,u.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",n),v(n)},ef=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.J$)(l,e.toISOString(),s.toISOString(),0===$.length?void 0:$)).spend_per_tag),console.log("Tag spend data updated successfully"))};function e_(e){let l=e.getFullYear(),s=e.getMonth()+1,t=e.getDate();return"".concat(l,"-").concat(s<10?"0"+s:s,"-").concat(t<10?"0"+t:t)}return console.log("Start date is ".concat(ep)),console.log("End date is ".concat(ej)),(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{if(console.log("user role: ".concat(t)),"Admin"==t||"Admin Viewer"==t){var e,a;let t=await (0,u.FC)(l);m(t);let n=await (0,u.OU)(l,s,ep,ej);console.log("provider_spend",n),R(n);let r=(await (0,u.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));g(r);let i=(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend}));f(i);let o=await (0,u.mR)(l);console.log("teamSpend",o),k(o.daily_spend),P(o.teams);let d=o.total_spend_per_team;d=d.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),E(d);let c=await (0,u.X)(l);A(c.tag_names);let h=await (0,u.J$)(l,null===(e=em.from)||void 0===e?void 0:e.toISOString(),null===(a=em.to)||void 0===a?void 0:a.toISOString(),void 0);N(h.spend_per_tag);let x=await (0,u.b1)(l,null,void 0,void 0);v(x),console.log("spend/user result",x);let p=await (0,u.wd)(l,ep,ej);W(p);let j=await (0,u.xA)(l,ep,ej);console.log("global activity per model",j),Y(j)}else"App Owner"==t&&await (0,u.HK)(l,s,t,n,ep,ej).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 s=e.top_api_keys;g(s)}else{let s=(await (0,u.e2)(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,t]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&l.push({key:s,spend:t})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let s=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(s[0]))),s}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));g(s),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,s,t,n,ep,ej]),(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{className:"mt-2",children:[(0,a.jsx)(es.Z,{children:"All Up"}),(0,a.jsx)(es.Z,{children:"Team Based Usage"}),(0,a.jsx)(es.Z,{children:"Customer Usage"}),(0,a.jsx)(es.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(es.Z,{children:"Cost"}),(0,a.jsx)(es.Z,{children:"Activity"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(H,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(ec.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(ec.Z,{className:"mt-4 h-40",data:j,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(ec.Z,{className:"mt-4 h-40",data:Z,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(ll.Z,{className:"mt-4 h-40",variant:"pie",data:O,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Provider"}),(0,a.jsx)(q.Z,{children:"Spend"})]})}),(0,a.jsx)(D.Z,{children:O.map(e=>(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.provider}),(0,a.jsx)(U.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)(p.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)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"All Up"}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(F.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:F.daily_data,valueFormatter:eg,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(F.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:F.daily_data,valueFormatter:eg,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:G.map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(e.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eg,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(e.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:eg,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:G&&G.length>0&&G.slice(0,1).map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.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)(p.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)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(e.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eg,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(e.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:eg,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsxs)(M.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(le.Z,{data:T})]}),(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(ec.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:C,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["Customers 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)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(el.Z,{enableSelect:!0,value:em,onValueChange:e=>{eu(e),eZ(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{eZ(em.from,em.to,null)},children:"All Keys"},"all-keys"),null==i?void 0:i.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{eZ(em.from,em.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(M.Z,{className:"mt-4",children:(0,a.jsxs)(L.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Customer"}),(0,a.jsx)(q.Z,{children:"Spend"}),(0,a.jsx)(q.Z,{children:"Total Events"})]})}),(0,a.jsx)(D.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.end_user}),(0,a.jsx)(U.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(U.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(el.Z,{className:"mb-4",enableSelect:!0,value:em,onValueChange:e=>{eu(e),ef(e.from,e.to)}})}),(0,a.jsx)(h.Z,{children:o?(0,a.jsx)("div",{children:(0,a.jsxs)(ei.Z,{value:$,onValueChange:e=>Q(e),children:[(0,a.jsx)(eo.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsx)(eo.Z,{value:String(e),children:e},e))]})}):(0,a.jsx)("div",{children:(0,a.jsxs)(ei.Z,{value:$,onValueChange:e=>Q(e),children:[(0,a.jsx)(eo.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsxs)(K.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(_.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,a.jsx)(ec.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,a.jsx)(h.Z,{numColSpan:2})]})]})]})]})})},lt=()=>{let{Title:e,Paragraph:l}=$.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[x,p]=(0,r.useState)(null),[j,g]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[Z,f]=(0,r.useState)(!0),_=(0,i.useSearchParams)(),[y,b]=(0,r.useState)({data:[]}),v=_.get("userID"),S=_.get("token"),[k,w]=(0,r.useState)("api-keys"),[N,I]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(S){let e=(0,X.o)(S);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),I(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"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&w("usage")}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?f("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user)}}},[S]),(0,a.jsx)(r.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:v,userRole:s,userEmail:d,showSSOBanner:Z,premiumUser:n,setProxySettings:g,proxySettings:j}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(e7,{setPage:w,userRole:s,defaultSelectedKey:null})}),"api-keys"==k?(0,a.jsx)(Q,{userID:v,userRole:s,teams:u,keys:x,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:h,setKeys:p,setProxySettings:g,proxySettings:j}):"models"==k?(0,a.jsx)(eP,{userID:v,userRole:s,token:S,keys:x,accessToken:N,modelData:y,setModelData:b,premiumUser:n}):"llm-playground"==k?(0,a.jsx)(e8,{userID:v,userRole:s,token:S,accessToken:N}):"users"==k?(0,a.jsx)(eM,{userID:v,userRole:s,token:S,keys:x,teams:u,accessToken:N,setKeys:p}):"teams"==k?(0,a.jsx)(eF,{teams:u,setTeams:h,searchParams:_,accessToken:N,userID:v,userRole:s}):"admin-panel"==k?(0,a.jsx)(eL,{setTeams:h,searchParams:_,accessToken:N,showSSOBanner:Z}):"api_ref"==k?(0,a.jsx)(e4,{proxySettings:j}):"settings"==k?(0,a.jsx)(eW,{userID:v,userRole:s,accessToken:N,premiumUser:n}):"budgets"==k?(0,a.jsx)(e1,{accessToken:N}):"general-settings"==k?(0,a.jsx)(eQ,{userID:v,userRole:s,accessToken:N,modelData:y}):"model-hub"==k?(0,a.jsx)(e2.Z,{accessToken:N,publicPage:!1,premiumUser:n}):(0,a.jsx)(ls,{userID:v,userRole:s,token:S,accessToken:N,keys:x,premiumUser:n})]})]})})}},41134:function(e,l,s){"use strict";s.d(l,{Z:function(){return y}});var t=s(3827),n=s(64090),a=s(47907),r=s(777),i=s(16450),o=s(13810),d=s(92836),c=s(26734),m=s(41608),u=s(32126),h=s(23682),x=s(71801),p=s(42440),j=s(84174),g=s(50459),Z=s(6180),f=s(99129),_=s(67951),y=e=>{var l;let{accessToken:s,publicPage:y,premiumUser:b}=e,[v,S]=(0,n.useState)(!1),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(!1),[A,C]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null),E=(0,a.useRouter)();(0,n.useEffect)(()=>{s&&(async()=>{try{let e=await (0,r.kn)(s);console.log("ModelHubData:",e),w(e.data),(0,r.E9)(s,"enable_public_model_hub").then(e=>{console.log("data: ".concat(JSON.stringify(e))),!0==e.field_value&&S(!0)}).catch(e=>{})}catch(e){console.error("There was an error fetching the model data",e)}})()},[s,y]);let O=e=>{T(e),I(!0)},R=async()=>{s&&(0,r.jA)(s,"enable_public_model_hub",!0).then(e=>{C(!0)})},M=()=>{I(!1),C(!1),T(null)},F=()=>{I(!1),C(!1),T(null)},L=e=>{navigator.clipboard.writeText(e)};return(0,t.jsxs)("div",{children:[y&&v||!1==y?(0,t.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,t.jsx)("div",{className:"relative w-full"}),(0,t.jsxs)("div",{className:"flex ".concat(y?"justify-between":"items-center"),children:[(0,t.jsx)(p.Z,{className:"ml-8 text-center ",children:"Model Hub"}),!1==y?b?(0,t.jsx)(i.Z,{className:"ml-4",onClick:()=>R(),children:"✨ Make Public"}):(0,t.jsx)(i.Z,{className:"ml-4",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})}):(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("p",{children:"Filter by key:"}),(0,t.jsx)(x.Z,{className:"bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center",children:"/ui/model_hub?key="})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4 pr-8",children:k&&k.map(e=>(0,t.jsxs)(o.Z,{className:"mt-5 mx-8",children:[(0,t.jsxs)("pre",{className:"flex justify-between",children:[(0,t.jsx)(p.Z,{children:e.model_group}),(0,t.jsx)(Z.Z,{title:e.model_group,children:(0,t.jsx)(j.Z,{onClick:()=>L(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,t.jsxs)("div",{className:"my-5",children:[(0,t.jsxs)(x.Z,{children:["Mode: ",e.mode]}),(0,t.jsxs)(x.Z,{children:["Supports Function Calling:"," ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Supports Vision:"," ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Max Input Tokens:"," ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,t.jsxs)(x.Z,{children:["Max Output Tokens:"," ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,t.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,t.jsxs)("a",{href:"#",onClick:()=>O(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,t.jsx)(g.Z,{})]})})]},e.model_group))})]}):(0,t.jsxs)(o.Z,{className:"mx-auto max-w-xl mt-10",children:[(0,t.jsx)(x.Z,{className:"text-xl text-center mb-2 text-black",children:"Public Model Hub not enabled."}),(0,t.jsx)("p",{className:"text-base text-center text-slate-800",children:"Ask your proxy admin to enable this on their Admin UI."})]}),(0,t.jsx)(f.Z,{title:"Public Model Hub",width:600,visible:A,footer:null,onOk:M,onCancel:F,children:(0,t.jsxs)("div",{className:"pt-5 pb-5",children:[(0,t.jsxs)("div",{className:"flex justify-between mb-4",children:[(0,t.jsx)(x.Z,{className:"text-base mr-2",children:"Shareable Link:"}),(0,t.jsx)(x.Z,{className:"max-w-sm ml-2 bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center rounded",children:"/ui/model_hub?key="})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(i.Z,{onClick:()=>{E.replace("/model_hub?key=".concat(s))},children:"See Page"})})]})}),(0,t.jsx)(f.Z,{title:P&&P.model_group?P.model_group:"Unknown Model",width:800,visible:N,footer:null,onOk:M,onCancel:F,children:P&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-4",children:(0,t.jsx)("strong",{children:"Model Information & Usage"})}),(0,t.jsxs)(c.Z,{children:[(0,t.jsxs)(m.Z,{children:[(0,t.jsx)(d.Z,{children:"OpenAI Python SDK"}),(0,t.jsx)(d.Z,{children:"Supported OpenAI Params"}),(0,t.jsx)(d.Z,{children:"LlamaIndex"}),(0,t.jsx)(d.Z,{children:"Langchain Py"})]}),(0,t.jsxs)(h.Z,{children:[(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:"".concat(null===(l=P.supported_openai_params)||void 0===l?void 0:l.map(e=>"".concat(e,"\n")).join(""))})}),(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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 ')})})]})]})]})})]})}}},function(e){e.O(0,[936,294,131,684,759,777,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,s){Promise.resolve().then(s.bind(s,45980))},45980:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return lt}});var t,n,a=s(3827),r=s(64090),i=s(47907),o=s(8792),d=s(40491),c=s(65270),m=e=>{let{userID:l,userRole:s,userEmail:t,showSSOBanner:n,premiumUser:r,setProxySettings:i,proxySettings:m}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("showSSOBanner:",n),console.log("premiumUser:",r);let u="";console.log("PROXY_settings=",m),m&&m.PROXY_LOGOUT_URL&&void 0!==m.PROXY_LOGOUT_URL&&(u=m.PROXY_LOGOUT_URL),console.log("logoutUrl=",u);let h=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",s]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(r)]})]})},{key:"2",label:(0,a.jsx)("a",{href:u,children:(0,a.jsx)("p",{children:"Logout"})})}];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)(o.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:[n?(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 enterprise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:h},children:(0,a.jsx)(c.Z,{children:t})})})]})]})},u=s(777),h=s(10384),x=s(46453),p=s(16450),j=s(52273),g=s(26780),Z=s(15595),f=s(6698),_=s(71801),y=s(42440),b=s(42308),v=s(50670),S=s(60620),k=s(80588),w=s(99129),N=s(44839),I=s(88707),A=s(1861);let{Option:C}=v.default;var P=e=>{let{userID:l,team:s,userRole:t,accessToken:n,data:i,setData:o}=e,[d]=S.Z.useForm(),[c,m]=(0,r.useState)(!1),[P,T]=(0,r.useState)(null),[E,O]=(0,r.useState)(null),[R,M]=(0,r.useState)([]),[F,L]=(0,r.useState)([]),D=()=>{m(!1),d.resetFields()},U=()=>{m(!1),T(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==n){let e=(await (0,u.So)(n,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),M(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let z=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",c=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(a=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));k.ZP.info("Making API Call"),m(!0);let h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),T(h.key),O(h.soft_budget),k.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.useEffect)(()=>{L(s&&s.models.length>0?s.models.includes("all-proxy-models")?R:s.models:R)},[s,R]),(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(w.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:D,onCancel:U,children:(0,a.jsxs)(S.Z,{form:d,onFinish:z,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(N.Z,{value:s?s.team_alias:"",disabled:!0})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(C,{value:"all-team-models",children:"All Team Models"},"all-team-models"),F.map(e=>(0,a.jsx)(C,{value:e,children:e},e))]})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==s?void 0:s.max_budget)!==null&&(null==s?void 0:s.max_budget)!==void 0?null==s?void 0:s.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.max_budget&&l>s.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(s.max_budget))}}],children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==s?void 0:s.budget_duration)!==null&&(null==s?void 0:s.budget_duration)!==void 0?null==s?void 0:s.budget_duration:"None"),children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==s?void 0:s.tpm_limit)!==null&&(null==s?void 0:s.tpm_limit)!==void 0?null==s?void 0:s.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.tpm_limit&&l>s.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(s.tpm_limit))}}],children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==s?void 0:s.rpm_limit)!==null&&(null==s?void 0:s.rpm_limit)!==void 0?null==s?void 0:s.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.rpm_limit&&l>s.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(s.rpm_limit))}}],children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Key"})})]})}),P&&(0,a.jsx)(w.Z,{visible:c,onOk:D,onCancel:U,footer:null,children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Save your Key"}),(0,a.jsx)(h.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)(h.Z,{numColSpan:1,children:null!=P?(0,a.jsxs)("div",{children:[(0,a.jsx)(_.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:P})}),(0,a.jsx)(b.CopyToClipboard,{text:P,onCopy:()=>{k.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(_.Z,{children:"Key being created, this might take 30s"})})]})})]})},T=s(9454),E=s(98941),O=s(33393),R=s(5),M=s(13810),F=s(61244),L=s(10827),D=s(3851),U=s(2044),z=s(64167),V=s(74480),q=s(7178),B=s(95093),K=s(27166);let{Option:W}=v.default;var G=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d}=e,[c,m]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)(null),[b,C]=(0,r.useState)(null),[P,G]=(0,r.useState)(""),[H,Y]=(0,r.useState)(!1),[J,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(null),[ee,el]=(0,r.useState)([]),es=new Set,[et,en]=(0,r.useState)(es);(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,u.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),el(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),en(e)}},[d]);let ea=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),Q(e),Y(!0)},er=async e=>{if(null==t)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let s=await (0,u.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),k.ZP.success("Key updated successfully"),Y(!1),Q(null)},ei=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(g(e.token),localStorage.removeItem("userData"+l),x(!0))},eo=async()=>{if(null!=j&&null!=i){try{await (0,u.I1)(t,j);let e=i.filter(e=>e.token!==j);o(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),g(null)}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(L.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Key Alias"}),(0,a.jsx)(V.Z,{children:"Secret Key"}),(0,a.jsx)(V.Z,{children:"Spend (USD)"}),(0,a.jsx)(V.Z,{children:"Budget (USD)"}),(0,a.jsx)(V.Z,{children:"Models"}),(0,a.jsx)(V.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(D.Z,{children:i.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(n){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(et.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||et.has(e.team_id))&&e.team_id!=n.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(_.Z,{children:e.key_alias}):(0,a.jsx)(_.Z,{children:"Not Set"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(U.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(U.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:n&&n.models&&n.models.length>0?n.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(_.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)(U.Z,{children:[(0,a.jsx)(F.Z,{onClick:()=>{Q(e),X(!0)},icon:T.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:J,onCancel:()=>{X(!1),Q(null)},footer:null,width:800,children:$&&(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)(M.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($.spend).toFixed(4)}catch(e){return $.spend}})()})})]}),(0,a.jsxs)(M.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!=$.max_budget?(0,a.jsx)(a.Fragment,{children:$.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(M.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!=$.expires?(0,a.jsx)(a.Fragment,{children:new Date($.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)(M.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:$.key_alias?$.key_alias:$.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:$.token}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify($.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{X(!1),Q(null)},children:"Close"})]})}),(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>ea(e)}),(0,a.jsx)(F.Z,{onClick:()=>ei(e),icon:O.Z,size:"sm"})]})]},e.token)})})]}),h&&(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)(p.Z,{onClick:eo,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{x(!1),g(null)},children:"Cancel"})]})]})]})})]}),$&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=S.Z.useForm(),[c,m]=(0,r.useState)(n),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(!1);return(0,a.jsx)(w.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:o,onFinish:er,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let s=l.filter(e=>!c.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!c.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(s)),s.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(s,"Team models: ").concat(c.models)):Promise.resolve()}}],children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(W,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ee.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(W,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(W,{value:e,children:e},e)):ee.map(e=>(0,a.jsx)(W,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==c?void 0:c.max_budget)!==null&&(null==c?void 0:c.max_budget)!==void 0?null==c?void 0:c.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.max_budget&&l>c.max_budget)throw console.log("keyTeam.max_budget: ".concat(c.max_budget)),Error("Budget cannot exceed team max budget: $".concat(c.max_budget))}}],children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(B.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(K.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)(A.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:H,onCancel:()=>{Y(!1),Q(null)},token:$,onSubmit:er})]})},H=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,selectedTeam:i}=e;console.log("userSpend: ".concat(n));let[o,d]=(0,r.useState)(null!==n?n:0),[c,m]=(0,r.useState)(0),[h,x]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(t&&l&&s&&"Admin"===s&&null==n)try{let e=await (0,u.Qy)(t);e&&(e.spend?d(e.spend):d(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===s)return;if(null!==t){let e=(await (0,u.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==n&&d(n)},[n]);let p=[];i&&i.models&&(p=i.models),p&&p.includes("all-proxy-models")?(console.log("user models:",h),p=h):p&&p.includes("all-team-models")?p=i.models:p&&0===p.length&&(p=h);let j=void 0!==o?o.toFixed(4):null;return console.log("spend in view user spend: ".concat(o)),(0,a.jsx)("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:["$",j]})]})})},Y=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==n){let e=(await (0,u.So)(n,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,s]);let d=[];return t&&t.models&&(d=t.models),d&&d.includes("all-proxy-models")&&(console.log("user models:",i),d=i),(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==t?void 0:t.team_alias})})})},J=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n}=e,i={models:[],team_id:null,team_alias:"Default Team"},[o,d]=(0,r.useState)(i);return(l="App User"===n?s:s?[...s,i]:[i],"App User"===n)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(y.Z,{children:"Select Team"}),(0,a.jsx)(_.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)(_.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)(B.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(K.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,a.jsxs)(_.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},X=s(37963),$=s(97482);console.log("isLocal:",!1);var Q=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p,setProxySettings:j,proxySettings:g}=e,[Z,f]=(0,r.useState)(null),_=(0,i.useSearchParams)();_.get("viewSpend"),(0,i.useRouter)();let y=_.get("token"),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)(null),[w,N]=(0,r.useState)([]),I={models:[],team_alias:"Default Team",team_id:null},[A,C]=(0,r.useState)(t?t[0]:I);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(y){let e=(0,X.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),v(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";case"internal_user":return"Internal User";case"internal_user_viewer":return"Internal Viewer";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),o(l)}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&b&&s&&!n&&!Z){let e=sessionStorage.getItem("userModels"+l);e?N(JSON.parse(e)):(async()=>{try{let e=await (0,u.Dj)(b);j(e);let t=await (0,u.Br)(b,l,s,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(t),"; team values: ").concat(Object.entries(t.teams))),"Admin"==s){let e=await (0,u.Qy)(b);f(e),console.log("globalSpend:",e)}else f(t.user_info);p(t.keys),m(t.teams);let n=[...t.teams];n.length>0?(console.log("response['teams']: ".concat(n)),C(n[0])):C(I),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,u.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),N(a),console.log("userModels:",w),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,y,b,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=A&&null!==A.team_id){let e=0;for(let l of n)A.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===A.team_id&&(e+=l.spend);k(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;k(e)}},[A]),null==l||null==y){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==b)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=$.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",A),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(Y,{userID:l,userRole:s,selectedTeam:A||null,accessToken:b}),(0,a.jsx)(H,{userID:l,userRole:s,accessToken:b,userSpend:S,selectedTeam:A||null}),(0,a.jsx)(G,{userID:l,userRole:s,accessToken:b,selectedTeam:A||null,data:n,setData:p,teams:t}),(0,a.jsx)(P,{userID:l,team:A||null,userRole:s,accessToken:b,data:n,setData:p},A?A.team_id:null),(0,a.jsx)(J,{teams:t,setSelectedTeam:C,userRole:s})]})})})},ee=s(49167),el=s(35087),es=s(92836),et=s(26734),en=s(41608),ea=s(32126),er=s(23682),ei=s(47047),eo=s(76628),ed=s(25707),ec=s(44041),em=s(6180),eu=s(28683),eh=s(38302),ex=s(66242),ep=s(78578),ej=s(63954),eg=s(34658),eZ=e=>{let{modelID:l,accessToken:s}=e,[t,n]=(0,r.useState)(!1),i=async()=>{try{k.ZP.info("Making API Call"),n(!0);let e=await (0,u.Og)(s,l);console.log("model delete Response:",e),k.ZP.success("Model ".concat(l," deleted successfully")),n(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(F.Z,{onClick:()=>n(!0),icon:O.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>n(!1),children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Delete Model"}),(0,a.jsx)(h.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)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},ef=s(97766),e_=s(46495),ey=s(18190),eb=s(91118),ev=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(eb.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:s,colors:["indigo","rose"],connectNulls:!0,customTooltip:t}):(0,a.jsxs)("div",{children:[(0,a.jsx)(ey.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)(p.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eS=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(S.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)(j.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},ek=s(67951);let{Title:ew,Link:eN}=$.default;(t=n||(n={})).OpenAI="OpenAI",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Studio",t.Anthropic="Anthropic",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Databricks="Databricks",t.Ollama="Ollama";let eI={OpenAI:"openai",Azure:"azure",Azure_AI_Studio:"azure_ai",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks",Ollama:"ollama"},eA={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eC=async(e,l,s)=>{try{let t=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(t)),console.log("received type of deployments: ".concat(typeof t)),t.forEach(async s=>{console.log("litellm_model: ".concat(s));let t={},n={};t.model=s;let a="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)a+=s;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)n[l]=s;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw k.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else t[l]=s}let r={model_name:a,litellm_params:t,model_info:n},i=await (0,u.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){k.ZP.error("Failed to create model: "+e,10)}};var eP=e=>{var l,s,t;let i,{accessToken:o,token:d,userRole:c,userID:m,modelData:h={data:[]},keys:g,setModelData:Z,premiumUser:f}=e,[b,v]=(0,r.useState)([]),[N]=S.Z.useForm(),[C,P]=(0,r.useState)(null),[O,W]=(0,r.useState)(""),[G,H]=(0,r.useState)([]),Y=Object.values(n).filter(e=>isNaN(Number(e))),[J,X]=(0,r.useState)([]),[Q,ey]=(0,r.useState)("OpenAI"),[eb,eP]=(0,r.useState)(""),[eT,eE]=(0,r.useState)(!1),[eO,eR]=(0,r.useState)(!1),[eM,eF]=(0,r.useState)(null),[eL,eD]=(0,r.useState)([]),[eU,ez]=(0,r.useState)(null),[eV,eq]=(0,r.useState)([]),[eB,eK]=(0,r.useState)([]),[eW,eG]=(0,r.useState)([]),[eH,eY]=(0,r.useState)([]),[eJ,eX]=(0,r.useState)([]),[e$,eQ]=(0,r.useState)([]),[e0,e1]=(0,r.useState)([]),[e2,e4]=(0,r.useState)([]),[e5,e8]=(0,r.useState)([]),[e3,e6]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e9,e7]=(0,r.useState)(null),[le,ll]=(0,r.useState)(0),[ls,lt]=(0,r.useState)({}),[ln,la]=(0,r.useState)([]),[lr,li]=(0,r.useState)(!1),[lo,ld]=(0,r.useState)(null),[lc,lm]=(0,r.useState)(null),[lu,lh]=(0,r.useState)([]);(0,r.useEffect)(()=>{lb(eU,e3.from,e3.to)},[lo,lc]);let lx=e=>{eF(e),eE(!0)},lp=e=>{eF(e),eR(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==o)return;let l={},s=null;for(let[t,n]of Object.entries(e))"model_id"!==t?l[t]=n:s=n;let t={litellm_params:l,model_info:{id:s}};console.log("handleEditSubmit payload:",t);try{await (0,u.um)(o,t),k.ZP.success("Model updated successfully, restart server to see updates"),eE(!1),eF(null)}catch(e){console.log("Error occurred")}},lg=()=>{W(new Date().toLocaleString())},lZ=async()=>{if(!o){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e9);try{await (0,u.K_)(o,{router_settings:{model_group_retry_policy:e9}}),k.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),k.ZP.error("Failed to save retry settings")}};if((0,r.useEffect)(()=>{if(!o||!d||!c||!m)return;let e=async()=>{try{var e,l,s,t,n,a,r,i,d,h,x,p;let j=await (0,u.hy)(o);X(j);let g=await (0,u.AZ)(o,m,c);console.log("Model data response:",g.data),Z(g);let f=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y),ez(y)),console.log("selectedModelGroup:",eU);let b=await (0,u.o6)(o,m,c,y,null===(e=e3.from)||void 0===e?void 0:e.toISOString(),null===(l=e3.to)||void 0===l?void 0:l.toISOString(),null==lo?void 0:lo.token,lc);console.log("Model metrics response:",b),eK(b.data),eG(b.all_api_bases);let v=await (0,u.Rg)(o,y,null===(s=e3.from)||void 0===s?void 0:s.toISOString(),null===(t=e3.to)||void 0===t?void 0:t.toISOString());eY(v.data),eX(v.all_api_bases);let S=await (0,u.N8)(o,m,c,y,null===(n=e3.from)||void 0===n?void 0:n.toISOString(),null===(a=e3.to)||void 0===a?void 0:a.toISOString(),null==lo?void 0:lo.token,lc);console.log("Model exceptions response:",S),eQ(S.data),e1(S.exception_types);let k=await (0,u.fP)(o,m,c,y,null===(r=e3.from)||void 0===r?void 0:r.toISOString(),null===(i=e3.to)||void 0===i?void 0:i.toISOString(),null==lo?void 0:lo.token,lc),w=await (0,u.n$)(o,null===(d=e3.from)||void 0===d?void 0:d.toISOString().split("T")[0],null===(h=e3.to)||void 0===h?void 0:h.toISOString().split("T")[0],y);lt(w);let N=await (0,u.v9)(o,null===(x=e3.from)||void 0===x?void 0:x.toISOString().split("T")[0],null===(p=e3.to)||void 0===p?void 0:p.toISOString().split("T")[0],y);la(N),console.log("dailyExceptions:",w),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",k),e8(k);let I=await (0,u.j2)(o);lh(null==I?void 0:I.end_users);let A=(await (0,u.BL)(o,m,c)).router_settings;console.log("routerSettingsInfo:",A);let C=A.model_group_retry_policy,P=A.num_retries;console.log("model_group_retry_policy:",C),console.log("default_retries:",P),e7(C),ll(P)}catch(e){console.error("There was an error fetching the model data",e)}};o&&d&&c&&m&&e();let l=async()=>{let e=await (0,u.qm)();console.log("received model cost map data: ".concat(Object.keys(e))),P(e)};null==C&&l(),lg()},[o,d,c,m,C,O]),!h||!o||!d||!c||!m)return(0,a.jsx)("div",{children:"Loading..."});let lf=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(C)),null!=C&&"object"==typeof C&&e in C)?C[e].litellm_provider:"openai";if(n){let e=n.split("/"),l=e[0];r=1===e.length?u(n):l}else r="openai";a&&(i=null==a?void 0:a.input_cost_per_token,o=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==t?void 0:t.litellm_params)&&(m=Object.fromEntries(Object.entries(null==t?void 0:t.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),h.data[e].provider=r,h.data[e].input_cost=i,h.data[e].output_cost=o,h.data[e].input_cost&&(h.data[e].input_cost=(1e6*Number(h.data[e].input_cost)).toFixed(2)),h.data[e].output_cost&&(h.data[e].output_cost=(1e6*Number(h.data[e].output_cost)).toFixed(2)),h.data[e].max_tokens=d,h.data[e].max_input_tokens=c,h.data[e].api_base=null==t?void 0:null===(s=t.litellm_params)||void 0===s?void 0:s.api_base,h.data[e].cleanedLitellmParams=m,lf.push(t.model_name),console.log(h.data[e])}if(c&&"Admin Viewer"==c){let{Title:e,Paragraph:l}=$.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 l_=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eI[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof C&&Object.entries(C).forEach(l=>{let[t,n]=l;null!==n&&"object"==typeof n&&"litellm_provider"in n&&(n.litellm_provider===e||n.litellm_provider.includes(e))&&s.push(t)}),H(s),console.log("providerModels: ".concat(G))}},ly=async()=>{try{k.ZP.info("Running health check..."),eP("");let e=await (0,u.EY)(o);eP(e)}catch(e){console.error("Error running health check:",e),eP("Error running health check")}},lb=async(e,l,s)=>{if(console.log("Updating model metrics for group:",e),!o||!m||!c||!l||!s)return;console.log("inside updateModelMetrics - startTime:",l,"endTime:",s),ez(e);let t=null==lo?void 0:lo.token;void 0===t&&(t=null);let n=lc;void 0===n&&(n=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),s.setHours(23),s.setMinutes(59),s.setSeconds(59);try{let a=await (0,u.o6)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);console.log("Model metrics response:",a),eK(a.data),eG(a.all_api_bases);let r=await (0,u.Rg)(o,e,l.toISOString(),s.toISOString());eY(r.data),eX(r.all_api_bases);let i=await (0,u.N8)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);console.log("Model exceptions response:",i),eQ(i.data),e1(i.exception_types);let d=await (0,u.fP)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);if(console.log("slowResponses:",d),e8(d),e){let t=await (0,u.n$)(o,null==l?void 0:l.toISOString().split("T")[0],null==s?void 0:s.toISOString().split("T")[0],e);lt(t);let n=await (0,u.v9)(o,null==l?void 0:l.toISOString().split("T")[0],null==s?void 0:s.toISOString().split("T")[0],e);la(n)}}catch(e){console.error("Failed to fetch model metrics",e)}},lv=(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Select API Key Name"}),f?(0,a.jsxs)("div",{children:[(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{ld(null)},children:"All Keys"},"all-keys"),null==g?void 0:g.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{ld(e)},children:e.key_alias},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(B.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(K.Z,{value:"all-customers",onClick:()=>{lm(null)},children:"All Customers"},"all-customers"),null==lu?void 0:lu.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>{lm(e)},children:e},l))]})]}):(0,a.jsxs)("div",{children:[(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{ld(null)},children:"All Keys"},"all-keys"),null==g?void 0:g.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsxs)(K.Z,{value:String(l),disabled:!0,onClick:()=>{ld(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(B.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(K.Z,{value:"all-customers",onClick:()=>{lm(null)},children:"All Customers"},"all-customers"),null==lu?void 0:lu.map((e,l)=>(0,a.jsxs)(K.Z,{value:e,disabled:!0,onClick:()=>{lm(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lS=e=>{var l,s;let{payload:t,active:n}=e;if(!n||!t)return null;let r=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,i=t.sort((e,l)=>l.value-e.value);if(i.length>5){let e=i.length-5;(i=i.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:t.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:[r&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",r]}),i.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.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:t})]},l)})]})};console.log("selectedProvider: ".concat(Q)),console.log("providerModels.length: ".concat(G.length));let lk=Object.keys(n).find(e=>n[e]===Q);return lk&&(i=J.find(e=>e.name===eI[lk])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(et.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(es.Z,{children:"All Models"}),(0,a.jsx)(es.Z,{children:"Add Model"}),(0,a.jsx)(es.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(es.Z,{children:"Model Analytics"}),(0,a.jsx)(es.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[O&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",O]}),(0,a.jsx)(F.Z,{icon:ej.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(B.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eU||eL[0],onValueChange:e=>ez("all"===e?"all":e),value:eU||eL[0],children:[(0,a.jsx)(K.Z,{value:"all",children:"All Models"}),eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>ez(e),children:e},l))]})]}),(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(V.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),"Admin"===c&&(0,a.jsx)(V.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(V.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(V.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(V.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:f?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(V.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:f?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(V.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(V.Z,{})]})}),(0,a.jsx)(D.Z,{children:h.data.filter(e=>"all"===eU||e.model_name===eU||null==eU||""===eU).map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),"Admin"===c&&(0,a.jsx)(U.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(em.Z,{title:e&&e.api_base,children:(0,a.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,a.jsx)(U.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{className:"text-xs",children:e.input_cost?e.input_cost:e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(U.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{className:"text-xs",children:e.output_cost?e.output_cost:e.litellm_params.output_cost_per_token?(1e6*Number(e.litellm_params.output_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:f&&((s=e.model_info.created_at)?new Date(s).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:f&&e.model_info.created_by||"-"})}),(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(R.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,a.jsx)(R.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,a.jsx)(U.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eu.Z,{children:(0,a.jsx)(F.Z,{icon:T.Z,size:"sm",onClick:()=>lp(e)})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>lx(e)})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(eZ,{modelID:e.model_info.id,accessToken:o})})]})})]},l)})})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:n}=e,[r]=S.Z.useForm(),i={},o="",d="";if(t){i=t.litellm_params,o=t.model_name;let e=t.model_info;e&&(d=e.id,console.log("model_id: ".concat(d)),i.model_id=d)}return(0,a.jsx)(w.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.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)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(I.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(I.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:eT,onCancel:()=>{eE(!1),eF(null)},model:eM,onSubmit:lj}),(0,a.jsxs)(w.Z,{title:eM&&eM.model_name,visible:eO,width:800,footer:null,onCancel:()=>{eR(!1),eF(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(ek.Z,{language:"json",children:eM&&JSON.stringify(eM,null,2)})]})]}),(0,a.jsxs)(ea.Z,{className:"h-full",children:[(0,a.jsx)(ew,{level:2,children:"Add new model"}),(0,a.jsx)(M.Z,{children:(0,a.jsxs)(S.Z,{form:N,onFinish:()=>{N.validateFields().then(e=>{eC(e,o,N)}).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)(S.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)(B.Z,{value:Q.toString(),children:Y.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>{l_(e),ey(e)},children:e},l))})}),(0,a.jsx)(S.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)(j.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(t=Q.toString())?"gemini-pro":"Anthropic"==t||"Amazon Bedrock"==t?"claude-3-opus":"Google AI Studio"==t?"gemini-pro":"Azure AI Studio"==t?"azure_ai/command-r-plus":"Azure"==t?"azure/my-deployment":"gpt-3.5-turbo"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(S.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"===Q?(0,a.jsx)(j.Z,{placeholder:"Enter model name"}):G.length>0?(0,a.jsx)(ei.Z,{value:G,children:G.map((e,l)=>(0,a.jsx)(eo.Z,{value:e,children:e},l))}):(0,a.jsx)(j.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(eN,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(eN,{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!==i&&i.fields.length>0&&(0,a.jsx)(eS,{fields:i.fields,selectedProvider:i.name}),"Amazon Bedrock"!=Q&&"Vertex AI (Anthropic, Gemini, etc.)"!=Q&&"Ollama"!=Q&&(void 0===i||0==i.fields.length)&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(j.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==Q&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(j.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(j.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(e_.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;N.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?k.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&k.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(A.ZP,{icon:(0,a.jsx)(ef.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==Q||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==Q)&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(j.Z,{placeholder:"https://..."})}),"Azure"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==Q&&(0,a.jsxs)("div",{children:[(0,a.jsx)(S.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(j.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(eN,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(S.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)(ep.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(eN,{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)(A.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(em.Z,{title:"Get help on our github",children:(0,a.jsx)($.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(_.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(p.Z,{onClick:ly,children:"Run `/health`"}),eb&&(0,a.jsx)("pre",{children:JSON.stringify(eb,null,2)})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(el.Z,{enableSelect:!0,value:e3,className:"mr-2",onValueChange:e=>{e6(e),lb(eU,e.from,e.to)}})]}),(0,a.jsxs)(eu.Z,{className:"ml-2",children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(B.Z,{defaultValue:eU||eL[0],value:eU||eL[0],children:eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>lb(e,e3.from,e3.to),children:e},l))})]}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(ex.Z,{trigger:"click",content:lv,overlayStyle:{width:"20vw"},children:(0,a.jsx)(p.Z,{icon:eg.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>li(!0)})})})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eu.Z,{children:(0,a.jsx)(M.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(es.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(_.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),eB&&eW&&(0,a.jsx)(ed.Z,{title:"Model Latency",className:"h-72",data:eB,showLegend:!1,index:"date",categories:eW,connectNulls:!0,customTooltip:lS})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ev,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lS,premiumUser:f})})]})]})})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(M.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Deployment"}),(0,a.jsx)(V.Z,{children:"Success Responses"}),(0,a.jsxs)(V.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(D.Z,{children:e5.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.api_base}),(0,a.jsx)(U.Z,{children:e.total_count}),(0,a.jsx)(U.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eU]}),(0,a.jsxs)(x.Z,{numItems:1,children:[(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ls.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:ls.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,a.jsx)(eu.Z,{})]})]}),f?(0,a.jsx)(a.Fragment,{children:ln.map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,a.jsx)(a.Fragment,{children:ln&&ln.length>0&&ln.slice(0,1).map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,a.jsx)(p.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)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(B.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eU||eL[0],value:eU||eL[0],onValueChange:e=>ez(e),children:eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>ez(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eU]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eA&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eA).map((e,l)=>{var s;let[t,n]=e,r=null==e9?void 0:null===(s=e9[eU])||void 0===s?void 0:s[n];return null==r&&(r=le),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)("td",{children:(0,a.jsx)(I.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e7(l=>{var s;let t=null!==(s=null==l?void 0:l[eU])&&void 0!==s?s:{};return{...null!=l?l:{},[eU]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})},eT=e=>{let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:n}=e,{Title:r,Paragraph:i}=$.default;return(0,a.jsxs)(w.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,a.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"User ID"}),(0,a.jsx)(_.Z,{children:null==n?void 0:n.user_id})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{children:"Invitation Link"}),(0,a.jsxs)(_.Z,{children:[t,"/ui/onboarding?id=",null==n?void 0:n.id]})]}),(0,a.jsxs)("div",{className:"flex justify-end mt-5",children:[(0,a.jsx)("div",{}),(0,a.jsx)(b.CopyToClipboard,{text:"".concat(t,"/ui/onboarding?id=").concat(null==n?void 0:n.id),onCopy:()=>k.ZP.success("Copied!"),children:(0,a.jsx)(p.Z,{variant:"primary",children:"Copy invitation link"})})]})]})};let{Option:eE}=v.default;var eO=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:n}=e,[o]=S.Z.useForm(),[d,c]=(0,r.useState)(!1),[m,h]=(0,r.useState)(null),[x,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[y,b]=(0,r.useState)(null),I=(0,i.useRouter)(),[C,P]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{if(I){let{protocol:e,host:l}=window.location;P("".concat(e,"/").concat(l))}},[I]);let T=async e=>{try{var t;k.ZP.info("Making API Call"),c(!0),console.log("formValues in create user:",e);let n=await (0,u.Ov)(s,null,e);console.log("user create Response:",n),h(n.key);let a=(null===(t=n.data)||void 0===t?void 0:t.user_id)||n.user_id;(0,u.XO)(s,a).then(e=>{b(e),f(!0)}),k.ZP.success("API user Created"),o.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-0",onClick:()=>c(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:d,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),h(null),o.resetFields()},children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,a.jsxs)(S.Z,{form:o,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(S.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:n&&Object.entries(n).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(K.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(v.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,a.jsx)(eE,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eE,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create User"})})]})]}),m&&(0,a.jsx)(eT,{isInvitationLinkModalVisible:Z,setIsInvitationLinkModalVisible:f,baseUrl:C,invitationLinkData:y})]})},eR=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:n,onSubmit:i}=e,[o,d]=(0,r.useState)(n),[c]=S.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[n]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return n?(0,a.jsx)(w.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+n.user_id,width:1e3,children:(0,a.jsx)(S.Z,{form:c,onFinish:u,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(K.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})}):null},eM=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(0),[Z,f]=r.useState(null),[_,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(!1),[S,w]=(0,r.useState)(null),[N,I]=(0,r.useState)({}),A=async()=>{w(null),v(!1)},C=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&n&&i){try{await (0,u.pf)(l,e,null),k.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}c&&m(c.map(l=>l.user_id===e.user_id?e:l)),w(null),v(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=await (0,u.Br)(l,null,n,!0,j,25);console.log("user data response:",e),m(e);let s=await (0,u.lg)(l);I(s)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,j]),c&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,a.jsx)(eO,{userID:i,accessToken:l,teams:o,possibleUIRoles:N}),(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1"}),(0,a.jsx)(et.Z,{children:(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(L.Z,{className:"mt-5",children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"User ID"}),(0,a.jsx)(V.Z,{children:"User Email"}),(0,a.jsx)(V.Z,{children:"Role"}),(0,a.jsx)(V.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(V.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(V.Z,{children:"API Keys"}),(0,a.jsx)(V.Z,{})]})}),(0,a.jsx)(D.Z,{children:c.map(e=>{var l,s;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_id||"-"}),(0,a.jsx)(U.Z,{children:e.user_email||"-"}),(0,a.jsx)(U.Z,{children:(null==N?void 0:null===(l=N[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,a.jsx)(U.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,a.jsx)(U.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsxs)(R.Z,{size:"xs",color:"indigo",children:[e.key_aliases.filter(e=>null!==e).length,"\xa0Keys"]}):(0,a.jsx)(R.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:E.Z,onClick:()=>{w(e),v(!0)},children:"View Keys"})})]},e.user_id)})})]})}),(0,a.jsx)(ea.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"})]})})]})}),(0,a.jsx)(eR,{visible:b,possibleUIRoles:N,onCancel:A,user:S,onSubmit:C})]}),function(){if(!c)return null;let e=Math.ceil(c.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",j+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===j,onClick:()=>g(j-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:()=>{g(j+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},eF=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,userID:i,userRole:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=$.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[C,P]=(0,r.useState)(l?l[0]:null),[T,W]=(0,r.useState)(!1),[G,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)([]),[X,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),[es,et]=(0,r.useState)({}),en=e=>{P(e),b(!0)},ea=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let a=await (0,u.Gh)(t,e);l&&n(l.map(e=>e.team_id===s?a.data:e)),k.ZP.success("Team updated successfully"),b(!1),P(null)},er=async e=>{el(e),Q(!0)},ei=async()=>{if(null!=ee&&null!=l&&null!=t){try{await (0,u.rs)(t,ee);let e=l.filter(e=>e.team_id!==ee);n(e)}catch(e){console.error("Error deleting the team:",e)}Q(!1),el(null)}};(0,r.useEffect)(()=>{let e=async()=>{try{if(null===i||null===o||null===t||null===l)return;console.log("fetching team info:");let e={};for(let s=0;s<(null==l?void 0:l.length);s++){let n=l[s].team_id,a=await (0,u.Xm)(t,n);console.log("teamInfo response:",a),null!==a&&(e={...e,[n]:a})}et(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,u.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),J(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eo=async e=>{try{if(null!=t){var s;let a=null==e?void 0:e.team_alias;if((null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));k.ZP.info("Creating Team");let r=await (0,u.hT)(t,e);null!==l?n([...l,r]):n([r]),console.log("response for team create call: ".concat(r)),k.ZP.success("Team created"),W(!1)}}catch(e){console.error("Error creating the team:",e),k.ZP.error("Error creating the team: "+e,20)}},ed=async e=>{try{if(null!=t&&null!=l){k.ZP.info("Adding Member");let s={role:"user",user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,C.team_id,s);console.log("response for team create call: ".concat(a.data));let r=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(r)),-1!==r){let e=[...l];e[r]=a.data,n(e),P(a.data)}H(!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)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Team Name"}),(0,a.jsx)(V.Z,{children:"Spend (USD)"}),(0,a.jsx)(V.Z,{children:"Budget (USD)"}),(0,a.jsx)(V.Z,{children:"Models"}),(0,a.jsx)(V.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(V.Z,{children:"Info"})]})}),(0,a.jsx)(D.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(U.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(_.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)(U.Z,{children:[(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].keys&&es[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].team_info&&es[e.team_id].team_info.members_with_roles&&es[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>en(e)}),(0,a.jsx)(F.Z,{onClick:()=>er(e.team_id),icon:O.Z,size:"sm"})]})]},e.team_id)):null})]}),X&&(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)(p.Z,{onClick:ei,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{Q(!1),el(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>W(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:T,width:800,footer:null,onOk:()=>{W(!1),d.resetFields()},onCancel:()=>{W(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:eo,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),Y.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(g,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(B.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{P(e)},children:e.team_alias},l))}):(0,a.jsxs)(g,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Member Name"}),(0,a.jsx)(V.Z,{children:"Role"})]})}),(0,a.jsx)(D.Z,{children:C?C.members_with_roles.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(U.Z,{children:e.role})]},l)):null})]})}),C&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:n}=e,[r]=S.Z.useForm();return(0,a.jsx)(w.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:ea,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),Y&&Y.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.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)(A.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),P(null)},team:C,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-5",onClick:()=>H(!0),children:"+ Add member"}),(0,a.jsx)(w.Z,{title:"Add member",visible:G,width:800,footer:null,onOk:()=>{H(!1),c.resetFields()},onCancel:()=>{H(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(N.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)(S.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(N.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)(A.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eL=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n}=e,[o]=S.Z.useForm(),[d]=S.Z.useForm(),{Title:c,Paragraph:m}=$.default,[j,g]=(0,r.useState)(""),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)(null),[v,I]=(0,r.useState)(!1),[C,P]=(0,r.useState)(!1),[T,O]=(0,r.useState)(!1),[R,W]=(0,r.useState)(!1),[G,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)(!1),X=(0,i.useRouter)(),[Q,ee]=(0,r.useState)(null),[el,es]=(0,r.useState)("");try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let et=()=>{J(!1)},en=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{if(X){let{protocol:e,host:l}=window.location;es("".concat(e,"//").concat(l))}},[X]),(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,u.Xd)(t,"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 s=await (0,u.Xd)(t,"proxy_admin");s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(s)),console.log("combinedList: ".concat(e)),f(e),ee(await (0,u.lg)(t))}})()},[t]);let ea=()=>{W(!1),d.resetFields(),o.resetFields()},er=()=>{W(!1),d.resetFields(),o.resetFields()},ei=e=>(0,a.jsxs)(S.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,a.jsx)(N.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Add member"})})]}),eo=(e,l,s)=>(0,a.jsxs)(S.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(B.Z,{value:l,children:en.map((e,l)=>(0,a.jsx)(K.Z,{value:e,children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(N.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Update role"})})]}),ed=async e=>{try{if(null!=t&&null!=Z){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=Z.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(s)),-1==s&&(console.log("updates admin with new user"),Z.push(l),f(Z)),k.ZP.success("Refresh tab to see updated user role"),W(!1)}}catch(e){console.error("Error creating the key:",e)}},ec=async e=>{try{if(null!=t&&null!=Z){var l;k.ZP.info("Making API Call");let s=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{b(e),I(!0)});let a=Z.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(s.user_id)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),Z.push(s),f(Z)),o.resetFields(),P(!1)}}catch(e){console.error("Error creating the key:",e)}},em=async e=>{try{if(null!=t&&null!=Z){var l;k.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,u.pf)(t,e,"proxy_admin"),n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{b(e),I(!0)}),console.log("response for team create call: ".concat(s));let a=Z.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(n)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),Z.push(s),f(Z)),o.resetFields(),O(!1)}}catch(e){console.error("Error creating the key:",e)}},eu=async e=>{if(null==t)return;let l={environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}};(0,u.K_)(t,l)};return console.log("admins: ".concat(null==Z?void 0:Z.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)(m,{children:[n&&(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)(x.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Member Name"}),(0,a.jsx)(V.Z,{children:"Role"})]})}),(0,a.jsx)(D.Z,{children:Z?Z.map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsxs)(U.Z,{children:[" ",(null==Q?void 0:null===(s=Q[null==e?void 0:e.user_role])||void 0===s?void 0:s.ui_label)||"-"]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>W(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:R,width:800,footer:null,onOk:ea,onCancel:er,children:eo(ed,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(p.Z,{className:"mr-4 mb-5",onClick:()=>O(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:T,width:800,footer:null,onOk:()=>{O(!1),d.resetFields(),o.resetFields()},onCancel:()=>{O(!1),I(!1),d.resetFields(),o.resetFields()},children:ei(em)}),(0,a.jsx)(eT,{isInvitationLinkModalVisible:v,setIsInvitationLinkModalVisible:I,baseUrl:el,invitationLinkData:y}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>P(!0),children:"+ Add viewer"}),(0,a.jsx)(w.Z,{title:"Add viewer",visible:C,width:800,footer:null,onOk:()=>{P(!1),d.resetFields(),o.resetFields()},onCancel:()=>{P(!1),d.resetFields(),o.resetFields()},children:ei(ec)})]})})]}),(0,a.jsxs)(x.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)(p.Z,{onClick:()=>H(!0),children:"Add SSO"}),(0,a.jsx)(w.Z,{title:"Add SSO",visible:G,width:800,footer:null,onOk:()=>{H(!1),o.resetFields()},onCancel:()=>{H(!1),o.resetFields()},children:(0,a.jsxs)(S.Z,{form:o,onFinish:e=>{em(e),eu(e),H(!1),J(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(N.Z.Password,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(N.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:et,onCancel:()=>{J(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(_.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)(A.ZP,{onClick:et,children:"Done"})})]})]}),(0,a.jsxs)(ey.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})," "]})]})]})]})},eD=s(42556),eU=s(90252),ez=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:n,premiumUser:r}=e,[i]=S.Z.useForm();return(0,a.jsxs)(S.Z,{form:i,onFinish:()=>{let e=i.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(U.Z,{align:"center",children:[(0,a.jsx)(_.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?r?(0,a.jsx)(S.Z.Item,{name:e.field_name,children:(0,a.jsx)(U.Z,{children:"Integer"===e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(U.Z,{children:(0,a.jsx)(p.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)(S.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(U.Z,{children:"Integer"===e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(U.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eU.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:O.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eV=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(ez,{alertingSettings:t,handleInputChange:(e,l)=>{n(t.map(s=>s.field_name===e?{...s,field_value:l}:s))},handleResetField:(e,s)=>{if(l)try{let l=t.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),n(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let n={...e,...s};try{(0,u.jA)(l,"alerting_args",n),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},eq=s(84406);let{Title:eB,Paragraph:eK}=$.default;var eW=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g]=S.Z.useForm(),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[C,P]=(0,r.useState)({}),[T,O]=(0,r.useState)([]),[R,B]=(0,r.useState)(!1),[W,G]=(0,r.useState)([]),[H,Y]=(0,r.useState)(null),[J,X]=(0,r.useState)([]),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),ei=e=>{T.includes(e)?O(T.filter(l=>l!==e)):O([...T,e])},eo={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,r.useEffect)(()=>{l&&s&&t&&(0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),G(e.available_callbacks);let l=e.alerts;if(console.log("alerts_data",l),l&&l.length>0){let e=l[0];console.log("_alert_info",e);let s=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",s),O(e.active_alerts),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ed=e=>T&&T.includes(e),ec=()=>{if(!l)return;let e={};d.filter(e=>"email"===e.name).forEach(l=>{var s;Object.entries(null!==(s=l.variables)&&void 0!==s?s:{}).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));n&&n.value&&(e[s]=null==n?void 0:n.value)})}),console.log("updatedVariables",e);try{(0,u.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Email settings updated successfully")},em=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,u.K_)(l,{environment_variables:s}),k.ZP.success("Callback added successfully"),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eu=async e=>{if(!l)return;let s=null==e?void 0:e.callback,t={};Object.entries(e).forEach(e=>{let[l,s]=e;"callback"!==l&&(t[l]=s)});try{await (0,u.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),k.ZP.success("Callback ".concat(s," added successfully")),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),f(e.litellm_callback_name),console.log("all callbacks",W),e&&e.litellm_callback_params?(X(e.litellm_callback_params),console.log("selectedCallbackParams",J)):X([])};return l?(console.log("callbacks: ".concat(i)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(es.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(es.Z,{value:"3",children:"Alerting Settings"}),(0,a.jsx)(es.Z,{value:"4",children:"Email Alerts"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(eB,{level:4,children:"Active Logging Callbacks"}),(0,a.jsx)(x.Z,{numItems:2,children:(0,a.jsx)(M.Z,{className:"max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{children:"Callback Name"})})}),(0,a.jsx)(D.Z,{children:i.map((e,s)=>(0,a.jsxs)(q.Z,{className:"flex justify-between",children:[(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:e.name})}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"flex justify-between",children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>B(!0),children:"Add Callback"})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(_.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)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{}),(0,a.jsx)(V.Z,{}),(0,a.jsx)(V.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(eo).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(eD.Z,{id:"switch",name:"switch",checked:ed(s),onChange:()=>ei(s)}):(0,a.jsx)(p.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)(eD.Z,{id:"switch",name:"switch",checked:ed(s),onChange:()=>ei(s)})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:C&&C[s]?C[s]:N})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(eo).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",n);let a=(null==n?void 0:n.value)||"";console.log("newWebhookValue",a),e[s]=a}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:T}};console.log("payload",s);try{(0,u.K_)(l,s)}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(eV,{accessToken:l,premiumUser:n})}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(eB,{level:4,children:"Email Settings"}),(0,a.jsxs)(_.Z,{children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,a.jsx)("br",{})]}),(0,a.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,a.jsx)(U.Z,{children:(0,a.jsx)("ul",{children:(0,a.jsx)(x.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{className:"mx-2 my-2",children:[!0!=n&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,a.jsxs)(_.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,a.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,a.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,a.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the Logo that appears in the email, pass a url to your logo"}),"EMAIL_SUPPORT_CONTACT"===l&&(0,a.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the support email address that appears in the email. Default is support@berri.ai"})]})]},l)})})})},l)})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>ec(),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,a.jsxs)(w.Z,{title:"Add Logging Callback",visible:R,width:800,onCancel:()=>B(!1),footer:null,children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/logging",className:"mb-8 mt-4",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: Logging"}),(0,a.jsx)(S.Z,{form:g,onFinish:eu,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eq.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsx)(v.default,{onChange:e=>{let l=W[e];l&&(console.log(l.ui_callback_name),eh(l))},children:W&&Object.values(W).map(e=>(0,a.jsx)(K.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),J&&J.map(e=>(0,a.jsx)(eq.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,a.jsx)(j.Z,{type:"password"})},e)),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,a.jsx)(w.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,a.jsxs)(S.Z,{form:g,onFinish:em,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,a.jsx)(eq.Z,{label:l,name:l,children:(0,a.jsx)(j.Z,{type:"password",defaultValue:s})},l)})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eG}=v.default;var eH=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:n}=e,[i]=S.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(w.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,r=[...t.fallbacks||[],{[l]:a}],o={...t,fallbacks:r};console.log(o);try{(0,u.K_)(s,{router_settings:o}),n(o)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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)(B.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(ei.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(eo.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},eY=s(12968);async function eJ(e,l){console.log("isLocal:",!1);let s=window.location.origin,t=new eY.ZP.OpenAI({apiKey:l,baseURL:s,dangerouslyAllowBrowser:!0});try{let l=await t.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});k.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){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let eX={ttl:3600,lowest_latency_buffer:0},e$=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(Z.Z,{children:"latency-based-routing"==l?(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Setting"}),(0,a.jsx)(V.Z,{children:"Value"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,a.jsx)(_.Z,{children:"No specific settings"})})]})};var eQ=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[b]=S.Z.useForm(),[v,w]=(0,r.useState)(null),[N,A]=(0,r.useState)(null),[C,P]=(0,r.useState)(null),T={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,r.useEffect)(()=>{l&&s&&t&&((0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.router_settings)}),(0,u.YU)(l).then(e=>{g(e)}))},[l,s,t]);let E=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks)),i.fallbacks.map(l=>(e in l&&delete l[e],l));try{await (0,u.K_)(l,{router_settings:i}),o({...i}),A(i.routing_strategy),k.ZP.success("Router settings updated successfully")}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}}},W=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},G=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,u.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},H=(e,s)=>{if(l)try{(0,u.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},Y=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,u.K_)(l,{router_settings:s})}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(et.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(es.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(es.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(y.Z,{children:"Router Settings"}),(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Setting"}),(0,a.jsx)(V.Z,{children:"Value"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(i).filter(e=>{let[l,s]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,s]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:T[l]})]}),(0,a.jsx)(U.Z,{children:"routing_strategy"==l?(0,a.jsxs)(B.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:A,children:[(0,a.jsx)(K.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(K.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(K.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,a.jsx)(e$,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:eX,paramExplanation:T})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>Y(i),children:"Save Changes"})})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Model Name"}),(0,a.jsx)(V.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(D.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:t}),(0,a.jsx)(U.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>eJ(t,l),children:"Test Fallback"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:O.Z,size:"sm",onClick:()=>E(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(eH,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Setting"}),(0,a.jsx)(V.Z,{children:"Value"}),(0,a.jsx)(V.Z,{children:"Status"}),(0,a.jsx)(V.Z,{children:"Action"})]})}),(0,a.jsx)(D.Z,{children:m.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.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)(U.Z,{children:"Integer"==e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>W(e.field_name,l)}):null}),(0,a.jsx)(U.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eU.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>G(e.field_name,l),children:"Update"}),(0,a.jsx)(F.Z,{icon:O.Z,color:"red",onClick:()=>H(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},e0=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n}=e,[r]=S.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call");let l=await (0,u.Zr)(s,e);console.log("key create Response:",l),n(e=>e?[...e,l]:[l]),k.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,a.jsxs)(S.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(I.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(I.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},e1=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{i(e)})},[l]);let o=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...n];t.splice(s,1),i(t),k.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)(p.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,a.jsx)(e0,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:i}),(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Budget ID"}),(0,a.jsx)(V.Z,{children:"Max Budget"}),(0,a.jsx)(V.Z,{children:"TPM"}),(0,a.jsx)(V.Z,{children:"RPM"})]})}),(0,a.jsx)(D.Z,{children:n.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.budget_id}),(0,a.jsx)(U.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(U.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(U.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(F.Z,{icon:O.Z,size:"sm",onClick:()=>o(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(es.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(es.Z,{children:"Test it (Curl)"}),(0,a.jsx)(es.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ek.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)(ea.Z,{children:(0,a.jsx)(ek.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)(ea.Z,{children:(0,a.jsx)(ek.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{let{proxySettings:l}=e,s="http://localhost:4000";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(x.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)(_.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)(et.Z,{children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(es.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(es.Z,{children:"LlamaIndex"}),(0,a.jsx)(es.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ek.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="'.concat(s,'" # 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)(ea.Z,{children:(0,a.jsx)(ek.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="'.concat(s,'", # 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="').concat(s,'",\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)(ea.Z,{children:(0,a.jsx)(ek.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="'.concat(s,'",\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 e5(e,l,s,t){console.log("isLocal:",!1);let n=window.location.origin,a=new eY.ZP.OpenAI({apiKey:t,baseURL:n,dangerouslyAllowBrowser:!0});try{for await(let t of(await a.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content)}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var e8=e=>{let{accessToken:l,token:s,userRole:t,userID:n}=e,[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(""),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(void 0),[y,b]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{let e=await (0,u.So)(l,n,t);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}));if(console.log(l),l.length>0){let e=Array.from(new Set(l));console.log("Unique models:",e),e.sort((e,l)=>e.label.localeCompare(l.label)),console.log("Model info:",y),b(e)}f(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,n,t]);let S=(e,l)=>{g(s=>{let t=s[s.length-1];return t&&t.role===e?[...s.slice(0,s.length-1),{role:e,content:t.content+l}]:[...s,{role:e,content:l}]})},k=async()=>{if(""!==d.trim()&&i&&s&&t&&n){g(e=>[...e,{role:"user",content:d}]);try{Z&&await e5(d,e=>S("assistant",e),Z,i)}catch(e){console.error("Error fetching model response",e),S("assistant","Error fetching model response")}c("")}};if(t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=$.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)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(M.Z,{children:(0,a.jsxs)(et.Z,{children:[(0,a.jsx)(en.Z,{children:(0,a.jsx)(es.Z,{children:"Chat"})}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"API Key"}),(0,a.jsx)(j.Z,{placeholder:"Type API Key here",type:"password",onValueChange:o,value:i})]}),(0,a.jsxs)(h.Z,{className:"mx-2",children:[(0,a.jsx)(_.Z,{children:"Select Model:"}),(0,a.jsx)(v.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),f(e)},options:y,style:{width:"200px"}})]})]})}),(0,a.jsxs)(L.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(z.Z,{children:(0,a.jsx)(q.Z,{children:(0,a.jsx)(U.Z,{})})}),(0,a.jsx)(D.Z,{children:m.map((e,l)=>(0,a.jsx)(q.Z,{children:(0,a.jsx)(U.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)(j.Z,{type:"text",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},e3=s(33509),e6=s(95781);let{Sider:e9}=e3.default;var e7=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e;return"Admin Viewer"==s?(0,a.jsx)(e3.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(e9,{width:120,children:(0,a.jsx)(e6.Z,{mode:"inline",defaultSelectedKeys:t||["4"],style:{height:"100%",borderRight:0},children:(0,a.jsx)(e6.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")})})}):(0,a.jsx)(e3.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(e9,{width:145,children:(0,a.jsxs)(e6.Z,{mode:"inline",defaultSelectedKeys:t||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e6.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(_.Z,{children:"API Keys"})},"1"),(0,a.jsx)(e6.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(_.Z,{children:"Test Key"})},"3"),"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(_.Z,{children:"Models"})},"2"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(_.Z,{children:"Usage"})},"4"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(_.Z,{children:"Teams"})},"6"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(_.Z,{children:"Internal Users"})},"5"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(_.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(_.Z,{children:"Budgets"})},"9"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(_.Z,{children:"Router Settings"})},"10"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(_.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(e6.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(_.Z,{children:"API Reference"})},"12"),(0,a.jsx)(e6.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(_.Z,{children:"Model Hub"})},"14")]})})})},le=s(67989),ll=s(52703),ls=e=>{let{accessToken:l,token:s,userRole:t,userID:n,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[S,k]=(0,r.useState)([]),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)([]),[C,P]=(0,r.useState)([]),[T,E]=(0,r.useState)([]),[O,R]=(0,r.useState)([]),[F,W]=(0,r.useState)({}),[G,Y]=(0,r.useState)([]),[J,X]=(0,r.useState)(""),[$,Q]=(0,r.useState)(["all-tags"]),[em,eu]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),eh=new Date(d.getFullYear(),d.getMonth(),1),ex=new Date(d.getFullYear(),d.getMonth()+1,0),ep=e_(eh),ej=e_(ex);function eg(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}console.log("keys in usage",i),console.log("premium user in usage",o),(0,r.useEffect)(()=>{ef(em.from,em.to)},[em,$]);let eZ=async(e,s,t)=>{if(!e||!s||!l)return;s.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",t);let n=await (0,u.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",n),v(n)},ef=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.J$)(l,e.toISOString(),s.toISOString(),0===$.length?void 0:$)).spend_per_tag),console.log("Tag spend data updated successfully"))};function e_(e){let l=e.getFullYear(),s=e.getMonth()+1,t=e.getDate();return"".concat(l,"-").concat(s<10?"0"+s:s,"-").concat(t<10?"0"+t:t)}return console.log("Start date is ".concat(ep)),console.log("End date is ".concat(ej)),(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{if(console.log("user role: ".concat(t)),"Admin"==t||"Admin Viewer"==t){var e,a;let t=await (0,u.FC)(l);m(t);let n=await (0,u.OU)(l,s,ep,ej);console.log("provider_spend",n),R(n);let r=(await (0,u.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));g(r);let i=(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend}));f(i);let o=await (0,u.mR)(l);console.log("teamSpend",o),k(o.daily_spend),P(o.teams);let d=o.total_spend_per_team;d=d.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),E(d);let c=await (0,u.X)(l);A(c.tag_names);let h=await (0,u.J$)(l,null===(e=em.from)||void 0===e?void 0:e.toISOString(),null===(a=em.to)||void 0===a?void 0:a.toISOString(),void 0);N(h.spend_per_tag);let x=await (0,u.b1)(l,null,void 0,void 0);v(x),console.log("spend/user result",x);let p=await (0,u.wd)(l,ep,ej);W(p);let j=await (0,u.xA)(l,ep,ej);console.log("global activity per model",j),Y(j)}else"App Owner"==t&&await (0,u.HK)(l,s,t,n,ep,ej).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 s=e.top_api_keys;g(s)}else{let s=(await (0,u.e2)(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,t]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&l.push({key:s,spend:t})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let s=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(s[0]))),s}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));g(s),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,s,t,n,ep,ej]),(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{className:"mt-2",children:[(0,a.jsx)(es.Z,{children:"All Up"}),(0,a.jsx)(es.Z,{children:"Team Based Usage"}),(0,a.jsx)(es.Z,{children:"Customer Usage"}),(0,a.jsx)(es.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(es.Z,{children:"Cost"}),(0,a.jsx)(es.Z,{children:"Activity"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(H,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(ec.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(ec.Z,{className:"mt-4 h-40",data:j,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(ec.Z,{className:"mt-4 h-40",data:Z,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(ll.Z,{className:"mt-4 h-40",variant:"pie",data:O,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Provider"}),(0,a.jsx)(V.Z,{children:"Spend"})]})}),(0,a.jsx)(D.Z,{children:O.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.provider}),(0,a.jsx)(U.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)(p.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)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"All Up"}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(F.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:F.daily_data,valueFormatter:eg,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(F.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:F.daily_data,valueFormatter:eg,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:G.map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(e.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eg,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(e.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:eg,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:G&&G.length>0&&G.slice(0,1).map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.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)(p.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)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(e.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eg,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(e.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:eg,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsxs)(M.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(le.Z,{data:T})]}),(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(ec.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:C,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["Customers 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)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(el.Z,{enableSelect:!0,value:em,onValueChange:e=>{eu(e),eZ(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{eZ(em.from,em.to,null)},children:"All Keys"},"all-keys"),null==i?void 0:i.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{eZ(em.from,em.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(M.Z,{className:"mt-4",children:(0,a.jsxs)(L.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Customer"}),(0,a.jsx)(V.Z,{children:"Spend"}),(0,a.jsx)(V.Z,{children:"Total Events"})]})}),(0,a.jsx)(D.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.end_user}),(0,a.jsx)(U.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(U.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(el.Z,{className:"mb-4",enableSelect:!0,value:em,onValueChange:e=>{eu(e),ef(e.from,e.to)}})}),(0,a.jsx)(h.Z,{children:o?(0,a.jsx)("div",{children:(0,a.jsxs)(ei.Z,{value:$,onValueChange:e=>Q(e),children:[(0,a.jsx)(eo.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsx)(eo.Z,{value:String(e),children:e},e))]})}):(0,a.jsx)("div",{children:(0,a.jsxs)(ei.Z,{value:$,onValueChange:e=>Q(e),children:[(0,a.jsx)(eo.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsxs)(K.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(_.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,a.jsx)(ec.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,a.jsx)(h.Z,{numColSpan:2})]})]})]})]})})},lt=()=>{let{Title:e,Paragraph:l}=$.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[x,p]=(0,r.useState)(null),[j,g]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[Z,f]=(0,r.useState)(!0),_=(0,i.useSearchParams)(),[y,b]=(0,r.useState)({data:[]}),v=_.get("userID"),S=_.get("token"),[k,w]=(0,r.useState)("api-keys"),[N,I]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(S){let e=(0,X.o)(S);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),I(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"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&w("usage")}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?f("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user)}}},[S]),(0,a.jsx)(r.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:v,userRole:s,userEmail:d,showSSOBanner:Z,premiumUser:n,setProxySettings:g,proxySettings:j}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(e7,{setPage:w,userRole:s,defaultSelectedKey:null})}),"api-keys"==k?(0,a.jsx)(Q,{userID:v,userRole:s,teams:u,keys:x,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:h,setKeys:p,setProxySettings:g,proxySettings:j}):"models"==k?(0,a.jsx)(eP,{userID:v,userRole:s,token:S,keys:x,accessToken:N,modelData:y,setModelData:b,premiumUser:n}):"llm-playground"==k?(0,a.jsx)(e8,{userID:v,userRole:s,token:S,accessToken:N}):"users"==k?(0,a.jsx)(eM,{userID:v,userRole:s,token:S,keys:x,teams:u,accessToken:N,setKeys:p}):"teams"==k?(0,a.jsx)(eF,{teams:u,setTeams:h,searchParams:_,accessToken:N,userID:v,userRole:s}):"admin-panel"==k?(0,a.jsx)(eL,{setTeams:h,searchParams:_,accessToken:N,showSSOBanner:Z}):"api_ref"==k?(0,a.jsx)(e4,{proxySettings:j}):"settings"==k?(0,a.jsx)(eW,{userID:v,userRole:s,accessToken:N,premiumUser:n}):"budgets"==k?(0,a.jsx)(e1,{accessToken:N}):"general-settings"==k?(0,a.jsx)(eQ,{userID:v,userRole:s,accessToken:N,modelData:y}):"model-hub"==k?(0,a.jsx)(e2.Z,{accessToken:N,publicPage:!1,premiumUser:n}):(0,a.jsx)(ls,{userID:v,userRole:s,token:S,accessToken:N,keys:x,premiumUser:n})]})]})})}},41134:function(e,l,s){"use strict";s.d(l,{Z:function(){return y}});var t=s(3827),n=s(64090),a=s(47907),r=s(777),i=s(16450),o=s(13810),d=s(92836),c=s(26734),m=s(41608),u=s(32126),h=s(23682),x=s(71801),p=s(42440),j=s(84174),g=s(50459),Z=s(6180),f=s(99129),_=s(67951),y=e=>{var l;let{accessToken:s,publicPage:y,premiumUser:b}=e,[v,S]=(0,n.useState)(!1),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(!1),[A,C]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null),E=(0,a.useRouter)();(0,n.useEffect)(()=>{s&&(async()=>{try{let e=await (0,r.kn)(s);console.log("ModelHubData:",e),w(e.data),(0,r.E9)(s,"enable_public_model_hub").then(e=>{console.log("data: ".concat(JSON.stringify(e))),!0==e.field_value&&S(!0)}).catch(e=>{})}catch(e){console.error("There was an error fetching the model data",e)}})()},[s,y]);let O=e=>{T(e),I(!0)},R=async()=>{s&&(0,r.jA)(s,"enable_public_model_hub",!0).then(e=>{C(!0)})},M=()=>{I(!1),C(!1),T(null)},F=()=>{I(!1),C(!1),T(null)},L=e=>{navigator.clipboard.writeText(e)};return(0,t.jsxs)("div",{children:[y&&v||!1==y?(0,t.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,t.jsx)("div",{className:"relative w-full"}),(0,t.jsxs)("div",{className:"flex ".concat(y?"justify-between":"items-center"),children:[(0,t.jsx)(p.Z,{className:"ml-8 text-center ",children:"Model Hub"}),!1==y?b?(0,t.jsx)(i.Z,{className:"ml-4",onClick:()=>R(),children:"✨ Make Public"}):(0,t.jsx)(i.Z,{className:"ml-4",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})}):(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("p",{children:"Filter by key:"}),(0,t.jsx)(x.Z,{className:"bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center",children:"/ui/model_hub?key="})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4 pr-8",children:k&&k.map(e=>(0,t.jsxs)(o.Z,{className:"mt-5 mx-8",children:[(0,t.jsxs)("pre",{className:"flex justify-between",children:[(0,t.jsx)(p.Z,{children:e.model_group}),(0,t.jsx)(Z.Z,{title:e.model_group,children:(0,t.jsx)(j.Z,{onClick:()=>L(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,t.jsxs)("div",{className:"my-5",children:[(0,t.jsxs)(x.Z,{children:["Mode: ",e.mode]}),(0,t.jsxs)(x.Z,{children:["Supports Function Calling:"," ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Supports Vision:"," ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Max Input Tokens:"," ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,t.jsxs)(x.Z,{children:["Max Output Tokens:"," ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,t.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,t.jsxs)("a",{href:"#",onClick:()=>O(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,t.jsx)(g.Z,{})]})})]},e.model_group))})]}):(0,t.jsxs)(o.Z,{className:"mx-auto max-w-xl mt-10",children:[(0,t.jsx)(x.Z,{className:"text-xl text-center mb-2 text-black",children:"Public Model Hub not enabled."}),(0,t.jsx)("p",{className:"text-base text-center text-slate-800",children:"Ask your proxy admin to enable this on their Admin UI."})]}),(0,t.jsx)(f.Z,{title:"Public Model Hub",width:600,visible:A,footer:null,onOk:M,onCancel:F,children:(0,t.jsxs)("div",{className:"pt-5 pb-5",children:[(0,t.jsxs)("div",{className:"flex justify-between mb-4",children:[(0,t.jsx)(x.Z,{className:"text-base mr-2",children:"Shareable Link:"}),(0,t.jsx)(x.Z,{className:"max-w-sm ml-2 bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center rounded",children:"/ui/model_hub?key="})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(i.Z,{onClick:()=>{E.replace("/model_hub?key=".concat(s))},children:"See Page"})})]})}),(0,t.jsx)(f.Z,{title:P&&P.model_group?P.model_group:"Unknown Model",width:800,visible:N,footer:null,onOk:M,onCancel:F,children:P&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-4",children:(0,t.jsx)("strong",{children:"Model Information & Usage"})}),(0,t.jsxs)(c.Z,{children:[(0,t.jsxs)(m.Z,{children:[(0,t.jsx)(d.Z,{children:"OpenAI Python SDK"}),(0,t.jsx)(d.Z,{children:"Supported OpenAI Params"}),(0,t.jsx)(d.Z,{children:"LlamaIndex"}),(0,t.jsx)(d.Z,{children:"Langchain Py"})]}),(0,t.jsxs)(h.Z,{children:[(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:"".concat(null===(l=P.supported_openai_params)||void 0===l?void 0:l.map(e=>"".concat(e,"\n")).join(""))})}),(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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 ')})})]})]})]})})]})}}},function(e){e.O(0,[936,294,131,684,759,777,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/_next/static/chunks/webpack-d12f0c7c134d3e60.js b/litellm/proxy/_experimental/out/_next/static/chunks/webpack-496e007a0280178b.js similarity index 98% rename from ui/litellm-dashboard/out/_next/static/chunks/webpack-d12f0c7c134d3e60.js rename to litellm/proxy/_experimental/out/_next/static/chunks/webpack-496e007a0280178b.js index dbd5f5398..a08c6655b 100644 --- a/ui/litellm-dashboard/out/_next/static/chunks/webpack-d12f0c7c134d3e60.js +++ b/litellm/proxy/_experimental/out/_next/static/chunks/webpack-496e007a0280178b.js @@ -1 +1 @@ -!function(){"use strict";var e,t,n,r,o,u,i,c,f,a={},l={};function d(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={id:e,loaded:!1,exports:{}},r=!0;try{a[e](n,n.exports,d),r=!1}finally{r&&delete l[e]}return n.loaded=!0,n.exports}d.m=a,e=[],d.O=function(t,n,r,o){if(n){o=o||0;for(var u=e.length;u>0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u=o&&Object.keys(d.O).every(function(e){return d.O[e](n[f])})?n.splice(f--,1):(c=!1,o0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u=o&&Object.keys(d.O).every(function(e){return d.O[e](n[f])})?n.splice(f--,1):(c=!1,oLiteLLM 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 edb78dac3..aa1a67c15 100644 --- a/litellm/proxy/_experimental/out/index.txt +++ b/litellm/proxy/_experimental/out/index.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[45980,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","294","static/chunks/294-0e35509d5ca95267.js","131","static/chunks/131-6a03368053f9d26d.js","684","static/chunks/684-bb2d2f93d92acb0b.js","759","static/chunks/759-83a8bdddfe32b5d9.js","777","static/chunks/777-17b0c91edd3a24fe.js","931","static/chunks/app/page-bd882aee817406ff.js"],""] +3:I[45980,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","294","static/chunks/294-0e35509d5ca95267.js","131","static/chunks/131-6a03368053f9d26d.js","684","static/chunks/684-bb2d2f93d92acb0b.js","759","static/chunks/759-83a8bdddfe32b5d9.js","777","static/chunks/777-71fb78fdb4897cc3.js","931","static/chunks/app/page-d301c202a2cebcd3.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["48nWsJi-LJrUlOLzcK-Yz",[[["",{"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/f02cb03d96e276ef.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["Q9smtS3bJUKJtn7pvgodO",[[["",{"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_12bbc4","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/159e0004b5599df8.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/litellm/proxy/_experimental/out/model_hub.html b/litellm/proxy/_experimental/out/model_hub.html new file mode 100644 index 000000000..5b965b3bd --- /dev/null +++ b/litellm/proxy/_experimental/out/model_hub.html @@ -0,0 +1 @@ +LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/model_hub.txt b/litellm/proxy/_experimental/out/model_hub.txt index caaee3a57..b205cf508 100644 --- a/litellm/proxy/_experimental/out/model_hub.txt +++ b/litellm/proxy/_experimental/out/model_hub.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[87494,["294","static/chunks/294-0e35509d5ca95267.js","131","static/chunks/131-6a03368053f9d26d.js","777","static/chunks/777-17b0c91edd3a24fe.js","418","static/chunks/app/model_hub/page-4cb65c32467214b5.js"],""] +3:I[87494,["294","static/chunks/294-0e35509d5ca95267.js","131","static/chunks/131-6a03368053f9d26d.js","777","static/chunks/777-71fb78fdb4897cc3.js","418","static/chunks/app/model_hub/page-4cb65c32467214b5.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["48nWsJi-LJrUlOLzcK-Yz",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":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/f02cb03d96e276ef.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["Q9smtS3bJUKJtn7pvgodO",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_12bbc4","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/159e0004b5599df8.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/litellm/proxy/_experimental/out/onboarding.html b/litellm/proxy/_experimental/out/onboarding.html new file mode 100644 index 000000000..33efe1f8e --- /dev/null +++ b/litellm/proxy/_experimental/out/onboarding.html @@ -0,0 +1 @@ +LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/onboarding.txt b/litellm/proxy/_experimental/out/onboarding.txt index fd4d8cff6..4fcc6fff2 100644 --- a/litellm/proxy/_experimental/out/onboarding.txt +++ b/litellm/proxy/_experimental/out/onboarding.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[667,["665","static/chunks/3014691f-589a5f4865c3822f.js","294","static/chunks/294-0e35509d5ca95267.js","684","static/chunks/684-bb2d2f93d92acb0b.js","777","static/chunks/777-17b0c91edd3a24fe.js","461","static/chunks/app/onboarding/page-664c7288e11fff5a.js"],""] +3:I[667,["665","static/chunks/3014691f-589a5f4865c3822f.js","294","static/chunks/294-0e35509d5ca95267.js","684","static/chunks/684-bb2d2f93d92acb0b.js","777","static/chunks/777-71fb78fdb4897cc3.js","461","static/chunks/app/onboarding/page-664c7288e11fff5a.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["48nWsJi-LJrUlOLzcK-Yz",[[["",{"children":["onboarding",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["onboarding",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","onboarding","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":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/f02cb03d96e276ef.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["Q9smtS3bJUKJtn7pvgodO",[[["",{"children":["onboarding",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["onboarding",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","onboarding","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_12bbc4","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/159e0004b5599df8.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/litellm/proxy/_types.py b/litellm/proxy/_types.py index 1930a0faa..ccc8ed347 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -224,6 +224,7 @@ class LiteLLMRoutes(enum.Enum): "/key/delete", "/global/spend/logs", "/global/predict/spend/logs", + "/sso/get/logout_url", ] management_routes: List = [ # key diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.py index 089d469af..d8dc798f0 100644 --- a/litellm/proxy/litellm_pre_call_utils.py +++ b/litellm/proxy/litellm_pre_call_utils.py @@ -79,10 +79,6 @@ async def add_litellm_data_to_request( data["cache"][k] = v verbose_proxy_logger.debug("receiving data: %s", data) - # users can pass in 'user' param to /chat/completions. Don't override it - if data.get("user", None) is None and user_api_key_dict.user_id is not None: - # if users are using user_api_key_auth, set `user` in `data` - data["user"] = user_api_key_dict.user_id if "metadata" not in data: data["metadata"] = {} diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yaml index 3c6b2f201..a21378f31 100644 --- a/litellm/proxy/proxy_config.yaml +++ b/litellm/proxy/proxy_config.yaml @@ -14,10 +14,9 @@ model_list: litellm_params: model: openai/* api_key: os.environ/OPENAI_API_KEY - - model_name: my-triton-model + - model_name: mistral-embed litellm_params: - model: triton/any" - api_base: https://exampleopenaiendpoint-production.up.railway.app/triton/embeddings + model: mistral/mistral-embed general_settings: master_key: sk-1234 diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index d1591d188..1ab6ade0e 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -879,6 +879,7 @@ async def user_api_key_auth( ## check for cache hit (In-Memory Cache) original_api_key = api_key # (Patch: For DynamoDB Backwards Compatibility) + _user_role = None if api_key.startswith("sk-"): api_key = hash_token(token=api_key) valid_token: Optional[UserAPIKeyAuth] = user_api_key_cache.get_cache( # type: ignore @@ -1512,7 +1513,7 @@ async def user_api_key_auth( ): return UserAPIKeyAuth( api_key=api_key, - user_role="app_owner", + user_role=_user_role, parent_otel_span=parent_otel_span, **valid_token_dict, ) @@ -8857,7 +8858,7 @@ async def new_user(data: NewUserRequest): - organization_id: Optional[str] - specify the org a user belongs to. - user_email: Optional[str] - Specify a user email. - send_invite_email: Optional[bool] - Specify if an invite email should be sent. - - user_role: Optional[str] - Specify a user role - "admin", "app_owner", "app_user" + - user_role: Optional[str] - Specify a user role - "proxy_admin", "proxy_admin_viewer", "internal_user", "internal_user_viewer", "team", "customer". Info about each role here: `https://github.com/BerriAI/litellm/litellm/proxy/_types.py#L20` - max_budget: Optional[float] - Specify max budget for a given user. - models: Optional[list] - Model_name's a user is allowed to call. (if empty, key is allowed to call all models) - tpm_limit: Optional[int] - Specify tpm limit for a given user (Tokens per minute) @@ -14737,6 +14738,22 @@ async def cache_flushall(): ) +@router.get( + "/get/litellm_model_cost_map", + include_in_schema=False, + dependencies=[Depends(user_api_key_auth)], +) +async def get_litellm_model_cost_map(): + try: + _model_cost_map = litellm.model_cost + return _model_cost_map + except Exception as e: + raise HTTPException( + status_code=500, + detail=f"Internal Server Error ({str(e)})", + ) + + @router.get("/", dependencies=[Depends(user_api_key_auth)]) async def home(request: Request): return "LiteLLM: RUNNING" diff --git a/litellm/router.py b/litellm/router.py index 251c9eebc..4d7a36a38 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -3618,6 +3618,7 @@ class Router: except Exception: model_info = None # get llm provider + model, llm_provider = "", "" try: model, llm_provider, _, _ = litellm.get_llm_provider( model=litellm_params.model, diff --git a/litellm/tests/test_amazing_vertex_completion.py b/litellm/tests/test_amazing_vertex_completion.py index 3037f51e6..7281b8a08 100644 --- a/litellm/tests/test_amazing_vertex_completion.py +++ b/litellm/tests/test_amazing_vertex_completion.py @@ -905,10 +905,17 @@ def test_vertexai_embedding_embedding_latest(): try: load_vertex_ai_credentials() litellm.set_verbose = True + response = embedding( model="vertex_ai/text-embedding-004", - input=["good morning from litellm", "this is another item"], + input=["hi"], + dimensions=1, + auto_truncate=True, + task_type="RETRIEVAL_QUERY", ) + + assert len(response.data[0]["embedding"]) == 1 + assert response.usage.prompt_tokens > 0 print(f"response:", response) except litellm.RateLimitError as e: pass diff --git a/litellm/tests/test_bedrock_completion.py b/litellm/tests/test_bedrock_completion.py index 64e7741e2..b953ca2a3 100644 --- a/litellm/tests/test_bedrock_completion.py +++ b/litellm/tests/test_bedrock_completion.py @@ -220,13 +220,13 @@ def test_completion_bedrock_claude_sts_oidc_auth(): aws_web_identity_token = "oidc/circleci_v2/" aws_region_name = os.environ["AWS_REGION_NAME"] # aws_role_name = os.environ["AWS_TEMP_ROLE_NAME"] - # TODO: This is using David's IAM role, we should use Litellm's IAM role eventually + # TODO: This is using ai.moda's IAM role, we should use LiteLLM's IAM role eventually aws_role_name = "arn:aws:iam::335785316107:role/litellm-github-unit-tests-circleci" try: litellm.set_verbose = True - response = completion( + response_1 = completion( model="bedrock/anthropic.claude-3-haiku-20240307-v1:0", messages=messages, max_tokens=10, @@ -236,8 +236,40 @@ def test_completion_bedrock_claude_sts_oidc_auth(): aws_role_name=aws_role_name, aws_session_name="my-test-session", ) - # Add any assertions here to check the response - print(response) + print(response_1) + assert len(response_1.choices) > 0 + assert len(response_1.choices[0].message.content) > 0 + + # This second call is to verify that the cache isn't breaking anything + response_2 = completion( + model="bedrock/anthropic.claude-3-haiku-20240307-v1:0", + messages=messages, + max_tokens=5, + temperature=0.2, + aws_region_name=aws_region_name, + aws_web_identity_token=aws_web_identity_token, + aws_role_name=aws_role_name, + aws_session_name="my-test-session", + ) + print(response_2) + assert len(response_2.choices) > 0 + assert len(response_2.choices[0].message.content) > 0 + + # This third call is to verify that the cache isn't used for a different region + response_3 = completion( + model="bedrock/anthropic.claude-3-haiku-20240307-v1:0", + messages=messages, + max_tokens=6, + temperature=0.3, + aws_region_name="us-east-1", + aws_web_identity_token=aws_web_identity_token, + aws_role_name=aws_role_name, + aws_session_name="my-test-session", + ) + print(response_3) + assert len(response_3.choices) > 0 + assert len(response_3.choices[0].message.content) > 0 + except RateLimitError: pass except Exception as e: @@ -255,7 +287,7 @@ def test_completion_bedrock_httpx_command_r_sts_oidc_auth(): aws_web_identity_token = "oidc/circleci_v2/" aws_region_name = os.environ["AWS_REGION_NAME"] # aws_role_name = os.environ["AWS_TEMP_ROLE_NAME"] - # TODO: This is using David's IAM role, we should use Litellm's IAM role eventually + # TODO: This is using ai.moda's IAM role, we should use LiteLLM's IAM role eventually aws_role_name = "arn:aws:iam::335785316107:role/litellm-github-unit-tests-circleci" try: diff --git a/litellm/tests/test_streaming.py b/litellm/tests/test_streaming.py index c23dbb7d9..7eafa8a60 100644 --- a/litellm/tests/test_streaming.py +++ b/litellm/tests/test_streaming.py @@ -557,7 +557,13 @@ async def test_completion_predibase_streaming(sync_mode): print(f"complete_response: {complete_response}") except litellm.Timeout as e: pass + except litellm.InternalServerError as e: + pass except Exception as e: + print("ERROR class", e.__class__) + print("ERROR message", e) + print("ERROR traceback", traceback.format_exc()) + pytest.fail(f"Error occurred: {e}") diff --git a/litellm/utils.py b/litellm/utils.py index cfec3fd4a..dbde3c1a1 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -4903,6 +4903,18 @@ def get_optional_params_embeddings( ) final_params = {**optional_params, **kwargs} return final_params + if custom_llm_provider == "vertex_ai": + supported_params = get_supported_openai_params( + model=model, + custom_llm_provider="vertex_ai", + request_type="embeddings", + ) + _check_valid_arg(supported_params=supported_params) + optional_params = litellm.VertexAITextEmbeddingConfig().map_openai_params( + non_default_params=non_default_params, optional_params={} + ) + final_params = {**optional_params, **kwargs} + return final_params if custom_llm_provider == "vertex_ai": if len(non_default_params.keys()) > 0: if litellm.drop_params is True: # drop the unsupported non-default values @@ -4936,7 +4948,18 @@ def get_optional_params_embeddings( message=f"Setting user/encoding format is not supported by {custom_llm_provider}. To drop it from the call, set `litellm.drop_params = True`.", ) return {**non_default_params, **kwargs} - + if custom_llm_provider == "mistral": + supported_params = get_supported_openai_params( + model=model, + custom_llm_provider="mistral", + request_type="embeddings", + ) + _check_valid_arg(supported_params=supported_params) + optional_params = litellm.MistralEmbeddingConfig().map_openai_params( + non_default_params=non_default_params, optional_params={} + ) + final_params = {**optional_params, **kwargs} + return final_params if ( custom_llm_provider != "openai" and custom_llm_provider != "azure" @@ -6355,7 +6378,10 @@ def get_supported_openai_params( "max_retries", ] elif custom_llm_provider == "mistral": - return litellm.MistralConfig().get_supported_openai_params() + if request_type == "chat_completion": + return litellm.MistralConfig().get_supported_openai_params() + elif request_type == "embeddings": + return litellm.MistralEmbeddingConfig().get_supported_openai_params() elif custom_llm_provider == "replicate": return [ "stream", @@ -6397,7 +6423,10 @@ def get_supported_openai_params( elif custom_llm_provider == "palm" or custom_llm_provider == "gemini": return ["temperature", "top_p", "stream", "n", "stop", "max_tokens"] elif custom_llm_provider == "vertex_ai": - return litellm.VertexAIConfig().get_supported_openai_params() + if request_type == "chat_completion": + return litellm.VertexAIConfig().get_supported_openai_params() + elif request_type == "embeddings": + return litellm.VertexAITextEmbeddingConfig().get_supported_openai_params() elif custom_llm_provider == "sagemaker": return ["stream", "temperature", "max_tokens", "top_p", "stop", "n"] elif custom_llm_provider == "aleph_alpha": @@ -7207,6 +7236,9 @@ def get_provider_fields(custom_llm_provider: str) -> List[ProviderField]: elif custom_llm_provider == "ollama": return litellm.OllamaConfig().get_required_params() + elif custom_llm_provider == "azure_ai": + return litellm.AzureAIStudioConfig().get_required_params() + else: return [] @@ -10081,6 +10113,14 @@ def get_secret( return oidc_token else: raise ValueError("Github OIDC provider failed") + elif oidc_provider == "azure": + # https://azure.github.io/azure-workload-identity/docs/quick-start.html + azure_federated_token_file = os.getenv("AZURE_FEDERATED_TOKEN_FILE") + if azure_federated_token_file is None: + raise ValueError("AZURE_FEDERATED_TOKEN_FILE not found in environment") + with open(azure_federated_token_file, "r") as f: + oidc_token = f.read() + return oidc_token else: raise ValueError("Unsupported OIDC provider") diff --git a/proxy_server_config.yaml b/proxy_server_config.yaml index f9f77c05a..f1853dc83 100644 --- a/proxy_server_config.yaml +++ b/proxy_server_config.yaml @@ -85,6 +85,9 @@ model_list: litellm_params: model: openai/* api_key: os.environ/OPENAI_API_KEY + - model_name: mistral-embed + litellm_params: + model: mistral/mistral-embed - model_name: gpt-instruct # [PROD TEST] - tests if `/health` automatically infers this to be a text completion model litellm_params: model: text-completion-openai/gpt-3.5-turbo-instruct diff --git a/pyproject.toml b/pyproject.toml index 8ce9c280a..462ebb642 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm" -version = "1.40.9" +version = "1.40.10" description = "Library to easily interface with LLM API providers" authors = ["BerriAI"] license = "MIT" @@ -85,7 +85,7 @@ requires = ["poetry-core", "wheel"] build-backend = "poetry.core.masonry.api" [tool.commitizen] -version = "1.40.9" +version = "1.40.10" version_files = [ "pyproject.toml:^version" ] diff --git a/tests/test_openai_endpoints.py b/tests/test_openai_endpoints.py index 83d387ffb..e2f600b76 100644 --- a/tests/test_openai_endpoints.py +++ b/tests/test_openai_endpoints.py @@ -22,6 +22,7 @@ async def generate_key( "text-embedding-ada-002", "dall-e-2", "fake-openai-endpoint-2", + "mistral-embed", ], ): url = "http://0.0.0.0:4000/key/generate" @@ -197,14 +198,14 @@ async def completion(session, key): return response -async def embeddings(session, key): +async def embeddings(session, key, model="text-embedding-ada-002"): url = "http://0.0.0.0:4000/embeddings" headers = { "Authorization": f"Bearer {key}", "Content-Type": "application/json", } data = { - "model": "text-embedding-ada-002", + "model": model, "input": ["hello world"], } @@ -408,6 +409,9 @@ async def test_embeddings(): key_2 = key_gen["key"] await embeddings(session=session, key=key_2) + # embedding request with non OpenAI model + await embeddings(session=session, key=key, model="mistral-embed") + @pytest.mark.asyncio async def test_image_generation(): diff --git a/ui/litellm-dashboard/out/404.html b/ui/litellm-dashboard/out/404.html index fc813d761..e97c72fc1 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/48nWsJi-LJrUlOLzcK-Yz/_buildManifest.js b/ui/litellm-dashboard/out/_next/static/Q9smtS3bJUKJtn7pvgodO/_buildManifest.js similarity index 100% rename from ui/litellm-dashboard/out/_next/static/48nWsJi-LJrUlOLzcK-Yz/_buildManifest.js rename to ui/litellm-dashboard/out/_next/static/Q9smtS3bJUKJtn7pvgodO/_buildManifest.js diff --git a/ui/litellm-dashboard/out/_next/static/48nWsJi-LJrUlOLzcK-Yz/_ssgManifest.js b/ui/litellm-dashboard/out/_next/static/Q9smtS3bJUKJtn7pvgodO/_ssgManifest.js similarity index 100% rename from ui/litellm-dashboard/out/_next/static/48nWsJi-LJrUlOLzcK-Yz/_ssgManifest.js rename to ui/litellm-dashboard/out/_next/static/Q9smtS3bJUKJtn7pvgodO/_ssgManifest.js diff --git a/ui/litellm-dashboard/out/_next/static/chunks/777-17b0c91edd3a24fe.js b/ui/litellm-dashboard/out/_next/static/chunks/777-17b0c91edd3a24fe.js deleted file mode 100644 index f6e7b217f..000000000 --- a/ui/litellm-dashboard/out/_next/static/chunks/777-17b0c91edd3a24fe.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[777],{777:function(e,t,o){o.d(t,{AZ:function(){return j},Au:function(){return V},BL:function(){return $},Br:function(){return k},Dj:function(){return ec},E9:function(){return et},EY:function(){return en},FC:function(){return Z},Gh:function(){return K},HK:function(){return z},I1:function(){return u},J$:function(){return b},K_:function(){return ea},N8:function(){return N},NV:function(){return i},Nc:function(){return D},O3:function(){return Y},OU:function(){return v},Og:function(){return s},Ov:function(){return p},Qy:function(){return m},RQ:function(){return d},Rg:function(){return F},So:function(){return A},W_:function(){return g},X:function(){return x},XO:function(){return h},Xd:function(){return X},Xm:function(){return f},YU:function(){return ee},Zr:function(){return l},ao:function(){return er},b1:function(){return S},cu:function(){return H},e2:function(){return U},fP:function(){return P},hT:function(){return q},hy:function(){return c},j2:function(){return B},jA:function(){return eo},jE:function(){return W},kK:function(){return n},kn:function(){return E},lg:function(){return M},mR:function(){return C},m_:function(){return T},n$:function(){return I},o6:function(){return _},pf:function(){return Q},qm:function(){return a},rs:function(){return y},tN:function(){return O},um:function(){return L},v9:function(){return R},wX:function(){return w},wd:function(){return G},xA:function(){return J}});var r=o(80588);let a=async()=>{try{let e=await fetch("https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"),t=await e.json();return console.log("received data: ".concat(t)),t}catch(e){throw console.error("Failed to get model cost map:",e),e}},n=async(e,t)=>{try{let o=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),r.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),a}catch(e){throw console.error("Failed to create key:",e),e}},c=async e=>{try{let t=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},s=async(e,t)=>{console.log("model_id in model delete call: ".concat(t));try{let o=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),r.ZP.success("Model deleted successfully. Restart server to see this."),a}catch(e){throw console.error("Failed to create key:",e),e}},i=async(e,t)=>{if(console.log("budget_id in budget delete call: ".concat(t)),null!=e)try{let o=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},l=async(e,t)=>{try{console.log("Form Values in budgetCreateCall:",t),console.log("Form Values after check:",t);let o=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},h=async(e,t)=>{try{let o=await fetch("/invitation/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},d=async e=>{try{let t=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},w=async(e,t,o)=>{try{if(console.log("Form Values in keyCreateCall:",o),o.description&&(o.metadata||(o.metadata={}),o.metadata.description=o.description,delete o.description,o.metadata=JSON.stringify(o.metadata)),o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw r.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",o);let a=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},p=async(e,t,o)=>{try{if(console.log("Form Values in keyCreateCall:",o),o.description&&(o.metadata||(o.metadata={}),o.metadata.description=o.description,delete o.description,o.metadata=JSON.stringify(o.metadata)),o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw r.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",o);let a=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},u=async(e,t)=>{try{console.log("in keyDeleteCall:",t);let o=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[t]})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,t)=>{try{console.log("in teamDeleteCall:",t);let o=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[t]})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4?arguments[4]:void 0,c=arguments.length>5?arguments[5]:void 0;try{let s="/user/info";"App Owner"==o&&t&&(s="".concat(s,"?user_id=").concat(t)),"App User"==o&&t&&(s="".concat(s,"?user_id=").concat(t)),("Internal User"==o||"Internal Viewer"==o)&&t&&(s="".concat(s,"?user_id=").concat(t)),console.log("in userInfoCall viewAll=",a),a&&c&&null!=n&&void 0!=n&&(s="".concat(s,"?view_all=true&page=").concat(n,"&page_size=").concat(c));let i=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let l=await i.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},f=async(e,t)=>{try{let o="/team/info";t&&(o="".concat(o,"?team_id=").concat(t)),console.log("in teamInfoCall");let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},m=async e=>{try{let t=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.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}},g=async e=>{try{let t="/onboarding/get_token";t+="?invite_link=".concat(e);let o=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,t,o,a)=>{try{let n=await fetch("/onboarding/claim_token",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({invitation_link:t,user_id:o,password:a})});if(!n.ok){let e=await n.text();throw r.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to delete key:",e),e}},j=async(e,t,o)=>{try{let t=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log("modelInfoCall:",o),o}catch(e){throw console.error("Failed to create key:",e),e}},E=async e=>{try{let t=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log("modelHubCall:",o),o}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},F=async(e,t,o,a)=>{try{let n="/model/streaming_metrics";t&&(n="".concat(n,"?_selected_model_group=").concat(t,"&startTime=").concat(o,"&endTime=").concat(a));let c=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await c.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics/slow_responses";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics/exceptions";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,t,o)=>{try{let t=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.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}},C=async e=>{try{let t="/global/spend/teams";console.log("in teamSpendLogsCall:",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,t,o,r)=>{try{let a="/global/spend/tags";t&&o&&(a="".concat(a,"?start_date=").concat(t,"&end_date=").concat(o)),r&&(a+="".concat(a,"&tags=").concat(r.join(","))),console.log("in tagsSpendLogsCall:",a);let n=await fetch("".concat(a),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to create key:",e),e}},x=async e=>{try{let t="/global/spend/all_tag_names";console.log("in global/spend/all_tag_names call",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");let r=await o.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},B=async e=>{try{let t="/global/all_end_users";console.log("in global/all_end_users call",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");let r=await o.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},z=async(e,t,o,a,n,c)=>{try{console.log("user role in spend logs call: ".concat(o));let t="/spend/logs";t="App Owner"==o?"".concat(t,"?user_id=").concat(a,"&start_date=").concat(n,"&end_date=").concat(c):"".concat(t,"?start_date=").concat(n,"&end_date=").concat(c);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 r.ZP.error(e,10),Error("Network response was not ok")}let i=await s.json();return console.log(i),i}catch(e){throw console.error("Failed to create key:",e),e}},Z=async e=>{try{let t=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},O=async e=>{try{let t=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},S=async(e,t,o,a)=>{try{let n="";n=t?JSON.stringify({api_key:t,startTime:o,endTime:a}):JSON.stringify({startTime:o,endTime:a});let c={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};c.body=n;let s=await fetch("/global/spend/end_users",c);if(!s.ok){let e=await s.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let i=await s.json();return console.log(i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,t,o,a)=>{try{let n="/global/spend/provider";o&&a&&(n+="?start_date=".concat(o,"&end_date=").concat(a)),t&&(n+="&api_key=".concat(t));let c=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!c.ok){let e=await c.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let s=await c.json();return console.log(s),s}catch(e){throw console.error("Failed to fetch spend data:",e),e}},G=async(e,t,o)=>{try{let r="/global/activity";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok)throw await a.text(),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}},J=async(e,t,o)=>{try{let r="/global/activity/model";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok)throw await a.text(),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}},I=async(e,t,o,r)=>{try{let a="/global/activity/exceptions";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o)),r&&(a+="&model_group=".concat(r));let n=await fetch(a,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to fetch spend data:",e),e}},R=async(e,t,o,r)=>{try{let a="/global/activity/exceptions/deployment";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o)),r&&(a+="&model_group=".concat(r));let n=await fetch(a,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to fetch spend data:",e),e}},V=async e=>{try{let t=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,t)=>{try{let o=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:t})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,t)=>{try{let o="/user/get_users?role=".concat(t);console.log("in userGetAllUsersCall:",o);let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to delete key: "+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 get requested models:",e),e}},M=async e=>{try{let t=await fetch("/user/available_roles",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok)throw await t.text(),Error("Network response was not ok");let o=await t.json();return console.log("response from user/available_role",o),o}catch(e){throw e}},q=async(e,t)=>{try{console.log("Form Values in teamCreateCall:",t);let o=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,t)=>{try{console.log("Form Values in keyUpdateCall:",t);let o=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update key Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},K=async(e,t)=>{try{console.log("Form Values in teamUpateCall:",t);let o=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update Team Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},L=async(e,t)=>{try{console.log("Form Values in modelUpateCall:",t);let o=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update model Response:",a),a}catch(e){throw console.error("Failed to update model:",e),e}},H=async(e,t,o)=>{try{console.log("Form Values in teamMemberAddCall:",o);let a=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,member:o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},Q=async(e,t,o)=>{try{console.log("Form Values in userUpdateUserCall:",t);let a={...t};null!==o&&(a.user_role=o),a=JSON.stringify(a);let n=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:a});if(!n.ok){let e=await n.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let c=await n.json();return console.log("API Response:",c),c}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,t)=>{try{let o="/health/services?service=".concat(t);console.log("Checking Slack Budget Alerts service health");let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed ".concat(t," service health check ")+e),Error(e)}let n=await a.json();return r.ZP.success("Test request to ".concat(t," made - check logs/alerts on ").concat(t," to verify")),n}catch(e){throw console.error("Failed to perform health check:",e),e}},Y=async e=>{try{let t=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},$=async(e,t,o)=>{try{let t=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async e=>{try{let t=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,t)=>{try{let o=await fetch("/config/field/info?field_name=".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");return await o.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},eo=async(e,t,o)=>{try{let a=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,field_value:o,config_type:"general_settings"})});if(!a.ok){let e=await a.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return r.ZP.success("Successfully updated value!"),n}catch(e){throw console.error("Failed to set callbacks:",e),e}},er=async(e,t)=>{try{let o=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,config_type:"general_settings"})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return r.ZP.success("Field reset on proxy"),a}catch(e){throw console.error("Failed to get callbacks:",e),e}},ea=async(e,t)=>{try{let o=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},en=async e=>{try{let t=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to call /health:",e),e}},ec=async e=>{try{let t=await fetch("/sso/get/logout_url",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}}}}]); \ No newline at end of file diff --git a/ui/litellm-dashboard/out/_next/static/chunks/777-71fb78fdb4897cc3.js b/ui/litellm-dashboard/out/_next/static/chunks/777-71fb78fdb4897cc3.js new file mode 100644 index 000000000..371adff18 --- /dev/null +++ b/ui/litellm-dashboard/out/_next/static/chunks/777-71fb78fdb4897cc3.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[777],{777:function(e,t,o){o.d(t,{AZ:function(){return j},Au:function(){return V},BL:function(){return $},Br:function(){return k},Dj:function(){return ec},E9:function(){return et},EY:function(){return en},FC:function(){return Z},Gh:function(){return K},HK:function(){return z},I1:function(){return u},J$:function(){return b},K_:function(){return ea},N8:function(){return P},NV:function(){return i},Nc:function(){return D},O3:function(){return Y},OU:function(){return v},Og:function(){return s},Ov:function(){return p},Qy:function(){return m},RQ:function(){return d},Rg:function(){return _},So:function(){return A},W_:function(){return g},X:function(){return x},XO:function(){return h},Xd:function(){return X},Xm:function(){return f},YU:function(){return ee},Zr:function(){return l},ao:function(){return er},b1:function(){return S},cu:function(){return H},e2:function(){return U},fP:function(){return N},hT:function(){return q},hy:function(){return c},j2:function(){return B},jA:function(){return eo},jE:function(){return W},kK:function(){return n},kn:function(){return E},lg:function(){return M},mR:function(){return C},m_:function(){return T},n$:function(){return R},o6:function(){return F},pf:function(){return Q},qm:function(){return a},rs:function(){return y},tN:function(){return O},um:function(){return L},v9:function(){return I},wX:function(){return w},wd:function(){return G},xA:function(){return J}});var r=o(80588);let a=async()=>{try{let e=await fetch("/get/litellm_model_cost_map"),t=await e.json();return console.log("received litellm model cost data: ".concat(t)),t}catch(e){throw console.error("Failed to get model cost map:",e),e}},n=async(e,t)=>{try{let o=await fetch("/model/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),r.ZP.success("Model created successfully. Wait 60s and refresh on 'All Models' page"),a}catch(e){throw console.error("Failed to create key:",e),e}},c=async e=>{try{let t=await fetch("/model/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},s=async(e,t)=>{console.log("model_id in model delete call: ".concat(t));try{let o=await fetch("/model/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),r.ZP.success("Model deleted successfully. Restart server to see this."),a}catch(e){throw console.error("Failed to create key:",e),e}},i=async(e,t)=>{if(console.log("budget_id in budget delete call: ".concat(t)),null!=e)try{let o=await fetch("/budget/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},l=async(e,t)=>{try{console.log("Form Values in budgetCreateCall:",t),console.log("Form Values after check:",t);let o=await fetch("/budget/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},h=async(e,t)=>{try{let o=await fetch("/invitation/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},d=async e=>{try{let t=await fetch("/alerting/settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},w=async(e,t,o)=>{try{if(console.log("Form Values in keyCreateCall:",o),o.description&&(o.metadata||(o.metadata={}),o.metadata.description=o.description,delete o.description,o.metadata=JSON.stringify(o.metadata)),o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw r.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",o);let a=await fetch("/key/generate",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},p=async(e,t,o)=>{try{if(console.log("Form Values in keyCreateCall:",o),o.description&&(o.metadata||(o.metadata={}),o.metadata.description=o.description,delete o.description,o.metadata=JSON.stringify(o.metadata)),o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw r.ZP.error("Failed to parse metadata: "+e,10),Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",o);let a=await fetch("/user/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},u=async(e,t)=>{try{console.log("in keyDeleteCall:",t);let o=await fetch("/key/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[t]})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to delete key: "+e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},y=async(e,t)=>{try{console.log("in teamDeleteCall:",t);let o=await fetch("/team/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[t]})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to delete key:",e),e}},k=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4?arguments[4]:void 0,c=arguments.length>5?arguments[5]:void 0;try{let s="/user/info";"App Owner"==o&&t&&(s="".concat(s,"?user_id=").concat(t)),"App User"==o&&t&&(s="".concat(s,"?user_id=").concat(t)),("Internal User"==o||"Internal Viewer"==o)&&t&&(s="".concat(s,"?user_id=").concat(t)),console.log("in userInfoCall viewAll=",a),a&&c&&null!=n&&void 0!=n&&(s="".concat(s,"?view_all=true&page=").concat(n,"&page_size=").concat(c));let i=await fetch(s,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let l=await i.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},f=async(e,t)=>{try{let o="/team/info";t&&(o="".concat(o,"?team_id=").concat(t)),console.log("in teamInfoCall");let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},m=async e=>{try{let t=await fetch("/global/spend",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.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}},g=async e=>{try{let t="/onboarding/get_token";t+="?invite_link=".concat(e);let o=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},T=async(e,t,o,a)=>{try{let n=await fetch("/onboarding/claim_token",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({invitation_link:t,user_id:o,password:a})});if(!n.ok){let e=await n.text();throw r.ZP.error("Failed to delete team: "+e,10),Error("Network response was not ok")}let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to delete key:",e),e}},j=async(e,t,o)=>{try{let t=await fetch("/v2/model/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log("modelInfoCall:",o),o}catch(e){throw console.error("Failed to create key:",e),e}},E=async e=>{try{let t=await fetch("/model_group/info",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log("modelHubCall:",o),o}catch(e){throw console.error("Failed to create key:",e),e}},F=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},_=async(e,t,o,a)=>{try{let n="/model/streaming_metrics";t&&(n="".concat(n,"?_selected_model_group=").concat(t,"&startTime=").concat(o,"&endTime=").concat(a));let c=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await c.json()}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics/slow_responses";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,t,o,a,n,c,s,i)=>{try{let t="/model/metrics/exceptions";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(n,"&endTime=").concat(c,"&api_key=").concat(s,"&customer=").concat(i));let o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,t,o)=>{try{let t=await fetch("/models",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.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}},C=async e=>{try{let t="/global/spend/teams";console.log("in teamSpendLogsCall:",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},b=async(e,t,o,r)=>{try{let a="/global/spend/tags";t&&o&&(a="".concat(a,"?start_date=").concat(t,"&end_date=").concat(o)),r&&(a+="".concat(a,"&tags=").concat(r.join(","))),console.log("in tagsSpendLogsCall:",a);let n=await fetch("".concat(a),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to create key:",e),e}},x=async e=>{try{let t="/global/spend/all_tag_names";console.log("in global/spend/all_tag_names call",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");let r=await o.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},B=async e=>{try{let t="/global/all_end_users";console.log("in global/all_end_users call",t);let o=await fetch("".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");let r=await o.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},z=async(e,t,o,a,n,c)=>{try{console.log("user role in spend logs call: ".concat(o));let t="/spend/logs";t="App Owner"==o?"".concat(t,"?user_id=").concat(a,"&start_date=").concat(n,"&end_date=").concat(c):"".concat(t,"?start_date=").concat(n,"&end_date=").concat(c);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 r.ZP.error(e,10),Error("Network response was not ok")}let i=await s.json();return console.log(i),i}catch(e){throw console.error("Failed to create key:",e),e}},Z=async e=>{try{let t=await fetch("/global/spend/logs",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},O=async e=>{try{let t=await fetch("/global/spend/keys?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},S=async(e,t,o,a)=>{try{let n="";n=t?JSON.stringify({api_key:t,startTime:o,endTime:a}):JSON.stringify({startTime:o,endTime:a});let c={method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}};c.body=n;let s=await fetch("/global/spend/end_users",c);if(!s.ok){let e=await s.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let i=await s.json();return console.log(i),i}catch(e){throw console.error("Failed to create key:",e),e}},v=async(e,t,o,a)=>{try{let n="/global/spend/provider";o&&a&&(n+="?start_date=".concat(o,"&end_date=").concat(a)),t&&(n+="&api_key=".concat(t));let c=await fetch(n,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!c.ok){let e=await c.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let s=await c.json();return console.log(s),s}catch(e){throw console.error("Failed to fetch spend data:",e),e}},G=async(e,t,o)=>{try{let r="/global/activity";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok)throw await a.text(),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}},J=async(e,t,o)=>{try{let r="/global/activity/model";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o));let a=await fetch(r,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!a.ok)throw await a.text(),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}},R=async(e,t,o,r)=>{try{let a="/global/activity/exceptions";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o)),r&&(a+="&model_group=".concat(r));let n=await fetch(a,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to fetch spend data:",e),e}},I=async(e,t,o,r)=>{try{let a="/global/activity/exceptions/deployment";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o)),r&&(a+="&model_group=".concat(r));let n=await fetch(a,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!n.ok)throw await n.text(),Error("Network response was not ok");let c=await n.json();return console.log(c),c}catch(e){throw console.error("Failed to fetch spend data:",e),e}},V=async e=>{try{let t=await fetch("/global/spend/models?limit=5",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let o=await t.json();return console.log(o),o}catch(e){throw console.error("Failed to create key:",e),e}},U=async(e,t)=>{try{let o=await fetch("/v2/key/info",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:t})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,t)=>{try{let o="/user/get_users?role=".concat(t);console.log("in userGetAllUsersCall:",o);let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to delete key: "+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 get requested models:",e),e}},M=async e=>{try{let t=await fetch("/user/available_roles",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok)throw await t.text(),Error("Network response was not ok");let o=await t.json();return console.log("response from user/available_role",o),o}catch(e){throw e}},q=async(e,t)=>{try{console.log("Form Values in teamCreateCall:",t);let o=await fetch("/team/new",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.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 o.json();return console.log("API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},D=async(e,t)=>{try{console.log("Form Values in keyUpdateCall:",t);let o=await fetch("/key/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update key Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},K=async(e,t)=>{try{console.log("Form Values in teamUpateCall:",t);let o=await fetch("/team/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update team: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update Team Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},L=async(e,t)=>{try{console.log("Form Values in modelUpateCall:",t);let o=await fetch("/model/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error("Failed to update model: "+e,10),console.error("Error update from the server:",e),Error("Network response was not ok")}let a=await o.json();return console.log("Update model Response:",a),a}catch(e){throw console.error("Failed to update model:",e),e}},H=async(e,t,o)=>{try{console.log("Form Values in teamMemberAddCall:",o);let a=await fetch("/team/member_add",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,member:o})});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},Q=async(e,t,o)=>{try{console.log("Form Values in userUpdateUserCall:",t);let a={...t};null!==o&&(a.user_role=o),a=JSON.stringify(a);let n=await fetch("/user/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:a});if(!n.ok){let e=await n.text();throw r.ZP.error("Failed to create key: "+e,10),console.error("Error response from the server:",e),Error("Network response was not ok")}let c=await n.json();return console.log("API Response:",c),c}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,t)=>{try{let o="/health/services?service=".concat(t);console.log("Checking Slack Budget Alerts service health");let a=await fetch(o,{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw r.ZP.error("Failed ".concat(t," service health check ")+e),Error(e)}let n=await a.json();return r.ZP.success("Test request to ".concat(t," made - check logs/alerts on ").concat(t," to verify")),n}catch(e){throw console.error("Failed to perform health check:",e),e}},Y=async e=>{try{let t=await fetch("/budget/list",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},$=async(e,t,o)=>{try{let t=await fetch("/get/config/callbacks",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ee=async e=>{try{let t=await fetch("/config/list?config_type=general_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},et=async(e,t)=>{try{let o=await fetch("/config/field/info?field_name=".concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");return await o.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},eo=async(e,t,o)=>{try{let a=await fetch("/config/field/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,field_value:o,config_type:"general_settings"})});if(!a.ok){let e=await a.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let n=await a.json();return r.ZP.success("Successfully updated value!"),n}catch(e){throw console.error("Failed to set callbacks:",e),e}},er=async(e,t)=>{try{let o=await fetch("/config/field/delete",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,config_type:"general_settings"})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}let a=await o.json();return r.ZP.success("Field reset on proxy"),a}catch(e){throw console.error("Failed to get callbacks:",e),e}},ea=async(e,t)=>{try{let o=await fetch("/config/update",{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!o.ok){let e=await o.text();throw r.ZP.error(e,10),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},en=async e=>{try{let t=await fetch("/health",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok){let e=await t.text();throw r.ZP.error(e),Error("Network response was not ok")}return await t.json()}catch(e){throw console.error("Failed to call /health:",e),e}},ec=async e=>{try{let t=await fetch("/sso/get/logout_url",{method:"GET",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!t.ok)throw await t.text(),Error("Network response was not ok");return await t.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}}}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/layout-cb827484903e98d8.js b/ui/litellm-dashboard/out/_next/static/chunks/app/layout-9bbef188642a56c0.js similarity index 54% rename from litellm/proxy/_experimental/out/_next/static/chunks/app/layout-cb827484903e98d8.js rename to ui/litellm-dashboard/out/_next/static/chunks/app/layout-9bbef188642a56c0.js index e261adc05..2fae6a1d3 100644 --- a/litellm/proxy/_experimental/out/_next/static/chunks/app/layout-cb827484903e98d8.js +++ b/ui/litellm-dashboard/out/_next/static/chunks/app/layout-9bbef188642a56c0.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{87421:function(n,e,t){Promise.resolve().then(t.t.bind(t,99646,23)),Promise.resolve().then(t.t.bind(t,63385,23))},63385:function(){},99646:function(n){n.exports={style:{fontFamily:"'__Inter_c23dc8', '__Inter_Fallback_c23dc8'",fontStyle:"normal"},className:"__className_c23dc8"}}},function(n){n.O(0,[971,69,744],function(){return n(n.s=87421)}),_N_E=n.O()}]); \ No newline at end of file +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{87421:function(n,e,t){Promise.resolve().then(t.t.bind(t,99646,23)),Promise.resolve().then(t.t.bind(t,63385,23))},63385:function(){},99646:function(n){n.exports={style:{fontFamily:"'__Inter_12bbc4', '__Inter_Fallback_12bbc4'",fontStyle:"normal"},className:"__className_12bbc4"}}},function(n){n.O(0,[971,69,744],function(){return n(n.s=87421)}),_N_E=n.O()}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-bd882aee817406ff.js b/ui/litellm-dashboard/out/_next/static/chunks/app/page-d301c202a2cebcd3.js similarity index 82% rename from litellm/proxy/_experimental/out/_next/static/chunks/app/page-bd882aee817406ff.js rename to ui/litellm-dashboard/out/_next/static/chunks/app/page-d301c202a2cebcd3.js index a5a509e8f..0361a3c21 100644 --- a/litellm/proxy/_experimental/out/_next/static/chunks/app/page-bd882aee817406ff.js +++ b/ui/litellm-dashboard/out/_next/static/chunks/app/page-d301c202a2cebcd3.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{20661:function(e,l,s){Promise.resolve().then(s.bind(s,45980))},45980:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return lt}});var t,n,a=s(3827),r=s(64090),i=s(47907),o=s(8792),d=s(40491),c=s(65270),m=e=>{let{userID:l,userRole:s,userEmail:t,showSSOBanner:n,premiumUser:r,setProxySettings:i,proxySettings:m}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("showSSOBanner:",n),console.log("premiumUser:",r);let u="";console.log("PROXY_settings=",m),m&&m.PROXY_LOGOUT_URL&&void 0!==m.PROXY_LOGOUT_URL&&(u=m.PROXY_LOGOUT_URL),console.log("logoutUrl=",u);let h=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",s]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(r)]})]})},{key:"2",label:(0,a.jsx)("a",{href:u,children:(0,a.jsx)("p",{children:"Logout"})})}];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)(o.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:[n?(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 enterprise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:h},children:(0,a.jsx)(c.Z,{children:t})})})]})]})},u=s(777),h=s(10384),x=s(46453),p=s(16450),j=s(52273),g=s(26780),Z=s(15595),f=s(6698),_=s(71801),y=s(42440),b=s(42308),v=s(50670),S=s(60620),k=s(80588),w=s(99129),N=s(44839),I=s(88707),A=s(1861);let{Option:C}=v.default;var P=e=>{let{userID:l,team:s,userRole:t,accessToken:n,data:i,setData:o}=e,[d]=S.Z.useForm(),[c,m]=(0,r.useState)(!1),[P,T]=(0,r.useState)(null),[E,O]=(0,r.useState)(null),[R,M]=(0,r.useState)([]),[F,L]=(0,r.useState)([]),D=()=>{m(!1),d.resetFields()},U=()=>{m(!1),T(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==n){let e=(await (0,u.So)(n,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),M(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let V=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",c=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(a=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));k.ZP.info("Making API Call"),m(!0);let h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),T(h.key),O(h.soft_budget),k.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.useEffect)(()=>{L(s&&s.models.length>0?s.models.includes("all-proxy-models")?R:s.models:R)},[s,R]),(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(w.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:D,onCancel:U,children:(0,a.jsxs)(S.Z,{form:d,onFinish:V,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(N.Z,{value:s?s.team_alias:"",disabled:!0})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(C,{value:"all-team-models",children:"All Team Models"},"all-team-models"),F.map(e=>(0,a.jsx)(C,{value:e,children:e},e))]})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==s?void 0:s.max_budget)!==null&&(null==s?void 0:s.max_budget)!==void 0?null==s?void 0:s.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.max_budget&&l>s.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(s.max_budget))}}],children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==s?void 0:s.budget_duration)!==null&&(null==s?void 0:s.budget_duration)!==void 0?null==s?void 0:s.budget_duration:"None"),children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==s?void 0:s.tpm_limit)!==null&&(null==s?void 0:s.tpm_limit)!==void 0?null==s?void 0:s.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.tpm_limit&&l>s.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(s.tpm_limit))}}],children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==s?void 0:s.rpm_limit)!==null&&(null==s?void 0:s.rpm_limit)!==void 0?null==s?void 0:s.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.rpm_limit&&l>s.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(s.rpm_limit))}}],children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Key"})})]})}),P&&(0,a.jsx)(w.Z,{visible:c,onOk:D,onCancel:U,footer:null,children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Save your Key"}),(0,a.jsx)(h.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)(h.Z,{numColSpan:1,children:null!=P?(0,a.jsxs)("div",{children:[(0,a.jsx)(_.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:P})}),(0,a.jsx)(b.CopyToClipboard,{text:P,onCopy:()=>{k.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(_.Z,{children:"Key being created, this might take 30s"})})]})})]})},T=s(9454),E=s(98941),O=s(33393),R=s(5),M=s(13810),F=s(61244),L=s(10827),D=s(3851),U=s(2044),V=s(64167),q=s(74480),z=s(7178),B=s(95093),K=s(27166);let{Option:W}=v.default;var G=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d}=e,[c,m]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)(null),[b,C]=(0,r.useState)(null),[P,G]=(0,r.useState)(""),[H,Y]=(0,r.useState)(!1),[J,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(null),[ee,el]=(0,r.useState)([]),es=new Set,[et,en]=(0,r.useState)(es);(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,u.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),el(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),en(e)}},[d]);let ea=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),Q(e),Y(!0)},er=async e=>{if(null==t)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let s=await (0,u.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),k.ZP.success("Key updated successfully"),Y(!1),Q(null)},ei=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(g(e.token),localStorage.removeItem("userData"+l),x(!0))},eo=async()=>{if(null!=j&&null!=i){try{await (0,u.I1)(t,j);let e=i.filter(e=>e.token!==j);o(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),g(null)}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(L.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Key Alias"}),(0,a.jsx)(q.Z,{children:"Secret Key"}),(0,a.jsx)(q.Z,{children:"Spend (USD)"}),(0,a.jsx)(q.Z,{children:"Budget (USD)"}),(0,a.jsx)(q.Z,{children:"Models"}),(0,a.jsx)(q.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(D.Z,{children:i.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(n){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(et.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||et.has(e.team_id))&&e.team_id!=n.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(_.Z,{children:e.key_alias}):(0,a.jsx)(_.Z,{children:"Not Set"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(U.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(U.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:n&&n.models&&n.models.length>0?n.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(_.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)(U.Z,{children:[(0,a.jsx)(F.Z,{onClick:()=>{Q(e),X(!0)},icon:T.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:J,onCancel:()=>{X(!1),Q(null)},footer:null,width:800,children:$&&(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)(M.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($.spend).toFixed(4)}catch(e){return $.spend}})()})})]}),(0,a.jsxs)(M.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!=$.max_budget?(0,a.jsx)(a.Fragment,{children:$.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(M.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!=$.expires?(0,a.jsx)(a.Fragment,{children:new Date($.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)(M.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:$.key_alias?$.key_alias:$.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:$.token}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify($.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{X(!1),Q(null)},children:"Close"})]})}),(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>ea(e)}),(0,a.jsx)(F.Z,{onClick:()=>ei(e),icon:O.Z,size:"sm"})]})]},e.token)})})]}),h&&(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)(p.Z,{onClick:eo,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{x(!1),g(null)},children:"Cancel"})]})]})]})})]}),$&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=S.Z.useForm(),[c,m]=(0,r.useState)(n),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(!1);return(0,a.jsx)(w.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:o,onFinish:er,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let s=l.filter(e=>!c.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!c.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(s)),s.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(s,"Team models: ").concat(c.models)):Promise.resolve()}}],children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(W,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ee.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(W,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(W,{value:e,children:e},e)):ee.map(e=>(0,a.jsx)(W,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==c?void 0:c.max_budget)!==null&&(null==c?void 0:c.max_budget)!==void 0?null==c?void 0:c.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.max_budget&&l>c.max_budget)throw console.log("keyTeam.max_budget: ".concat(c.max_budget)),Error("Budget cannot exceed team max budget: $".concat(c.max_budget))}}],children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(B.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(K.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)(A.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:H,onCancel:()=>{Y(!1),Q(null)},token:$,onSubmit:er})]})},H=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,selectedTeam:i}=e;console.log("userSpend: ".concat(n));let[o,d]=(0,r.useState)(null!==n?n:0),[c,m]=(0,r.useState)(0),[h,x]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(t&&l&&s&&"Admin"===s&&null==n)try{let e=await (0,u.Qy)(t);e&&(e.spend?d(e.spend):d(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===s)return;if(null!==t){let e=(await (0,u.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==n&&d(n)},[n]);let p=[];i&&i.models&&(p=i.models),p&&p.includes("all-proxy-models")?(console.log("user models:",h),p=h):p&&p.includes("all-team-models")?p=i.models:p&&0===p.length&&(p=h);let j=void 0!==o?o.toFixed(4):null;return console.log("spend in view user spend: ".concat(o)),(0,a.jsx)("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:["$",j]})]})})},Y=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==n){let e=(await (0,u.So)(n,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,s]);let d=[];return t&&t.models&&(d=t.models),d&&d.includes("all-proxy-models")&&(console.log("user models:",i),d=i),(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==t?void 0:t.team_alias})})})},J=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n}=e,i={models:[],team_id:null,team_alias:"Default Team"},[o,d]=(0,r.useState)(i);return(l="App User"===n?s:s?[...s,i]:[i],"App User"===n)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(y.Z,{children:"Select Team"}),(0,a.jsx)(_.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)(_.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)(B.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(K.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,a.jsxs)(_.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},X=s(37963),$=s(97482);console.log("isLocal:",!1);var Q=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p,setProxySettings:j,proxySettings:g}=e,[Z,f]=(0,r.useState)(null),_=(0,i.useSearchParams)();_.get("viewSpend"),(0,i.useRouter)();let y=_.get("token"),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)(null),[w,N]=(0,r.useState)([]),I={models:[],team_alias:"Default Team",team_id:null},[A,C]=(0,r.useState)(t?t[0]:I);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(y){let e=(0,X.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),v(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";case"internal_user":return"Internal User";case"internal_user_viewer":return"Internal Viewer";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),o(l)}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&b&&s&&!n&&!Z){let e=sessionStorage.getItem("userModels"+l);e?N(JSON.parse(e)):(async()=>{try{let e=await (0,u.Dj)(b);j(e);let t=await (0,u.Br)(b,l,s,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(t),"; team values: ").concat(Object.entries(t.teams))),"Admin"==s){let e=await (0,u.Qy)(b);f(e),console.log("globalSpend:",e)}else f(t.user_info);p(t.keys),m(t.teams);let n=[...t.teams];n.length>0?(console.log("response['teams']: ".concat(n)),C(n[0])):C(I),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,u.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),N(a),console.log("userModels:",w),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,y,b,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=A&&null!==A.team_id){let e=0;for(let l of n)A.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===A.team_id&&(e+=l.spend);k(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;k(e)}},[A]),null==l||null==y){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==b)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=$.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",A),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(Y,{userID:l,userRole:s,selectedTeam:A||null,accessToken:b}),(0,a.jsx)(H,{userID:l,userRole:s,accessToken:b,userSpend:S,selectedTeam:A||null}),(0,a.jsx)(G,{userID:l,userRole:s,accessToken:b,selectedTeam:A||null,data:n,setData:p,teams:t}),(0,a.jsx)(P,{userID:l,team:A||null,userRole:s,accessToken:b,data:n,setData:p},A?A.team_id:null),(0,a.jsx)(J,{teams:t,setSelectedTeam:C,userRole:s})]})})})},ee=s(49167),el=s(35087),es=s(92836),et=s(26734),en=s(41608),ea=s(32126),er=s(23682),ei=s(47047),eo=s(76628),ed=s(25707),ec=s(44041),em=s(6180),eu=s(28683),eh=s(38302),ex=s(66242),ep=s(78578),ej=s(63954),eg=s(34658),eZ=e=>{let{modelID:l,accessToken:s}=e,[t,n]=(0,r.useState)(!1),i=async()=>{try{k.ZP.info("Making API Call"),n(!0);let e=await (0,u.Og)(s,l);console.log("model delete Response:",e),k.ZP.success("Model ".concat(l," deleted successfully")),n(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(F.Z,{onClick:()=>n(!0),icon:O.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>n(!1),children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Delete Model"}),(0,a.jsx)(h.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)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},ef=s(97766),e_=s(46495),ey=s(18190),eb=s(91118),ev=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(eb.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:s,colors:["indigo","rose"],connectNulls:!0,customTooltip:t}):(0,a.jsxs)("div",{children:[(0,a.jsx)(ey.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)(p.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eS=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(S.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)(j.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},ek=s(67951);let{Title:ew,Link:eN}=$.default;(t=n||(n={})).OpenAI="OpenAI",t.Azure="Azure",t.Anthropic="Anthropic",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Databricks="Databricks",t.Ollama="Ollama";let eI={OpenAI:"openai",Azure:"azure",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks",Ollama:"ollama"},eA={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eC=async(e,l,s)=>{try{let t=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(t)),console.log("received type of deployments: ".concat(typeof t)),t.forEach(async s=>{console.log("litellm_model: ".concat(s));let t={},n={};t.model=s;let a="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)a+=s;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)n[l]=s;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw k.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else t[l]=s}let r={model_name:a,litellm_params:t,model_info:n},i=await (0,u.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){k.ZP.error("Failed to create model: "+e,10)}};var eP=e=>{var l,s,t;let i,{accessToken:o,token:d,userRole:c,userID:m,modelData:h={data:[]},keys:g,setModelData:Z,premiumUser:f}=e,[b,v]=(0,r.useState)([]),[N]=S.Z.useForm(),[C,P]=(0,r.useState)(null),[O,W]=(0,r.useState)(""),[G,H]=(0,r.useState)([]),Y=Object.values(n).filter(e=>isNaN(Number(e))),[J,X]=(0,r.useState)([]),[Q,ey]=(0,r.useState)("OpenAI"),[eb,eP]=(0,r.useState)(""),[eT,eE]=(0,r.useState)(!1),[eO,eR]=(0,r.useState)(!1),[eM,eF]=(0,r.useState)(null),[eL,eD]=(0,r.useState)([]),[eU,eV]=(0,r.useState)(null),[eq,ez]=(0,r.useState)([]),[eB,eK]=(0,r.useState)([]),[eW,eG]=(0,r.useState)([]),[eH,eY]=(0,r.useState)([]),[eJ,eX]=(0,r.useState)([]),[e$,eQ]=(0,r.useState)([]),[e0,e1]=(0,r.useState)([]),[e2,e4]=(0,r.useState)([]),[e5,e8]=(0,r.useState)([]),[e3,e6]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e9,e7]=(0,r.useState)(null),[le,ll]=(0,r.useState)(0),[ls,lt]=(0,r.useState)({}),[ln,la]=(0,r.useState)([]),[lr,li]=(0,r.useState)(!1),[lo,ld]=(0,r.useState)(null),[lc,lm]=(0,r.useState)(null),[lu,lh]=(0,r.useState)([]);(0,r.useEffect)(()=>{lb(eU,e3.from,e3.to)},[lo,lc]);let lx=e=>{eF(e),eE(!0)},lp=e=>{eF(e),eR(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==o)return;let l={},s=null;for(let[t,n]of Object.entries(e))"model_id"!==t?l[t]=n:s=n;let t={litellm_params:l,model_info:{id:s}};console.log("handleEditSubmit payload:",t);try{await (0,u.um)(o,t),k.ZP.success("Model updated successfully, restart server to see updates"),eE(!1),eF(null)}catch(e){console.log("Error occurred")}},lg=()=>{W(new Date().toLocaleString())},lZ=async()=>{if(!o){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e9);try{await (0,u.K_)(o,{router_settings:{model_group_retry_policy:e9}}),k.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),k.ZP.error("Failed to save retry settings")}};if((0,r.useEffect)(()=>{if(!o||!d||!c||!m)return;let e=async()=>{try{var e,l,s,t,n,a,r,i,d,h,x,p;let j=await (0,u.hy)(o);X(j);let g=await (0,u.AZ)(o,m,c);console.log("Model data response:",g.data),Z(g);let f=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y),eV(y)),console.log("selectedModelGroup:",eU);let b=await (0,u.o6)(o,m,c,y,null===(e=e3.from)||void 0===e?void 0:e.toISOString(),null===(l=e3.to)||void 0===l?void 0:l.toISOString(),null==lo?void 0:lo.token,lc);console.log("Model metrics response:",b),eK(b.data),eG(b.all_api_bases);let v=await (0,u.Rg)(o,y,null===(s=e3.from)||void 0===s?void 0:s.toISOString(),null===(t=e3.to)||void 0===t?void 0:t.toISOString());eY(v.data),eX(v.all_api_bases);let S=await (0,u.N8)(o,m,c,y,null===(n=e3.from)||void 0===n?void 0:n.toISOString(),null===(a=e3.to)||void 0===a?void 0:a.toISOString(),null==lo?void 0:lo.token,lc);console.log("Model exceptions response:",S),eQ(S.data),e1(S.exception_types);let k=await (0,u.fP)(o,m,c,y,null===(r=e3.from)||void 0===r?void 0:r.toISOString(),null===(i=e3.to)||void 0===i?void 0:i.toISOString(),null==lo?void 0:lo.token,lc),w=await (0,u.n$)(o,null===(d=e3.from)||void 0===d?void 0:d.toISOString().split("T")[0],null===(h=e3.to)||void 0===h?void 0:h.toISOString().split("T")[0],y);lt(w);let N=await (0,u.v9)(o,null===(x=e3.from)||void 0===x?void 0:x.toISOString().split("T")[0],null===(p=e3.to)||void 0===p?void 0:p.toISOString().split("T")[0],y);la(N),console.log("dailyExceptions:",w),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",k),e8(k);let I=await (0,u.j2)(o);lh(null==I?void 0:I.end_users);let A=(await (0,u.BL)(o,m,c)).router_settings;console.log("routerSettingsInfo:",A);let C=A.model_group_retry_policy,P=A.num_retries;console.log("model_group_retry_policy:",C),console.log("default_retries:",P),e7(C),ll(P)}catch(e){console.error("There was an error fetching the model data",e)}};o&&d&&c&&m&&e();let l=async()=>{let e=await (0,u.qm)();console.log("received model cost map data: ".concat(Object.keys(e))),P(e)};null==C&&l(),lg()},[o,d,c,m,C,O]),!h||!o||!d||!c||!m)return(0,a.jsx)("div",{children:"Loading..."});let lf=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(C)),null!=C&&"object"==typeof C&&e in C)?C[e].litellm_provider:"openai";if(n){let e=n.split("/"),l=e[0];r=1===e.length?u(n):l}else r="openai";a&&(i=null==a?void 0:a.input_cost_per_token,o=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==t?void 0:t.litellm_params)&&(m=Object.fromEntries(Object.entries(null==t?void 0:t.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),h.data[e].provider=r,h.data[e].input_cost=i,h.data[e].output_cost=o,h.data[e].input_cost&&(h.data[e].input_cost=(1e6*Number(h.data[e].input_cost)).toFixed(2)),h.data[e].output_cost&&(h.data[e].output_cost=(1e6*Number(h.data[e].output_cost)).toFixed(2)),h.data[e].max_tokens=d,h.data[e].max_input_tokens=c,h.data[e].api_base=null==t?void 0:null===(s=t.litellm_params)||void 0===s?void 0:s.api_base,h.data[e].cleanedLitellmParams=m,lf.push(t.model_name),console.log(h.data[e])}if(c&&"Admin Viewer"==c){let{Title:e,Paragraph:l}=$.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 l_=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eI[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof C&&Object.entries(C).forEach(l=>{let[t,n]=l;null!==n&&"object"==typeof n&&"litellm_provider"in n&&(n.litellm_provider===e||n.litellm_provider.includes(e))&&s.push(t)}),H(s),console.log("providerModels: ".concat(G))}},ly=async()=>{try{k.ZP.info("Running health check..."),eP("");let e=await (0,u.EY)(o);eP(e)}catch(e){console.error("Error running health check:",e),eP("Error running health check")}},lb=async(e,l,s)=>{if(console.log("Updating model metrics for group:",e),!o||!m||!c||!l||!s)return;console.log("inside updateModelMetrics - startTime:",l,"endTime:",s),eV(e);let t=null==lo?void 0:lo.token;void 0===t&&(t=null);let n=lc;void 0===n&&(n=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),s.setHours(23),s.setMinutes(59),s.setSeconds(59);try{let a=await (0,u.o6)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);console.log("Model metrics response:",a),eK(a.data),eG(a.all_api_bases);let r=await (0,u.Rg)(o,e,l.toISOString(),s.toISOString());eY(r.data),eX(r.all_api_bases);let i=await (0,u.N8)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);console.log("Model exceptions response:",i),eQ(i.data),e1(i.exception_types);let d=await (0,u.fP)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);if(console.log("slowResponses:",d),e8(d),e){let t=await (0,u.n$)(o,null==l?void 0:l.toISOString().split("T")[0],null==s?void 0:s.toISOString().split("T")[0],e);lt(t);let n=await (0,u.v9)(o,null==l?void 0:l.toISOString().split("T")[0],null==s?void 0:s.toISOString().split("T")[0],e);la(n)}}catch(e){console.error("Failed to fetch model metrics",e)}},lv=(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Select API Key Name"}),f?(0,a.jsxs)("div",{children:[(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{ld(null)},children:"All Keys"},"all-keys"),null==g?void 0:g.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{ld(e)},children:e.key_alias},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(B.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(K.Z,{value:"all-customers",onClick:()=>{lm(null)},children:"All Customers"},"all-customers"),null==lu?void 0:lu.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>{lm(e)},children:e},l))]})]}):(0,a.jsxs)("div",{children:[(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{ld(null)},children:"All Keys"},"all-keys"),null==g?void 0:g.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsxs)(K.Z,{value:String(l),disabled:!0,onClick:()=>{ld(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(B.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(K.Z,{value:"all-customers",onClick:()=>{lm(null)},children:"All Customers"},"all-customers"),null==lu?void 0:lu.map((e,l)=>(0,a.jsxs)(K.Z,{value:e,disabled:!0,onClick:()=>{lm(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lS=e=>{var l,s;let{payload:t,active:n}=e;if(!n||!t)return null;let r=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,i=t.sort((e,l)=>l.value-e.value);if(i.length>5){let e=i.length-5;(i=i.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:t.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:[r&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",r]}),i.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.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:t})]},l)})]})};console.log("selectedProvider: ".concat(Q)),console.log("providerModels.length: ".concat(G.length));let lk=Object.keys(n).find(e=>n[e]===Q);return lk&&(i=J.find(e=>e.name===eI[lk])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(et.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(es.Z,{children:"All Models"}),(0,a.jsx)(es.Z,{children:"Add Model"}),(0,a.jsx)(es.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(es.Z,{children:"Model Analytics"}),(0,a.jsx)(es.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[O&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",O]}),(0,a.jsx)(F.Z,{icon:ej.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(B.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eU||eL[0],onValueChange:e=>eV("all"===e?"all":e),value:eU||eL[0],children:[(0,a.jsx)(K.Z,{value:"all",children:"All Models"}),eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>eV(e),children:e},l))]})]}),(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),"Admin"===c&&(0,a.jsx)(q.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(q.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:f?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(q.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:f?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(q.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(q.Z,{})]})}),(0,a.jsx)(D.Z,{children:h.data.filter(e=>"all"===eU||e.model_name===eU||null==eU||""===eU).map((e,l)=>{var s;return(0,a.jsxs)(z.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),"Admin"===c&&(0,a.jsx)(U.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(em.Z,{title:e&&e.api_base,children:(0,a.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,a.jsx)(U.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{className:"text-xs",children:e.input_cost?e.input_cost:e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(U.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{className:"text-xs",children:e.output_cost?e.output_cost:e.litellm_params.output_cost_per_token?(1e6*Number(e.litellm_params.output_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:f&&((s=e.model_info.created_at)?new Date(s).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:f&&e.model_info.created_by||"-"})}),(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(R.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,a.jsx)(R.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,a.jsx)(U.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eu.Z,{children:(0,a.jsx)(F.Z,{icon:T.Z,size:"sm",onClick:()=>lp(e)})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>lx(e)})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(eZ,{modelID:e.model_info.id,accessToken:o})})]})})]},l)})})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:n}=e,[r]=S.Z.useForm(),i={},o="",d="";if(t){i=t.litellm_params,o=t.model_name;let e=t.model_info;e&&(d=e.id,console.log("model_id: ".concat(d)),i.model_id=d)}return(0,a.jsx)(w.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.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)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(I.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(I.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:eT,onCancel:()=>{eE(!1),eF(null)},model:eM,onSubmit:lj}),(0,a.jsxs)(w.Z,{title:eM&&eM.model_name,visible:eO,width:800,footer:null,onCancel:()=>{eR(!1),eF(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(ek.Z,{language:"json",children:eM&&JSON.stringify(eM,null,2)})]})]}),(0,a.jsxs)(ea.Z,{className:"h-full",children:[(0,a.jsx)(ew,{level:2,children:"Add new model"}),(0,a.jsx)(M.Z,{children:(0,a.jsxs)(S.Z,{form:N,onFinish:()=>{N.validateFields().then(e=>{eC(e,o,N)}).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)(S.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)(B.Z,{value:Q.toString(),children:Y.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>{l_(e),ey(e)},children:e},l))})}),(0,a.jsx)(S.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)(j.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(t=Q.toString())?"gemini-pro":"Anthropic"==t?"claude-3-opus":"Amazon Bedrock"==t?"claude-3-opus":"Google AI Studio"==t?"gemini-pro":"gpt-3.5-turbo"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(S.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"===Q?(0,a.jsx)(j.Z,{placeholder:"Enter model name"}):G.length>0?(0,a.jsx)(ei.Z,{value:G,children:G.map((e,l)=>(0,a.jsx)(eo.Z,{value:e,children:e},l))}):(0,a.jsx)(j.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(eN,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(eN,{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!==i&&i.fields.length>0&&(0,a.jsx)(eS,{fields:i.fields,selectedProvider:i.name}),"Amazon Bedrock"!=Q&&"Vertex AI (Anthropic, Gemini, etc.)"!=Q&&"Ollama"!=Q&&(void 0===i||0==i.fields.length)&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(j.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==Q&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(j.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(j.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(e_.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;N.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?k.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&k.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(A.ZP,{icon:(0,a.jsx)(ef.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==Q||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==Q)&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(j.Z,{placeholder:"https://..."})}),"Azure"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==Q&&(0,a.jsxs)("div",{children:[(0,a.jsx)(S.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(j.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(eN,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(S.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)(ep.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(eN,{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)(A.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(em.Z,{title:"Get help on our github",children:(0,a.jsx)($.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(_.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(p.Z,{onClick:ly,children:"Run `/health`"}),eb&&(0,a.jsx)("pre",{children:JSON.stringify(eb,null,2)})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(el.Z,{enableSelect:!0,value:e3,className:"mr-2",onValueChange:e=>{e6(e),lb(eU,e.from,e.to)}})]}),(0,a.jsxs)(eu.Z,{className:"ml-2",children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(B.Z,{defaultValue:eU||eL[0],value:eU||eL[0],children:eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>lb(e,e3.from,e3.to),children:e},l))})]}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(ex.Z,{trigger:"click",content:lv,overlayStyle:{width:"20vw"},children:(0,a.jsx)(p.Z,{icon:eg.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>li(!0)})})})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eu.Z,{children:(0,a.jsx)(M.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(es.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(_.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),eB&&eW&&(0,a.jsx)(ed.Z,{title:"Model Latency",className:"h-72",data:eB,showLegend:!1,index:"date",categories:eW,connectNulls:!0,customTooltip:lS})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ev,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lS,premiumUser:f})})]})]})})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(M.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Deployment"}),(0,a.jsx)(q.Z,{children:"Success Responses"}),(0,a.jsxs)(q.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(D.Z,{children:e5.map((e,l)=>(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.api_base}),(0,a.jsx)(U.Z,{children:e.total_count}),(0,a.jsx)(U.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eU]}),(0,a.jsxs)(x.Z,{numItems:1,children:[(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ls.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:ls.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,a.jsx)(eu.Z,{})]})]}),f?(0,a.jsx)(a.Fragment,{children:ln.map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,a.jsx)(a.Fragment,{children:ln&&ln.length>0&&ln.slice(0,1).map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,a.jsx)(p.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)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(B.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eU||eL[0],value:eU||eL[0],onValueChange:e=>eV(e),children:eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>eV(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eU]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eA&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eA).map((e,l)=>{var s;let[t,n]=e,r=null==e9?void 0:null===(s=e9[eU])||void 0===s?void 0:s[n];return null==r&&(r=le),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)("td",{children:(0,a.jsx)(I.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e7(l=>{var s;let t=null!==(s=null==l?void 0:l[eU])&&void 0!==s?s:{};return{...null!=l?l:{},[eU]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})},eT=e=>{let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:n}=e,{Title:r,Paragraph:i}=$.default;return(0,a.jsxs)(w.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,a.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"User ID"}),(0,a.jsx)(_.Z,{children:null==n?void 0:n.user_id})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{children:"Invitation Link"}),(0,a.jsxs)(_.Z,{children:[t,"/ui/onboarding?id=",null==n?void 0:n.id]})]}),(0,a.jsxs)("div",{className:"flex justify-end mt-5",children:[(0,a.jsx)("div",{}),(0,a.jsx)(b.CopyToClipboard,{text:"".concat(t,"/ui/onboarding?id=").concat(null==n?void 0:n.id),onCopy:()=>k.ZP.success("Copied!"),children:(0,a.jsx)(p.Z,{variant:"primary",children:"Copy invitation link"})})]})]})};let{Option:eE}=v.default;var eO=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:n}=e,[o]=S.Z.useForm(),[d,c]=(0,r.useState)(!1),[m,h]=(0,r.useState)(null),[x,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[y,b]=(0,r.useState)(null),I=(0,i.useRouter)(),[C,P]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{if(I){let{protocol:e,host:l}=window.location;P("".concat(e,"/").concat(l))}},[I]);let T=async e=>{try{var t;k.ZP.info("Making API Call"),c(!0),console.log("formValues in create user:",e);let n=await (0,u.Ov)(s,null,e);console.log("user create Response:",n),h(n.key);let a=(null===(t=n.data)||void 0===t?void 0:t.user_id)||n.user_id;(0,u.XO)(s,a).then(e=>{b(e),f(!0)}),k.ZP.success("API user Created"),o.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-0",onClick:()=>c(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:d,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),h(null),o.resetFields()},children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,a.jsxs)(S.Z,{form:o,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(S.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:n&&Object.entries(n).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(K.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(v.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,a.jsx)(eE,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eE,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create User"})})]})]}),m&&(0,a.jsx)(eT,{isInvitationLinkModalVisible:Z,setIsInvitationLinkModalVisible:f,baseUrl:C,invitationLinkData:y})]})},eR=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:n,onSubmit:i}=e,[o,d]=(0,r.useState)(n),[c]=S.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[n]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return n?(0,a.jsx)(w.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+n.user_id,width:1e3,children:(0,a.jsx)(S.Z,{form:c,onFinish:u,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(K.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})}):null},eM=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(0),[Z,f]=r.useState(null),[_,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(!1),[S,w]=(0,r.useState)(null),[N,I]=(0,r.useState)({}),A=async()=>{w(null),v(!1)},C=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&n&&i){try{await (0,u.pf)(l,e,null),k.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}c&&m(c.map(l=>l.user_id===e.user_id?e:l)),w(null),v(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=await (0,u.Br)(l,null,n,!0,j,25);console.log("user data response:",e),m(e);let s=await (0,u.lg)(l);I(s)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,j]),c&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,a.jsx)(eO,{userID:i,accessToken:l,teams:o,possibleUIRoles:N}),(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1"}),(0,a.jsx)(et.Z,{children:(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(L.Z,{className:"mt-5",children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"User ID"}),(0,a.jsx)(q.Z,{children:"User Email"}),(0,a.jsx)(q.Z,{children:"Role"}),(0,a.jsx)(q.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(q.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(q.Z,{children:"API Keys"}),(0,a.jsx)(q.Z,{})]})}),(0,a.jsx)(D.Z,{children:c.map(e=>{var l,s;return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_id||"-"}),(0,a.jsx)(U.Z,{children:e.user_email||"-"}),(0,a.jsx)(U.Z,{children:(null==N?void 0:null===(l=N[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,a.jsx)(U.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,a.jsx)(U.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsxs)(R.Z,{size:"xs",color:"indigo",children:[e.key_aliases.filter(e=>null!==e).length,"\xa0Keys"]}):(0,a.jsx)(R.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:E.Z,onClick:()=>{w(e),v(!0)},children:"View Keys"})})]},e.user_id)})})]})}),(0,a.jsx)(ea.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"})]})})]})}),(0,a.jsx)(eR,{visible:b,possibleUIRoles:N,onCancel:A,user:S,onSubmit:C})]}),function(){if(!c)return null;let e=Math.ceil(c.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",j+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===j,onClick:()=>g(j-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:()=>{g(j+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},eF=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,userID:i,userRole:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=$.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[C,P]=(0,r.useState)(l?l[0]:null),[T,W]=(0,r.useState)(!1),[G,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)([]),[X,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),[es,et]=(0,r.useState)({}),en=e=>{P(e),b(!0)},ea=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let a=await (0,u.Gh)(t,e);l&&n(l.map(e=>e.team_id===s?a.data:e)),k.ZP.success("Team updated successfully"),b(!1),P(null)},er=async e=>{el(e),Q(!0)},ei=async()=>{if(null!=ee&&null!=l&&null!=t){try{await (0,u.rs)(t,ee);let e=l.filter(e=>e.team_id!==ee);n(e)}catch(e){console.error("Error deleting the team:",e)}Q(!1),el(null)}};(0,r.useEffect)(()=>{let e=async()=>{try{if(null===i||null===o||null===t||null===l)return;console.log("fetching team info:");let e={};for(let s=0;s<(null==l?void 0:l.length);s++){let n=l[s].team_id,a=await (0,u.Xm)(t,n);console.log("teamInfo response:",a),null!==a&&(e={...e,[n]:a})}et(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,u.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),J(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eo=async e=>{try{if(null!=t){var s;let a=null==e?void 0:e.team_alias;if((null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));k.ZP.info("Creating Team");let r=await (0,u.hT)(t,e);null!==l?n([...l,r]):n([r]),console.log("response for team create call: ".concat(r)),k.ZP.success("Team created"),W(!1)}}catch(e){console.error("Error creating the team:",e),k.ZP.error("Error creating the team: "+e,20)}},ed=async e=>{try{if(null!=t&&null!=l){k.ZP.info("Adding Member");let s={role:"user",user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,C.team_id,s);console.log("response for team create call: ".concat(a.data));let r=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(r)),-1!==r){let e=[...l];e[r]=a.data,n(e),P(a.data)}H(!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)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Team Name"}),(0,a.jsx)(q.Z,{children:"Spend (USD)"}),(0,a.jsx)(q.Z,{children:"Budget (USD)"}),(0,a.jsx)(q.Z,{children:"Models"}),(0,a.jsx)(q.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(q.Z,{children:"Info"})]})}),(0,a.jsx)(D.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(U.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(_.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)(U.Z,{children:[(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].keys&&es[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].team_info&&es[e.team_id].team_info.members_with_roles&&es[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>en(e)}),(0,a.jsx)(F.Z,{onClick:()=>er(e.team_id),icon:O.Z,size:"sm"})]})]},e.team_id)):null})]}),X&&(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)(p.Z,{onClick:ei,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{Q(!1),el(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>W(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:T,width:800,footer:null,onOk:()=>{W(!1),d.resetFields()},onCancel:()=>{W(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:eo,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),Y.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(g,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(B.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{P(e)},children:e.team_alias},l))}):(0,a.jsxs)(g,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Member Name"}),(0,a.jsx)(q.Z,{children:"Role"})]})}),(0,a.jsx)(D.Z,{children:C?C.members_with_roles.map((e,l)=>(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(U.Z,{children:e.role})]},l)):null})]})}),C&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:n}=e,[r]=S.Z.useForm();return(0,a.jsx)(w.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:ea,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),Y&&Y.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.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)(A.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),P(null)},team:C,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-5",onClick:()=>H(!0),children:"+ Add member"}),(0,a.jsx)(w.Z,{title:"Add member",visible:G,width:800,footer:null,onOk:()=>{H(!1),c.resetFields()},onCancel:()=>{H(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(N.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)(S.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(N.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)(A.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eL=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n}=e,[o]=S.Z.useForm(),[d]=S.Z.useForm(),{Title:c,Paragraph:m}=$.default,[j,g]=(0,r.useState)(""),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)(null),[v,I]=(0,r.useState)(!1),[C,P]=(0,r.useState)(!1),[T,O]=(0,r.useState)(!1),[R,W]=(0,r.useState)(!1),[G,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)(!1),X=(0,i.useRouter)(),[Q,ee]=(0,r.useState)(null),[el,es]=(0,r.useState)("");try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let et=()=>{J(!1)},en=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{if(X){let{protocol:e,host:l}=window.location;es("".concat(e,"//").concat(l))}},[X]),(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,u.Xd)(t,"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 s=await (0,u.Xd)(t,"proxy_admin");s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(s)),console.log("combinedList: ".concat(e)),f(e),ee(await (0,u.lg)(t))}})()},[t]);let ea=()=>{W(!1),d.resetFields(),o.resetFields()},er=()=>{W(!1),d.resetFields(),o.resetFields()},ei=e=>(0,a.jsxs)(S.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,a.jsx)(N.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Add member"})})]}),eo=(e,l,s)=>(0,a.jsxs)(S.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(B.Z,{value:l,children:en.map((e,l)=>(0,a.jsx)(K.Z,{value:e,children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(N.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Update role"})})]}),ed=async e=>{try{if(null!=t&&null!=Z){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=Z.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(s)),-1==s&&(console.log("updates admin with new user"),Z.push(l),f(Z)),k.ZP.success("Refresh tab to see updated user role"),W(!1)}}catch(e){console.error("Error creating the key:",e)}},ec=async e=>{try{if(null!=t&&null!=Z){var l;k.ZP.info("Making API Call");let s=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{b(e),I(!0)});let a=Z.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(s.user_id)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),Z.push(s),f(Z)),o.resetFields(),P(!1)}}catch(e){console.error("Error creating the key:",e)}},em=async e=>{try{if(null!=t&&null!=Z){var l;k.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,u.pf)(t,e,"proxy_admin"),n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{b(e),I(!0)}),console.log("response for team create call: ".concat(s));let a=Z.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(n)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),Z.push(s),f(Z)),o.resetFields(),O(!1)}}catch(e){console.error("Error creating the key:",e)}},eu=async e=>{if(null==t)return;let l={environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}};(0,u.K_)(t,l)};return console.log("admins: ".concat(null==Z?void 0:Z.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)(m,{children:[n&&(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)(x.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Member Name"}),(0,a.jsx)(q.Z,{children:"Role"})]})}),(0,a.jsx)(D.Z,{children:Z?Z.map((e,l)=>{var s;return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsxs)(U.Z,{children:[" ",(null==Q?void 0:null===(s=Q[null==e?void 0:e.user_role])||void 0===s?void 0:s.ui_label)||"-"]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>W(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:R,width:800,footer:null,onOk:ea,onCancel:er,children:eo(ed,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(p.Z,{className:"mr-4 mb-5",onClick:()=>O(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:T,width:800,footer:null,onOk:()=>{O(!1),d.resetFields(),o.resetFields()},onCancel:()=>{O(!1),I(!1),d.resetFields(),o.resetFields()},children:ei(em)}),(0,a.jsx)(eT,{isInvitationLinkModalVisible:v,setIsInvitationLinkModalVisible:I,baseUrl:el,invitationLinkData:y}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>P(!0),children:"+ Add viewer"}),(0,a.jsx)(w.Z,{title:"Add viewer",visible:C,width:800,footer:null,onOk:()=>{P(!1),d.resetFields(),o.resetFields()},onCancel:()=>{P(!1),d.resetFields(),o.resetFields()},children:ei(ec)})]})})]}),(0,a.jsxs)(x.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)(p.Z,{onClick:()=>H(!0),children:"Add SSO"}),(0,a.jsx)(w.Z,{title:"Add SSO",visible:G,width:800,footer:null,onOk:()=>{H(!1),o.resetFields()},onCancel:()=>{H(!1),o.resetFields()},children:(0,a.jsxs)(S.Z,{form:o,onFinish:e=>{em(e),eu(e),H(!1),J(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(N.Z.Password,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(N.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:et,onCancel:()=>{J(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(_.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)(A.ZP,{onClick:et,children:"Done"})})]})]}),(0,a.jsxs)(ey.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})," "]})]})]})]})},eD=s(42556),eU=s(90252),eV=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:n,premiumUser:r}=e,[i]=S.Z.useForm();return(0,a.jsxs)(S.Z,{form:i,onFinish:()=>{let e=i.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(z.Z,{children:[(0,a.jsxs)(U.Z,{align:"center",children:[(0,a.jsx)(_.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?r?(0,a.jsx)(S.Z.Item,{name:e.field_name,children:(0,a.jsx)(U.Z,{children:"Integer"===e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(U.Z,{children:(0,a.jsx)(p.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)(S.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(U.Z,{children:"Integer"===e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(U.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eU.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:O.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eq=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(eV,{alertingSettings:t,handleInputChange:(e,l)=>{n(t.map(s=>s.field_name===e?{...s,field_value:l}:s))},handleResetField:(e,s)=>{if(l)try{let l=t.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),n(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let n={...e,...s};try{(0,u.jA)(l,"alerting_args",n),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},ez=s(84406);let{Title:eB,Paragraph:eK}=$.default;var eW=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g]=S.Z.useForm(),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[C,P]=(0,r.useState)({}),[T,O]=(0,r.useState)([]),[R,B]=(0,r.useState)(!1),[W,G]=(0,r.useState)([]),[H,Y]=(0,r.useState)(null),[J,X]=(0,r.useState)([]),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),ei=e=>{T.includes(e)?O(T.filter(l=>l!==e)):O([...T,e])},eo={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,r.useEffect)(()=>{l&&s&&t&&(0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),G(e.available_callbacks);let l=e.alerts;if(console.log("alerts_data",l),l&&l.length>0){let e=l[0];console.log("_alert_info",e);let s=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",s),O(e.active_alerts),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ed=e=>T&&T.includes(e),ec=()=>{if(!l)return;let e={};d.filter(e=>"email"===e.name).forEach(l=>{var s;Object.entries(null!==(s=l.variables)&&void 0!==s?s:{}).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));n&&n.value&&(e[s]=null==n?void 0:n.value)})}),console.log("updatedVariables",e);try{(0,u.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Email settings updated successfully")},em=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,u.K_)(l,{environment_variables:s}),k.ZP.success("Callback added successfully"),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eu=async e=>{if(!l)return;let s=null==e?void 0:e.callback,t={};Object.entries(e).forEach(e=>{let[l,s]=e;"callback"!==l&&(t[l]=s)});try{await (0,u.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),k.ZP.success("Callback ".concat(s," added successfully")),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),f(e.litellm_callback_name),console.log("all callbacks",W),e&&e.litellm_callback_params?(X(e.litellm_callback_params),console.log("selectedCallbackParams",J)):X([])};return l?(console.log("callbacks: ".concat(i)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(es.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(es.Z,{value:"3",children:"Alerting Settings"}),(0,a.jsx)(es.Z,{value:"4",children:"Email Alerts"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(eB,{level:4,children:"Active Logging Callbacks"}),(0,a.jsx)(x.Z,{numItems:2,children:(0,a.jsx)(M.Z,{className:"max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsx)(z.Z,{children:(0,a.jsx)(q.Z,{children:"Callback Name"})})}),(0,a.jsx)(D.Z,{children:i.map((e,s)=>(0,a.jsxs)(z.Z,{className:"flex justify-between",children:[(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:e.name})}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"flex justify-between",children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>B(!0),children:"Add Callback"})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(_.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)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{}),(0,a.jsx)(q.Z,{}),(0,a.jsx)(q.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(eo).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(eD.Z,{id:"switch",name:"switch",checked:ed(s),onChange:()=>ei(s)}):(0,a.jsx)(p.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)(eD.Z,{id:"switch",name:"switch",checked:ed(s),onChange:()=>ei(s)})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:C&&C[s]?C[s]:N})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(eo).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",n);let a=(null==n?void 0:n.value)||"";console.log("newWebhookValue",a),e[s]=a}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:T}};console.log("payload",s);try{(0,u.K_)(l,s)}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(eq,{accessToken:l,premiumUser:n})}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(eB,{level:4,children:"Email Settings"}),(0,a.jsxs)(_.Z,{children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,a.jsx)("br",{})]}),(0,a.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,a.jsx)(U.Z,{children:(0,a.jsx)("ul",{children:(0,a.jsx)(x.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{className:"mx-2 my-2",children:[!0!=n&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,a.jsxs)(_.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,a.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,a.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,a.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the Logo that appears in the email, pass a url to your logo"}),"EMAIL_SUPPORT_CONTACT"===l&&(0,a.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the support email address that appears in the email. Default is support@berri.ai"})]})]},l)})})})},l)})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>ec(),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,a.jsxs)(w.Z,{title:"Add Logging Callback",visible:R,width:800,onCancel:()=>B(!1),footer:null,children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/logging",className:"mb-8 mt-4",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: Logging"}),(0,a.jsx)(S.Z,{form:g,onFinish:eu,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ez.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsx)(v.default,{onChange:e=>{let l=W[e];l&&(console.log(l.ui_callback_name),eh(l))},children:W&&Object.values(W).map(e=>(0,a.jsx)(K.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),J&&J.map(e=>(0,a.jsx)(ez.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,a.jsx)(j.Z,{type:"password"})},e)),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,a.jsx)(w.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,a.jsxs)(S.Z,{form:g,onFinish:em,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,a.jsx)(ez.Z,{label:l,name:l,children:(0,a.jsx)(j.Z,{type:"password",defaultValue:s})},l)})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eG}=v.default;var eH=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:n}=e,[i]=S.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(w.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,r=[...t.fallbacks||[],{[l]:a}],o={...t,fallbacks:r};console.log(o);try{(0,u.K_)(s,{router_settings:o}),n(o)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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)(B.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(ei.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(eo.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},eY=s(12968);async function eJ(e,l){console.log("isLocal:",!1);let s=window.location.origin,t=new eY.ZP.OpenAI({apiKey:l,baseURL:s,dangerouslyAllowBrowser:!0});try{let l=await t.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});k.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){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let eX={ttl:3600,lowest_latency_buffer:0},e$=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(Z.Z,{children:"latency-based-routing"==l?(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Setting"}),(0,a.jsx)(q.Z,{children:"Value"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(z.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,a.jsx)(_.Z,{children:"No specific settings"})})]})};var eQ=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[b]=S.Z.useForm(),[v,w]=(0,r.useState)(null),[N,A]=(0,r.useState)(null),[C,P]=(0,r.useState)(null),T={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,r.useEffect)(()=>{l&&s&&t&&((0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.router_settings)}),(0,u.YU)(l).then(e=>{g(e)}))},[l,s,t]);let E=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks)),i.fallbacks.map(l=>(e in l&&delete l[e],l));try{await (0,u.K_)(l,{router_settings:i}),o({...i}),A(i.routing_strategy),k.ZP.success("Router settings updated successfully")}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}}},W=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},G=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,u.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},H=(e,s)=>{if(l)try{(0,u.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},Y=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,u.K_)(l,{router_settings:s})}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(et.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(es.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(es.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(y.Z,{children:"Router Settings"}),(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Setting"}),(0,a.jsx)(q.Z,{children:"Value"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(i).filter(e=>{let[l,s]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,s]=e;return(0,a.jsxs)(z.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:T[l]})]}),(0,a.jsx)(U.Z,{children:"routing_strategy"==l?(0,a.jsxs)(B.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:A,children:[(0,a.jsx)(K.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(K.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(K.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,a.jsx)(e$,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:eX,paramExplanation:T})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>Y(i),children:"Save Changes"})})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Model Name"}),(0,a.jsx)(q.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(D.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:t}),(0,a.jsx)(U.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>eJ(t,l),children:"Test Fallback"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:O.Z,size:"sm",onClick:()=>E(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(eH,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Setting"}),(0,a.jsx)(q.Z,{children:"Value"}),(0,a.jsx)(q.Z,{children:"Status"}),(0,a.jsx)(q.Z,{children:"Action"})]})}),(0,a.jsx)(D.Z,{children:m.map((e,l)=>(0,a.jsxs)(z.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.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)(U.Z,{children:"Integer"==e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>W(e.field_name,l)}):null}),(0,a.jsx)(U.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eU.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>G(e.field_name,l),children:"Update"}),(0,a.jsx)(F.Z,{icon:O.Z,color:"red",onClick:()=>H(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},e0=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n}=e,[r]=S.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call");let l=await (0,u.Zr)(s,e);console.log("key create Response:",l),n(e=>e?[...e,l]:[l]),k.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,a.jsxs)(S.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(I.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(I.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},e1=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{i(e)})},[l]);let o=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...n];t.splice(s,1),i(t),k.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)(p.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,a.jsx)(e0,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:i}),(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Budget ID"}),(0,a.jsx)(q.Z,{children:"Max Budget"}),(0,a.jsx)(q.Z,{children:"TPM"}),(0,a.jsx)(q.Z,{children:"RPM"})]})}),(0,a.jsx)(D.Z,{children:n.map((e,l)=>(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.budget_id}),(0,a.jsx)(U.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(U.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(U.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(F.Z,{icon:O.Z,size:"sm",onClick:()=>o(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(es.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(es.Z,{children:"Test it (Curl)"}),(0,a.jsx)(es.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ek.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)(ea.Z,{children:(0,a.jsx)(ek.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)(ea.Z,{children:(0,a.jsx)(ek.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{let{proxySettings:l}=e,s="http://localhost:4000";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(x.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)(_.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)(et.Z,{children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(es.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(es.Z,{children:"LlamaIndex"}),(0,a.jsx)(es.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ek.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="'.concat(s,'" # 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)(ea.Z,{children:(0,a.jsx)(ek.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="'.concat(s,'", # 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="').concat(s,'",\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)(ea.Z,{children:(0,a.jsx)(ek.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="'.concat(s,'",\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 e5(e,l,s,t){console.log("isLocal:",!1);let n=window.location.origin,a=new eY.ZP.OpenAI({apiKey:t,baseURL:n,dangerouslyAllowBrowser:!0});try{for await(let t of(await a.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content)}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var e8=e=>{let{accessToken:l,token:s,userRole:t,userID:n}=e,[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(""),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(void 0),[y,b]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{let e=await (0,u.So)(l,n,t);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}));if(console.log(l),l.length>0){let e=Array.from(new Set(l));console.log("Unique models:",e),e.sort((e,l)=>e.label.localeCompare(l.label)),console.log("Model info:",y),b(e)}f(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,n,t]);let S=(e,l)=>{g(s=>{let t=s[s.length-1];return t&&t.role===e?[...s.slice(0,s.length-1),{role:e,content:t.content+l}]:[...s,{role:e,content:l}]})},k=async()=>{if(""!==d.trim()&&i&&s&&t&&n){g(e=>[...e,{role:"user",content:d}]);try{Z&&await e5(d,e=>S("assistant",e),Z,i)}catch(e){console.error("Error fetching model response",e),S("assistant","Error fetching model response")}c("")}};if(t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=$.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)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(M.Z,{children:(0,a.jsxs)(et.Z,{children:[(0,a.jsx)(en.Z,{children:(0,a.jsx)(es.Z,{children:"Chat"})}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"API Key"}),(0,a.jsx)(j.Z,{placeholder:"Type API Key here",type:"password",onValueChange:o,value:i})]}),(0,a.jsxs)(h.Z,{className:"mx-2",children:[(0,a.jsx)(_.Z,{children:"Select Model:"}),(0,a.jsx)(v.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),f(e)},options:y,style:{width:"200px"}})]})]})}),(0,a.jsxs)(L.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(V.Z,{children:(0,a.jsx)(z.Z,{children:(0,a.jsx)(U.Z,{})})}),(0,a.jsx)(D.Z,{children:m.map((e,l)=>(0,a.jsx)(z.Z,{children:(0,a.jsx)(U.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)(j.Z,{type:"text",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},e3=s(33509),e6=s(95781);let{Sider:e9}=e3.default;var e7=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e;return"Admin Viewer"==s?(0,a.jsx)(e3.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(e9,{width:120,children:(0,a.jsx)(e6.Z,{mode:"inline",defaultSelectedKeys:t||["4"],style:{height:"100%",borderRight:0},children:(0,a.jsx)(e6.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")})})}):(0,a.jsx)(e3.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(e9,{width:145,children:(0,a.jsxs)(e6.Z,{mode:"inline",defaultSelectedKeys:t||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e6.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(_.Z,{children:"API Keys"})},"1"),(0,a.jsx)(e6.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(_.Z,{children:"Test Key"})},"3"),"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(_.Z,{children:"Models"})},"2"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(_.Z,{children:"Usage"})},"4"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(_.Z,{children:"Teams"})},"6"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(_.Z,{children:"Internal Users"})},"5"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(_.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(_.Z,{children:"Budgets"})},"9"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(_.Z,{children:"Router Settings"})},"10"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(_.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(e6.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(_.Z,{children:"API Reference"})},"12"),(0,a.jsx)(e6.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(_.Z,{children:"Model Hub"})},"14")]})})})},le=s(67989),ll=s(52703),ls=e=>{let{accessToken:l,token:s,userRole:t,userID:n,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[S,k]=(0,r.useState)([]),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)([]),[C,P]=(0,r.useState)([]),[T,E]=(0,r.useState)([]),[O,R]=(0,r.useState)([]),[F,W]=(0,r.useState)({}),[G,Y]=(0,r.useState)([]),[J,X]=(0,r.useState)(""),[$,Q]=(0,r.useState)(["all-tags"]),[em,eu]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),eh=new Date(d.getFullYear(),d.getMonth(),1),ex=new Date(d.getFullYear(),d.getMonth()+1,0),ep=e_(eh),ej=e_(ex);function eg(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}console.log("keys in usage",i),console.log("premium user in usage",o),(0,r.useEffect)(()=>{ef(em.from,em.to)},[em,$]);let eZ=async(e,s,t)=>{if(!e||!s||!l)return;s.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",t);let n=await (0,u.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",n),v(n)},ef=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.J$)(l,e.toISOString(),s.toISOString(),0===$.length?void 0:$)).spend_per_tag),console.log("Tag spend data updated successfully"))};function e_(e){let l=e.getFullYear(),s=e.getMonth()+1,t=e.getDate();return"".concat(l,"-").concat(s<10?"0"+s:s,"-").concat(t<10?"0"+t:t)}return console.log("Start date is ".concat(ep)),console.log("End date is ".concat(ej)),(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{if(console.log("user role: ".concat(t)),"Admin"==t||"Admin Viewer"==t){var e,a;let t=await (0,u.FC)(l);m(t);let n=await (0,u.OU)(l,s,ep,ej);console.log("provider_spend",n),R(n);let r=(await (0,u.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));g(r);let i=(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend}));f(i);let o=await (0,u.mR)(l);console.log("teamSpend",o),k(o.daily_spend),P(o.teams);let d=o.total_spend_per_team;d=d.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),E(d);let c=await (0,u.X)(l);A(c.tag_names);let h=await (0,u.J$)(l,null===(e=em.from)||void 0===e?void 0:e.toISOString(),null===(a=em.to)||void 0===a?void 0:a.toISOString(),void 0);N(h.spend_per_tag);let x=await (0,u.b1)(l,null,void 0,void 0);v(x),console.log("spend/user result",x);let p=await (0,u.wd)(l,ep,ej);W(p);let j=await (0,u.xA)(l,ep,ej);console.log("global activity per model",j),Y(j)}else"App Owner"==t&&await (0,u.HK)(l,s,t,n,ep,ej).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 s=e.top_api_keys;g(s)}else{let s=(await (0,u.e2)(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,t]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&l.push({key:s,spend:t})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let s=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(s[0]))),s}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));g(s),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,s,t,n,ep,ej]),(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{className:"mt-2",children:[(0,a.jsx)(es.Z,{children:"All Up"}),(0,a.jsx)(es.Z,{children:"Team Based Usage"}),(0,a.jsx)(es.Z,{children:"Customer Usage"}),(0,a.jsx)(es.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(es.Z,{children:"Cost"}),(0,a.jsx)(es.Z,{children:"Activity"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(H,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(ec.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(ec.Z,{className:"mt-4 h-40",data:j,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(ec.Z,{className:"mt-4 h-40",data:Z,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(ll.Z,{className:"mt-4 h-40",variant:"pie",data:O,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Provider"}),(0,a.jsx)(q.Z,{children:"Spend"})]})}),(0,a.jsx)(D.Z,{children:O.map(e=>(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.provider}),(0,a.jsx)(U.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)(p.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)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"All Up"}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(F.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:F.daily_data,valueFormatter:eg,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(F.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:F.daily_data,valueFormatter:eg,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:G.map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(e.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eg,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(e.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:eg,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:G&&G.length>0&&G.slice(0,1).map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.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)(p.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)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(e.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eg,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(e.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:eg,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsxs)(M.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(le.Z,{data:T})]}),(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(ec.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:C,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["Customers 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)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(el.Z,{enableSelect:!0,value:em,onValueChange:e=>{eu(e),eZ(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{eZ(em.from,em.to,null)},children:"All Keys"},"all-keys"),null==i?void 0:i.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{eZ(em.from,em.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(M.Z,{className:"mt-4",children:(0,a.jsxs)(L.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(V.Z,{children:(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(q.Z,{children:"Customer"}),(0,a.jsx)(q.Z,{children:"Spend"}),(0,a.jsx)(q.Z,{children:"Total Events"})]})}),(0,a.jsx)(D.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(z.Z,{children:[(0,a.jsx)(U.Z,{children:e.end_user}),(0,a.jsx)(U.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(U.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(el.Z,{className:"mb-4",enableSelect:!0,value:em,onValueChange:e=>{eu(e),ef(e.from,e.to)}})}),(0,a.jsx)(h.Z,{children:o?(0,a.jsx)("div",{children:(0,a.jsxs)(ei.Z,{value:$,onValueChange:e=>Q(e),children:[(0,a.jsx)(eo.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsx)(eo.Z,{value:String(e),children:e},e))]})}):(0,a.jsx)("div",{children:(0,a.jsxs)(ei.Z,{value:$,onValueChange:e=>Q(e),children:[(0,a.jsx)(eo.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsxs)(K.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(_.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,a.jsx)(ec.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,a.jsx)(h.Z,{numColSpan:2})]})]})]})]})})},lt=()=>{let{Title:e,Paragraph:l}=$.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[x,p]=(0,r.useState)(null),[j,g]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[Z,f]=(0,r.useState)(!0),_=(0,i.useSearchParams)(),[y,b]=(0,r.useState)({data:[]}),v=_.get("userID"),S=_.get("token"),[k,w]=(0,r.useState)("api-keys"),[N,I]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(S){let e=(0,X.o)(S);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),I(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"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&w("usage")}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?f("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user)}}},[S]),(0,a.jsx)(r.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:v,userRole:s,userEmail:d,showSSOBanner:Z,premiumUser:n,setProxySettings:g,proxySettings:j}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(e7,{setPage:w,userRole:s,defaultSelectedKey:null})}),"api-keys"==k?(0,a.jsx)(Q,{userID:v,userRole:s,teams:u,keys:x,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:h,setKeys:p,setProxySettings:g,proxySettings:j}):"models"==k?(0,a.jsx)(eP,{userID:v,userRole:s,token:S,keys:x,accessToken:N,modelData:y,setModelData:b,premiumUser:n}):"llm-playground"==k?(0,a.jsx)(e8,{userID:v,userRole:s,token:S,accessToken:N}):"users"==k?(0,a.jsx)(eM,{userID:v,userRole:s,token:S,keys:x,teams:u,accessToken:N,setKeys:p}):"teams"==k?(0,a.jsx)(eF,{teams:u,setTeams:h,searchParams:_,accessToken:N,userID:v,userRole:s}):"admin-panel"==k?(0,a.jsx)(eL,{setTeams:h,searchParams:_,accessToken:N,showSSOBanner:Z}):"api_ref"==k?(0,a.jsx)(e4,{proxySettings:j}):"settings"==k?(0,a.jsx)(eW,{userID:v,userRole:s,accessToken:N,premiumUser:n}):"budgets"==k?(0,a.jsx)(e1,{accessToken:N}):"general-settings"==k?(0,a.jsx)(eQ,{userID:v,userRole:s,accessToken:N,modelData:y}):"model-hub"==k?(0,a.jsx)(e2.Z,{accessToken:N,publicPage:!1,premiumUser:n}):(0,a.jsx)(ls,{userID:v,userRole:s,token:S,accessToken:N,keys:x,premiumUser:n})]})]})})}},41134:function(e,l,s){"use strict";s.d(l,{Z:function(){return y}});var t=s(3827),n=s(64090),a=s(47907),r=s(777),i=s(16450),o=s(13810),d=s(92836),c=s(26734),m=s(41608),u=s(32126),h=s(23682),x=s(71801),p=s(42440),j=s(84174),g=s(50459),Z=s(6180),f=s(99129),_=s(67951),y=e=>{var l;let{accessToken:s,publicPage:y,premiumUser:b}=e,[v,S]=(0,n.useState)(!1),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(!1),[A,C]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null),E=(0,a.useRouter)();(0,n.useEffect)(()=>{s&&(async()=>{try{let e=await (0,r.kn)(s);console.log("ModelHubData:",e),w(e.data),(0,r.E9)(s,"enable_public_model_hub").then(e=>{console.log("data: ".concat(JSON.stringify(e))),!0==e.field_value&&S(!0)}).catch(e=>{})}catch(e){console.error("There was an error fetching the model data",e)}})()},[s,y]);let O=e=>{T(e),I(!0)},R=async()=>{s&&(0,r.jA)(s,"enable_public_model_hub",!0).then(e=>{C(!0)})},M=()=>{I(!1),C(!1),T(null)},F=()=>{I(!1),C(!1),T(null)},L=e=>{navigator.clipboard.writeText(e)};return(0,t.jsxs)("div",{children:[y&&v||!1==y?(0,t.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,t.jsx)("div",{className:"relative w-full"}),(0,t.jsxs)("div",{className:"flex ".concat(y?"justify-between":"items-center"),children:[(0,t.jsx)(p.Z,{className:"ml-8 text-center ",children:"Model Hub"}),!1==y?b?(0,t.jsx)(i.Z,{className:"ml-4",onClick:()=>R(),children:"✨ Make Public"}):(0,t.jsx)(i.Z,{className:"ml-4",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})}):(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("p",{children:"Filter by key:"}),(0,t.jsx)(x.Z,{className:"bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center",children:"/ui/model_hub?key="})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4 pr-8",children:k&&k.map(e=>(0,t.jsxs)(o.Z,{className:"mt-5 mx-8",children:[(0,t.jsxs)("pre",{className:"flex justify-between",children:[(0,t.jsx)(p.Z,{children:e.model_group}),(0,t.jsx)(Z.Z,{title:e.model_group,children:(0,t.jsx)(j.Z,{onClick:()=>L(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,t.jsxs)("div",{className:"my-5",children:[(0,t.jsxs)(x.Z,{children:["Mode: ",e.mode]}),(0,t.jsxs)(x.Z,{children:["Supports Function Calling:"," ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Supports Vision:"," ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Max Input Tokens:"," ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,t.jsxs)(x.Z,{children:["Max Output Tokens:"," ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,t.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,t.jsxs)("a",{href:"#",onClick:()=>O(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,t.jsx)(g.Z,{})]})})]},e.model_group))})]}):(0,t.jsxs)(o.Z,{className:"mx-auto max-w-xl mt-10",children:[(0,t.jsx)(x.Z,{className:"text-xl text-center mb-2 text-black",children:"Public Model Hub not enabled."}),(0,t.jsx)("p",{className:"text-base text-center text-slate-800",children:"Ask your proxy admin to enable this on their Admin UI."})]}),(0,t.jsx)(f.Z,{title:"Public Model Hub",width:600,visible:A,footer:null,onOk:M,onCancel:F,children:(0,t.jsxs)("div",{className:"pt-5 pb-5",children:[(0,t.jsxs)("div",{className:"flex justify-between mb-4",children:[(0,t.jsx)(x.Z,{className:"text-base mr-2",children:"Shareable Link:"}),(0,t.jsx)(x.Z,{className:"max-w-sm ml-2 bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center rounded",children:"/ui/model_hub?key="})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(i.Z,{onClick:()=>{E.replace("/model_hub?key=".concat(s))},children:"See Page"})})]})}),(0,t.jsx)(f.Z,{title:P&&P.model_group?P.model_group:"Unknown Model",width:800,visible:N,footer:null,onOk:M,onCancel:F,children:P&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-4",children:(0,t.jsx)("strong",{children:"Model Information & Usage"})}),(0,t.jsxs)(c.Z,{children:[(0,t.jsxs)(m.Z,{children:[(0,t.jsx)(d.Z,{children:"OpenAI Python SDK"}),(0,t.jsx)(d.Z,{children:"Supported OpenAI Params"}),(0,t.jsx)(d.Z,{children:"LlamaIndex"}),(0,t.jsx)(d.Z,{children:"Langchain Py"})]}),(0,t.jsxs)(h.Z,{children:[(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:"".concat(null===(l=P.supported_openai_params)||void 0===l?void 0:l.map(e=>"".concat(e,"\n")).join(""))})}),(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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 ')})})]})]})]})})]})}}},function(e){e.O(0,[936,294,131,684,759,777,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,s){Promise.resolve().then(s.bind(s,45980))},45980:function(e,l,s){"use strict";s.r(l),s.d(l,{default:function(){return lt}});var t,n,a=s(3827),r=s(64090),i=s(47907),o=s(8792),d=s(40491),c=s(65270),m=e=>{let{userID:l,userRole:s,userEmail:t,showSSOBanner:n,premiumUser:r,setProxySettings:i,proxySettings:m}=e;console.log("User ID:",l),console.log("userEmail:",t),console.log("showSSOBanner:",n),console.log("premiumUser:",r);let u="";console.log("PROXY_settings=",m),m&&m.PROXY_LOGOUT_URL&&void 0!==m.PROXY_LOGOUT_URL&&(u=m.PROXY_LOGOUT_URL),console.log("logoutUrl=",u);let h=[{key:"1",label:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Role: ",s]}),(0,a.jsxs)("p",{children:["ID: ",l]}),(0,a.jsxs)("p",{children:["Premium User: ",String(r)]})]})},{key:"2",label:(0,a.jsx)("a",{href:u,children:(0,a.jsx)("p",{children:"Logout"})})}];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)(o.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:[n?(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 enterprise license"})}):null,(0,a.jsx)("div",{style:{border:"1px solid #391085",padding:"6px",borderRadius:"8px"},children:(0,a.jsx)(d.Z,{menu:{items:h},children:(0,a.jsx)(c.Z,{children:t})})})]})]})},u=s(777),h=s(10384),x=s(46453),p=s(16450),j=s(52273),g=s(26780),Z=s(15595),f=s(6698),_=s(71801),y=s(42440),b=s(42308),v=s(50670),S=s(60620),k=s(80588),w=s(99129),N=s(44839),I=s(88707),A=s(1861);let{Option:C}=v.default;var P=e=>{let{userID:l,team:s,userRole:t,accessToken:n,data:i,setData:o}=e,[d]=S.Z.useForm(),[c,m]=(0,r.useState)(!1),[P,T]=(0,r.useState)(null),[E,O]=(0,r.useState)(null),[R,M]=(0,r.useState)([]),[F,L]=(0,r.useState)([]),D=()=>{m(!1),d.resetFields()},U=()=>{m(!1),T(null),d.resetFields()};(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===t)return;if(null!==n){let e=(await (0,u.So)(n,l,t)).data.map(e=>e.id);console.log("available_model_names:",e),M(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,t]);let z=async e=>{try{var s,t,a;let r=null!==(s=null==e?void 0:e.key_alias)&&void 0!==s?s:"",c=null!==(t=null==e?void 0:e.team_id)&&void 0!==t?t:null;if((null!==(a=null==i?void 0:i.filter(e=>e.team_id===c).map(e=>e.key_alias))&&void 0!==a?a:[]).includes(r))throw Error("Key alias ".concat(r," already exists for team with ID ").concat(c,", please provide another key alias"));k.ZP.info("Making API Call"),m(!0);let h=await (0,u.wX)(n,l,e);console.log("key create Response:",h),o(e=>e?[...e,h]:[h]),T(h.key),O(h.soft_budget),k.ZP.success("API Key Created"),d.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,r.useEffect)(()=>{L(s&&s.models.length>0?s.models.includes("all-proxy-models")?R:s.models:R)},[s,R]),(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>m(!0),children:"+ Create New Key"}),(0,a.jsx)(w.Z,{title:"Create Key",visible:c,width:800,footer:null,onOk:D,onCancel:U,children:(0,a.jsxs)(S.Z,{form:d,onFinish:z,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",hidden:!0,initialValue:s?s.team_id:null,valuePropName:"team_id",className:"mt-8",children:(0,a.jsx)(N.Z,{value:s?s.team_alias:"",disabled:!0})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},onChange:e=>{e.includes("all-team-models")&&d.setFieldsValue({models:["all-team-models"]})},children:[(0,a.jsx)(C,{value:"all-team-models",children:"All Team Models"},"all-team-models"),F.map(e=>(0,a.jsx)(C,{value:e,children:e},e))]})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==s?void 0:s.max_budget)!==null&&(null==s?void 0:s.max_budget)!==void 0?null==s?void 0:s.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.max_budget&&l>s.max_budget)throw Error("Budget cannot exceed team max budget: $".concat(s.max_budget))}}],children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",help:"Team Reset Budget: ".concat((null==s?void 0:s.budget_duration)!==null&&(null==s?void 0:s.budget_duration)!==void 0?null==s?void 0:s.budget_duration:"None"),children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Tokens per minute Limit (TPM)",name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==s?void 0:s.tpm_limit)!==null&&(null==s?void 0:s.tpm_limit)!==void 0?null==s?void 0:s.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.tpm_limit&&l>s.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(s.tpm_limit))}}],children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Requests per minute Limit (RPM)",name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==s?void 0:s.rpm_limit)!==null&&(null==s?void 0:s.rpm_limit)!==void 0?null==s?void 0:s.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&s&&null!==s.rpm_limit&&l>s.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(s.rpm_limit))}}],children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Expire Key (eg: 30s, 30h, 30d)",name:"duration",className:"mt-8",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",className:"mt-8",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Key"})})]})}),P&&(0,a.jsx)(w.Z,{visible:c,onOk:D,onCancel:U,footer:null,children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Save your Key"}),(0,a.jsx)(h.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)(h.Z,{numColSpan:1,children:null!=P?(0,a.jsxs)("div",{children:[(0,a.jsx)(_.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:P})}),(0,a.jsx)(b.CopyToClipboard,{text:P,onCopy:()=>{k.ZP.success("API Key copied to clipboard")},children:(0,a.jsx)(p.Z,{className:"mt-3",children:"Copy API Key"})})]}):(0,a.jsx)(_.Z,{children:"Key being created, this might take 30s"})})]})})]})},T=s(9454),E=s(98941),O=s(33393),R=s(5),M=s(13810),F=s(61244),L=s(10827),D=s(3851),U=s(2044),z=s(64167),V=s(74480),q=s(7178),B=s(95093),K=s(27166);let{Option:W}=v.default;var G=e=>{let{userID:l,userRole:s,accessToken:t,selectedTeam:n,data:i,setData:o,teams:d}=e,[c,m]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1),[j,g]=(0,r.useState)(null),[Z,f]=(0,r.useState)(null),[b,C]=(0,r.useState)(null),[P,G]=(0,r.useState)(""),[H,Y]=(0,r.useState)(!1),[J,X]=(0,r.useState)(!1),[$,Q]=(0,r.useState)(null),[ee,el]=(0,r.useState)([]),es=new Set,[et,en]=(0,r.useState)(es);(0,r.useEffect)(()=>{(async()=>{try{if(null===l)return;if(null!==t&&null!==s){let e=(await (0,u.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),el(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[t,l,s]),(0,r.useEffect)(()=>{if(d){let e=new Set;d.forEach((l,s)=>{let t=l.team_id;e.add(t)}),en(e)}},[d]);let ea=e=>{console.log("handleEditClick:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),Q(e),Y(!0)},er=async e=>{if(null==t)return;let l=e.token;e.key=l,console.log("handleEditSubmit:",e);let s=await (0,u.Nc)(t,e);console.log("handleEditSubmit: newKeyValues",s),i&&o(i.map(e=>e.token===l?s:e)),k.ZP.success("Key updated successfully"),Y(!1),Q(null)},ei=async e=>{console.log("handleDelete:",e),null==e.token&&null!==e.token_id&&(e.token=e.token_id),null!=i&&(g(e.token),localStorage.removeItem("userData"+l),x(!0))},eo=async()=>{if(null!=j&&null!=i){try{await (0,u.I1)(t,j);let e=i.filter(e=>e.token!==j);o(e)}catch(e){console.error("Error deleting the key:",e)}x(!1),g(null)}};if(null!=i)return console.log("RERENDER TRIGGERED"),(0,a.jsxs)("div",{children:[(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2",children:[(0,a.jsxs)(L.Z,{className:"mt-5 max-h-[300px] min-h-[300px]",children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Key Alias"}),(0,a.jsx)(V.Z,{children:"Secret Key"}),(0,a.jsx)(V.Z,{children:"Spend (USD)"}),(0,a.jsx)(V.Z,{children:"Budget (USD)"}),(0,a.jsx)(V.Z,{children:"Models"}),(0,a.jsx)(V.Z,{children:"TPM / RPM Limits"})]})}),(0,a.jsx)(D.Z,{children:i.map(e=>{if(console.log(e),"litellm-dashboard"===e.team_id)return null;if(n){if(console.log("item team id: ".concat(e.team_id,", knownTeamIDs.has(item.team_id): ").concat(et.has(e.team_id),", selectedTeam id: ").concat(n.team_id)),(null!=n.team_id||null===e.team_id||et.has(e.team_id))&&e.team_id!=n.team_id)return null;console.log("item team id: ".concat(e.team_id,", is returned"))}return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{style:{maxWidth:"2px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!=e.key_alias?(0,a.jsx)(_.Z,{children:e.key_alias}):(0,a.jsx)(_.Z,{children:"Not Set"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:e.key_name})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:(()=>{try{return parseFloat(e.spend).toFixed(4)}catch(l){return e.spend}})()})}),(0,a.jsx)(U.Z,{children:null!=e.max_budget?(0,a.jsx)(_.Z,{children:e.max_budget}):(0,a.jsx)(_.Z,{children:"Unlimited"})}),(0,a.jsx)(U.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:n&&n.models&&n.models.length>0?n.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l)):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:"all-proxy-models"})})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):"all-team-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Team Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(_.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)(U.Z,{children:[(0,a.jsx)(F.Z,{onClick:()=>{Q(e),X(!0)},icon:T.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:J,onCancel:()=>{X(!1),Q(null)},footer:null,width:800,children:$&&(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)(M.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($.spend).toFixed(4)}catch(e){return $.spend}})()})})]}),(0,a.jsxs)(M.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!=$.max_budget?(0,a.jsx)(a.Fragment,{children:$.max_budget}):(0,a.jsx)(a.Fragment,{children:"Unlimited"})})})]},e.name),(0,a.jsxs)(M.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!=$.expires?(0,a.jsx)(a.Fragment,{children:new Date($.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)(M.Z,{className:"my-4",children:[(0,a.jsx)(y.Z,{children:"Token Name"}),(0,a.jsx)(_.Z,{className:"my-1",children:$.key_alias?$.key_alias:$.key_name}),(0,a.jsx)(y.Z,{children:"Token ID"}),(0,a.jsx)(_.Z,{className:"my-1 text-[12px]",children:$.token}),(0,a.jsx)(y.Z,{children:"Metadata"}),(0,a.jsx)(_.Z,{className:"my-1",children:(0,a.jsxs)("pre",{children:[JSON.stringify($.metadata)," "]})})]}),(0,a.jsx)(p.Z,{className:"mx-auto flex items-center",onClick:()=>{X(!1),Q(null)},children:"Close"})]})}),(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>ea(e)}),(0,a.jsx)(F.Z,{onClick:()=>ei(e),icon:O.Z,size:"sm"})]})]},e.token)})})]}),h&&(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)(p.Z,{onClick:eo,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{x(!1),g(null)},children:"Cancel"})]})]})]})})]}),$&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,token:t,onSubmit:i}=e,[o]=S.Z.useForm(),[c,m]=(0,r.useState)(n),[u,h]=(0,r.useState)([]),[x,p]=(0,r.useState)(!1);return(0,a.jsx)(w.Z,{title:"Edit Key",visible:l,width:800,footer:null,onOk:()=>{o.validateFields().then(e=>{o.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:o,onFinish:er,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Key Name",name:"key_alias",rules:[{required:!0,message:"Please input a key name"}],help:"required",children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",rules:[{validator:(e,l)=>{let s=l.filter(e=>!c.models.includes(e)&&"all-team-models"!==e&&"all-proxy-models"!==e&&!c.models.includes("all-proxy-models"));return(console.log("errorModels: ".concat(s)),s.length>0)?Promise.reject("Some models are not part of the new team's models - ".concat(s,"Team models: ").concat(c.models)):Promise.resolve()}}],children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(W,{value:"all-team-models",children:"All Team Models"},"all-team-models"),c&&c.models?c.models.includes("all-proxy-models")?ee.filter(e=>"all-proxy-models"!==e).map(e=>(0,a.jsx)(W,{value:e,children:e},e)):c.models.map(e=>(0,a.jsx)(W,{value:e,children:e},e)):ee.map(e=>(0,a.jsx)(W,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Max Budget (USD)",name:"max_budget",help:"Budget cannot exceed team max budget: ".concat((null==c?void 0:c.max_budget)!==null&&(null==c?void 0:c.max_budget)!==void 0?null==c?void 0:c.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&c&&null!==c.max_budget&&l>c.max_budget)throw console.log("keyTeam.max_budget: ".concat(c.max_budget)),Error("Budget cannot exceed team max budget: $".concat(c.max_budget))}}],children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"token",name:"token",hidden:!0}),(0,a.jsx)(S.Z.Item,{label:"Team",name:"team_id",help:"the team this key belongs to",children:(0,a.jsx)(B.Z,{value:t.team_alias,children:null==d?void 0:d.map((e,l)=>(0,a.jsx)(K.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)(A.ZP,{htmlType:"submit",children:"Edit Key"})})]})})},{visible:H,onCancel:()=>{Y(!1),Q(null)},token:$,onSubmit:er})]})},H=e=>{let{userID:l,userRole:s,accessToken:t,userSpend:n,selectedTeam:i}=e;console.log("userSpend: ".concat(n));let[o,d]=(0,r.useState)(null!==n?n:0),[c,m]=(0,r.useState)(0),[h,x]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=async()=>{if(t&&l&&s&&"Admin"===s&&null==n)try{let e=await (0,u.Qy)(t);e&&(e.spend?d(e.spend):d(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===s)return;if(null!==t){let e=(await (0,u.So)(t,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),x(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[s,t,l]),(0,r.useEffect)(()=>{null!==n&&d(n)},[n]);let p=[];i&&i.models&&(p=i.models),p&&p.includes("all-proxy-models")?(console.log("user models:",h),p=h):p&&p.includes("all-team-models")?p=i.models:p&&0===p.length&&(p=h);let j=void 0!==o?o.toFixed(4):null;return console.log("spend in view user spend: ".concat(o)),(0,a.jsx)("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:["$",j]})]})})},Y=e=>{let{userID:l,userRole:s,selectedTeam:t,accessToken:n}=e,[i,o]=(0,r.useState)([]);(0,r.useEffect)(()=>{(async()=>{try{if(null===l||null===s)return;if(null!==n){let e=(await (0,u.So)(n,l,s)).data.map(e=>e.id);console.log("available_model_names:",e),o(e)}}catch(e){console.error("Error fetching user models:",e)}})()},[n,l,s]);let d=[];return t&&t.models&&(d=t.models),d&&d.includes("all-proxy-models")&&(console.log("user models:",i),d=i),(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==t?void 0:t.team_alias})})})},J=e=>{let l,{teams:s,setSelectedTeam:t,userRole:n}=e,i={models:[],team_id:null,team_alias:"Default Team"},[o,d]=(0,r.useState)(i);return(l="App User"===n?s:s?[...s,i]:[i],"App User"===n)?null:(0,a.jsxs)("div",{className:"mt-5 mb-5",children:[(0,a.jsx)(y.Z,{children:"Select Team"}),(0,a.jsx)(_.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)(_.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)(B.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(K.Z,{value:String(l),onClick:()=>t(e),children:e.team_alias},l))}):(0,a.jsxs)(_.Z,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]})},X=s(37963),$=s(97482);console.log("isLocal:",!1);var Q=e=>{let{userID:l,userRole:s,teams:t,keys:n,setUserRole:o,userEmail:d,setUserEmail:c,setTeams:m,setKeys:p,setProxySettings:j,proxySettings:g}=e,[Z,f]=(0,r.useState)(null),_=(0,i.useSearchParams)();_.get("viewSpend"),(0,i.useRouter)();let y=_.get("token"),[b,v]=(0,r.useState)(null),[S,k]=(0,r.useState)(null),[w,N]=(0,r.useState)([]),I={models:[],team_alias:"Default Team",team_id:null},[A,C]=(0,r.useState)(t?t[0]:I);if(window.addEventListener("beforeunload",function(){sessionStorage.clear()}),(0,r.useEffect)(()=>{if(y){let e=(0,X.o)(y);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),v(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";case"internal_user":return"Internal User";case"internal_user_viewer":return"Internal Viewer";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),o(l)}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e))}}if(l&&b&&s&&!n&&!Z){let e=sessionStorage.getItem("userModels"+l);e?N(JSON.parse(e)):(async()=>{try{let e=await (0,u.Dj)(b);j(e);let t=await (0,u.Br)(b,l,s,!1,null,null);if(console.log("received teams in user dashboard: ".concat(Object.keys(t),"; team values: ").concat(Object.entries(t.teams))),"Admin"==s){let e=await (0,u.Qy)(b);f(e),console.log("globalSpend:",e)}else f(t.user_info);p(t.keys),m(t.teams);let n=[...t.teams];n.length>0?(console.log("response['teams']: ".concat(n)),C(n[0])):C(I),sessionStorage.setItem("userData"+l,JSON.stringify(t.keys)),sessionStorage.setItem("userSpendData"+l,JSON.stringify(t.user_info));let a=(await (0,u.So)(b,l,s)).data.map(e=>e.id);console.log("available_model_names:",a),N(a),console.log("userModels:",w),sessionStorage.setItem("userModels"+l,JSON.stringify(a))}catch(e){console.error("There was an error fetching the data",e)}})()}},[l,y,b,n,s]),(0,r.useEffect)(()=>{if(null!==n&&null!=A&&null!==A.team_id){let e=0;for(let l of n)A.hasOwnProperty("team_id")&&null!==l.team_id&&l.team_id===A.team_id&&(e+=l.spend);k(e)}else if(null!==n){let e=0;for(let l of n)e+=l.spend;k(e)}},[A]),null==l||null==y){let e="/sso/key/generate";return console.log("Full URL:",e),window.location.href=e,null}if(null==b)return null;if(null==s&&o("App Owner"),s&&"Admin Viewer"==s){let{Title:e,Paragraph:l}=$.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",A),(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(Y,{userID:l,userRole:s,selectedTeam:A||null,accessToken:b}),(0,a.jsx)(H,{userID:l,userRole:s,accessToken:b,userSpend:S,selectedTeam:A||null}),(0,a.jsx)(G,{userID:l,userRole:s,accessToken:b,selectedTeam:A||null,data:n,setData:p,teams:t}),(0,a.jsx)(P,{userID:l,team:A||null,userRole:s,accessToken:b,data:n,setData:p},A?A.team_id:null),(0,a.jsx)(J,{teams:t,setSelectedTeam:C,userRole:s})]})})})},ee=s(49167),el=s(35087),es=s(92836),et=s(26734),en=s(41608),ea=s(32126),er=s(23682),ei=s(47047),eo=s(76628),ed=s(25707),ec=s(44041),em=s(6180),eu=s(28683),eh=s(38302),ex=s(66242),ep=s(78578),ej=s(63954),eg=s(34658),eZ=e=>{let{modelID:l,accessToken:s}=e,[t,n]=(0,r.useState)(!1),i=async()=>{try{k.ZP.info("Making API Call"),n(!0);let e=await (0,u.Og)(s,l);console.log("model delete Response:",e),k.ZP.success("Model ".concat(l," deleted successfully")),n(!1)}catch(e){console.error("Error deleting the model:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(F.Z,{onClick:()=>n(!0),icon:O.Z,size:"sm"}),(0,a.jsx)(w.Z,{open:t,onOk:i,okType:"danger",onCancel:()=>n(!1),children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full",children:[(0,a.jsx)(y.Z,{children:"Delete Model"}),(0,a.jsx)(h.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)(h.Z,{numColSpan:1,children:(0,a.jsxs)("p",{children:["Model ID: ",(0,a.jsx)("b",{children:l})]})})]})})]})},ef=s(97766),e_=s(46495),ey=s(18190),eb=s(91118),ev=e=>{let{modelMetrics:l,modelMetricsCategories:s,customTooltip:t,premiumUser:n}=e;return n?(0,a.jsx)(eb.Z,{title:"Time to First token (s)",className:"h-72",data:l,index:"date",showLegend:!1,categories:s,colors:["indigo","rose"],connectNulls:!0,customTooltip:t}):(0,a.jsxs)("div",{children:[(0,a.jsx)(ey.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)(p.Z,{variant:"primary",children:(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"Get in touch"})})]})},eS=e=>{let{fields:l,selectedProvider:s}=e;return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)(S.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)(j.Z,{placeholder:e.field_value,type:"password"})},e.field_name))})},ek=s(67951);let{Title:ew,Link:eN}=$.default;(t=n||(n={})).OpenAI="OpenAI",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Studio",t.Anthropic="Anthropic",t.Google_AI_Studio="Google AI Studio",t.Bedrock="Amazon Bedrock",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.Databricks="Databricks",t.Ollama="Ollama";let eI={OpenAI:"openai",Azure:"azure",Azure_AI_Studio:"azure_ai",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",OpenAI_Compatible:"openai",Vertex_AI:"vertex_ai",Databricks:"databricks",Ollama:"ollama"},eA={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"},eC=async(e,l,s)=>{try{let t=Array.isArray(e.model)?e.model:[e.model];console.log("received deployments: ".concat(t)),console.log("received type of deployments: ".concat(typeof t)),t.forEach(async s=>{console.log("litellm_model: ".concat(s));let t={},n={};t.model=s;let a="";for(let[l,s]of(console.log("formValues add deployment:",e),Object.entries(e)))if(""!==s){if("model_name"==l)a+=s;else if("custom_llm_provider"==l)continue;else if("model"==l)continue;else if("base_model"===l)n[l]=s;else if("litellm_extra_params"==l){console.log("litellm_extra_params:",s);let e={};if(s&&void 0!=s){try{e=JSON.parse(s)}catch(e){throw k.ZP.error("Failed to parse LiteLLM Extra Params: "+e,10),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,s]of Object.entries(e))t[l]=s}}else t[l]=s}let r={model_name:a,litellm_params:t,model_info:n},i=await (0,u.kK)(l,r);console.log("response for model create call: ".concat(i.data))}),s.resetFields()}catch(e){k.ZP.error("Failed to create model: "+e,10)}};var eP=e=>{var l,s,t;let i,{accessToken:o,token:d,userRole:c,userID:m,modelData:h={data:[]},keys:g,setModelData:Z,premiumUser:f}=e,[b,v]=(0,r.useState)([]),[N]=S.Z.useForm(),[C,P]=(0,r.useState)(null),[O,W]=(0,r.useState)(""),[G,H]=(0,r.useState)([]),Y=Object.values(n).filter(e=>isNaN(Number(e))),[J,X]=(0,r.useState)([]),[Q,ey]=(0,r.useState)("OpenAI"),[eb,eP]=(0,r.useState)(""),[eT,eE]=(0,r.useState)(!1),[eO,eR]=(0,r.useState)(!1),[eM,eF]=(0,r.useState)(null),[eL,eD]=(0,r.useState)([]),[eU,ez]=(0,r.useState)(null),[eV,eq]=(0,r.useState)([]),[eB,eK]=(0,r.useState)([]),[eW,eG]=(0,r.useState)([]),[eH,eY]=(0,r.useState)([]),[eJ,eX]=(0,r.useState)([]),[e$,eQ]=(0,r.useState)([]),[e0,e1]=(0,r.useState)([]),[e2,e4]=(0,r.useState)([]),[e5,e8]=(0,r.useState)([]),[e3,e6]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),[e9,e7]=(0,r.useState)(null),[le,ll]=(0,r.useState)(0),[ls,lt]=(0,r.useState)({}),[ln,la]=(0,r.useState)([]),[lr,li]=(0,r.useState)(!1),[lo,ld]=(0,r.useState)(null),[lc,lm]=(0,r.useState)(null),[lu,lh]=(0,r.useState)([]);(0,r.useEffect)(()=>{lb(eU,e3.from,e3.to)},[lo,lc]);let lx=e=>{eF(e),eE(!0)},lp=e=>{eF(e),eR(!0)},lj=async e=>{if(console.log("handleEditSubmit:",e),null==o)return;let l={},s=null;for(let[t,n]of Object.entries(e))"model_id"!==t?l[t]=n:s=n;let t={litellm_params:l,model_info:{id:s}};console.log("handleEditSubmit payload:",t);try{await (0,u.um)(o,t),k.ZP.success("Model updated successfully, restart server to see updates"),eE(!1),eF(null)}catch(e){console.log("Error occurred")}},lg=()=>{W(new Date().toLocaleString())},lZ=async()=>{if(!o){console.error("Access token is missing");return}console.log("new modelGroupRetryPolicy:",e9);try{await (0,u.K_)(o,{router_settings:{model_group_retry_policy:e9}}),k.ZP.success("Retry settings saved successfully")}catch(e){console.error("Failed to save retry settings:",e),k.ZP.error("Failed to save retry settings")}};if((0,r.useEffect)(()=>{if(!o||!d||!c||!m)return;let e=async()=>{try{var e,l,s,t,n,a,r,i,d,h,x,p;let j=await (0,u.hy)(o);X(j);let g=await (0,u.AZ)(o,m,c);console.log("Model data response:",g.data),Z(g);let f=new Set;for(let e=0;e0&&(y=_[_.length-1],console.log("_initial_model_group:",y),ez(y)),console.log("selectedModelGroup:",eU);let b=await (0,u.o6)(o,m,c,y,null===(e=e3.from)||void 0===e?void 0:e.toISOString(),null===(l=e3.to)||void 0===l?void 0:l.toISOString(),null==lo?void 0:lo.token,lc);console.log("Model metrics response:",b),eK(b.data),eG(b.all_api_bases);let v=await (0,u.Rg)(o,y,null===(s=e3.from)||void 0===s?void 0:s.toISOString(),null===(t=e3.to)||void 0===t?void 0:t.toISOString());eY(v.data),eX(v.all_api_bases);let S=await (0,u.N8)(o,m,c,y,null===(n=e3.from)||void 0===n?void 0:n.toISOString(),null===(a=e3.to)||void 0===a?void 0:a.toISOString(),null==lo?void 0:lo.token,lc);console.log("Model exceptions response:",S),eQ(S.data),e1(S.exception_types);let k=await (0,u.fP)(o,m,c,y,null===(r=e3.from)||void 0===r?void 0:r.toISOString(),null===(i=e3.to)||void 0===i?void 0:i.toISOString(),null==lo?void 0:lo.token,lc),w=await (0,u.n$)(o,null===(d=e3.from)||void 0===d?void 0:d.toISOString().split("T")[0],null===(h=e3.to)||void 0===h?void 0:h.toISOString().split("T")[0],y);lt(w);let N=await (0,u.v9)(o,null===(x=e3.from)||void 0===x?void 0:x.toISOString().split("T")[0],null===(p=e3.to)||void 0===p?void 0:p.toISOString().split("T")[0],y);la(N),console.log("dailyExceptions:",w),console.log("dailyExceptionsPerDeplyment:",N),console.log("slowResponses:",k),e8(k);let I=await (0,u.j2)(o);lh(null==I?void 0:I.end_users);let A=(await (0,u.BL)(o,m,c)).router_settings;console.log("routerSettingsInfo:",A);let C=A.model_group_retry_policy,P=A.num_retries;console.log("model_group_retry_policy:",C),console.log("default_retries:",P),e7(C),ll(P)}catch(e){console.error("There was an error fetching the model data",e)}};o&&d&&c&&m&&e();let l=async()=>{let e=await (0,u.qm)();console.log("received model cost map data: ".concat(Object.keys(e))),P(e)};null==C&&l(),lg()},[o,d,c,m,C,O]),!h||!o||!d||!c||!m)return(0,a.jsx)("div",{children:"Loading..."});let lf=[];for(let e=0;e(console.log("GET PROVIDER CALLED! - ".concat(C)),null!=C&&"object"==typeof C&&e in C)?C[e].litellm_provider:"openai";if(n){let e=n.split("/"),l=e[0];r=1===e.length?u(n):l}else r="openai";a&&(i=null==a?void 0:a.input_cost_per_token,o=null==a?void 0:a.output_cost_per_token,d=null==a?void 0:a.max_tokens,c=null==a?void 0:a.max_input_tokens),(null==t?void 0:t.litellm_params)&&(m=Object.fromEntries(Object.entries(null==t?void 0:t.litellm_params).filter(e=>{let[l]=e;return"model"!==l&&"api_base"!==l}))),h.data[e].provider=r,h.data[e].input_cost=i,h.data[e].output_cost=o,h.data[e].input_cost&&(h.data[e].input_cost=(1e6*Number(h.data[e].input_cost)).toFixed(2)),h.data[e].output_cost&&(h.data[e].output_cost=(1e6*Number(h.data[e].output_cost)).toFixed(2)),h.data[e].max_tokens=d,h.data[e].max_input_tokens=c,h.data[e].api_base=null==t?void 0:null===(s=t.litellm_params)||void 0===s?void 0:s.api_base,h.data[e].cleanedLitellmParams=m,lf.push(t.model_name),console.log(h.data[e])}if(c&&"Admin Viewer"==c){let{Title:e,Paragraph:l}=$.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 l_=e=>{console.log("received provider string: ".concat(e));let l=Object.keys(n).find(l=>n[l]===e);if(l){let e=eI[l];console.log("mappingResult: ".concat(e));let s=[];"object"==typeof C&&Object.entries(C).forEach(l=>{let[t,n]=l;null!==n&&"object"==typeof n&&"litellm_provider"in n&&(n.litellm_provider===e||n.litellm_provider.includes(e))&&s.push(t)}),H(s),console.log("providerModels: ".concat(G))}},ly=async()=>{try{k.ZP.info("Running health check..."),eP("");let e=await (0,u.EY)(o);eP(e)}catch(e){console.error("Error running health check:",e),eP("Error running health check")}},lb=async(e,l,s)=>{if(console.log("Updating model metrics for group:",e),!o||!m||!c||!l||!s)return;console.log("inside updateModelMetrics - startTime:",l,"endTime:",s),ez(e);let t=null==lo?void 0:lo.token;void 0===t&&(t=null);let n=lc;void 0===n&&(n=null),l.setHours(0),l.setMinutes(0),l.setSeconds(0),s.setHours(23),s.setMinutes(59),s.setSeconds(59);try{let a=await (0,u.o6)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);console.log("Model metrics response:",a),eK(a.data),eG(a.all_api_bases);let r=await (0,u.Rg)(o,e,l.toISOString(),s.toISOString());eY(r.data),eX(r.all_api_bases);let i=await (0,u.N8)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);console.log("Model exceptions response:",i),eQ(i.data),e1(i.exception_types);let d=await (0,u.fP)(o,m,c,e,l.toISOString(),s.toISOString(),t,n);if(console.log("slowResponses:",d),e8(d),e){let t=await (0,u.n$)(o,null==l?void 0:l.toISOString().split("T")[0],null==s?void 0:s.toISOString().split("T")[0],e);lt(t);let n=await (0,u.v9)(o,null==l?void 0:l.toISOString().split("T")[0],null==s?void 0:s.toISOString().split("T")[0],e);la(n)}}catch(e){console.error("Failed to fetch model metrics",e)}},lv=(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Select API Key Name"}),f?(0,a.jsxs)("div",{children:[(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{ld(null)},children:"All Keys"},"all-keys"),null==g?void 0:g.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{ld(e)},children:e.key_alias},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(B.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(K.Z,{value:"all-customers",onClick:()=>{lm(null)},children:"All Customers"},"all-customers"),null==lu?void 0:lu.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>{lm(e)},children:e},l))]})]}):(0,a.jsxs)("div",{children:[(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{ld(null)},children:"All Keys"},"all-keys"),null==g?void 0:g.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsxs)(K.Z,{value:String(l),disabled:!0,onClick:()=>{ld(e)},children:["✨ ",e.key_alias," (Enterprise only Feature)"]},l):null)]}),(0,a.jsx)(_.Z,{className:"mt-1",children:"Select Customer Name"}),(0,a.jsxs)(B.Z,{defaultValue:"all-customers",children:[(0,a.jsx)(K.Z,{value:"all-customers",onClick:()=>{lm(null)},children:"All Customers"},"all-customers"),null==lu?void 0:lu.map((e,l)=>(0,a.jsxs)(K.Z,{value:e,disabled:!0,onClick:()=>{lm(e)},children:["✨ ",e," (Enterprise only Feature)"]},l))]})]})]}),lS=e=>{var l,s;let{payload:t,active:n}=e;if(!n||!t)return null;let r=null===(s=t[0])||void 0===s?void 0:null===(l=s.payload)||void 0===l?void 0:l.date,i=t.sort((e,l)=>l.value-e.value);if(i.length>5){let e=i.length-5;(i=i.slice(0,5)).push({dataKey:"".concat(e," other deployments"),value:t.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:[r&&(0,a.jsxs)("p",{className:"text-tremor-content-emphasis mb-2",children:["Date: ",r]}),i.map((e,l)=>{let s=parseFloat(e.value.toFixed(5)),t=0===s&&e.value>0?"<0.00001":s.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:t})]},l)})]})};console.log("selectedProvider: ".concat(Q)),console.log("providerModels.length: ".concat(G.length));let lk=Object.keys(n).find(e=>n[e]===Q);return lk&&(i=J.find(e=>e.name===eI[lk])),(0,a.jsx)("div",{style:{width:"100%",height:"100%"},children:(0,a.jsxs)(et.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(es.Z,{children:"All Models"}),(0,a.jsx)(es.Z,{children:"Add Model"}),(0,a.jsx)(es.Z,{children:(0,a.jsx)("pre",{children:"/health Models"})}),(0,a.jsx)(es.Z,{children:"Model Analytics"}),(0,a.jsx)(es.Z,{children:"Model Retry Settings"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[O&&(0,a.jsxs)(_.Z,{children:["Last Refreshed: ",O]}),(0,a.jsx)(F.Z,{icon:ej.Z,variant:"shadow",size:"xs",className:"self-center",onClick:lg})]})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsxs)(B.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eU||eL[0],onValueChange:e=>ez("all"===e?"all":e),value:eU||eL[0],children:[(0,a.jsx)(K.Z,{value:"all",children:"All Models"}),eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>ez(e),children:e},l))]})]}),(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{style:{maxWidth:"1500px",width:"100%"},children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Public Model Name"}),(0,a.jsx)(V.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Provider"}),"Admin"===c&&(0,a.jsx)(V.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"API Base"}),(0,a.jsxs)(V.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Input Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsxs)(V.Z,{style:{maxWidth:"85px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:["Output Price"," ",(0,a.jsx)("p",{style:{fontSize:"10px",color:"gray"},children:"/1M Tokens ($)"})]}),(0,a.jsx)(V.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:f?"Created At":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created At"]})}),(0,a.jsx)(V.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:f?"Created By":(0,a.jsxs)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",style:{color:"#72bcd4"},children:[" ","✨ Created By"]})}),(0,a.jsx)(V.Z,{style:{maxWidth:"50px",whiteSpace:"normal",wordBreak:"break-word",fontSize:"11px"},children:"Status"}),(0,a.jsx)(V.Z,{})]})}),(0,a.jsx)(D.Z,{children:h.data.filter(e=>"all"===eU||e.model_name===eU||null==eU||""===eU).map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{style:{maxHeight:"1px",minHeight:"1px"},children:[(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.model_name||"-"})}),(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("p",{className:"text-xs",children:e.provider||"-"})}),"Admin"===c&&(0,a.jsx)(U.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)(em.Z,{title:e&&e.api_base,children:(0,a.jsx)("pre",{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},className:"text-xs",title:e&&e.api_base?e.api_base:"",children:e&&e.api_base?e.api_base.slice(0,20):"-"})})}),(0,a.jsx)(U.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{className:"text-xs",children:e.input_cost?e.input_cost:e.litellm_params.input_cost_per_token?(1e6*Number(e.litellm_params.input_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(U.Z,{style:{maxWidth:"80px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsx)("pre",{className:"text-xs",children:e.output_cost?e.output_cost:e.litellm_params.output_cost_per_token?(1e6*Number(e.litellm_params.output_cost_per_token)).toFixed(2):null})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:f&&((s=e.model_info.created_at)?new Date(s).toLocaleDateString("en-US"):null)||"-"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)("p",{className:"text-xs",children:f&&e.model_info.created_by||"-"})}),(0,a.jsx)(U.Z,{style:{maxWidth:"100px",whiteSpace:"normal",wordBreak:"break-word"},children:e.model_info.db_model?(0,a.jsx)(R.Z,{size:"xs",className:"text-white",children:(0,a.jsx)("p",{className:"text-xs",children:"DB Model"})}):(0,a.jsx)(R.Z,{size:"xs",className:"text-black",children:(0,a.jsx)("p",{className:"text-xs",children:"Config Model"})})}),(0,a.jsx)(U.Z,{style:{maxWidth:"150px",whiteSpace:"normal",wordBreak:"break-word"},children:(0,a.jsxs)(x.Z,{numItems:3,children:[(0,a.jsx)(eu.Z,{children:(0,a.jsx)(F.Z,{icon:T.Z,size:"sm",onClick:()=>lp(e)})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>lx(e)})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(eZ,{modelID:e.model_info.id,accessToken:o})})]})})]},l)})})]})})]}),(0,a.jsx)(e=>{let{visible:l,onCancel:s,model:t,onSubmit:n}=e,[r]=S.Z.useForm(),i={},o="",d="";if(t){i=t.litellm_params,o=t.model_name;let e=t.model_info;e&&(d=e.id,console.log("model_id: ".concat(d)),i.model_id=d)}return(0,a.jsx)(w.Z,{title:"Edit Model "+o,visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n(e),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:lj,initialValues:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"api_base",name:"api_base",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.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)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.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)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"max_retries",name:"max_retries",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"timeout",name:"timeout",tooltip:"int (optional) - Timeout in seconds for LLM requests (Defaults to 600 seconds)",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"stream_timeout",name:"stream_timeout",tooltip:"int (optional) - Timeout for stream requests (seconds)",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"input_cost_per_token",name:"input_cost_per_token",tooltip:"float (optional) - Input cost per token",children:(0,a.jsx)(I.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"output_cost_per_token",name:"output_cost_per_token",tooltip:"float (optional) - Output cost per token",children:(0,a.jsx)(I.Z,{min:0,step:1e-4})}),(0,a.jsx)(S.Z.Item,{label:"model_id",name:"model_id",hidden:!0})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})},{visible:eT,onCancel:()=>{eE(!1),eF(null)},model:eM,onSubmit:lj}),(0,a.jsxs)(w.Z,{title:eM&&eM.model_name,visible:eO,width:800,footer:null,onCancel:()=>{eR(!1),eF(null)},children:[(0,a.jsx)(y.Z,{children:"Model Info"}),(0,a.jsx)(ek.Z,{language:"json",children:eM&&JSON.stringify(eM,null,2)})]})]}),(0,a.jsxs)(ea.Z,{className:"h-full",children:[(0,a.jsx)(ew,{level:2,children:"Add new model"}),(0,a.jsx)(M.Z,{children:(0,a.jsxs)(S.Z,{form:N,onFinish:()=>{N.validateFields().then(e=>{eC(e,o,N)}).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)(S.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)(B.Z,{value:Q.toString(),children:Y.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>{l_(e),ey(e)},children:e},l))})}),(0,a.jsx)(S.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)(j.Z,{placeholder:"Vertex AI (Anthropic, Gemini, etc.)"===(t=Q.toString())?"gemini-pro":"Anthropic"==t||"Amazon Bedrock"==t?"claude-3-opus":"Google AI Studio"==t?"gemini-pro":"Azure AI Studio"==t?"azure_ai/command-r-plus":"Azure"==t?"azure/my-deployment":"gpt-3.5-turbo"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Model name your users will pass in."})})]}),(0,a.jsx)(S.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"===Q?(0,a.jsx)(j.Z,{placeholder:"Enter model name"}):G.length>0?(0,a.jsx)(ei.Z,{value:G,children:G.map((e,l)=>(0,a.jsx)(eo.Z,{value:e,children:e},l))}):(0,a.jsx)(j.Z,{placeholder:"gpt-3.5-turbo-0125"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Actual model name used for making"," ",(0,a.jsx)(eN,{href:"https://docs.litellm.ai/docs/providers",target:"_blank",children:"litellm.completion() call"}),". We'll"," ",(0,a.jsx)(eN,{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!==i&&i.fields.length>0&&(0,a.jsx)(eS,{fields:i.fields,selectedProvider:i.name}),"Amazon Bedrock"!=Q&&"Vertex AI (Anthropic, Gemini, etc.)"!=Q&&"Ollama"!=Q&&(void 0===i||0==i.fields.length)&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Key",name:"api_key",children:(0,a.jsx)(j.Z,{placeholder:"sk-",type:"password"})}),"OpenAI"==Q&&(0,a.jsx)(S.Z.Item,{label:"Organization ID",name:"organization_id",children:(0,a.jsx)(j.Z,{placeholder:"[OPTIONAL] my-unique-org"})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Project",name:"vertex_project",children:(0,a.jsx)(j.Z,{placeholder:"adroit-cadet-1234.."})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Location",name:"vertex_location",children:(0,a.jsx)(j.Z,{placeholder:"us-east-1"})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Vertex Credentials",name:"vertex_credentials",className:"mb-0",children:(0,a.jsx)(e_.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;N.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?k.ZP.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&k.ZP.error("".concat(e.file.name," file upload failed."))},children:(0,a.jsx)(A.ZP,{icon:(0,a.jsx)(ef.Z,{}),children:"Click to Upload"})})}),"Vertex AI (Anthropic, Gemini, etc.)"==Q&&(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsx)(_.Z,{className:"mb-3 mt-1",children:"Give litellm a gcp service account(.json file), so it can make the relevant calls"})})]}),("Azure"==Q||"OpenAI-Compatible Endpoints (Groq, Together AI, Mistral AI, etc.)"==Q)&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Base",name:"api_base",children:(0,a.jsx)(j.Z,{placeholder:"https://..."})}),"Azure"==Q&&(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"API Version",name:"api_version",children:(0,a.jsx)(j.Z,{placeholder:"2023-07-01-preview"})}),"Azure"==Q&&(0,a.jsxs)("div",{children:[(0,a.jsx)(S.Z.Item,{label:"Base Model",name:"base_model",className:"mb-0",children:(0,a.jsx)(j.Z,{placeholder:"azure/gpt-3.5-turbo"})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,a.jsx)(eN,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),"Amazon Bedrock"==Q&&(0,a.jsx)(S.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)(j.Z,{placeholder:"us-east-1"})}),(0,a.jsx)(S.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)(ep.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,a.jsxs)(eh.Z,{children:[(0,a.jsx)(eu.Z,{span:10}),(0,a.jsx)(eu.Z,{span:10,children:(0,a.jsxs)(_.Z,{className:"mb-3 mt-1",children:["Pass JSON of litellm supported params"," ",(0,a.jsx)(eN,{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)(A.ZP,{htmlType:"submit",children:"Add Model"})}),(0,a.jsx)(em.Z,{title:"Get help on our github",children:(0,a.jsx)($.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})})]})})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(_.Z,{children:"`/health` will run a very small request through your models configured on litellm"}),(0,a.jsx)(p.Z,{onClick:ly,children:"Run `/health`"}),eb&&(0,a.jsx)("pre",{children:JSON.stringify(eb,null,2)})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{numItems:4,className:"mt-2 mb-2",children:[(0,a.jsxs)(eu.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(el.Z,{enableSelect:!0,value:e3,className:"mr-2",onValueChange:e=>{e6(e),lb(eU,e.from,e.to)}})]}),(0,a.jsxs)(eu.Z,{className:"ml-2",children:[(0,a.jsx)(_.Z,{children:"Select Model Group"}),(0,a.jsx)(B.Z,{defaultValue:eU||eL[0],value:eU||eL[0],children:eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>lb(e,e3.from,e3.to),children:e},l))})]}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(ex.Z,{trigger:"click",content:lv,overlayStyle:{width:"20vw"},children:(0,a.jsx)(p.Z,{icon:eg.Z,size:"md",variant:"secondary",className:"mt-4 ml-2",style:{border:"none"},onClick:()=>li(!0)})})})]}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(eu.Z,{children:(0,a.jsx)(M.Z,{className:"mr-2 max-h-[400px] min-h-[400px]",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Avg. Latency per Token"}),(0,a.jsx)(es.Z,{value:"2",children:"✨ Time to first token"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)("p",{className:"text-gray-500 italic",children:" (seconds/token)"}),(0,a.jsx)(_.Z,{className:"text-gray-500 italic mt-1 mb-1",children:"average Latency for successfull requests divided by the total tokens"}),eB&&eW&&(0,a.jsx)(ed.Z,{title:"Model Latency",className:"h-72",data:eB,showLegend:!1,index:"date",categories:eW,connectNulls:!0,customTooltip:lS})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ev,{modelMetrics:eH,modelMetricsCategories:eJ,customTooltip:lS,premiumUser:f})})]})]})})}),(0,a.jsx)(eu.Z,{children:(0,a.jsx)(M.Z,{className:"ml-2 max-h-[400px] min-h-[400px] overflow-y-auto",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Deployment"}),(0,a.jsx)(V.Z,{children:"Success Responses"}),(0,a.jsxs)(V.Z,{children:["Slow Responses ",(0,a.jsx)("p",{children:"Success Responses taking 600+s"})]})]})}),(0,a.jsx)(D.Z,{children:e5.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.api_base}),(0,a.jsx)(U.Z,{children:e.total_count}),(0,a.jsx)(U.Z,{children:e.slow_count})]},l))})]})})})]}),(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 w-full mt-2",children:[(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(y.Z,{children:["All Up Rate Limit Errors (429) for ",eU]}),(0,a.jsxs)(x.Z,{numItems:1,children:[(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",ls.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:ls.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]}),(0,a.jsx)(eu.Z,{})]})]}),f?(0,a.jsx)(a.Fragment,{children:ln.map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base?e.api_base:"Unknown API Base"}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors (429) ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]},l))}):(0,a.jsx)(a.Fragment,{children:ln&&ln.length>0&&ln.slice(0,1).map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"✨ Rate Limit Errors by Deployment"}),(0,a.jsx)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:"Upgrade to see exceptions for all deployments"}),(0,a.jsx)(p.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)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.api_base}),(0,a.jsx)(x.Z,{numItems:1,children:(0,a.jsxs)(eu.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Num Rate Limit Errors ",e.sum_num_rate_limit_exceptions]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["rose"],categories:["num_rate_limit_exceptions"],onValueChange:e=>console.log(e)})]})})]})]},l))})]})]}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(_.Z,{children:"Filter by Public Model Name"}),(0,a.jsx)(B.Z,{className:"mb-4 mt-2 ml-2 w-50",defaultValue:eU||eL[0],value:eU||eL[0],onValueChange:e=>ez(e),children:eL.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>ez(e),children:e},l))})]}),(0,a.jsxs)(y.Z,{children:["Retry Policy for ",eU]}),(0,a.jsx)(_.Z,{className:"mb-6",children:"How many retries should be attempted based on the Exception"}),eA&&(0,a.jsx)("table",{children:(0,a.jsx)("tbody",{children:Object.entries(eA).map((e,l)=>{var s;let[t,n]=e,r=null==e9?void 0:null===(s=e9[eU])||void 0===s?void 0:s[n];return null==r&&(r=le),(0,a.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,a.jsx)("td",{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)("td",{children:(0,a.jsx)(I.Z,{className:"ml-5",value:r,min:0,step:1,onChange:e=>{e7(l=>{var s;let t=null!==(s=null==l?void 0:l[eU])&&void 0!==s?s:{};return{...null!=l?l:{},[eU]:{...t,[n]:e}}})}})})]},l)})})}),(0,a.jsx)(p.Z,{className:"mt-6 mr-8",onClick:lZ,children:"Save"})]})]})]})})},eT=e=>{let{isInvitationLinkModalVisible:l,setIsInvitationLinkModalVisible:s,baseUrl:t,invitationLinkData:n}=e,{Title:r,Paragraph:i}=$.default;return(0,a.jsxs)(w.Z,{title:"Invitation Link",visible:l,width:800,footer:null,onOk:()=>{s(!1)},onCancel:()=>{s(!1)},children:[(0,a.jsx)(i,{children:"Copy and send the generated link to onboard this user to the proxy."}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"User ID"}),(0,a.jsx)(_.Z,{children:null==n?void 0:n.user_id})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,a.jsx)(_.Z,{children:"Invitation Link"}),(0,a.jsxs)(_.Z,{children:[t,"/ui/onboarding?id=",null==n?void 0:n.id]})]}),(0,a.jsxs)("div",{className:"flex justify-end mt-5",children:[(0,a.jsx)("div",{}),(0,a.jsx)(b.CopyToClipboard,{text:"".concat(t,"/ui/onboarding?id=").concat(null==n?void 0:n.id),onCopy:()=>k.ZP.success("Copied!"),children:(0,a.jsx)(p.Z,{variant:"primary",children:"Copy invitation link"})})]})]})};let{Option:eE}=v.default;var eO=e=>{let{userID:l,accessToken:s,teams:t,possibleUIRoles:n}=e,[o]=S.Z.useForm(),[d,c]=(0,r.useState)(!1),[m,h]=(0,r.useState)(null),[x,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[y,b]=(0,r.useState)(null),I=(0,i.useRouter)(),[C,P]=(0,r.useState)("");(0,r.useEffect)(()=>{(async()=>{try{let e=await (0,u.So)(s,l,"any"),t=[];for(let l=0;l{if(I){let{protocol:e,host:l}=window.location;P("".concat(e,"/").concat(l))}},[I]);let T=async e=>{try{var t;k.ZP.info("Making API Call"),c(!0),console.log("formValues in create user:",e);let n=await (0,u.Ov)(s,null,e);console.log("user create Response:",n),h(n.key);let a=(null===(t=n.data)||void 0===t?void 0:t.user_id)||n.user_id;(0,u.XO)(s,a).then(e=>{b(e),f(!0)}),k.ZP.success("API user Created"),o.resetFields(),localStorage.removeItem("userData"+l)}catch(e){console.error("Error creating the user:",e)}};return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-0",onClick:()=>c(!0),children:"+ Invite User"}),(0,a.jsxs)(w.Z,{title:"Invite User",visible:d,width:800,footer:null,onOk:()=>{c(!1),o.resetFields()},onCancel:()=>{c(!1),h(null),o.resetFields()},children:[(0,a.jsx)(_.Z,{className:"mb-1",children:"Create a User who can own keys"}),(0,a.jsxs)(S.Z,{form:o,onFinish:T,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(S.Z.Item,{label:"User Email",name:"user_email",children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:n&&Object.entries(n).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(K.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"team_id",children:(0,a.jsx)(v.default,{placeholder:"Select Team ID",style:{width:"100%"},children:t?t.map(e=>(0,a.jsx)(eE,{value:e.team_id,children:e.team_alias},e.team_id)):(0,a.jsx)(eE,{value:null,children:"Default Team"},"default")})}),(0,a.jsx)(S.Z.Item,{label:"Metadata",name:"metadata",children:(0,a.jsx)(N.Z.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create User"})})]})]}),m&&(0,a.jsx)(eT,{isInvitationLinkModalVisible:Z,setIsInvitationLinkModalVisible:f,baseUrl:C,invitationLinkData:y})]})},eR=e=>{let{visible:l,possibleUIRoles:s,onCancel:t,user:n,onSubmit:i}=e,[o,d]=(0,r.useState)(n),[c]=S.Z.useForm();(0,r.useEffect)(()=>{c.resetFields()},[n]);let m=async()=>{c.resetFields(),t()},u=async e=>{i(e),c.resetFields(),t()};return n?(0,a.jsx)(w.Z,{visible:l,onCancel:m,footer:null,title:"Edit User "+n.user_id,width:1e3,children:(0,a.jsx)(S.Z,{form:c,onFinish:u,initialValues:n,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"User Email",tooltip:"Email of the User",name:"user_email",children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"user_id",name:"user_id",hidden:!0,children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"User Role",name:"user_role",children:(0,a.jsx)(v.default,{children:s&&Object.entries(s).map(e=>{let[l,{ui_label:s,description:t}]=e;return(0,a.jsx)(K.Z,{value:l,title:s,children:(0,a.jsxs)("div",{className:"flex",children:[s," ",(0,a.jsx)("p",{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:t})]})},l)})})}),(0,a.jsx)(S.Z.Item,{label:"Spend (USD)",name:"spend",tooltip:"(float) - Spend of all LLM calls completed by this user",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)(S.Z.Item,{label:"User Budget (USD)",name:"max_budget",tooltip:"(float) - Maximum budget of this user",children:(0,a.jsx)(I.Z,{min:0,step:1})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})}):null},eM=e=>{let{accessToken:l,token:s,keys:t,userRole:n,userID:i,teams:o,setKeys:d}=e,[c,m]=(0,r.useState)(null),[h,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(0),[Z,f]=r.useState(null),[_,y]=(0,r.useState)(null),[b,v]=(0,r.useState)(!1),[S,w]=(0,r.useState)(null),[N,I]=(0,r.useState)({}),A=async()=>{w(null),v(!1)},C=async e=>{if(console.log("inside handleEditSubmit:",e),l&&s&&n&&i){try{await (0,u.pf)(l,e,null),k.ZP.success("User ".concat(e.user_id," updated successfully"))}catch(e){console.error("There was an error updating the user",e)}c&&m(c.map(l=>l.user_id===e.user_id?e:l)),w(null),v(!1)}};return((0,r.useEffect)(()=>{if(!l||!s||!n||!i)return;let e=async()=>{try{let e=await (0,u.Br)(l,null,n,!0,j,25);console.log("user data response:",e),m(e);let s=await (0,u.lg)(l);I(s)}catch(e){console.error("There was an error fetching the model data",e)}};l&&s&&n&&i&&e()},[l,s,n,i,j]),c&&l&&s&&n&&i)?(0,a.jsx)("div",{style:{width:"100%"},children:(0,a.jsxs)(x.Z,{className:"gap-2 p-2 h-[90vh] w-full mt-8",children:[(0,a.jsx)(eO,{userID:i,accessToken:l,teams:o,possibleUIRoles:N}),(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[90vh] mb-4",children:[(0,a.jsx)("div",{className:"mb-4 mt-1"}),(0,a.jsx)(et.Z,{children:(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(L.Z,{className:"mt-5",children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"User ID"}),(0,a.jsx)(V.Z,{children:"User Email"}),(0,a.jsx)(V.Z,{children:"Role"}),(0,a.jsx)(V.Z,{children:"User Spend ($ USD)"}),(0,a.jsx)(V.Z,{children:"User Max Budget ($ USD)"}),(0,a.jsx)(V.Z,{children:"API Keys"}),(0,a.jsx)(V.Z,{})]})}),(0,a.jsx)(D.Z,{children:c.map(e=>{var l,s;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_id||"-"}),(0,a.jsx)(U.Z,{children:e.user_email||"-"}),(0,a.jsx)(U.Z,{children:(null==N?void 0:null===(l=N[null==e?void 0:e.user_role])||void 0===l?void 0:l.ui_label)||"-"}),(0,a.jsx)(U.Z,{children:e.spend?null===(s=e.spend)||void 0===s?void 0:s.toFixed(2):"-"}),(0,a.jsx)(U.Z,{children:e.max_budget?e.max_budget:"Unlimited"}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(x.Z,{numItems:2,children:e&&e.key_aliases&&e.key_aliases.filter(e=>null!==e).length>0?(0,a.jsxs)(R.Z,{size:"xs",color:"indigo",children:[e.key_aliases.filter(e=>null!==e).length,"\xa0Keys"]}):(0,a.jsx)(R.Z,{size:"xs",color:"gray",children:"No Keys"})})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:E.Z,onClick:()=>{w(e),v(!0)},children:"View Keys"})})]},e.user_id)})})]})}),(0,a.jsx)(ea.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"})]})})]})}),(0,a.jsx)(eR,{visible:b,possibleUIRoles:N,onCancel:A,user:S,onSubmit:C})]}),function(){if(!c)return null;let e=Math.ceil(c.length/25);return(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{children:["Showing Page ",j+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===j,onClick:()=>g(j-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:()=>{g(j+1)},children:"Next →"})]})]})}()]})}):(0,a.jsx)("div",{children:"Loading..."})},eF=e=>{let{teams:l,searchParams:s,accessToken:t,setTeams:n,userID:i,userRole:o}=e,[d]=S.Z.useForm(),[c]=S.Z.useForm(),{Title:m,Paragraph:g}=$.default,[Z,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(!1),[C,P]=(0,r.useState)(l?l[0]:null),[T,W]=(0,r.useState)(!1),[G,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)([]),[X,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),[es,et]=(0,r.useState)({}),en=e=>{P(e),b(!0)},ea=async e=>{let s=e.team_id;if(console.log("handleEditSubmit:",e),null==t)return;let a=await (0,u.Gh)(t,e);l&&n(l.map(e=>e.team_id===s?a.data:e)),k.ZP.success("Team updated successfully"),b(!1),P(null)},er=async e=>{el(e),Q(!0)},ei=async()=>{if(null!=ee&&null!=l&&null!=t){try{await (0,u.rs)(t,ee);let e=l.filter(e=>e.team_id!==ee);n(e)}catch(e){console.error("Error deleting the team:",e)}Q(!1),el(null)}};(0,r.useEffect)(()=>{let e=async()=>{try{if(null===i||null===o||null===t||null===l)return;console.log("fetching team info:");let e={};for(let s=0;s<(null==l?void 0:l.length);s++){let n=l[s].team_id,a=await (0,u.Xm)(t,n);console.log("teamInfo response:",a),null!==a&&(e={...e,[n]:a})}et(e)}catch(e){console.error("Error fetching team info:",e)}};(async()=>{try{if(null===i||null===o)return;if(null!==t){let e=(await (0,u.So)(t,i,o)).data.map(e=>e.id);console.log("available_model_names:",e),J(e)}}catch(e){console.error("Error fetching user models:",e)}})(),e()},[t,i,o,l]);let eo=async e=>{try{if(null!=t){var s;let a=null==e?void 0:e.team_alias;if((null!==(s=null==l?void 0:l.map(e=>e.team_alias))&&void 0!==s?s:[]).includes(a))throw Error("Team alias ".concat(a," already exists, please pick another alias"));k.ZP.info("Creating Team");let r=await (0,u.hT)(t,e);null!==l?n([...l,r]):n([r]),console.log("response for team create call: ".concat(r)),k.ZP.success("Team created"),W(!1)}}catch(e){console.error("Error creating the team:",e),k.ZP.error("Error creating the team: "+e,20)}},ed=async e=>{try{if(null!=t&&null!=l){k.ZP.info("Adding Member");let s={role:"user",user_email:e.user_email,user_id:e.user_id},a=await (0,u.cu)(t,C.team_id,s);console.log("response for team create call: ".concat(a.data));let r=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(r)),-1!==r){let e=[...l];e[r]=a.data,n(e),P(a.data)}H(!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)(x.Z,{numItems:1,className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"All Teams"}),(0,a.jsxs)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Team Name"}),(0,a.jsx)(V.Z,{children:"Spend (USD)"}),(0,a.jsx)(V.Z,{children:"Budget (USD)"}),(0,a.jsx)(V.Z,{children:"Models"}),(0,a.jsx)(V.Z,{children:"TPM / RPM Limits"}),(0,a.jsx)(V.Z,{children:"Info"})]})}),(0,a.jsx)(D.Z,{children:l&&l.length>0?l.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.spend}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.max_budget?e.max_budget:"No limit"}),(0,a.jsx)(U.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)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})}):e.models.map((e,l)=>"all-proxy-models"===e?(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"red",children:(0,a.jsx)(_.Z,{children:"All Proxy Models"})},l):(0,a.jsx)(R.Z,{size:"xs",className:"mb-1",color:"blue",children:(0,a.jsx)(_.Z,{children:e.length>30?"".concat(e.slice(0,30),"..."):e})},l))}):null}),(0,a.jsx)(U.Z,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,a.jsxs)(_.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)(U.Z,{children:[(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].keys&&es[e.team_id].keys.length," ","Keys"]}),(0,a.jsxs)(_.Z,{children:[es&&e.team_id&&es[e.team_id]&&es[e.team_id].team_info&&es[e.team_id].team_info.members_with_roles&&es[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>en(e)}),(0,a.jsx)(F.Z,{onClick:()=>er(e.team_id),icon:O.Z,size:"sm"})]})]},e.team_id)):null})]}),X&&(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)(p.Z,{onClick:ei,color:"red",className:"ml-2",children:"Delete"}),(0,a.jsx)(p.Z,{onClick:()=>{Q(!1),el(null)},children:"Cancel"})]})]})]})})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>W(!0),children:"+ Create New Team"}),(0,a.jsx)(w.Z,{title:"Create Team",visible:T,width:800,footer:null,onOk:()=>{W(!1),d.resetFields()},onCancel:()=>{W(!1),d.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:eo,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),Y.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Team"})})]})})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(m,{level:4,children:"Team Members"}),(0,a.jsx)(g,{children:"If you belong to multiple teams, this setting controls which teams members you see."}),l&&l.length>0?(0,a.jsx)(B.Z,{defaultValue:"0",children:l.map((e,l)=>(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{P(e)},children:e.team_alias},l))}):(0,a.jsxs)(g,{children:["No team created. ",(0,a.jsx)("b",{children:"Defaulting to personal account."})]})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Member Name"}),(0,a.jsx)(V.Z,{children:"Role"})]})}),(0,a.jsx)(D.Z,{children:C?C.members_with_roles.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsx)(U.Z,{children:e.role})]},l)):null})]})}),C&&(0,a.jsx)(e=>{let{visible:l,onCancel:s,team:t,onSubmit:n}=e,[r]=S.Z.useForm();return(0,a.jsx)(w.Z,{title:"Edit Team",visible:l,width:800,footer:null,onOk:()=>{r.validateFields().then(e=>{n({...e,team_id:t.team_id}),r.resetFields()}).catch(e=>{console.error("Validation failed:",e)})},onCancel:s,children:(0,a.jsxs)(S.Z,{form:r,onFinish:ea,initialValues:t,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,a.jsx)(j.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"Models",name:"models",children:(0,a.jsxs)(v.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,a.jsx)(v.default.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),Y&&Y.map(e=>(0,a.jsx)(v.default.Option,{value:e,children:e},e))]})}),(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.Z.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,a.jsx)(I.Z,{step:1,width:400})}),(0,a.jsx)(S.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)(A.ZP,{htmlType:"submit",children:"Edit Team"})})]})})},{visible:y,onCancel:()=>{b(!1),P(null)},team:C,onSubmit:ea})]}),(0,a.jsxs)(h.Z,{numColSpan:1,children:[(0,a.jsx)(p.Z,{className:"mx-auto mb-5",onClick:()=>H(!0),children:"+ Add member"}),(0,a.jsx)(w.Z,{title:"Add member",visible:G,width:800,footer:null,onOk:()=>{H(!1),c.resetFields()},onCancel:()=>{H(!1),c.resetFields()},children:(0,a.jsxs)(S.Z,{form:d,onFinish:ed,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-4",children:(0,a.jsx)(N.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)(S.Z.Item,{label:"User ID",name:"user_id",className:"mb-4",children:(0,a.jsx)(N.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)(A.ZP,{htmlType:"submit",children:"Add member"})})]})})]})]})})},eL=e=>{let l,{searchParams:s,accessToken:t,showSSOBanner:n}=e,[o]=S.Z.useForm(),[d]=S.Z.useForm(),{Title:c,Paragraph:m}=$.default,[j,g]=(0,r.useState)(""),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)(null),[v,I]=(0,r.useState)(!1),[C,P]=(0,r.useState)(!1),[T,O]=(0,r.useState)(!1),[R,W]=(0,r.useState)(!1),[G,H]=(0,r.useState)(!1),[Y,J]=(0,r.useState)(!1),X=(0,i.useRouter)(),[Q,ee]=(0,r.useState)(null),[el,es]=(0,r.useState)("");try{l=window.location.origin}catch(e){l=""}l+="/fallback/login";let et=()=>{J(!1)},en=["proxy_admin","proxy_admin_viewer"];(0,r.useEffect)(()=>{if(X){let{protocol:e,host:l}=window.location;es("".concat(e,"//").concat(l))}},[X]),(0,r.useEffect)(()=>{(async()=>{if(null!=t){let e=[],l=await (0,u.Xd)(t,"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 s=await (0,u.Xd)(t,"proxy_admin");s.forEach(l=>{e.push({user_role:l.user_role,user_id:l.user_id,user_email:l.user_email})}),console.log("proxy admins: ".concat(s)),console.log("combinedList: ".concat(e)),f(e),ee(await (0,u.lg)(t))}})()},[t]);let ea=()=>{W(!1),d.resetFields(),o.resetFields()},er=()=>{W(!1),d.resetFields(),o.resetFields()},ei=e=>(0,a.jsxs)(S.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.Z.Item,{label:"Email",name:"user_email",className:"mb-8 mt-4",children:(0,a.jsx)(N.Z,{name:"user_email",className:"px-3 py-2 border rounded-md w-full"})})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},className:"mt-4",children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Add member"})})]}),eo=(e,l,s)=>(0,a.jsxs)(S.Z,{form:o,onFinish:e,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{rules:[{required:!0,message:"Required"}],label:"User Role",name:"user_role",labelCol:{span:10},labelAlign:"left",children:(0,a.jsx)(B.Z,{value:l,children:en.map((e,l)=>(0,a.jsx)(K.Z,{value:e,children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Team ID",name:"user_id",hidden:!0,initialValue:s,valuePropName:"user_id",className:"mt-8",children:(0,a.jsx)(N.Z,{value:s,disabled:!0})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Update role"})})]}),ed=async e=>{try{if(null!=t&&null!=Z){k.ZP.info("Making API Call");let l=await (0,u.pf)(t,e,null);console.log("response for team create call: ".concat(l));let s=Z.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(s)),-1==s&&(console.log("updates admin with new user"),Z.push(l),f(Z)),k.ZP.success("Refresh tab to see updated user role"),W(!1)}}catch(e){console.error("Error creating the key:",e)}},ec=async e=>{try{if(null!=t&&null!=Z){var l;k.ZP.info("Making API Call");let s=await (0,u.pf)(t,e,"proxy_admin_viewer");console.log("response for team create call: ".concat(s));let n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{b(e),I(!0)});let a=Z.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(s.user_id)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),Z.push(s),f(Z)),o.resetFields(),P(!1)}}catch(e){console.error("Error creating the key:",e)}},em=async e=>{try{if(null!=t&&null!=Z){var l;k.ZP.info("Making API Call"),e.user_email,e.user_id;let s=await (0,u.pf)(t,e,"proxy_admin"),n=(null===(l=s.data)||void 0===l?void 0:l.user_id)||s.user_id;(0,u.XO)(t,n).then(e=>{b(e),I(!0)}),console.log("response for team create call: ".concat(s));let a=Z.findIndex(e=>(console.log("user.user_id=".concat(e.user_id,"; response.user_id=").concat(n)),e.user_id===s.user_id));console.log("foundIndex: ".concat(a)),-1==a&&(console.log("updates admin with new user"),Z.push(s),f(Z)),o.resetFields(),O(!1)}}catch(e){console.error("Error creating the key:",e)}},eu=async e=>{if(null==t)return;let l={environment_variables:{PROXY_BASE_URL:e.proxy_base_url,GOOGLE_CLIENT_ID:e.google_client_id,GOOGLE_CLIENT_SECRET:e.google_client_secret}};(0,u.K_)(t,l)};return console.log("admins: ".concat(null==Z?void 0:Z.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)(m,{children:[n&&(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)(x.Z,{numItems:1,className:"gap-2 p-2 w-full",children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(M.Z,{className:"w-full mx-auto flex-auto overflow-y-auto max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Member Name"}),(0,a.jsx)(V.Z,{children:"Role"})]})}),(0,a.jsx)(D.Z,{children:Z?Z.map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.user_email?e.user_email:e.user_id?e.user_id:null}),(0,a.jsxs)(U.Z,{children:[" ",(null==Q?void 0:null===(s=Q[null==e?void 0:e.user_role])||void 0===s?void 0:s.ui_label)||"-"]}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>W(!0)}),(0,a.jsx)(w.Z,{title:"Update role",visible:R,width:800,footer:null,onOk:ea,onCancel:er,children:eo(ed,e.user_role,e.user_id)})]})]},l)}):null})]})})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)(p.Z,{className:"mr-4 mb-5",onClick:()=>O(!0),children:"+ Add admin"}),(0,a.jsx)(w.Z,{title:"Add admin",visible:T,width:800,footer:null,onOk:()=>{O(!1),d.resetFields(),o.resetFields()},onCancel:()=>{O(!1),I(!1),d.resetFields(),o.resetFields()},children:ei(em)}),(0,a.jsx)(eT,{isInvitationLinkModalVisible:v,setIsInvitationLinkModalVisible:I,baseUrl:el,invitationLinkData:y}),(0,a.jsx)(p.Z,{className:"mb-5",onClick:()=>P(!0),children:"+ Add viewer"}),(0,a.jsx)(w.Z,{title:"Add viewer",visible:C,width:800,footer:null,onOk:()=>{P(!1),d.resetFields(),o.resetFields()},onCancel:()=>{P(!1),d.resetFields(),o.resetFields()},children:ei(ec)})]})})]}),(0,a.jsxs)(x.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)(p.Z,{onClick:()=>H(!0),children:"Add SSO"}),(0,a.jsx)(w.Z,{title:"Add SSO",visible:G,width:800,footer:null,onOk:()=>{H(!1),o.resetFields()},onCancel:()=>{H(!1),o.resetFields()},children:(0,a.jsxs)(S.Z,{form:o,onFinish:e=>{em(e),eu(e),H(!1),J(!0)},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.Z.Item,{label:"Admin Email",name:"user_email",rules:[{required:!0,message:"Please enter the email of the proxy admin"}],children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"PROXY BASE URL",name:"proxy_base_url",rules:[{required:!0,message:"Please enter the proxy base url"}],children:(0,a.jsx)(N.Z,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT ID",name:"google_client_id",rules:[{required:!0,message:"Please enter the google client id"}],children:(0,a.jsx)(N.Z.Password,{})}),(0,a.jsx)(S.Z.Item,{label:"GOOGLE CLIENT SECRET",name:"google_client_secret",rules:[{required:!0,message:"Please enter the google client secret"}],children:(0,a.jsx)(N.Z.Password,{})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})}),(0,a.jsxs)(w.Z,{title:"SSO Setup Instructions",visible:Y,width:800,footer:null,onOk:et,onCancel:()=>{J(!1)},children:[(0,a.jsx)("p",{children:"Follow these steps to complete the SSO setup:"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"1. DO NOT Exit this TAB"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"2. Open a new tab, visit your proxy base url"}),(0,a.jsx)(_.Z,{className:"mt-2",children:"3. Confirm your SSO is configured correctly and you can login on the new Tab"}),(0,a.jsx)(_.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)(A.ZP,{onClick:et,children:"Done"})})]})]}),(0,a.jsxs)(ey.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})," "]})]})]})]})},eD=s(42556),eU=s(90252),ez=e=>{let{alertingSettings:l,handleInputChange:s,handleResetField:t,handleSubmit:n,premiumUser:r}=e,[i]=S.Z.useForm();return(0,a.jsxs)(S.Z,{form:i,onFinish:()=>{let e=i.getFieldsValue();Object.values(e).some(e=>""===e||null==e)?console.log("Some form fields are empty."):n(e)},labelAlign:"left",children:[l.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(U.Z,{align:"center",children:[(0,a.jsx)(_.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?r?(0,a.jsx)(S.Z.Item,{name:e.field_name,children:(0,a.jsx)(U.Z,{children:"Integer"===e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l)}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}):(0,a.jsx)(U.Z,{children:(0,a.jsx)(p.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)(S.Z.Item,{name:e.field_name,className:"mb-0",children:(0,a.jsx)(U.Z,{children:"Integer"===e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>s(e.field_name,l),className:"p-0"}):(0,a.jsx)(N.Z,{value:e.field_value,onChange:l=>s(e.field_name,l)})})}),(0,a.jsx)(U.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eU.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:O.Z,color:"red",onClick:()=>t(e.field_name,l),children:"Reset"})})]},l)),(0,a.jsx)("div",{children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Update Settings"})})]})},eV=e=>{let{accessToken:l,premiumUser:s}=e,[t,n]=(0,r.useState)([]);return console.log("INSIDE ALERTING SETTINGS"),(0,r.useEffect)(()=>{l&&(0,u.RQ)(l).then(e=>{n(e)})},[l]),(0,a.jsx)(ez,{alertingSettings:t,handleInputChange:(e,l)=>{n(t.map(s=>s.field_name===e?{...s,field_value:l}:s))},handleResetField:(e,s)=>{if(l)try{let l=t.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:l.field_default_value}:l);console.log("INSIDE HANDLE RESET FIELD"),n(l)}catch(e){console.log("ERROR OCCURRED!")}},handleSubmit:e=>{if(!l||null==e||void 0==e)return;let s={};t.forEach(e=>{s[e.field_name]=e.field_value});let n={...e,...s};try{(0,u.jA)(l,"alerting_args",n),k.ZP.success("Wait 10s for proxy to update.")}catch(e){}},premiumUser:s})},eq=s(84406);let{Title:eB,Paragraph:eK}=$.default;var eW=e=>{let{accessToken:l,userRole:s,userID:t,premiumUser:n}=e,[i,o]=(0,r.useState)([]),[d,c]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g]=S.Z.useForm(),[Z,f]=(0,r.useState)(null),[y,b]=(0,r.useState)([]),[N,I]=(0,r.useState)(""),[C,P]=(0,r.useState)({}),[T,O]=(0,r.useState)([]),[R,B]=(0,r.useState)(!1),[W,G]=(0,r.useState)([]),[H,Y]=(0,r.useState)(null),[J,X]=(0,r.useState)([]),[$,Q]=(0,r.useState)(!1),[ee,el]=(0,r.useState)(null),ei=e=>{T.includes(e)?O(T.filter(l=>l!==e)):O([...T,e])},eo={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,r.useEffect)(()=>{l&&s&&t&&(0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.callbacks),G(e.available_callbacks);let l=e.alerts;if(console.log("alerts_data",l),l&&l.length>0){let e=l[0];console.log("_alert_info",e);let s=e.variables.SLACK_WEBHOOK_URL;console.log("catch_all_webhook",s),O(e.active_alerts),I(s),P(e.alerts_to_webhook)}c(l)})},[l,s,t]);let ed=e=>T&&T.includes(e),ec=()=>{if(!l)return;let e={};d.filter(e=>"email"===e.name).forEach(l=>{var s;Object.entries(null!==(s=l.variables)&&void 0!==s?s:{}).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));n&&n.value&&(e[s]=null==n?void 0:n.value)})}),console.log("updatedVariables",e);try{(0,u.K_)(l,{general_settings:{alerting:["email"]},environment_variables:e})}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Email settings updated successfully")},em=async e=>{if(!l)return;let s={};Object.entries(e).forEach(e=>{let[l,t]=e;"callback"!==l&&(s[l]=t)});try{await (0,u.K_)(l,{environment_variables:s}),k.ZP.success("Callback added successfully"),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eu=async e=>{if(!l)return;let s=null==e?void 0:e.callback,t={};Object.entries(e).forEach(e=>{let[l,s]=e;"callback"!==l&&(t[l]=s)});try{await (0,u.K_)(l,{environment_variables:t,litellm_settings:{success_callback:[s]}}),k.ZP.success("Callback ".concat(s," added successfully")),h(!1),g.resetFields(),f(null)}catch(e){k.ZP.error("Failed to add callback: "+e,20)}},eh=e=>{console.log("inside handleSelectedCallbackChange",e),f(e.litellm_callback_name),console.log("all callbacks",W),e&&e.litellm_callback_params?(X(e.litellm_callback_params),console.log("selectedCallbackParams",J)):X([])};return l?(console.log("callbacks: ".concat(i)),(0,a.jsxs)("div",{className:"w-full mx-4",children:[(0,a.jsx)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Logging Callbacks"}),(0,a.jsx)(es.Z,{value:"2",children:"Alerting Types"}),(0,a.jsx)(es.Z,{value:"3",children:"Alerting Settings"}),(0,a.jsx)(es.Z,{value:"4",children:"Email Alerts"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)(eB,{level:4,children:"Active Logging Callbacks"}),(0,a.jsx)(x.Z,{numItems:2,children:(0,a.jsx)(M.Z,{className:"max-h-[50vh]",children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsx)(q.Z,{children:(0,a.jsx)(V.Z,{children:"Callback Name"})})}),(0,a.jsx)(D.Z,{children:i.map((e,s)=>(0,a.jsxs)(q.Z,{className:"flex justify-between",children:[(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:e.name})}),(0,a.jsx)(U.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"flex justify-between",children:[(0,a.jsx)(F.Z,{icon:E.Z,size:"sm",onClick:()=>{el(e),Q(!0)}}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,e.name),className:"ml-2",variant:"secondary",children:"Test Callback"})]})})]},s))})]})})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>B(!0),children:"Add Callback"})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(_.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)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{}),(0,a.jsx)(V.Z,{}),(0,a.jsx)(V.Z,{children:"Slack Webhook URL"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(eo).map((e,l)=>{let[s,t]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:"region_outage_alerts"==s?n?(0,a.jsx)(eD.Z,{id:"switch",name:"switch",checked:ed(s),onChange:()=>ei(s)}):(0,a.jsx)(p.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)(eD.Z,{id:"switch",name:"switch",checked:ed(s),onChange:()=>ei(s)})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(_.Z,{children:t})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(j.Z,{name:s,type:"password",defaultValue:C&&C[s]?C[s]:N})})]},l)})})]}),(0,a.jsx)(p.Z,{size:"xs",className:"mt-2",onClick:()=>{if(!l)return;let e={};Object.entries(eo).forEach(l=>{let[s,t]=l,n=document.querySelector('input[name="'.concat(s,'"]'));console.log("key",s),console.log("webhookInput",n);let a=(null==n?void 0:n.value)||"";console.log("newWebhookValue",a),e[s]=a}),console.log("updatedAlertToWebhooks",e);let s={general_settings:{alert_to_webhook_url:e,alert_types:T}};console.log("payload",s);try{(0,u.K_)(l,s)}catch(e){k.ZP.error("Failed to update alerts: "+e,20)}k.ZP.success("Alerts updated successfully")},children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"slack"),className:"mx-2",children:"Test Alerts"})]})}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(eV,{accessToken:l,premiumUser:n})}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(eB,{level:4,children:"Email Settings"}),(0,a.jsxs)(_.Z,{children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: email alerts"})," ",(0,a.jsx)("br",{})]}),(0,a.jsx)("div",{className:"flex w-full",children:d.filter(e=>"email"===e.name).map((e,l)=>{var s;return(0,a.jsx)(U.Z,{children:(0,a.jsx)("ul",{children:(0,a.jsx)(x.Z,{numItems:2,children:Object.entries(null!==(s=e.variables)&&void 0!==s?s:{}).map(e=>{let[l,s]=e;return(0,a.jsxs)("li",{className:"mx-2 my-2",children:[!0!=n&&("EMAIL_LOGO_URL"===l||"EMAIL_SUPPORT_CONTACT"===l)?(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:(0,a.jsxs)(_.Z,{className:"mt-2",children:[" ","✨ ",l]})}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",disabled:!0,style:{width:"400px"}})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)(_.Z,{className:"mt-2",children:l}),(0,a.jsx)(j.Z,{name:l,defaultValue:s,type:"password",style:{width:"400px"}})]}),(0,a.jsxs)("p",{style:{fontSize:"small",fontStyle:"italic"},children:["SMTP_HOST"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP host address, e.g. `smtp.resend.com`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PORT"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP port number, e.g. `587`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_USERNAME"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the SMTP username, e.g. `username`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"SMTP_PASSWORD"===l&&(0,a.jsx)("span",{style:{color:"red"},children:" Required * "}),"SMTP_SENDER_EMAIL"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Enter the sender email address, e.g. `sender@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"TEST_EMAIL_ADDRESS"===l&&(0,a.jsxs)("div",{style:{color:"gray"},children:["Email Address to send `Test Email Alert` to. example: `info@berri.ai`",(0,a.jsx)("span",{style:{color:"red"},children:" Required * "})]}),"EMAIL_LOGO_URL"===l&&(0,a.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the Logo that appears in the email, pass a url to your logo"}),"EMAIL_SUPPORT_CONTACT"===l&&(0,a.jsx)("div",{style:{color:"gray"},children:"(Optional) Customize the support email address that appears in the email. Default is support@berri.ai"})]})]},l)})})})},l)})}),(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>ec(),children:"Save Changes"}),(0,a.jsx)(p.Z,{onClick:()=>(0,u.jE)(l,"email"),className:"mx-2",children:"Test Email Alerts"})]})})]})]})}),(0,a.jsxs)(w.Z,{title:"Add Logging Callback",visible:R,width:800,onCancel:()=>B(!1),footer:null,children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/logging",className:"mb-8 mt-4",target:"_blank",style:{color:"blue"},children:" LiteLLM Docs: Logging"}),(0,a.jsx)(S.Z,{form:g,onFinish:eu,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eq.Z,{label:"Callback",name:"callback",rules:[{required:!0,message:"Please select a callback"}],children:(0,a.jsx)(v.default,{onChange:e=>{let l=W[e];l&&(console.log(l.ui_callback_name),eh(l))},children:W&&Object.values(W).map(e=>(0,a.jsx)(K.Z,{value:e.litellm_callback_name,children:e.ui_callback_name},e.litellm_callback_name))})}),J&&J.map(e=>(0,a.jsx)(eq.Z,{label:e,name:e,rules:[{required:!0,message:"Please enter the value for "+e}],children:(0,a.jsx)(j.Z,{type:"password"})},e)),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})]}),(0,a.jsx)(w.Z,{visible:$,width:800,title:"Edit ".concat(null==ee?void 0:ee.name," Settings"),onCancel:()=>Q(!1),footer:null,children:(0,a.jsxs)(S.Z,{form:g,onFinish:em,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsx)(a.Fragment,{children:ee&&ee.variables&&Object.entries(ee.variables).map(e=>{let[l,s]=e;return(0,a.jsx)(eq.Z,{label:l,name:l,children:(0,a.jsx)(j.Z,{type:"password",defaultValue:s})},l)})}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Save"})})]})})]})):null};let{Option:eG}=v.default;var eH=e=>{let{models:l,accessToken:s,routerSettings:t,setRouterSettings:n}=e,[i]=S.Z.useForm(),[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)("");return(0,a.jsxs)("div",{children:[(0,a.jsx)(p.Z,{className:"mx-auto",onClick:()=>d(!0),children:"+ Add Fallbacks"}),(0,a.jsx)(w.Z,{title:"Add Fallbacks",visible:o,width:800,footer:null,onOk:()=>{d(!1),i.resetFields()},onCancel:()=>{d(!1),i.resetFields()},children:(0,a.jsxs)(S.Z,{form:i,onFinish:e=>{console.log(e);let{model_name:l,models:a}=e,r=[...t.fallbacks||[],{[l]:a}],o={...t,fallbacks:r};console.log(o);try{(0,u.K_)(s,{router_settings:o}),n(o)}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully"),d(!1),i.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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)(B.Z,{defaultValue:c,children:l&&l.map((e,l)=>(0,a.jsx)(K.Z,{value:e,onClick:()=>m(e),children:e},l))})}),(0,a.jsx)(S.Z.Item,{label:"Fallback Models",name:"models",rules:[{required:!0,message:"Please select a model"}],help:"required",children:(0,a.jsx)(ei.Z,{value:l,children:l&&l.filter(e=>e!=c).map(e=>(0,a.jsx)(eo.Z,{value:e,children:e},e))})})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Add Fallbacks"})})]})})]})},eY=s(12968);async function eJ(e,l){console.log("isLocal:",!1);let s=window.location.origin,t=new eY.ZP.OpenAI({apiKey:l,baseURL:s,dangerouslyAllowBrowser:!0});try{let l=await t.chat.completions.create({model:e,messages:[{role:"user",content:"Hi, this is a test message"}],mock_testing_fallbacks:!0});k.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){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}let eX={ttl:3600,lowest_latency_buffer:0},e$=e=>{let{selectedStrategy:l,strategyArgs:s,paramExplanation:t}=e;return(0,a.jsxs)(g.Z,{children:[(0,a.jsx)(f.Z,{className:"text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Routing Strategy Specific Args"}),(0,a.jsx)(Z.Z,{children:"latency-based-routing"==l?(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Setting"}),(0,a.jsx)(V.Z,{children:"Value"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(s).map(e=>{let[l,s]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:t[l]})]}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]})}):(0,a.jsx)(_.Z,{children:"No specific settings"})})]})};var eQ=e=>{let{accessToken:l,userRole:s,userID:t,modelData:n}=e,[i,o]=(0,r.useState)({}),[d,c]=(0,r.useState)({}),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(!1),[b]=S.Z.useForm(),[v,w]=(0,r.useState)(null),[N,A]=(0,r.useState)(null),[C,P]=(0,r.useState)(null),T={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,r.useEffect)(()=>{l&&s&&t&&((0,u.BL)(l,t,s).then(e=>{console.log("callbacks",e),o(e.router_settings)}),(0,u.YU)(l).then(e=>{g(e)}))},[l,s,t]);let E=async e=>{if(l){console.log("received key: ".concat(e)),console.log("routerSettings['fallbacks']: ".concat(i.fallbacks)),i.fallbacks.map(l=>(e in l&&delete l[e],l));try{await (0,u.K_)(l,{router_settings:i}),o({...i}),A(i.routing_strategy),k.ZP.success("Router settings updated successfully")}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}}},W=(e,l)=>{g(m.map(s=>s.field_name===e?{...s,field_value:l}:s))},G=(e,s)=>{if(!l)return;let t=m[s].field_value;if(null!=t&&void 0!=t)try{(0,u.jA)(l,e,t);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:!0}:l);g(s)}catch(e){}},H=(e,s)=>{if(l)try{(0,u.ao)(l,e);let s=m.map(l=>l.field_name===e?{...l,stored_in_db:null,field_value:null}:l);g(s)}catch(e){}},Y=e=>{if(!l)return;console.log("router_settings",e);let s=Object.fromEntries(Object.entries(e).map(e=>{let[l,s]=e;if("routing_strategy_args"!==l&&"routing_strategy"!==l){var t;return[l,(null===(t=document.querySelector('input[name="'.concat(l,'"]')))||void 0===t?void 0:t.value)||s]}if("routing_strategy"==l)return[l,N];if("routing_strategy_args"==l&&"latency-based-routing"==N){let e={},l=document.querySelector('input[name="lowest_latency_buffer"]'),s=document.querySelector('input[name="ttl"]');return(null==l?void 0:l.value)&&(e.lowest_latency_buffer=Number(l.value)),(null==s?void 0:s.value)&&(e.ttl=Number(s.value)),console.log("setRoutingStrategyArgs: ".concat(e)),["routing_strategy_args",e]}return null}).filter(e=>null!=e));console.log("updatedVariables",s);try{(0,u.K_)(l,{router_settings:s})}catch(e){k.ZP.error("Failed to update router settings: "+e,20)}k.ZP.success("router settings updated successfully")};return l?(0,a.jsx)("div",{className:"w-full mx-4",children:(0,a.jsxs)(et.Z,{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,a.jsxs)(en.Z,{variant:"line",defaultValue:"1",children:[(0,a.jsx)(es.Z,{value:"1",children:"Loadbalancing"}),(0,a.jsx)(es.Z,{value:"2",children:"Fallbacks"}),(0,a.jsx)(es.Z,{value:"3",children:"General"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:[(0,a.jsx)(y.Z,{children:"Router Settings"}),(0,a.jsxs)(M.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Setting"}),(0,a.jsx)(V.Z,{children:"Value"})]})}),(0,a.jsx)(D.Z,{children:Object.entries(i).filter(e=>{let[l,s]=e;return"fallbacks"!=l&&"context_window_fallbacks"!=l&&"routing_strategy_args"!=l}).map(e=>{let[l,s]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.Z,{children:l}),(0,a.jsx)("p",{style:{fontSize:"0.65rem",color:"#808080",fontStyle:"italic"},className:"mt-1",children:T[l]})]}),(0,a.jsx)(U.Z,{children:"routing_strategy"==l?(0,a.jsxs)(B.Z,{defaultValue:s,className:"w-full max-w-md",onValueChange:A,children:[(0,a.jsx)(K.Z,{value:"usage-based-routing",children:"usage-based-routing"}),(0,a.jsx)(K.Z,{value:"latency-based-routing",children:"latency-based-routing"}),(0,a.jsx)(K.Z,{value:"simple-shuffle",children:"simple-shuffle"})]}):(0,a.jsx)(j.Z,{name:l,defaultValue:"object"==typeof s?JSON.stringify(s,null,2):s.toString()})})]},l)})})]}),(0,a.jsx)(e$,{selectedStrategy:N,strategyArgs:i&&i.routing_strategy_args&&Object.keys(i.routing_strategy_args).length>0?i.routing_strategy_args:eX,paramExplanation:T})]}),(0,a.jsx)(h.Z,{children:(0,a.jsx)(p.Z,{className:"mt-2",onClick:()=>Y(i),children:"Save Changes"})})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Model Name"}),(0,a.jsx)(V.Z,{children:"Fallbacks"})]})}),(0,a.jsx)(D.Z,{children:i.fallbacks&&i.fallbacks.map((e,s)=>Object.entries(e).map(e=>{let[t,n]=e;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:t}),(0,a.jsx)(U.Z,{children:Array.isArray(n)?n.join(", "):n}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(p.Z,{onClick:()=>eJ(t,l),children:"Test Fallback"})}),(0,a.jsx)(U.Z,{children:(0,a.jsx)(F.Z,{icon:O.Z,size:"sm",onClick:()=>E(t)})})]},s.toString()+t)}))})]}),(0,a.jsx)(eH,{models:(null==n?void 0:n.data)?n.data.map(e=>e.model_name):[],accessToken:l,routerSettings:i,setRouterSettings:o})]}),(0,a.jsx)(ea.Z,{children:(0,a.jsx)(M.Z,{children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Setting"}),(0,a.jsx)(V.Z,{children:"Value"}),(0,a.jsx)(V.Z,{children:"Status"}),(0,a.jsx)(V.Z,{children:"Action"})]})}),(0,a.jsx)(D.Z,{children:m.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(_.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)(U.Z,{children:"Integer"==e.field_type?(0,a.jsx)(I.Z,{step:1,value:e.field_value,onChange:l=>W(e.field_name,l)}):null}),(0,a.jsx)(U.Z,{children:!0==e.stored_in_db?(0,a.jsx)(R.Z,{icon:eU.Z,className:"text-white",children:"In DB"}):!1==e.stored_in_db?(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"In Config"}):(0,a.jsx)(R.Z,{className:"text-gray bg-white outline",children:"Not Set"})}),(0,a.jsxs)(U.Z,{children:[(0,a.jsx)(p.Z,{onClick:()=>G(e.field_name,l),children:"Update"}),(0,a.jsx)(F.Z,{icon:O.Z,color:"red",onClick:()=>H(e.field_name,l),children:"Reset"})]})]},l))})]})})})]})]})}):null},e0=e=>{let{isModalVisible:l,accessToken:s,setIsModalVisible:t,setBudgetList:n}=e,[r]=S.Z.useForm(),i=async e=>{if(null!=s&&void 0!=s)try{k.ZP.info("Making API Call");let l=await (0,u.Zr)(s,e);console.log("key create Response:",l),n(e=>e?[...e,l]:[l]),k.ZP.success("API Key Created"),r.resetFields()}catch(e){console.error("Error creating the key:",e),k.ZP.error("Error creating the key: ".concat(e),20)}};return(0,a.jsx)(w.Z,{title:"Create Budget",visible:l,width:800,footer:null,onOk:()=>{t(!1),r.resetFields()},onCancel:()=>{t(!1),r.resetFields()},children:(0,a.jsxs)(S.Z,{form:r,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.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)(j.Z,{placeholder:""})}),(0,a.jsx)(S.Z.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,a.jsx)(I.Z,{step:1,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,a.jsx)(I.Z,{step:1,precision:2,width:200})}),(0,a.jsxs)(g.Z,{className:"mt-20 mb-8",children:[(0,a.jsx)(f.Z,{children:(0,a.jsx)("b",{children:"Optional Settings"})}),(0,a.jsxs)(Z.Z,{children:[(0,a.jsx)(S.Z.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,a.jsx)(I.Z,{step:.01,precision:2,width:200})}),(0,a.jsx)(S.Z.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,a.jsxs)(v.default,{defaultValue:null,placeholder:"n/a",children:[(0,a.jsx)(v.default.Option,{value:"24h",children:"daily"}),(0,a.jsx)(v.default.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,a.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,a.jsx)(A.ZP,{htmlType:"submit",children:"Create Budget"})})]})})},e1=e=>{let{accessToken:l}=e,[s,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&(0,u.O3)(l).then(e=>{i(e)})},[l]);let o=async(e,s)=>{if(null==l)return;k.ZP.info("Request made"),await (0,u.NV)(l,e);let t=[...n];t.splice(s,1),i(t),k.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)(p.Z,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>t(!0),children:"+ Create Budget"}),(0,a.jsx)(e0,{accessToken:l,isModalVisible:s,setIsModalVisible:t,setBudgetList:i}),(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(_.Z,{children:"Create a budget to assign to customers."}),(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Budget ID"}),(0,a.jsx)(V.Z,{children:"Max Budget"}),(0,a.jsx)(V.Z,{children:"TPM"}),(0,a.jsx)(V.Z,{children:"RPM"})]})}),(0,a.jsx)(D.Z,{children:n.map((e,l)=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.budget_id}),(0,a.jsx)(U.Z,{children:e.max_budget?e.max_budget:"n/a"}),(0,a.jsx)(U.Z,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,a.jsx)(U.Z,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,a.jsx)(F.Z,{icon:O.Z,size:"sm",onClick:()=>o(e.budget_id,l)})]},l))})]})]}),(0,a.jsxs)("div",{className:"mt-5",children:[(0,a.jsx)(_.Z,{className:"text-base",children:"How to use budget id"}),(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(es.Z,{children:"Assign Budget to Customer"}),(0,a.jsx)(es.Z,{children:"Test it (Curl)"}),(0,a.jsx)(es.Z,{children:"Test it (OpenAI SDK)"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ek.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)(ea.Z,{children:(0,a.jsx)(ek.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)(ea.Z,{children:(0,a.jsx)(ek.Z,{language:"python",children:'from openai import OpenAI\nclient = OpenAI(\n base_url="{let{proxySettings:l}=e,s="http://localhost:4000";return l&&l.PROXY_BASE_URL&&void 0!==l.PROXY_BASE_URL&&(s=l.PROXY_BASE_URL),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(x.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)(_.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)(et.Z,{children:[(0,a.jsxs)(en.Z,{children:[(0,a.jsx)(es.Z,{children:"OpenAI Python SDK"}),(0,a.jsx)(es.Z,{children:"LlamaIndex"}),(0,a.jsx)(es.Z,{children:"Langchain Py"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsx)(ek.Z,{language:"python",children:'\nimport openai\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="'.concat(s,'" # 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)(ea.Z,{children:(0,a.jsx)(ek.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="'.concat(s,'", # 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="').concat(s,'",\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)(ea.Z,{children:(0,a.jsx)(ek.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="'.concat(s,'",\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 e5(e,l,s,t){console.log("isLocal:",!1);let n=window.location.origin,a=new eY.ZP.OpenAI({apiKey:t,baseURL:n,dangerouslyAllowBrowser:!0});try{for await(let t of(await a.chat.completions.create({model:s,stream:!0,messages:[{role:"user",content:e}]})))console.log(t),t.choices[0].delta.content&&l(t.choices[0].delta.content)}catch(e){k.ZP.error("Error occurred while generating model response. Please try again. Error: ".concat(e),20)}}var e8=e=>{let{accessToken:l,token:s,userRole:t,userID:n}=e,[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(""),[m,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)(void 0),[y,b]=(0,r.useState)([]);(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{let e=await (0,u.So)(l,n,t);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}));if(console.log(l),l.length>0){let e=Array.from(new Set(l));console.log("Unique models:",e),e.sort((e,l)=>e.label.localeCompare(l.label)),console.log("Model info:",y),b(e)}f(e.data[0].id)}}catch(e){console.error("Error fetching model info:",e)}})()},[l,n,t]);let S=(e,l)=>{g(s=>{let t=s[s.length-1];return t&&t.role===e?[...s.slice(0,s.length-1),{role:e,content:t.content+l}]:[...s,{role:e,content:l}]})},k=async()=>{if(""!==d.trim()&&i&&s&&t&&n){g(e=>[...e,{role:"user",content:d}]);try{Z&&await e5(d,e=>S("assistant",e),Z,i)}catch(e){console.error("Error fetching model response",e),S("assistant","Error fetching model response")}c("")}};if(t&&"Admin Viewer"==t){let{Title:e,Paragraph:l}=$.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)(x.Z,{className:"gap-2 p-8 h-[80vh] w-full mt-2",children:(0,a.jsx)(M.Z,{children:(0,a.jsxs)(et.Z,{children:[(0,a.jsx)(en.Z,{children:(0,a.jsx)(es.Z,{children:"Chat"})}),(0,a.jsx)(er.Z,{children:(0,a.jsxs)(ea.Z,{children:[(0,a.jsx)("div",{className:"sm:max-w-2xl",children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"API Key"}),(0,a.jsx)(j.Z,{placeholder:"Type API Key here",type:"password",onValueChange:o,value:i})]}),(0,a.jsxs)(h.Z,{className:"mx-2",children:[(0,a.jsx)(_.Z,{children:"Select Model:"}),(0,a.jsx)(v.default,{placeholder:"Select a Model",onChange:e=>{console.log("selected ".concat(e)),f(e)},options:y,style:{width:"200px"}})]})]})}),(0,a.jsxs)(L.Z,{className:"mt-5",style:{display:"block",maxHeight:"60vh",overflowY:"auto"},children:[(0,a.jsx)(z.Z,{children:(0,a.jsx)(q.Z,{children:(0,a.jsx)(U.Z,{})})}),(0,a.jsx)(D.Z,{children:m.map((e,l)=>(0,a.jsx)(q.Z,{children:(0,a.jsx)(U.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)(j.Z,{type:"text",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"Type your message..."}),(0,a.jsx)(p.Z,{onClick:k,className:"ml-2",children:"Send"})]})})]})})]})})})})},e3=s(33509),e6=s(95781);let{Sider:e9}=e3.default;var e7=e=>{let{setPage:l,userRole:s,defaultSelectedKey:t}=e;return"Admin Viewer"==s?(0,a.jsx)(e3.default,{style:{minHeight:"100vh",maxWidth:"120px"},children:(0,a.jsx)(e9,{width:120,children:(0,a.jsx)(e6.Z,{mode:"inline",defaultSelectedKeys:t||["4"],style:{height:"100%",borderRight:0},children:(0,a.jsx)(e6.Z.Item,{onClick:()=>l("usage"),children:"Usage"},"1")})})}):(0,a.jsx)(e3.default,{style:{minHeight:"100vh",maxWidth:"145px"},children:(0,a.jsx)(e9,{width:145,children:(0,a.jsxs)(e6.Z,{mode:"inline",defaultSelectedKeys:t||["1"],style:{height:"100%",borderRight:0},children:[(0,a.jsx)(e6.Z.Item,{onClick:()=>l("api-keys"),children:(0,a.jsx)(_.Z,{children:"API Keys"})},"1"),(0,a.jsx)(e6.Z.Item,{onClick:()=>l("llm-playground"),children:(0,a.jsx)(_.Z,{children:"Test Key"})},"3"),"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("models"),children:(0,a.jsx)(_.Z,{children:"Models"})},"2"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("usage"),children:(0,a.jsx)(_.Z,{children:"Usage"})},"4"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("teams"),children:(0,a.jsx)(_.Z,{children:"Teams"})},"6"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("users"),children:(0,a.jsx)(_.Z,{children:"Internal Users"})},"5"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("settings"),children:(0,a.jsx)(_.Z,{children:"Logging & Alerts"})},"8"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("budgets"),children:(0,a.jsx)(_.Z,{children:"Budgets"})},"9"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("general-settings"),children:(0,a.jsx)(_.Z,{children:"Router Settings"})},"10"):null,"Admin"==s?(0,a.jsx)(e6.Z.Item,{onClick:()=>l("admin-panel"),children:(0,a.jsx)(_.Z,{children:"Admin"})},"11"):null,(0,a.jsx)(e6.Z.Item,{onClick:()=>l("api_ref"),children:(0,a.jsx)(_.Z,{children:"API Reference"})},"12"),(0,a.jsx)(e6.Z.Item,{onClick:()=>l("model-hub"),children:(0,a.jsx)(_.Z,{children:"Model Hub"})},"14")]})})})},le=s(67989),ll=s(52703),ls=e=>{let{accessToken:l,token:s,userRole:t,userID:n,keys:i,premiumUser:o}=e,d=new Date,[c,m]=(0,r.useState)([]),[j,g]=(0,r.useState)([]),[Z,f]=(0,r.useState)([]),[b,v]=(0,r.useState)([]),[S,k]=(0,r.useState)([]),[w,N]=(0,r.useState)([]),[I,A]=(0,r.useState)([]),[C,P]=(0,r.useState)([]),[T,E]=(0,r.useState)([]),[O,R]=(0,r.useState)([]),[F,W]=(0,r.useState)({}),[G,Y]=(0,r.useState)([]),[J,X]=(0,r.useState)(""),[$,Q]=(0,r.useState)(["all-tags"]),[em,eu]=(0,r.useState)({from:new Date(Date.now()-6048e5),to:new Date}),eh=new Date(d.getFullYear(),d.getMonth(),1),ex=new Date(d.getFullYear(),d.getMonth()+1,0),ep=e_(eh),ej=e_(ex);function eg(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,notation:"compact",compactDisplay:"short"}).format(e)}console.log("keys in usage",i),console.log("premium user in usage",o),(0,r.useEffect)(()=>{ef(em.from,em.to)},[em,$]);let eZ=async(e,s,t)=>{if(!e||!s||!l)return;s.setHours(23,59,59,999),e.setHours(0,0,0,0),console.log("uiSelectedKey",t);let n=await (0,u.b1)(l,t,e.toISOString(),s.toISOString());console.log("End user data updated successfully",n),v(n)},ef=async(e,s)=>{e&&s&&l&&(s.setHours(23,59,59,999),e.setHours(0,0,0,0),N((await (0,u.J$)(l,e.toISOString(),s.toISOString(),0===$.length?void 0:$)).spend_per_tag),console.log("Tag spend data updated successfully"))};function e_(e){let l=e.getFullYear(),s=e.getMonth()+1,t=e.getDate();return"".concat(l,"-").concat(s<10?"0"+s:s,"-").concat(t<10?"0"+t:t)}return console.log("Start date is ".concat(ep)),console.log("End date is ".concat(ej)),(0,r.useEffect)(()=>{l&&s&&t&&n&&(async()=>{try{if(console.log("user role: ".concat(t)),"Admin"==t||"Admin Viewer"==t){var e,a;let t=await (0,u.FC)(l);m(t);let n=await (0,u.OU)(l,s,ep,ej);console.log("provider_spend",n),R(n);let r=(await (0,u.tN)(l)).map(e=>({key:(e.key_alias||e.key_name||e.api_key).substring(0,10),spend:e.total_spend}));g(r);let i=(await (0,u.Au)(l)).map(e=>({key:e.model,spend:e.total_spend}));f(i);let o=await (0,u.mR)(l);console.log("teamSpend",o),k(o.daily_spend),P(o.teams);let d=o.total_spend_per_team;d=d.map(e=>(e.name=e.team_id||"",e.value=e.total_spend||0,e.value=e.value.toFixed(2),e)),E(d);let c=await (0,u.X)(l);A(c.tag_names);let h=await (0,u.J$)(l,null===(e=em.from)||void 0===e?void 0:e.toISOString(),null===(a=em.to)||void 0===a?void 0:a.toISOString(),void 0);N(h.spend_per_tag);let x=await (0,u.b1)(l,null,void 0,void 0);v(x),console.log("spend/user result",x);let p=await (0,u.wd)(l,ep,ej);W(p);let j=await (0,u.xA)(l,ep,ej);console.log("global activity per model",j),Y(j)}else"App Owner"==t&&await (0,u.HK)(l,s,t,n,ep,ej).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 s=e.top_api_keys;g(s)}else{let s=(await (0,u.e2)(l,function(e){let l=[];e.forEach(e=>{Object.entries(e).forEach(e=>{let[s,t]=e;"spend"!==s&&"startTime"!==s&&"models"!==s&&"users"!==s&&l.push({key:s,spend:t})})}),l.sort((e,l)=>Number(l.spend)-Number(e.spend));let s=l.slice(0,5).map(e=>e.key);return console.log("topKeys: ".concat(Object.keys(s[0]))),s}(e))).info.map(e=>({key:(e.key_name||e.key_alias).substring(0,10),spend:e.spend}));g(s),m(e)}})}catch(e){console.error("There was an error fetching the data",e)}})()},[l,s,t,n,ep,ej]),(0,a.jsx)("div",{style:{width:"100%"},className:"p-8",children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{className:"mt-2",children:[(0,a.jsx)(es.Z,{children:"All Up"}),(0,a.jsx)(es.Z,{children:"Team Based Usage"}),(0,a.jsx)(es.Z,{children:"Customer Usage"}),(0,a.jsx)(es.Z,{children:"Tag Based Usage"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(et.Z,{children:[(0,a.jsxs)(en.Z,{variant:"solid",className:"mt-1",children:[(0,a.jsx)(es.Z,{children:"Cost"}),(0,a.jsx)(es.Z,{children:"Activity"})]}),(0,a.jsxs)(er.Z,{children:[(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[100vh] w-full",children:[(0,a.jsx)(H,{userID:n,userRole:t,accessToken:l,userSpend:null,selectedTeam:null}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Monthly Spend"}),(0,a.jsx)(ec.Z,{data:c,index:"date",categories:["spend"],colors:["blue"],valueFormatter:e=>"$ ".concat(new Intl.NumberFormat("us").format(e).toString()),yAxisWidth:100,tickGap:5})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Top API Keys"}),(0,a.jsx)(ec.Z,{className:"mt-4 h-40",data:j,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:80,tickGap:5,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Top Models"}),(0,a.jsx)(ec.Z,{className:"mt-4 h-40",data:Z,index:"key",categories:["spend"],colors:["blue"],yAxisWidth:200,layout:"vertical",showXAxis:!1,showLegend:!1})]})}),(0,a.jsx)(h.Z,{numColSpan:1}),(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"✨ Spend by Provider"}),o?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(ll.Z,{className:"mt-4 h-40",variant:"pie",data:O,index:"provider",category:"spend"})}),(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsxs)(L.Z,{children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Provider"}),(0,a.jsx)(V.Z,{children:"Spend"})]})}),(0,a.jsx)(D.Z,{children:O.map(e=>(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.provider}),(0,a.jsx)(U.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)(p.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)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:1,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"All Up"}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(F.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:F.daily_data,valueFormatter:eg,index:"date",colors:["cyan"],categories:["api_requests"],onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(F.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:F.daily_data,valueFormatter:eg,index:"date",colors:["cyan"],categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]}),o?(0,a.jsx)(a.Fragment,{children:G.map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(e.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eg,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(e.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["total_tokens"],valueFormatter:eg,onValueChange:e=>console.log(e)})]})]})]},l))}):(0,a.jsx)(a.Fragment,{children:G&&G.length>0&&G.slice(0,1).map((e,l)=>(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.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)(p.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)(M.Z,{children:[(0,a.jsx)(y.Z,{children:e.model}),(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["API Requests ",eg(e.sum_api_requests)]}),(0,a.jsx)(ed.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],categories:["api_requests"],valueFormatter:eg,onValueChange:e=>console.log(e)})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsxs)(ee.Z,{style:{fontSize:"15px",fontWeight:"normal",color:"#535452"},children:["Tokens ",eg(e.sum_total_tokens)]}),(0,a.jsx)(ec.Z,{className:"h-40",data:e.daily_data,index:"date",colors:["cyan"],valueFormatter:eg,categories:["total_tokens"],onValueChange:e=>console.log(e)})]})]})]})]},l))})]})})]})]})}),(0,a.jsx)(ea.Z,{children:(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full",children:[(0,a.jsxs)(h.Z,{numColSpan:2,children:[(0,a.jsxs)(M.Z,{className:"mb-2",children:[(0,a.jsx)(y.Z,{children:"Total Spend Per Team"}),(0,a.jsx)(le.Z,{data:T})]}),(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Daily Spend Per Team"}),(0,a.jsx)(ec.Z,{className:"h-72",data:S,showLegend:!0,index:"date",categories:C,yAxisWidth:80,colors:["blue","green","yellow","red","purple"],stack:!0})]})]}),(0,a.jsx)(h.Z,{numColSpan:2})]})}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)("p",{className:"mb-2 text-gray-500 italic text-[12px]",children:["Customers 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)(x.Z,{numItems:2,children:[(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Time Range"}),(0,a.jsx)(el.Z,{enableSelect:!0,value:em,onValueChange:e=>{eu(e),eZ(e.from,e.to,null)}})]}),(0,a.jsxs)(h.Z,{children:[(0,a.jsx)(_.Z,{children:"Select Key"}),(0,a.jsxs)(B.Z,{defaultValue:"all-keys",children:[(0,a.jsx)(K.Z,{value:"all-keys",onClick:()=>{eZ(em.from,em.to,null)},children:"All Keys"},"all-keys"),null==i?void 0:i.map((e,l)=>e&&null!==e.key_alias&&e.key_alias.length>0?(0,a.jsx)(K.Z,{value:String(l),onClick:()=>{eZ(em.from,em.to,e.token)},children:e.key_alias},l):null)]})]})]}),(0,a.jsx)(M.Z,{className:"mt-4",children:(0,a.jsxs)(L.Z,{className:"max-h-[70vh] min-h-[500px]",children:[(0,a.jsx)(z.Z,{children:(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(V.Z,{children:"Customer"}),(0,a.jsx)(V.Z,{children:"Spend"}),(0,a.jsx)(V.Z,{children:"Total Events"})]})}),(0,a.jsx)(D.Z,{children:null==b?void 0:b.map((e,l)=>{var s;return(0,a.jsxs)(q.Z,{children:[(0,a.jsx)(U.Z,{children:e.end_user}),(0,a.jsx)(U.Z,{children:null===(s=e.total_spend)||void 0===s?void 0:s.toFixed(4)}),(0,a.jsx)(U.Z,{children:e.total_count})]},l)})})]})})]}),(0,a.jsxs)(ea.Z,{children:[(0,a.jsxs)(x.Z,{numItems:2,children:[(0,a.jsx)(h.Z,{numColSpan:1,children:(0,a.jsx)(el.Z,{className:"mb-4",enableSelect:!0,value:em,onValueChange:e=>{eu(e),ef(e.from,e.to)}})}),(0,a.jsx)(h.Z,{children:o?(0,a.jsx)("div",{children:(0,a.jsxs)(ei.Z,{value:$,onValueChange:e=>Q(e),children:[(0,a.jsx)(eo.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsx)(eo.Z,{value:String(e),children:e},e))]})}):(0,a.jsx)("div",{children:(0,a.jsxs)(ei.Z,{value:$,onValueChange:e=>Q(e),children:[(0,a.jsx)(eo.Z,{value:"all-tags",onClick:()=>Q(["all-tags"]),children:"All Tags"},"all-tags"),I&&I.filter(e=>"all-tags"!==e).map((e,l)=>(0,a.jsxs)(K.Z,{value:String(e),disabled:!0,children:["✨ ",e," (Enterprise only Feature)"]},e))]})})})]}),(0,a.jsxs)(x.Z,{numItems:2,className:"gap-2 h-[75vh] w-full mb-4",children:[(0,a.jsx)(h.Z,{numColSpan:2,children:(0,a.jsxs)(M.Z,{children:[(0,a.jsx)(y.Z,{children:"Spend Per Tag"}),(0,a.jsxs)(_.Z,{children:["Get Started Tracking cost per tag ",(0,a.jsx)("a",{className:"text-blue-500",href:"https://docs.litellm.ai/docs/proxy/cost_tracking",target:"_blank",children:"here"})]}),(0,a.jsx)(ec.Z,{className:"h-72",data:w,index:"name",categories:["spend"],colors:["blue"]})]})}),(0,a.jsx)(h.Z,{numColSpan:2})]})]})]})]})})},lt=()=>{let{Title:e,Paragraph:l}=$.default,[s,t]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[x,p]=(0,r.useState)(null),[j,g]=(0,r.useState)({PROXY_BASE_URL:"",PROXY_LOGOUT_URL:""}),[Z,f]=(0,r.useState)(!0),_=(0,i.useSearchParams)(),[y,b]=(0,r.useState)({data:[]}),v=_.get("userID"),S=_.get("token"),[k,w]=(0,r.useState)("api-keys"),[N,I]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(S){let e=(0,X.o)(S);if(e){if(console.log("Decoded token:",e),console.log("Decoded key:",e.key),I(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"internal_user":return"Internal User";case"internal_viewer":return"Internal Viewer";case"app_user":return"App User";default:return"Unknown Role"}}(e.user_role);console.log("Decoded user_role:",l),t(l),"Admin Viewer"==l&&w("usage")}else console.log("User role not defined");e.user_email?c(e.user_email):console.log("User Email is not set ".concat(e)),e.login_method?f("username_password"==e.login_method):console.log("User Email is not set ".concat(e)),e.premium_user&&o(e.premium_user)}}},[S]),(0,a.jsx)(r.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:v,userRole:s,userEmail:d,showSSOBanner:Z,premiumUser:n,setProxySettings:g,proxySettings:j}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)(e7,{setPage:w,userRole:s,defaultSelectedKey:null})}),"api-keys"==k?(0,a.jsx)(Q,{userID:v,userRole:s,teams:u,keys:x,setUserRole:t,userEmail:d,setUserEmail:c,setTeams:h,setKeys:p,setProxySettings:g,proxySettings:j}):"models"==k?(0,a.jsx)(eP,{userID:v,userRole:s,token:S,keys:x,accessToken:N,modelData:y,setModelData:b,premiumUser:n}):"llm-playground"==k?(0,a.jsx)(e8,{userID:v,userRole:s,token:S,accessToken:N}):"users"==k?(0,a.jsx)(eM,{userID:v,userRole:s,token:S,keys:x,teams:u,accessToken:N,setKeys:p}):"teams"==k?(0,a.jsx)(eF,{teams:u,setTeams:h,searchParams:_,accessToken:N,userID:v,userRole:s}):"admin-panel"==k?(0,a.jsx)(eL,{setTeams:h,searchParams:_,accessToken:N,showSSOBanner:Z}):"api_ref"==k?(0,a.jsx)(e4,{proxySettings:j}):"settings"==k?(0,a.jsx)(eW,{userID:v,userRole:s,accessToken:N,premiumUser:n}):"budgets"==k?(0,a.jsx)(e1,{accessToken:N}):"general-settings"==k?(0,a.jsx)(eQ,{userID:v,userRole:s,accessToken:N,modelData:y}):"model-hub"==k?(0,a.jsx)(e2.Z,{accessToken:N,publicPage:!1,premiumUser:n}):(0,a.jsx)(ls,{userID:v,userRole:s,token:S,accessToken:N,keys:x,premiumUser:n})]})]})})}},41134:function(e,l,s){"use strict";s.d(l,{Z:function(){return y}});var t=s(3827),n=s(64090),a=s(47907),r=s(777),i=s(16450),o=s(13810),d=s(92836),c=s(26734),m=s(41608),u=s(32126),h=s(23682),x=s(71801),p=s(42440),j=s(84174),g=s(50459),Z=s(6180),f=s(99129),_=s(67951),y=e=>{var l;let{accessToken:s,publicPage:y,premiumUser:b}=e,[v,S]=(0,n.useState)(!1),[k,w]=(0,n.useState)(null),[N,I]=(0,n.useState)(!1),[A,C]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null),E=(0,a.useRouter)();(0,n.useEffect)(()=>{s&&(async()=>{try{let e=await (0,r.kn)(s);console.log("ModelHubData:",e),w(e.data),(0,r.E9)(s,"enable_public_model_hub").then(e=>{console.log("data: ".concat(JSON.stringify(e))),!0==e.field_value&&S(!0)}).catch(e=>{})}catch(e){console.error("There was an error fetching the model data",e)}})()},[s,y]);let O=e=>{T(e),I(!0)},R=async()=>{s&&(0,r.jA)(s,"enable_public_model_hub",!0).then(e=>{C(!0)})},M=()=>{I(!1),C(!1),T(null)},F=()=>{I(!1),C(!1),T(null)},L=e=>{navigator.clipboard.writeText(e)};return(0,t.jsxs)("div",{children:[y&&v||!1==y?(0,t.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,t.jsx)("div",{className:"relative w-full"}),(0,t.jsxs)("div",{className:"flex ".concat(y?"justify-between":"items-center"),children:[(0,t.jsx)(p.Z,{className:"ml-8 text-center ",children:"Model Hub"}),!1==y?b?(0,t.jsx)(i.Z,{className:"ml-4",onClick:()=>R(),children:"✨ Make Public"}):(0,t.jsx)(i.Z,{className:"ml-4",children:(0,t.jsx)("a",{href:"https://forms.gle/W3U4PZpJGFHWtHyA9",target:"_blank",children:"✨ Make Public"})}):(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("p",{children:"Filter by key:"}),(0,t.jsx)(x.Z,{className:"bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center",children:"/ui/model_hub?key="})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4 pr-8",children:k&&k.map(e=>(0,t.jsxs)(o.Z,{className:"mt-5 mx-8",children:[(0,t.jsxs)("pre",{className:"flex justify-between",children:[(0,t.jsx)(p.Z,{children:e.model_group}),(0,t.jsx)(Z.Z,{title:e.model_group,children:(0,t.jsx)(j.Z,{onClick:()=>L(e.model_group),style:{cursor:"pointer",marginRight:"10px"}})})]}),(0,t.jsxs)("div",{className:"my-5",children:[(0,t.jsxs)(x.Z,{children:["Mode: ",e.mode]}),(0,t.jsxs)(x.Z,{children:["Supports Function Calling:"," ",(null==e?void 0:e.supports_function_calling)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Supports Vision:"," ",(null==e?void 0:e.supports_vision)==!0?"Yes":"No"]}),(0,t.jsxs)(x.Z,{children:["Max Input Tokens:"," ",(null==e?void 0:e.max_input_tokens)?null==e?void 0:e.max_input_tokens:"N/A"]}),(0,t.jsxs)(x.Z,{children:["Max Output Tokens:"," ",(null==e?void 0:e.max_output_tokens)?null==e?void 0:e.max_output_tokens:"N/A"]})]}),(0,t.jsx)("div",{style:{marginTop:"auto",textAlign:"right"},children:(0,t.jsxs)("a",{href:"#",onClick:()=>O(e),style:{color:"#1890ff",fontSize:"smaller"},children:["View more ",(0,t.jsx)(g.Z,{})]})})]},e.model_group))})]}):(0,t.jsxs)(o.Z,{className:"mx-auto max-w-xl mt-10",children:[(0,t.jsx)(x.Z,{className:"text-xl text-center mb-2 text-black",children:"Public Model Hub not enabled."}),(0,t.jsx)("p",{className:"text-base text-center text-slate-800",children:"Ask your proxy admin to enable this on their Admin UI."})]}),(0,t.jsx)(f.Z,{title:"Public Model Hub",width:600,visible:A,footer:null,onOk:M,onCancel:F,children:(0,t.jsxs)("div",{className:"pt-5 pb-5",children:[(0,t.jsxs)("div",{className:"flex justify-between mb-4",children:[(0,t.jsx)(x.Z,{className:"text-base mr-2",children:"Shareable Link:"}),(0,t.jsx)(x.Z,{className:"max-w-sm ml-2 bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center rounded",children:"/ui/model_hub?key="})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(i.Z,{onClick:()=>{E.replace("/model_hub?key=".concat(s))},children:"See Page"})})]})}),(0,t.jsx)(f.Z,{title:P&&P.model_group?P.model_group:"Unknown Model",width:800,visible:N,footer:null,onOk:M,onCancel:F,children:P&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-4",children:(0,t.jsx)("strong",{children:"Model Information & Usage"})}),(0,t.jsxs)(c.Z,{children:[(0,t.jsxs)(m.Z,{children:[(0,t.jsx)(d.Z,{children:"OpenAI Python SDK"}),(0,t.jsx)(d.Z,{children:"Supported OpenAI Params"}),(0,t.jsx)(d.Z,{children:"LlamaIndex"}),(0,t.jsx)(d.Z,{children:"Langchain Py"})]}),(0,t.jsxs)(h.Z,{children:[(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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,t.jsx)(u.Z,{children:(0,t.jsx)(_.Z,{language:"python",children:"".concat(null===(l=P.supported_openai_params)||void 0===l?void 0:l.map(e=>"".concat(e,"\n")).join(""))})}),(0,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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,t.jsx)(u.Z,{children:(0,t.jsx)(_.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(P.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 ')})})]})]})]})})]})}}},function(e){e.O(0,[936,294,131,684,759,777,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/_next/static/chunks/webpack-d12f0c7c134d3e60.js b/ui/litellm-dashboard/out/_next/static/chunks/webpack-496e007a0280178b.js similarity index 98% rename from litellm/proxy/_experimental/out/_next/static/chunks/webpack-d12f0c7c134d3e60.js rename to ui/litellm-dashboard/out/_next/static/chunks/webpack-496e007a0280178b.js index dbd5f5398..a08c6655b 100644 --- a/litellm/proxy/_experimental/out/_next/static/chunks/webpack-d12f0c7c134d3e60.js +++ b/ui/litellm-dashboard/out/_next/static/chunks/webpack-496e007a0280178b.js @@ -1 +1 @@ -!function(){"use strict";var e,t,n,r,o,u,i,c,f,a={},l={};function d(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={id:e,loaded:!1,exports:{}},r=!0;try{a[e](n,n.exports,d),r=!1}finally{r&&delete l[e]}return n.loaded=!0,n.exports}d.m=a,e=[],d.O=function(t,n,r,o){if(n){o=o||0;for(var u=e.length;u>0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u=o&&Object.keys(d.O).every(function(e){return d.O[e](n[f])})?n.splice(f--,1):(c=!1,o0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u=o&&Object.keys(d.O).every(function(e){return d.O[e](n[f])})?n.splice(f--,1):(c=!1,oLiteLLM 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 edb78dac3..aa1a67c15 100644 --- a/ui/litellm-dashboard/out/index.txt +++ b/ui/litellm-dashboard/out/index.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[45980,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","294","static/chunks/294-0e35509d5ca95267.js","131","static/chunks/131-6a03368053f9d26d.js","684","static/chunks/684-bb2d2f93d92acb0b.js","759","static/chunks/759-83a8bdddfe32b5d9.js","777","static/chunks/777-17b0c91edd3a24fe.js","931","static/chunks/app/page-bd882aee817406ff.js"],""] +3:I[45980,["936","static/chunks/2f6dbc85-052c4579f80d66ae.js","294","static/chunks/294-0e35509d5ca95267.js","131","static/chunks/131-6a03368053f9d26d.js","684","static/chunks/684-bb2d2f93d92acb0b.js","759","static/chunks/759-83a8bdddfe32b5d9.js","777","static/chunks/777-71fb78fdb4897cc3.js","931","static/chunks/app/page-d301c202a2cebcd3.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["48nWsJi-LJrUlOLzcK-Yz",[[["",{"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/f02cb03d96e276ef.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["Q9smtS3bJUKJtn7pvgodO",[[["",{"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_12bbc4","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/159e0004b5599df8.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/model_hub.html b/ui/litellm-dashboard/out/model_hub.html index ab4594aac..5b965b3bd 100644 --- a/ui/litellm-dashboard/out/model_hub.html +++ b/ui/litellm-dashboard/out/model_hub.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/model_hub.txt b/ui/litellm-dashboard/out/model_hub.txt index caaee3a57..b205cf508 100644 --- a/ui/litellm-dashboard/out/model_hub.txt +++ b/ui/litellm-dashboard/out/model_hub.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[87494,["294","static/chunks/294-0e35509d5ca95267.js","131","static/chunks/131-6a03368053f9d26d.js","777","static/chunks/777-17b0c91edd3a24fe.js","418","static/chunks/app/model_hub/page-4cb65c32467214b5.js"],""] +3:I[87494,["294","static/chunks/294-0e35509d5ca95267.js","131","static/chunks/131-6a03368053f9d26d.js","777","static/chunks/777-71fb78fdb4897cc3.js","418","static/chunks/app/model_hub/page-4cb65c32467214b5.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["48nWsJi-LJrUlOLzcK-Yz",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":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/f02cb03d96e276ef.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["Q9smtS3bJUKJtn7pvgodO",[[["",{"children":["model_hub",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["model_hub",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","model_hub","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_12bbc4","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/159e0004b5599df8.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/onboarding.html b/ui/litellm-dashboard/out/onboarding.html index 65a15486d..33efe1f8e 100644 --- a/ui/litellm-dashboard/out/onboarding.html +++ b/ui/litellm-dashboard/out/onboarding.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/onboarding.txt b/ui/litellm-dashboard/out/onboarding.txt index fd4d8cff6..4fcc6fff2 100644 --- a/ui/litellm-dashboard/out/onboarding.txt +++ b/ui/litellm-dashboard/out/onboarding.txt @@ -1,7 +1,7 @@ 2:I[77831,[],""] -3:I[667,["665","static/chunks/3014691f-589a5f4865c3822f.js","294","static/chunks/294-0e35509d5ca95267.js","684","static/chunks/684-bb2d2f93d92acb0b.js","777","static/chunks/777-17b0c91edd3a24fe.js","461","static/chunks/app/onboarding/page-664c7288e11fff5a.js"],""] +3:I[667,["665","static/chunks/3014691f-589a5f4865c3822f.js","294","static/chunks/294-0e35509d5ca95267.js","684","static/chunks/684-bb2d2f93d92acb0b.js","777","static/chunks/777-71fb78fdb4897cc3.js","461","static/chunks/app/onboarding/page-664c7288e11fff5a.js"],""] 4:I[5613,[],""] 5:I[31778,[],""] -0:["48nWsJi-LJrUlOLzcK-Yz",[[["",{"children":["onboarding",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["onboarding",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","onboarding","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":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/f02cb03d96e276ef.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["Q9smtS3bJUKJtn7pvgodO",[[["",{"children":["onboarding",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["onboarding",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children","onboarding","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_12bbc4","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/159e0004b5599df8.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_dashboard.tsx b/ui/litellm-dashboard/src/components/model_dashboard.tsx index d16d8db13..e18f4233e 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard.tsx +++ b/ui/litellm-dashboard/src/components/model_dashboard.tsx @@ -139,6 +139,7 @@ interface ProviderSettings { enum Providers { OpenAI = "OpenAI", Azure = "Azure", + Azure_AI_Studio = "Azure AI Studio", Anthropic = "Anthropic", Google_AI_Studio = "Google AI Studio", Bedrock = "Amazon Bedrock", @@ -151,6 +152,7 @@ enum Providers { const provider_map: Record = { OpenAI: "openai", Azure: "azure", + Azure_AI_Studio: "azure_ai", Anthropic: "anthropic", Google_AI_Studio: "gemini", Bedrock: "bedrock", @@ -158,6 +160,7 @@ const provider_map: Record = { Vertex_AI: "vertex_ai", Databricks: "databricks", Ollama: "ollama", + }; const retry_policy_map: Record = { @@ -1245,6 +1248,10 @@ const ModelDashboard: React.FC = ({ return "claude-3-opus"; } else if (selectedProvider == Providers.Google_AI_Studio) { return "gemini-pro"; + } else if (selectedProvider == Providers.Azure_AI_Studio) { + return "azure_ai/command-r-plus"; + } else if (selectedProvider == Providers.Azure) { + return "azure/my-deployment"; } else { return "gpt-3.5-turbo"; } diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index 4a53df12b..e5371f22e 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -14,11 +14,12 @@ export interface Model { export const modelCostMap = async () => { try { + const url = proxyBaseUrl ? `${proxyBaseUrl}/get/litellm_model_cost_map` : `/get/litellm_model_cost_map`; const response = await fetch( - "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json" + url ); const jsonData = await response.json(); - console.log(`received data: ${jsonData}`); + console.log(`received litellm model cost data: ${jsonData}`); return jsonData; } catch (error) { console.error("Failed to get model cost map:", error); @@ -2405,7 +2406,6 @@ export const getProxyBaseUrlAndLogoutUrl = async ( if (!response.ok) { const errorData = await response.text(); - message.error(errorData, 10); throw new Error("Network response was not ok"); }