diff --git a/.circleci/config.yml b/.circleci/config.yml index a89fedc7511..faf43ff0b8b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -83,8 +83,8 @@ jobs: pip install "google-generativeai==0.3.2" pip install "google-cloud-aiplatform==1.43.0" pip install pyarrow - pip install "boto3==1.34.34" - pip install "aioboto3==12.3.0" + pip install "boto3==1.36.0" + pip install "aioboto3==13.4.0" pip install langchain pip install lunary==0.2.5 pip install "azure-identity==1.16.1" @@ -95,7 +95,7 @@ jobs: pip install opentelemetry-api==1.25.0 pip install opentelemetry-sdk==1.25.0 pip install opentelemetry-exporter-otlp==1.25.0 - pip install openai==1.99.5 + pip install openai==1.100.1 pip install prisma==0.11.0 pip install "detect_secrets==1.5.0" pip install "httpx==0.24.1" @@ -208,8 +208,8 @@ jobs: pip install "google-generativeai==0.3.2" pip install "google-cloud-aiplatform==1.43.0" pip install pyarrow - pip install "boto3==1.34.34" - pip install "aioboto3==12.3.0" + pip install "boto3==1.36.0" + pip install "aioboto3==13.4.0" pip install langchain pip install lunary==0.2.5 pip install "azure-identity==1.16.1" @@ -220,7 +220,7 @@ jobs: pip install opentelemetry-api==1.25.0 pip install opentelemetry-sdk==1.25.0 pip install opentelemetry-exporter-otlp==1.25.0 - pip install openai==1.99.5 + pip install openai==1.100.1 pip install prisma==0.11.0 pip install "detect_secrets==1.5.0" pip install "httpx==0.24.1" @@ -315,8 +315,8 @@ jobs: pip install "google-generativeai==0.3.2" pip install "google-cloud-aiplatform==1.43.0" pip install pyarrow - pip install "boto3==1.34.34" - pip install "aioboto3==12.3.0" + pip install "boto3==1.36.0" + pip install "aioboto3==13.4.0" pip install langchain pip install lunary==0.2.5 pip install "azure-identity==1.16.1" @@ -327,7 +327,7 @@ jobs: pip install opentelemetry-api==1.25.0 pip install opentelemetry-sdk==1.25.0 pip install opentelemetry-exporter-otlp==1.25.0 - pip install openai==1.99.5 + pip install openai==1.100.1 pip install prisma==0.11.0 pip install "detect_secrets==1.5.0" pip install "httpx==0.24.1" @@ -439,6 +439,7 @@ jobs: paths: - auth_ui_unit_tests_coverage.xml - auth_ui_unit_tests_coverage + litellm_router_testing: # Runs all tests with the "router" keyword docker: - image: cimg/python:3.11 @@ -469,7 +470,55 @@ jobs: command: | pwd ls - python -m pytest tests/local_testing tests/router_unit_tests --cov=litellm --cov-report=xml -vv -k "router" -x -v --junitxml=test-results/junit.xml --durations=5 + python -m pytest tests/local_testing --cov=litellm --cov-report=xml -vv -k "router" -x -v --junitxml=test-results/junit.xml --durations=5 + no_output_timeout: 120m + - run: + name: Rename the coverage files + command: | + mv coverage.xml litellm_router_coverage.xml + mv .coverage litellm_router_coverage + # Store test results + - store_test_results: + path: test-results + + - persist_to_workspace: + root: . + paths: + - litellm_router_coverage.xml + - litellm_router_coverage + + litellm_router_unit_testing: # Runs all tests with the "router" keyword + docker: + - image: cimg/python:3.11 + auth: + username: ${DOCKERHUB_USERNAME} + password: ${DOCKERHUB_PASSWORD} + working_directory: ~/project + + steps: + - checkout + - setup_google_dns + - run: + name: Install Dependencies + command: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + pip install "pytest==7.3.1" + pip install "respx==0.22.0" + pip install "pytest-cov==5.0.0" + pip install "pytest-retry==1.6.3" + pip install "pytest-asyncio==0.21.1" + pip install semantic_router --no-deps + pip install aurelio_sdk --no-deps + pip install "pytest-xdist==3.6.1" + # Run pytest and generate JUnit XML report + - setup_litellm_enterprise_pip + - run: + name: Run tests + command: | + pwd + ls + python -m pytest -vv tests/router_unit_tests --cov=litellm --cov-report=xml -x -s -v --junitxml=test-results/junit.xml --durations=5 no_output_timeout: 120m - run: name: Rename the coverage files @@ -590,8 +639,8 @@ jobs: pip install "google-generativeai==0.3.2" pip install "google-cloud-aiplatform==1.43.0" pip install pyarrow - pip install "boto3==1.34.34" - pip install "aioboto3==12.3.0" + pip install "boto3==1.36.0" + pip install "aioboto3==13.4.0" pip install langchain pip install lunary==0.2.5 pip install "azure-identity==1.16.1" @@ -602,7 +651,7 @@ jobs: pip install opentelemetry-api==1.25.0 pip install opentelemetry-sdk==1.25.0 pip install opentelemetry-exporter-otlp==1.25.0 - pip install openai==1.99.5 + pip install openai==1.100.1 pip install prisma==0.11.0 pip install "detect_secrets==1.5.0" pip install "httpx==0.24.1" @@ -816,7 +865,7 @@ jobs: pip install "pytest-asyncio==0.21.1" pip install "respx==0.22.0" pip install "pydantic==2.10.2" - pip install "boto3==1.34.34" + pip install "boto3==1.36.0" # Run pytest and generate JUnit XML report - run: name: Run tests @@ -1238,10 +1287,11 @@ jobs: pip install aiohttp pip install openai pip install click - pip install "boto3==1.34.34" + pip install "boto3==1.36.0" pip install jinja2 pip install "tokenizers==0.20.0" pip install "uvloop==0.21.0" + pip install "fastuuid==0.12.0" pip install jsonschema - setup_litellm_enterprise_pip - run: @@ -1507,8 +1557,8 @@ jobs: pip install "google-generativeai==0.3.2" pip install "google-cloud-aiplatform==1.43.0" pip install pyarrow - pip install "boto3==1.34.34" - pip install "aioboto3==12.3.0" + pip install "boto3==1.36.0" + pip install "aioboto3==13.4.0" pip install langchain pip install "langfuse>=2.0.0" pip install "logfire==0.29.0" @@ -1522,7 +1572,7 @@ jobs: pip install "aiodynamo==23.10.1" pip install "asyncio==3.4.3" pip install "PyGithub==1.59.1" - pip install "openai==1.99.5" + pip install "openai==1.100.1" - run: name: Install dockerize command: | @@ -1663,8 +1713,8 @@ jobs: pip install "google-generativeai==0.3.2" pip install "google-cloud-aiplatform==1.43.0" pip install pyarrow - pip install "boto3==1.34.34" - pip install "aioboto3==12.3.0" + pip install "boto3==1.36.0" + pip install "aioboto3==13.4.0" pip install langchain pip install "langchain_mcp_adapters==0.0.5" pip install "langfuse>=2.0.0" @@ -1679,7 +1729,7 @@ jobs: pip install "aiodynamo==23.10.1" pip install "asyncio==3.4.3" pip install "PyGithub==1.59.1" - pip install "openai==1.99.5" + pip install "openai==1.100.1" # Run pytest and generate JUnit XML report - run: name: Install dockerize @@ -1804,8 +1854,8 @@ jobs: pip install "google-generativeai==0.3.2" pip install "google-cloud-aiplatform==1.43.0" pip install pyarrow - pip install "boto3==1.34.34" - pip install "aioboto3==12.3.0" + pip install "boto3==1.36.0" + pip install "aioboto3==13.4.0" pip install langchain pip install "langfuse>=2.0.0" pip install "logfire==0.29.0" @@ -1819,7 +1869,7 @@ jobs: pip install "aiodynamo==23.10.1" pip install "asyncio==3.4.3" pip install "PyGithub==1.59.1" - pip install "openai==1.99.5" + pip install "openai==1.100.1" - run: name: Install dockerize command: | @@ -2399,14 +2449,14 @@ jobs: pip install "pytest-asyncio==0.21.1" pip install "google-cloud-aiplatform==1.43.0" pip install aiohttp - pip install "openai==1.99.5" + pip install "openai==1.100.1" pip install "assemblyai==0.37.0" python -m pip install --upgrade pip pip install "pydantic==2.10.2" pip install "pytest==7.3.1" pip install "pytest-mock==3.12.0" pip install "pytest-asyncio==0.21.1" - pip install "boto3==1.34.34" + pip install "boto3==1.36.0" pip install mypy pip install pyarrow pip install numpydoc @@ -2790,7 +2840,7 @@ jobs: pip install "pytest-retry==1.6.3" pip install "pytest-asyncio==0.21.1" pip install aiohttp - pip install "openai==1.99.5" + pip install "openai==1.100.1" python -m pip install --upgrade pip pip install "pydantic==2.10.2" pip install "pytest==7.3.1" @@ -2982,6 +3032,12 @@ workflows: only: - main - /litellm_.*/ + - litellm_router_unit_testing: + filters: + branches: + only: + - main + - /litellm_.*/ - check_code_and_doc_quality: filters: branches: @@ -3128,6 +3184,7 @@ workflows: - image_gen_testing - logging_testing - litellm_router_testing + - litellm_router_unit_testing - caching_unit_tests - litellm_proxy_unit_testing - litellm_security_tests @@ -3187,6 +3244,7 @@ workflows: - image_gen_testing - logging_testing - litellm_router_testing + - litellm_router_unit_testing - caching_unit_tests - langfuse_logging_unit_tests - litellm_assistants_api_testing diff --git a/.circleci/requirements.txt b/.circleci/requirements.txt index f610e1aa56f..8e0f1dfe7e9 100644 --- a/.circleci/requirements.txt +++ b/.circleci/requirements.txt @@ -1,5 +1,5 @@ # used by CI/CD testing -openai==1.99.5 +openai==1.100.1 python-dotenv tiktoken importlib_metadata @@ -14,4 +14,5 @@ google-cloud-iam==2.19.1 fastapi-sso==0.16.0 uvloop==0.21.0 mcp==1.10.1 # for MCP server -semantic_router==0.1.10 # for auto-routing with litellm \ No newline at end of file +semantic_router==0.1.10 # for auto-routing with litellm +fastuuid==0.12.0 \ No newline at end of file diff --git a/.github/workflows/test-linting.yml b/.github/workflows/test-linting.yml index 5a4323b3e9b..ffca305a0d0 100644 --- a/.github/workflows/test-linting.yml +++ b/.github/workflows/test-linting.yml @@ -22,11 +22,8 @@ jobs: - name: Install dependencies run: | - pip install openai==1.99.5 poetry install --with dev - pip install openai==1.99.5 - - + poetry run pip install openai==1.100.1 - name: Run Black formatting run: | @@ -40,6 +37,10 @@ jobs: poetry run ruff check . cd .. + - name: Print OpenAI version + run: | + poetry run python -c "import openai; print(f'OpenAI version: {openai.__version__}')" + - name: Run MyPy type checking run: | cd litellm diff --git a/.github/workflows/test-litellm.yml b/.github/workflows/test-litellm.yml index 4ec3dcbb4cf..7e67aee8d73 100644 --- a/.github/workflows/test-litellm.yml +++ b/.github/workflows/test-litellm.yml @@ -7,7 +7,7 @@ on: jobs: test: runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 25 steps: - uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index f8d028ff47b..ed8c88c8990 100644 --- a/.gitignore +++ b/.gitignore @@ -86,6 +86,7 @@ litellm/proxy/db/migrations/0_init/migration.sql litellm/proxy/db/migrations/* litellm/proxy/migrations/*config.yaml litellm/proxy/migrations/* +litellm/proxy/to_delete_loadtest_work/* config.yaml tests/litellm/litellm_core_utils/llm_cost_calc/log.txt tests/test_custom_dir/* @@ -93,4 +94,5 @@ test.py litellm_config.yaml .cursor -.vscode/launch.json \ No newline at end of file +.vscode/launch.json +litellm/proxy/to_delete_loadtest_work/* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 9261d55d7fe..addc109e10c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,8 +65,8 @@ COPY --from=builder /wheels/ /wheels/ # Install the built wheel using pip; again using a wildcard if it's the only file RUN pip install *.whl /wheels/* --no-index --find-links=/wheels/ && rm -f *.whl && rm -rf /wheels -# Install semantic_router without dependencies -RUN pip install semantic_router --no-deps +# Install semantic_router and aurelio-sdk using script +RUN chmod +x docker/install_auto_router.sh && ./docker/install_auto_router.sh # Generate prisma client RUN prisma generate diff --git a/README.md b/README.md index 47878747a60..45f0bbe1395 100644 --- a/README.md +++ b/README.md @@ -374,6 +374,8 @@ We welcome contributions to LiteLLM! Whether you're fixing bugs, adding features ## Quick Start for Contributors +This requires poetry to be installed. + ```bash git clone https://github.com/BerriAI/litellm.git cd litellm @@ -381,6 +383,7 @@ make install-dev # Install development dependencies make format # Format your code make lint # Run all linting checks make test-unit # Run unit tests +make format-check # Check formatting only ``` For detailed contributing guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md). @@ -396,11 +399,6 @@ Our automated checks include: - **Circular import detection** - **Import safety checks** -Run all checks locally: -```bash -make lint # Run all linting (matches CI) -make format-check # Check formatting only -``` All these checks must pass before your PR can be merged. @@ -442,7 +440,7 @@ All these checks must pass before your PR can be merged. 1. (In root) create virtual environment `python -m venv .venv` 2. Activate virtual environment `source .venv/bin/activate` 3. Install dependencies `pip install -e ".[all]"` -4. Start proxy backend `uvicorn litellm.proxy.proxy_server:app --host localhost --port 4000 --reload` +4. Start proxy backend `python3 /path/to/litellm/proxy_cli.py` ### Frontend 1. Navigate to `ui/litellm-dashboard` diff --git a/cookbook/liteLLM_Baseten.ipynb b/cookbook/liteLLM_Baseten.ipynb index e03bb3254a5..0a5bc5f1df7 100644 --- a/cookbook/liteLLM_Baseten.ipynb +++ b/cookbook/liteLLM_Baseten.ipynb @@ -6,19 +6,21 @@ "id": "gZx-wHJapG5w" }, "source": [ - "# Use liteLLM to call Falcon, Wizard, MPT 7B using OpenAI chatGPT Input/output\n", + "# LiteLLM with Baseten Model APIs\n", "\n", - "* Falcon 7B: https://app.baseten.co/explore/falcon_7b\n", - "* Wizard LM: https://app.baseten.co/explore/wizardlm\n", - "* MPT 7B Base: https://app.baseten.co/explore/mpt_7b_instruct\n", + "This notebook demonstrates how to use LiteLLM with Baseten's Model APIs instead of dedicated deployments.\n", "\n", - "\n", - "## Call all baseten llm models using OpenAI chatGPT Input/Output using liteLLM\n", - "Example call\n", + "## Example Usage\n", "```python\n", - "model = \"q841o8w\" # baseten model version ID\n", - "response = completion(model=model, messages=messages, custom_llm_provider=\"baseten\")\n", - "```" + "response = completion(\n", + " model=\"baseten/openai/gpt-oss-120b\",\n", + " messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n", + " max_tokens=1000,\n", + " temperature=0.7\n", + ")\n", + "```\n", + "\n", + "## Setup" ] }, { @@ -29,20 +31,25 @@ }, "outputs": [], "source": [ - "!pip install litellm==0.1.399\n", - "!pip install baseten urllib3" + "%pip install litellm" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": { "id": "VEukLhDzo4vw" }, "outputs": [], "source": [ "import os\n", - "from litellm import completion" + "from litellm import completion\n", + "\n", + "# Set your Baseten API key\n", + "os.environ['BASETEN_API_KEY'] = \"\" #@param {type:\"string\"}\n", + "\n", + "# Test message\n", + "messages = [{\"role\": \"user\", \"content\": \"What is AGI?\"}]" ] }, { @@ -51,19 +58,31 @@ "id": "4STYM2OHFNlc" }, "source": [ - "## Setup" + "## Example 1: Basic Completion\n", + "\n", + "Simple completion with the GPT-OSS 120B model" ] }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "metadata": { "id": "DorpLxw1FHbC" }, "outputs": [], "source": [ - "os.environ['BASETEN_API_KEY'] = \"\" #@param\n", - "messages = [{ \"content\": \"what does Baseten do? \",\"role\": \"user\"}]" + "print(\"=== Basic Completion ===\")\n", + "response = completion(\n", + " model=\"baseten/openai/gpt-oss-120b\",\n", + " messages=messages,\n", + " max_tokens=1000,\n", + " temperature=0.7,\n", + " top_p=0.9,\n", + " presence_penalty=0.1,\n", + " frequency_penalty=0.1,\n", + ")\n", + "print(f\"Response: {response.choices[0].message.content}\")\n", + "print(f\"Usage: {response.usage}\")" ] }, { @@ -72,13 +91,14 @@ "id": "syF3dTdKFSQQ" }, "source": [ - "## Calling Falcon 7B: https://app.baseten.co/explore/falcon_7b\n", - "### Pass Your Baseten model `Version ID` as `model`" + "## Example 2: Streaming Completion\n", + "\n", + "Streaming completion with usage statistics" ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -86,137 +106,26 @@ "id": "rPgSoMlsojz0", "outputId": "81d6dc7b-1681-4ae4-e4c8-5684eb1bd050" }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[32mINFO\u001b[0m API key set.\n", - "INFO:baseten:API key set.\n" - ] - }, - { - "data": { - "text/plain": [ - "{'choices': [{'finish_reason': 'stop',\n", - " 'index': 0,\n", - " 'message': {'role': 'assistant',\n", - " 'content': \"what does Baseten do? \\nI'm sorry, I cannot provide a specific answer as\"}}],\n", - " 'created': 1692135883.699066,\n", - " 'model': 'qvv0xeq'}" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "model = \"qvv0xeq\"\n", - "response = completion(model=model, messages=messages, custom_llm_provider=\"baseten\")\n", - "response" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "7n21UroEGCGa" - }, - "source": [ - "## Calling Wizard LM https://app.baseten.co/explore/wizardlm\n", - "### Pass Your Baseten model `Version ID` as `model`" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "uLVWFH899lAF", - "outputId": "61c2bc74-673b-413e-bb40-179cf408523d" - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[32mINFO\u001b[0m API key set.\n", - "INFO:baseten:API key set.\n" - ] - }, - { - "data": { - "text/plain": [ - "{'choices': [{'finish_reason': 'stop',\n", - " 'index': 0,\n", - " 'message': {'role': 'assistant',\n", - " 'content': 'As an AI language model, I do not have personal beliefs or practices, but based on the information available online, Baseten is a popular name for a traditional Ethiopian dish made with injera, a spongy flatbread, and wat, a spicy stew made with meat or vegetables. It is typically served for breakfast or dinner and is a staple in Ethiopian cuisine. The name Baseten is also used to refer to a traditional Ethiopian coffee ceremony, where coffee is brewed and served in a special ceremony with music and food.'}}],\n", - " 'created': 1692135900.2806294,\n", - " 'model': 'q841o8w'}" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "model = \"q841o8w\"\n", - "response = completion(model=model, messages=messages, custom_llm_provider=\"baseten\")\n", - "response" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "6-TFwmPAGPXq" - }, - "source": [ - "## Calling mosaicml/mpt-7b https://app.baseten.co/explore/mpt_7b_instruct\n", - "### Pass Your Baseten model `Version ID` as `model`" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "gbeYZOrUE_Bp", - "outputId": "838d86ea-2143-4cb3-bc80-2acc2346c37a" - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[32mINFO\u001b[0m API key set.\n", - "INFO:baseten:API key set.\n" - ] - }, - { - "data": { - "text/plain": [ - "{'choices': [{'finish_reason': 'stop',\n", - " 'index': 0,\n", - " 'message': {'role': 'assistant',\n", - " 'content': \"\\n===================\\n\\nIt's a tool to build a local version of a game on your own machine to host\\non your website.\\n\\nIt's used to make game demos and show them on Twitter, Tumblr, and Facebook.\\n\\n\\n\\n## What's built\\n\\n- A directory of all your game directories, named with a version name and build number, with images linked to.\\n- Includes HTML to include in another site.\\n- Includes images for your icons and\"}}],\n", - " 'created': 1692135914.7472186,\n", - " 'model': '31dxrj3'}" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "model = \"31dxrj3\"\n", - "response = completion(model=model, messages=messages, custom_llm_provider=\"baseten\")\n", - "response" + "print(\"=== Streaming Completion ===\")\n", + "response = completion(\n", + " model=\"baseten/openai/gpt-oss-120b\",\n", + " messages=[{\"role\": \"user\", \"content\": \"Write a short poem about AI\"}],\n", + " stream=True,\n", + " max_tokens=500,\n", + " temperature=0.8,\n", + " stream_options={\n", + " \"include_usage\": True,\n", + " \"continuous_usage_stats\": True\n", + " },\n", + ")\n", + "\n", + "print(\"Streaming response:\")\n", + "for chunk in response:\n", + " if chunk.choices and chunk.choices[0].delta.content:\n", + " print(chunk.choices[0].delta.content, end=\"\", flush=True)\n", + "print(\"\\n\")" ] } ], @@ -234,4 +143,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +} diff --git a/deploy/charts/litellm-helm/Chart.yaml b/deploy/charts/litellm-helm/Chart.yaml index bd63ca6bfca..b6ac264a228 100644 --- a/deploy/charts/litellm-helm/Chart.yaml +++ b/deploy/charts/litellm-helm/Chart.yaml @@ -18,7 +18,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.4.4 +version: 0.4.5 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/deploy/charts/litellm-helm/README.md b/deploy/charts/litellm-helm/README.md index cef2b8d162d..73b722b64c6 100644 --- a/deploy/charts/litellm-helm/README.md +++ b/deploy/charts/litellm-helm/README.md @@ -24,7 +24,7 @@ If `db.useStackgresOperator` is used (not yet implemented): | `replicaCount` | The number of LiteLLM Proxy pods to be deployed | `1` | | `masterkeySecretName` | The name of the Kubernetes Secret that contains the Master API Key for LiteLLM. If not specified, use the generated secret name. | N/A | | `masterkeySecretKey` | The key within the Kubernetes Secret that contains the Master API Key for LiteLLM. If not specified, use `masterkey` as the key. | N/A | -| `masterkey` | The Master API Key for LiteLLM. If not specified, a random key is generated. | N/A | +| `masterkey` | The Master API Key for LiteLLM. If not specified, a random key in the `sk-...` format is generated. | N/A | | `environmentSecrets` | An optional array of Secret object names. The keys and values in these secrets will be presented to the LiteLLM proxy pod as environment variables. See below for an example Secret object. | `[]` | | `environmentConfigMaps` | An optional array of ConfigMap object names. The keys and values in these configmaps will be presented to the LiteLLM proxy pod as environment variables. See below for an example Secret object. | `[]` | | `image.repository` | LiteLLM Proxy image repository | `ghcr.io/berriai/litellm` | @@ -135,7 +135,7 @@ service, the **Proxy Endpoint** should be set to `http://-litellm:4000` The **Proxy Key** is the value specified for `masterkey` or, if a `masterkey` was not provided to the helm command line, the `masterkey` is a randomly -generated string stored in the `-litellm-masterkey` Kubernetes Secret. +generated string in the `sk-...` format stored in the `-litellm-masterkey` Kubernetes Secret. ```bash kubectl -n litellm get secret -litellm-masterkey -o jsonpath="{.data.masterkey}" diff --git a/deploy/charts/litellm-helm/templates/deployment.yaml b/deploy/charts/litellm-helm/templates/deployment.yaml index 71412b8052b..b30b8829325 100644 --- a/deploy/charts/litellm-helm/templates/deployment.yaml +++ b/deploy/charts/litellm-helm/templates/deployment.yaml @@ -71,7 +71,14 @@ spec: name: {{ .Values.db.secret.name }} key: {{ .Values.db.secret.passwordKey }} - name: DATABASE_HOST + {{- if .Values.db.secret.endpointKey }} + valueFrom: + secretKeyRef: + name: {{ .Values.db.secret.name }} + key: {{ .Values.db.secret.endpointKey }} + {{- else }} value: {{ .Values.db.endpoint }} + {{- end }} - name: DATABASE_NAME value: {{ .Values.db.database }} - name: DATABASE_URL diff --git a/deploy/charts/litellm-helm/templates/migrations-job.yaml b/deploy/charts/litellm-helm/templates/migrations-job.yaml index cf10be0a76b..4c8925564af 100644 --- a/deploy/charts/litellm-helm/templates/migrations-job.yaml +++ b/deploy/charts/litellm-helm/templates/migrations-job.yaml @@ -49,7 +49,14 @@ spec: name: {{ .Values.db.secret.name }} key: {{ .Values.db.secret.passwordKey }} - name: DATABASE_HOST + {{- if .Values.db.secret.endpointKey }} + valueFrom: + secretKeyRef: + name: {{ .Values.db.secret.name }} + key: {{ .Values.db.secret.endpointKey }} + {{- else }} value: {{ .Values.db.endpoint }} + {{- end }} - name: DATABASE_NAME value: {{ .Values.db.database }} - name: DATABASE_URL @@ -73,6 +80,10 @@ spec: volumeMounts: {{- toYaml . | nindent 12 }} {{- end }} + {{- with .Values.migrationJob.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} {{- with .Values.migrationJob.extraContainers }} {{- toYaml . | nindent 8 }} {{- end }} diff --git a/deploy/charts/litellm-helm/templates/secret-masterkey.yaml b/deploy/charts/litellm-helm/templates/secret-masterkey.yaml index 5632957dc05..7c8560cc2cc 100644 --- a/deploy/charts/litellm-helm/templates/secret-masterkey.yaml +++ b/deploy/charts/litellm-helm/templates/secret-masterkey.yaml @@ -1,5 +1,5 @@ {{- if not .Values.masterkeySecretName }} -{{ $masterkey := (.Values.masterkey | default (randAlphaNum 17)) }} +{{ $masterkey := (.Values.masterkey | default (printf "sk-%s" (randAlphaNum 18))) }} apiVersion: v1 kind: Secret metadata: diff --git a/deploy/charts/litellm-helm/tests/masterkey-secret_tests.yaml b/deploy/charts/litellm-helm/tests/masterkey-secret_tests.yaml index eb1d3c3967f..bbbade9d802 100644 --- a/deploy/charts/litellm-helm/tests/masterkey-secret_tests.yaml +++ b/deploy/charts/litellm-helm/tests/masterkey-secret_tests.yaml @@ -2,13 +2,19 @@ suite: test masterkey secret templates: - secret-masterkey.yaml tests: - - it: should create a secret if masterkeySecretName is not set + - it: should create a secret if masterkeySecretName is not set. should start with sk-xxxx (base64 encoded as c2st*) template: secret-masterkey.yaml set: masterkeySecretName: "" asserts: - isKind: of: Secret + - matchRegex: + path: data.masterkey + pattern: ^c2st + # Note: The masterkey is generated as "sk-<18-random-chars>" in plain text, + # but stored as base64 encoded in Kubernetes secret (requirement). + # "sk-" base64 encodes to "c2st", so we check for "^c2st" pattern. - it: should not create a secret if masterkeySecretName is set template: secret-masterkey.yaml set: diff --git a/deploy/charts/litellm-helm/values.yaml b/deploy/charts/litellm-helm/values.yaml index f99204cbb4b..0bd95003c10 100644 --- a/deploy/charts/litellm-helm/values.yaml +++ b/deploy/charts/litellm-helm/values.yaml @@ -161,6 +161,8 @@ db: name: postgres usernameKey: username passwordKey: password + # Optional: when set, DATABASE_HOST will be sourced from this secret key instead of db.endpoint + endpointKey: "" # Use the Stackgres Helm chart to deploy an instance of a Stackgres cluster. # The Stackgres Operator must already be installed within the target @@ -206,6 +208,10 @@ migrationJob: disableSchemaUpdate: false # Skip schema migrations for specific environments. When True, the job will exit with code 0. annotations: {} ttlSecondsAfterFinished: 120 + resources: {} + # requests: + # cpu: 100m + # memory: 100Mi extraContainers: [] # Hook configuration diff --git a/docker/Dockerfile.database b/docker/Dockerfile.database index 956ec76dbe7..351c4f6bc48 100644 --- a/docker/Dockerfile.database +++ b/docker/Dockerfile.database @@ -57,8 +57,8 @@ COPY --from=builder /wheels/ /wheels/ # Install the built wheel using pip; again using a wildcard if it's the only file RUN pip install *.whl /wheels/* --no-index --find-links=/wheels/ && rm -f *.whl && rm -rf /wheels -# Install semantic_router without dependencies -RUN pip install semantic_router --no-deps +# Install semantic_router and aurelio-sdk using script +RUN chmod +x docker/install_auto_router.sh && ./docker/install_auto_router.sh # ensure pyjwt is used, not jwt RUN pip uninstall jwt -y diff --git a/docker/Dockerfile.non_root b/docker/Dockerfile.non_root index 388dc6d0766..4178724e6e4 100644 --- a/docker/Dockerfile.non_root +++ b/docker/Dockerfile.non_root @@ -33,11 +33,12 @@ WORKDIR /app # Install runtime dependencies USER root RUN apk upgrade --no-cache && \ - apk add --no-cache bash libstdc++ ca-certificates openssl + apk add --no-cache bash libstdc++ ca-certificates openssl supervisor # Copy only necessary artifacts from builder stage for runtime COPY . . COPY --from=builder /app/docker/entrypoint.sh /app/docker/prod_entrypoint.sh /app/docker/ +COPY --from=builder /app/docker/supervisord.conf /etc/supervisord.conf COPY --from=builder /app/schema.prisma /app/schema.prisma COPY --from=builder /app/dist/*.whl . COPY --from=builder /wheels/ /wheels/ @@ -47,8 +48,8 @@ RUN pip install *.whl /wheels/* --no-index --find-links=/wheels/ \ && rm -f *.whl \ && rm -rf /wheels -# Install semantic_router without dependencies -RUN pip install semantic_router --no-deps +# Install semantic_router and aurelio-sdk using script +RUN chmod +x docker/install_auto_router.sh && ./docker/install_auto_router.sh # Ensure correct JWT library is used (pyjwt not jwt) RUN pip uninstall jwt -y && \ @@ -70,7 +71,9 @@ RUN mkdir -p /nonexistent /.npm && \ chown -R nobody:nogroup /app && \ chown -R nobody:nogroup /nonexistent /.npm && \ PRISMA_PATH=$(python -c "import os, prisma; print(os.path.dirname(prisma.__file__))") && \ - chown -R nobody:nogroup $PRISMA_PATH + chown -R nobody:nogroup $PRISMA_PATH && \ + LITELLM_PKG_MIGRATIONS_PATH="$(python -c 'import os, litellm_proxy_extras; print(os.path.dirname(litellm_proxy_extras.__file__))' 2>/dev/null || echo '')/migrations" && \ + [ -n "$LITELLM_PKG_MIGRATIONS_PATH" ] && chown -R nobody:nogroup $LITELLM_PKG_MIGRATIONS_PATH # --- OpenShift Compatibility: Apply Red Hat recommended pattern --- # Get paths for directories that need write access at runtime diff --git a/docker/build_from_pip/requirements.txt b/docker/build_from_pip/requirements.txt index 71e038b6267..cc14b99727f 100644 --- a/docker/build_from_pip/requirements.txt +++ b/docker/build_from_pip/requirements.txt @@ -2,4 +2,5 @@ litellm[proxy]==1.67.4.dev1 # Specify the litellm version you want to use prometheus_client langfuse prisma +openai==1.99.9 ddtrace==2.19.0 # for advanced DD tracing / profiling diff --git a/docker/install_auto_router.sh b/docker/install_auto_router.sh new file mode 100755 index 00000000000..794f9a2bbce --- /dev/null +++ b/docker/install_auto_router.sh @@ -0,0 +1,3 @@ +#!/bin/bash +pip install semantic_router==0.1.11 --no-deps +pip install aurelio-sdk==0.0.19 \ No newline at end of file diff --git a/docs/my-website/docs/completion/document_understanding.md b/docs/my-website/docs/completion/document_understanding.md index b831a7b9da2..172e0792801 100644 --- a/docs/my-website/docs/completion/document_understanding.md +++ b/docs/my-website/docs/completion/document_understanding.md @@ -10,6 +10,7 @@ Works for: - Bedrock Models - Anthropic API Models - OpenAI API Models +- Mistral (Only using file ID of already uploaded file, similar to OpenAI file_id input) ## Quick Start @@ -279,6 +280,71 @@ curl -X POST 'http://0.0.0.0:4000/chat/completions' \ +## Mistral Example + +Here is a sample payload for using the Mistral model for document understanding: + + + + + +```python +from litellm.utils import completion + +# pdf file_id received from files endpoint +file_id = "fa778e5e-46ec-4562-8418-36623fe25a71" + +# model +model = "mistral/mistral-large-latest" + +file_content = [ + {"type": "text", "text": "What's this file about?"}, + { + "type": "file", + "file": { + "file_id": file_id, + } + }, +] + +response = completion( + model=model, + messages=[{"role": "user", "content": file_content}], +) +assert response is not None +``` + + + + +```bash +curl -X POST 'http://0.0.0.0:4000/chat/completions' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Bearer sk-1234' \ +-d '{ + "model": "mistral/mistral-large-latest", + "messages": [ + { + "role": "user", + "content": [ + { + "type": "text", + "text": "What is the content of the file?" + }, + { + "type": "file", + "file": { + "file_id": "fa778e5e-46ec-4562-8418-36623fe25a71" + } + } + ] + } + ] +} +``` + + + ## Checking if a model supports pdf input diff --git a/docs/my-website/docs/completion/image_generation_chat.md b/docs/my-website/docs/completion/image_generation_chat.md new file mode 100644 index 00000000000..58ae70e2fff --- /dev/null +++ b/docs/my-website/docs/completion/image_generation_chat.md @@ -0,0 +1,232 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Image Generation in Chat Completions, Responses API + +This guide covers how to generate images when using the `chat/completions`. Note - if you want this on Responses API please file a Feature Request [here](https://github.com/BerriAI/litellm/issues/new). + +:::info + +Requires LiteLLM v1.76.1+ + +::: + +Supported Providers: +- Google AI Studio (`gemini`) +- Vertex AI (`vertex_ai/`) + +LiteLLM will standardize the `image` response in the assistant message for models that support image generation during chat completions. + +```python title="Example response from litellm" +"message": { + ... + "content": "Here's the image you requested:", + "image": { + "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", + "detail": "auto" + } +} +``` + +## Quick Start + + + + +```python showLineNumbers title="Image generation with chat completion" +from litellm import completion +import os + +os.environ["GEMINI_API_KEY"] = "your-api-key" + +response = completion( + model="gemini/gemini-2.5-flash-image-preview", + messages=[ + {"role": "user", "content": "Generate an image of a banana wearing a costume that says LiteLLM"} + ], +) + +print(response.choices[0].message.content) # Text response +print(response.choices[0].message.image) # Image data +``` + + + + +1. Setup config.yaml + +```yaml showLineNumbers title="config.yaml" +model_list: + - model_name: gemini-image-gen + litellm_params: + model: gemini/gemini-2.5-flash-image-preview + api_key: os.environ/GEMINI_API_KEY +``` + +2. Run proxy server + +```bash showLineNumbers title="Start the proxy" +litellm --config config.yaml + +# RUNNING on http://0.0.0.0:4000 +``` + +3. Test it! + +```bash showLineNumbers title="Make request" +curl http://0.0.0.0:4000/v1/chat/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LITELLM_KEY" \ + -d '{ + "model": "gemini-image-gen", + "messages": [ + { + "role": "user", + "content": "Generate an image of a banana wearing a costume that says LiteLLM" + } + ] + }' +``` + + + + +**Expected Response** + +```bash +{ + "id": "chatcmpl-3b66124d79a708e10c603496b363574c", + "choices": [ + { + "finish_reason": "stop", + "index": 0, + "message": { + "content": "Here's the image you requested:", + "role": "assistant", + "image": { + "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", + "detail": "auto" + } + } + } + ], + "created": 1723323084, + "model": "gemini/gemini-2.5-flash-image-preview", + "object": "chat.completion", + "usage": { + "completion_tokens": 12, + "prompt_tokens": 16, + "total_tokens": 28 + } +} +``` + +## Streaming Support + + + + +```python showLineNumbers title="Streaming image generation" +from litellm import completion +import os + +os.environ["GEMINI_API_KEY"] = "your-api-key" + +response = completion( + model="gemini/gemini-2.5-flash-image-preview", + messages=[ + {"role": "user", "content": "Generate an image of a banana wearing a costume that says LiteLLM"} + ], + stream=True, +) + +for chunk in response: + if hasattr(chunk.choices[0].delta, "image") and chunk.choices[0].delta.image is not None: + print("Generated image:", chunk.choices[0].delta.image["url"]) + break +``` + + + + +```bash showLineNumbers title="Streaming request" +curl http://0.0.0.0:4000/v1/chat/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LITELLM_KEY" \ + -d '{ + "model": "gemini-image-gen", + "messages": [ + { + "role": "user", + "content": "Generate an image of a banana wearing a costume that says LiteLLM" + } + ], + "stream": true + }' +``` + + + + +**Expected Streaming Response** + +```bash +data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1723323084,"model":"gemini/gemini-2.5-flash-image-preview","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]} + +data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1723323084,"model":"gemini/gemini-2.5-flash-image-preview","choices":[{"index":0,"delta":{"content":"Here's the image you requested:"},"finish_reason":null}]} + +data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1723323084,"model":"gemini/gemini-2.5-flash-image-preview","choices":[{"index":0,"delta":{"image":{"url":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...","detail":"auto"}},"finish_reason":null}]} + +data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1723323084,"model":"gemini/gemini-2.5-flash-image-preview","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]} + +data: [DONE] +``` + +## Async Support + +```python showLineNumbers title="Async image generation" +from litellm import acompletion +import asyncio +import os + +os.environ["GEMINI_API_KEY"] = "your-api-key" + +async def generate_image(): + response = await acompletion( + model="gemini/gemini-2.5-flash-image-preview", + messages=[ + {"role": "user", "content": "Generate an image of a banana wearing a costume that says LiteLLM"} + ], + ) + + print(response.choices[0].message.content) # Text response + print(response.choices[0].message.image) # Image data + + return response + +# Run the async function +asyncio.run(generate_image()) +``` + +## Supported Models + +| Provider | Model | +|----------|--------| +| Google AI Studio | `gemini/gemini-2.5-flash-image-preview` | +| Vertex AI | `vertex_ai/gemini-2.5-flash-image-preview` | + +## Spec + +The `image` field in the response follows this structure: + +```python +"image": { + "url": "data:image/png;base64,", + "detail": "auto" +} +``` + +- `url` - str: Base64 encoded image data in data URI format +- `detail` - str: Image detail level (always "auto" for generated images) + +The image is returned as a base64-encoded data URI that can be directly used in HTML `` tags or saved to a file. diff --git a/docs/my-website/docs/extras/gemini_img_migration.md b/docs/my-website/docs/extras/gemini_img_migration.md new file mode 100644 index 00000000000..ae02c89e6fd --- /dev/null +++ b/docs/my-website/docs/extras/gemini_img_migration.md @@ -0,0 +1,201 @@ +# Gemini Image Generation Migration Guide + +## Who is impacted by this change? + +Anyone using the following models with /chat/completions: +- `gemini/gemini-2.0-flash-exp-image-generation` +- `vertex_ai/gemini-2.5-flash-image-preview` + +## Key Change + +Gemini models now support image generation through chat completions. Images are returned in `response.choices[0].message.image` with base64 data URLs. + +## Before and After + +### Before +```python +from litellm import completion + +response = completion( + model="gemini/gemini-2.0-flash-exp-image-generation", + messages=[{"role": "user", "content": "Generate an image of a cat"}], + modalities=["image", "text"], +) + + +base_64_image_data = response.choices[0].message.content +``` + +### After +```python +from litellm import completion + +response = completion( + model="gemini/gemini-2.0-flash-exp-image-generation", + messages=[{"role": "user", "content": "Generate an image of a cat"}], + modalities=["image", "text"], +) + +# Image is now available in the response +image_url = response.choices[0].message.image["url"] # "data:image/png;base64,..." +``` + +## Usage + +### Using the Python SDK + +**Key Change:** +```diff +# Before +-- base_64_image_data = response.choices[0].message.content + +# After +++ image_url = response.choices[0].message.image["url"] +``` + +#### Basic Image Generation + +```python +from litellm import completion +import os + +# Set your API key +os.environ["GEMINI_API_KEY"] = "your-api-key" + +# Generate an image +response = completion( + model="gemini/gemini-2.0-flash-exp-image-generation", + messages=[{"role": "user", "content": "Generate an image of a cat"}], + modalities=["image", "text"], +) + +# Access the generated image +print(response.choices[0].message.content) # Text response (if any) +print(response.choices[0].message.image) # Image data +``` + +#### Response Format + +The image is returned in the `message.image` field: + +```python +{ + "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", + "detail": "auto" +} +``` + +### Using the LiteLLM Proxy Server + +**Key Change:** +```diff +# Before +-- "content": "base64-image-data..." + +# After +++ "image": { +++ "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", +++ "detail": "auto" +++ } +``` + +#### Configuration Setup + +1. **Configure your models in `config.yaml`:** + +```yaml +model_list: + - model_name: gemini-image-gen + litellm_params: + model: gemini/gemini-2.0-flash-exp-image-generation + api_key: os.environ/GEMINI_API_KEY + - model_name: vertex-image-gen + litellm_params: + model: vertex_ai/gemini-2.5-flash-image-preview + vertex_project: your-project-id + vertex_location: us-central1 + +general_settings: + master_key: sk-1234 # Your proxy API key +``` + +2. **Start the proxy server:** + +```bash +litellm --config /path/to/config.yaml + +# RUNNING on http://0.0.0.0:4000 +``` + +#### Making Requests + +**Using OpenAI SDK:** + +```python +from openai import OpenAI + +# Point to your proxy server +client = OpenAI( + api_key="sk-1234", # Your proxy API key + base_url="http://0.0.0.0:4000" +) + +response = client.chat.completions.create( + model="gemini-image-gen", + messages=[{"role": "user", "content": "Generate an image of a cat"}], + extra_body={"modalities": ["image", "text"]} +) + +# Access the generated image +print(response.choices[0].message.content) # Text response (if any) +print(response.choices[0].message.image) # Image data +``` + +**Using curl:** + +```bash +curl -X POST 'http://0.0.0.0:4000/v1/chat/completions' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Bearer sk-1234' \ +-d '{ + "model": "gemini-image-gen", + "messages": [ + { + "role": "user", + "content": "Generate an image of a cat" + } + ], + "modalities": ["image", "text"] +}' +``` + +**Response format from proxy:** + +```json +{ + "id": "chatcmpl-123", + "object": "chat.completion", + "created": 1704089632, + "model": "gemini-image-gen", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "Here's an image of a cat for you!", + "image": { + "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", + "detail": "auto" + } + }, + "finish_reason": "stop" + } + ], + "usage": { + "prompt_tokens": 10, + "completion_tokens": 8, + "total_tokens": 18 + } +} +``` + diff --git a/docs/my-website/docs/image_edits.md b/docs/my-website/docs/image_edits.md index f0254032964..246e1c70f0e 100644 --- a/docs/my-website/docs/image_edits.md +++ b/docs/my-website/docs/image_edits.md @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem'; # /images/edits -LiteLLM provides image editing functionality that maps to OpenAI's `/images/edits` API endpoint. +LiteLLM provides image editing functionality that maps to OpenAI's `/images/edits` API endpoint. Now supports both single and multiple image editing. | Feature | Supported | Notes | |---------|-----------|--------| @@ -13,7 +13,7 @@ LiteLLM provides image editing functionality that maps to OpenAI's `/images/edit | End-user Tracking | ✅ | | | Fallbacks | ✅ | Works between supported models | | Loadbalancing | ✅ | Works between supported models | -| Supported operations | Create image edits | | +| Supported operations | Create image edits | Single and multiple images supported | | Supported LiteLLM SDK Versions | 1.63.8+ | | | Supported LiteLLM Proxy Versions | 1.71.1+ | | | Supported LLM providers | **OpenAI** | Currently only `openai` is supported | @@ -41,6 +41,26 @@ response = litellm.image_edit( print(response) ``` +#### Multiple Images Edit +```python showLineNumbers title="OpenAI Multiple Images Edit" +import litellm + +# Edit multiple images with a prompt +response = litellm.image_edit( + model="gpt-image-1", + image=[ + open("image1.png", "rb"), + open("image2.png", "rb"), + open("image3.png", "rb") + ], + prompt="Apply vintage filter to all images", + n=1, + size="1024x1024" +) + +print(response) +``` + #### Image Edit with Mask ```python showLineNumbers title="OpenAI Image Edit with Mask" import litellm @@ -80,6 +100,30 @@ response = asyncio.run(edit_image()) print(response) ``` +#### Async Multiple Images Edit +```python showLineNumbers title="Async OpenAI Multiple Images Edit" +import litellm +import asyncio + +async def edit_multiple_images(): + response = await litellm.aimage_edit( + model="gpt-image-1", + image=[ + open("portrait1.png", "rb"), + open("portrait2.png", "rb") + ], + prompt="Add professional lighting to the portraits", + n=1, + size="1024x1024", + response_format="url" + ) + return response + +# Run the async function +response = asyncio.run(edit_multiple_images()) +print(response) +``` + #### Image Edit with Custom Parameters ```python showLineNumbers title="OpenAI Image Edit with Custom Parameters" import litellm @@ -163,6 +207,20 @@ curl -X POST "http://localhost:4000/v1/images/edits" \ -F "response_format=url" ``` +#### cURL Multiple Images Example +```bash showLineNumbers title="cURL Multiple Images Edit Request" +curl -X POST "http://localhost:4000/v1/images/edits" \ + -H "Authorization: Bearer your-api-key" \ + -F "model=gpt-image-1" \ + -F "image=@image1.png" \ + -F "image=@image2.png" \ + -F "image=@image3.png" \ + -F "prompt=Apply artistic filter to all images" \ + -F "n=1" \ + -F "size=1024x1024" \ + -F "response_format=url" +``` + diff --git a/docs/my-website/docs/observability/braintrust.md b/docs/my-website/docs/observability/braintrust.md index eb26680b18a..e6b4fe769bc 100644 --- a/docs/my-website/docs/observability/braintrust.md +++ b/docs/my-website/docs/observability/braintrust.md @@ -71,6 +71,10 @@ curl -X POST 'http://0.0.0.0:4000/chat/completions' \ It is recommended that you include the `project_id` or `project_name` to ensure your traces are being written out to the correct Braintrust project. +### Custom Span Names + +You can customize the span name in Braintrust logging by passing `span_name` in the metadata. By default, the span name is set to "Chat Completion". + @@ -84,7 +88,9 @@ response = litellm.completion( "project_id": "1234", # passing project_name will try to find a project with that name, or create one if it doesn't exist # if both project_id and project_name are passed, project_id will be used - # "project_name": "my-special-project" + # "project_name": "my-special-project", + # custom span name for this operation (default: "Chat Completion") + "span_name": "User Greeting Handler" } ) ``` @@ -99,6 +105,7 @@ response = litellm.completion( ], metadata={ "project_id": "1234", + "span_name": "Custom Operation", "item1": "an item", "item2": "another item" } @@ -121,7 +128,8 @@ curl -X POST 'http://0.0.0.0:4000/chat/completions' \ { "role": "user", "content": "What time is it now? Use your tool"} ], "metadata": { - "project_id": "my-special-project" + "project_id": "my-special-project", + "span_name": "Tool Usage Request" } }' ``` @@ -146,7 +154,8 @@ response = client.chat.completions.create( ], extra_body={ # pass in any provider-specific param, if not supported by openai, https://docs.litellm.ai/docs/completion/input#provider-specific-params "metadata": { # 👈 use for logging additional params (e.g. to braintrust) - "project_id": "my-special-project" + "project_id": "my-special-project", + "span_name": "Poetry Generation" } } ) @@ -168,3 +177,7 @@ Here's everything you can pass in metadata for a braintrust request `braintrust_*` - If you are adding metadata from _proxy request headers_, any metadata field starting with `braintrust_` will be passed as metadata to the logging request. If you are using the SDK, just pass your metadata like normal (e.g., `metadata={"project_name": "my-test-project", "item1": "an item", "item2": "another item"}`) `project_id` - Set the project id for a braintrust call. Default is `litellm`. + +`project_name` - Set the project name for a braintrust call. Will try to find a project with that name, or create one if it doesn't exist. If both `project_id` and `project_name` are passed, `project_id` will be used. + +`span_name` - Set a custom span name for the operation. Default is `"Chat Completion"`. Use this to provide more descriptive names for different types of operations in your application (e.g., "User Query", "Document Summary", "Code Generation"). diff --git a/docs/my-website/docs/observability/langfuse_otel_integration.md b/docs/my-website/docs/observability/langfuse_otel_integration.md index 4801fa8e1b0..b4c9a2bd1ad 100644 --- a/docs/my-website/docs/observability/langfuse_otel_integration.md +++ b/docs/my-website/docs/observability/langfuse_otel_integration.md @@ -35,14 +35,14 @@ The Langfuse OpenTelemetry integration allows you to send LiteLLM traces and obs |----------|----------|-------------|---------| | `LANGFUSE_PUBLIC_KEY` | Yes | Your Langfuse public key | `pk-lf-...` | | `LANGFUSE_SECRET_KEY` | Yes | Your Langfuse secret key | `sk-lf-...` | -| `LANGFUSE_HOST` | No | Langfuse host URL | `https://us.cloud.langfuse.com` (default) | +| `LANGFUSE_OTEL_HOST` | No | OTEL endpoint host | `https://otel.my-langfuse.com` | ### Endpoint Resolution -The integration automatically constructs the OTEL endpoint from the `LANGFUSE_HOST`: +The integration automatically constructs the OTEL endpoint from `LANGFUSE_OTEL_HOST` - **Default (US)**: `https://us.cloud.langfuse.com/api/public/otel` - **EU Region**: `https://cloud.langfuse.com/api/public/otel` -- **Self-hosted**: `{LANGFUSE_HOST}/api/public/otel` +- **Self-hosted**: `{LANGFUSE_OTEL_HOST}/api/public/otel` ## Usage @@ -77,11 +77,11 @@ os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..." os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..." # Use EU region -os.environ["LANGFUSE_HOST"] = "https://cloud.langfuse.com" # EU region -# os.environ["LANGFUSE_HOST"] = "https://us.cloud.langfuse.com" # US region (default) +os.environ["LANGFUSE_OTEL_HOST"] = "https://cloud.langfuse.com" # EU region +# os.environ["LANGFUSE_OTEL_HOST"] = "https://otel.my-langfuse.company.com" # custom OTEL endpoint # Or use self-hosted instance -# os.environ["LANGFUSE_HOST"] = "https://my-langfuse.company.com" +# os.environ["LANGFUSE_OTEL_HOST"] = "https://my-langfuse.company.com" litellm.callbacks = ["langfuse_otel"] ``` @@ -98,14 +98,16 @@ import litellm # Get keys for your project from the project settings page: https://cloud.langfuse.com os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..." os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..." -os.environ["LANGFUSE_HOST"] = "https://cloud.langfuse.com" # EU region -# os.environ["LANGFUSE_HOST"] = "https://us.cloud.langfuse.com" # US region +os.environ["LANGFUSE_OTEL_HOST"] = "https://cloud.langfuse.com" # EU region +# os.environ["LANGFUSE_OTEL_HOST"] = "https://us.cloud.langfuse.com" # US region +# os.environ["LANGFUSE_OTEL_HOST"] = "https://otel.my-langfuse.company.com" # custom OTEL endpoint LANGFUSE_AUTH = base64.b64encode( f"{os.environ.get('LANGFUSE_PUBLIC_KEY')}:{os.environ.get('LANGFUSE_SECRET_KEY')}".encode() ).decode() -os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = os.environ.get("LANGFUSE_HOST") + "/api/public/otel" +host = os.environ.get("LANGFUSE_OTEL_HOST") +os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = host + "/api/public/otel" os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}" litellm.callbacks = ["langfuse_otel"] @@ -120,7 +122,8 @@ Add the integration to your proxy configuration: ```bash export LANGFUSE_PUBLIC_KEY="pk-lf-..." export LANGFUSE_SECRET_KEY="sk-lf-..." -export LANGFUSE_HOST="https://us.cloud.langfuse.com" # Default US region +export LANGFUSE_OTEL_HOST="https://us.cloud.langfuse.com" # Default US region +# export LANGFUSE_OTEL_HOST="https://otel.my-langfuse.company.com" # custom OTEL endpoint ``` 2. Setup config.yaml diff --git a/docs/my-website/docs/providers/aiml.md b/docs/my-website/docs/providers/aiml.md index 1343cbf8d8e..9d763daf7d7 100644 --- a/docs/my-website/docs/providers/aiml.md +++ b/docs/my-website/docs/providers/aiml.md @@ -1,5 +1,23 @@ # AI/ML API +https://aimlapi.com/ +## Overview + +| Property | Details | +|-------|-------| +| Description | AI/ML API provides access to state-of-the-art AI models including flux-pro/v1.1 for high-quality image generation. | +| Provider Route on LiteLLM | `aiml/` | +| Link to Provider Doc | [AI/ML API ↗](https://docs.aimlapi.com/) | +| Supported Operations | [`/chat/completions`], [`/images/generations`](#image-generation) | + +LiteLLM supports AI/ML API Image Generation calls. + +## API Base, Key +```python +# env variable +os.environ['AIML_API_KEY'] = "your-api-key" +os.environ['AIML_API_BASE'] = "https://api.aimlapi.com" # [optional] +``` Getting started with the AI/ML API is simple. Follow these steps to set up your integration: ### 1. Get Your API Key @@ -24,7 +42,7 @@ You can choose from LLama, Qwen, Flux, and 200+ other open and closed-source mod import litellm response = litellm.completion( - model="openai/meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo", # The model name must include prefix "openai" + the model name from ai/ml api + model="aiml/meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo", # The model name must include prefix "openai" + the model name from ai/ml api api_key="", # your aiml api-key api_base="https://api.aimlapi.com/v2", messages=[ @@ -42,7 +60,7 @@ response = litellm.completion( import litellm response = litellm.completion( - model="openai/Qwen/Qwen2-72B-Instruct", # The model name must include prefix "openai" + the model name from ai/ml api + model="aiml/Qwen/Qwen2-72B-Instruct", # The model name must include prefix "openai" + the model name from ai/ml api api_key="", # your aiml api-key api_base="https://api.aimlapi.com/v2", messages=[ @@ -67,7 +85,7 @@ import litellm async def main(): response = await litellm.acompletion( - model="openai/anthropic/claude-3-5-haiku", # The model name must include prefix "openai" + the model name from ai/ml api + model="aiml/anthropic/claude-3-5-haiku", # The model name must include prefix "openai" + the model name from ai/ml api api_key="", # your aiml api-key api_base="https://api.aimlapi.com/v2", messages=[ @@ -97,7 +115,7 @@ async def main(): try: print("test acompletion + streaming") response = await litellm.acompletion( - model="openai/nvidia/Llama-3.1-Nemotron-70B-Instruct-HF", # The model name must include prefix "openai" + the model name from ai/ml api + model="aiml/nvidia/Llama-3.1-Nemotron-70B-Instruct-HF", # The model name must include prefix "openai" + the model name from ai/ml api api_key="", # your aiml api-key api_base="https://api.aimlapi.com/v2", messages=[{"content": "Hey, how's it going?", "role": "user"}], @@ -125,7 +143,7 @@ import litellm async def main(): response = await litellm.aembedding( - model="openai/text-embedding-3-small", # The model name must include prefix "openai" + the model name from ai/ml api + model="aiml/text-embedding-3-small", # The model name must include prefix "openai" + the model name from ai/ml api api_key="", # your aiml api-key api_base="https://api.aimlapi.com/v1", # 👈 the URL has changed from v2 to v1 input="Your text string", @@ -147,7 +165,7 @@ import litellm async def main(): response = await litellm.aimage_generation( - model="openai/dall-e-3", # The model name must include prefix "openai" + the model name from ai/ml api + model="aiml/dall-e-3", # The model name must include prefix "openai" + the model name from ai/ml api api_key="", # your aiml api-key api_base="https://api.aimlapi.com/v1", # 👈 the URL has changed from v2 to v1 prompt="A cute baby sea otter", diff --git a/docs/my-website/docs/providers/azure_ai_img.md b/docs/my-website/docs/providers/azure_ai_img.md new file mode 100644 index 00000000000..8e2f5226866 --- /dev/null +++ b/docs/my-website/docs/providers/azure_ai_img.md @@ -0,0 +1,266 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Azure AI Image Generation + +Azure AI provides powerful image generation capabilities using FLUX models from Black Forest Labs to create high-quality images from text descriptions. + +## Overview + +| Property | Details | +|----------|---------| +| Description | Azure AI Image Generation uses FLUX models to generate high-quality images from text descriptions. | +| Provider Route on LiteLLM | `azure_ai/` | +| Provider Doc | [Azure AI FLUX Models ↗](https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/black-forest-labs-flux-1-kontext-pro-and-flux1-1-pro-now-available-in-azure-ai-f/4434659) | +| Supported Operations | [`/images/generations`](#image-generation) | + +## Setup + +### API Key & Base URL + +```python showLineNumbers +# Set your Azure AI API credentials +import os +os.environ["AZURE_AI_API_KEY"] = "your-api-key-here" +os.environ["AZURE_AI_API_BASE"] = "your-azure-ai-endpoint" # e.g., https://your-endpoint.eastus2.inference.ai.azure.com/ +``` + +Get your API key and endpoint from [Azure AI Studio](https://ai.azure.com/). + +## Supported Models + +| Model Name | Description | Cost per Image | +|------------|-------------|----------------| +| `azure_ai/FLUX-1.1-pro` | Latest FLUX 1.1 Pro model for high-quality image generation | $0.04 | +| `azure_ai/FLUX.1-Kontext-pro` | FLUX 1 Kontext Pro model with enhanced context understanding | $0.04 | + +## Image Generation + +### Usage - LiteLLM Python SDK + + + + +```python showLineNumbers title="Basic Image Generation" +import litellm +import os + +# Set your API credentials +os.environ["AZURE_AI_API_KEY"] = "your-api-key-here" +os.environ["AZURE_AI_API_BASE"] = "your-azure-ai-endpoint" + +# Generate a single image +response = litellm.image_generation( + model="azure_ai/FLUX.1-Kontext-pro", + prompt="A cute baby sea otter swimming in crystal clear water", + api_base=os.environ["AZURE_AI_API_BASE"], + api_key=os.environ["AZURE_AI_API_KEY"] +) + +print(response.data[0].url) +``` + + + + + +```python showLineNumbers title="FLUX 1.1 Pro Image Generation" +import litellm +import os + +# Set your API credentials +os.environ["AZURE_AI_API_KEY"] = "your-api-key-here" +os.environ["AZURE_AI_API_BASE"] = "your-azure-ai-endpoint" + +# Generate image with FLUX 1.1 Pro +response = litellm.image_generation( + model="azure_ai/FLUX-1.1-pro", + prompt="A futuristic cityscape at night with neon lights and flying cars", + api_base=os.environ["AZURE_AI_API_BASE"], + api_key=os.environ["AZURE_AI_API_KEY"] +) + +print(response.data[0].url) +``` + + + + + +```python showLineNumbers title="Async Image Generation" +import litellm +import asyncio +import os + +async def generate_image(): + # Set your API credentials + os.environ["AZURE_AI_API_KEY"] = "your-api-key-here" + os.environ["AZURE_AI_API_BASE"] = "your-azure-ai-endpoint" + + # Generate image asynchronously + response = await litellm.aimage_generation( + model="azure_ai/FLUX.1-Kontext-pro", + prompt="A beautiful sunset over mountains with vibrant colors", + api_base=os.environ["AZURE_AI_API_BASE"], + api_key=os.environ["AZURE_AI_API_KEY"], + n=1, + ) + + print(response.data[0].url) + return response + +# Run the async function +asyncio.run(generate_image()) +``` + + + + + +```python showLineNumbers title="Advanced Image Generation with Parameters" +import litellm +import os + +# Set your API credentials +os.environ["AZURE_AI_API_KEY"] = "your-api-key-here" +os.environ["AZURE_AI_API_BASE"] = "your-azure-ai-endpoint" + +# Generate image with additional parameters +response = litellm.image_generation( + model="azure_ai/FLUX-1.1-pro", + prompt="A majestic dragon soaring over a medieval castle at dawn", + api_base=os.environ["AZURE_AI_API_BASE"], + api_key=os.environ["AZURE_AI_API_KEY"], + n=1, + size="1024x1024", + quality="standard" +) + +for image in response.data: + print(f"Generated image URL: {image.url}") +``` + + + + +### Usage - LiteLLM Proxy Server + +#### 1. Configure your config.yaml + +```yaml showLineNumbers title="Azure AI Image Generation Configuration" +model_list: + - model_name: azure-flux-kontext + litellm_params: + model: azure_ai/FLUX.1-Kontext-pro + api_key: os.environ/AZURE_AI_API_KEY + api_base: os.environ/AZURE_AI_API_BASE + model_info: + mode: image_generation + + - model_name: azure-flux-11-pro + litellm_params: + model: azure_ai/FLUX-1.1-pro + api_key: os.environ/AZURE_AI_API_KEY + api_base: os.environ/AZURE_AI_API_BASE + model_info: + mode: image_generation + +general_settings: + master_key: sk-1234 +``` + +#### 2. Start LiteLLM Proxy Server + +```bash showLineNumbers title="Start LiteLLM Proxy Server" +litellm --config /path/to/config.yaml + +# RUNNING on http://0.0.0.0:4000 +``` + +#### 3. Make requests with OpenAI Python SDK + + + + +```python showLineNumbers title="Azure AI Image Generation via Proxy - OpenAI SDK" +from openai import OpenAI + +# Initialize client with your proxy URL +client = OpenAI( + base_url="http://localhost:4000", # Your proxy URL + api_key="sk-1234" # Your proxy API key +) + +# Generate image with FLUX Kontext Pro +response = client.images.generate( + model="azure-flux-kontext", + prompt="A serene Japanese garden with cherry blossoms and a peaceful pond", + n=1, + size="1024x1024" +) + +print(response.data[0].url) +``` + + + + + +```python showLineNumbers title="Azure AI Image Generation via Proxy - LiteLLM SDK" +import litellm + +# Configure LiteLLM to use your proxy +response = litellm.image_generation( + model="litellm_proxy/azure-flux-11-pro", + prompt="A cyberpunk warrior in a neon-lit alleyway", + api_base="http://localhost:4000", + api_key="sk-1234" +) + +print(response.data[0].url) +``` + + + + + +```bash showLineNumbers title="Azure AI Image Generation via Proxy - cURL" +curl --location 'http://localhost:4000/v1/images/generations' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer sk-1234' \ +--data '{ + "model": "azure-flux-kontext", + "prompt": "A cozy coffee shop interior with warm lighting and rustic wooden furniture", + "n": 1, + "size": "1024x1024" +}' +``` + + + + +## Supported Parameters + +Azure AI Image Generation supports the following OpenAI-compatible parameters: + +| Parameter | Type | Description | Default | Example | +|-----------|------|-------------|---------|---------| +| `prompt` | string | Text description of the image to generate | Required | `"A sunset over the ocean"` | +| `model` | string | The FLUX model to use for generation | Required | `"azure_ai/FLUX.1-Kontext-pro"` | +| `n` | integer | Number of images to generate (1-4) | `1` | `2` | +| `size` | string | Image dimensions | `"1024x1024"` | `"512x512"`, `"1024x1024"` | +| `api_base` | string | Your Azure AI endpoint URL | Required | `"https://your-endpoint.eastus2.inference.ai.azure.com/"` | +| `api_key` | string | Your Azure AI API key | Required | Environment variable or direct value | + +## Getting Started + +1. Create an account at [Azure AI Studio](https://ai.azure.com/) +2. Deploy a FLUX model in your Azure AI Studio workspace +3. Get your API key and endpoint from the deployment details +4. Set your `AZURE_AI_API_KEY` and `AZURE_AI_API_BASE` environment variables +5. Start generating images using LiteLLM + +## Additional Resources + +- [Azure AI Studio Documentation](https://docs.microsoft.com/en-us/azure/ai-services/) +- [FLUX Models Announcement](https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/black-forest-labs-flux-1-kontext-pro-and-flux1-1-pro-now-available-in-azure-ai-f/4434659) diff --git a/docs/my-website/docs/providers/baseten.md b/docs/my-website/docs/providers/baseten.md index 902b1548faa..4e42cdf0447 100644 --- a/docs/my-website/docs/providers/baseten.md +++ b/docs/my-website/docs/providers/baseten.md @@ -1,23 +1,106 @@ -# Baseten -LiteLLM supports any Text-Gen-Interface models on Baseten. +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; -[Here's a tutorial on deploying a huggingface TGI model (Llama2, CodeLlama, WizardCoder, Falcon, etc.) on Baseten](https://truss.baseten.co/examples/performance/tgi-server) +# Baseten + +LiteLLM supports both Baseten Model APIs and dedicated deployments with automatic routing. + +## API Types + +### Model API (Default) +- **URL**: `https://inference.baseten.co/v1` +- **Format**: `baseten/` (e.g., `baseten/openai/gpt-oss-120b`) +- **Best for**: Quick access to popular models + +### Dedicated Deployments +- **URL**: `https://model-{id}.api.baseten.co/environments/production/sync/v1` +- **Format**: `baseten/{8-digit-alphanumeric-code}` (e.g., `baseten/abcd1234`) +- **Best for**: Custom models, latency SLAs + +:::tip +**Automatic Routing**: LiteLLM detects the type based on model format: +- 8-digit alphanumeric codes → Dedicated deployment +- All other formats → Model API +::: + + +## Quick Start -### API KEYS ```python -import os -os.environ["BASETEN_API_KEY"] = "" +import os +from litellm import completion + +os.environ['BASETEN_API_KEY'] = "your-api-key" + +# Model API (default) +response = completion( + model="baseten/openai/gpt-oss-120b", + messages=[{"role": "user", "content": "Hello!"}] +) + +# Dedicated deployment (8-digit ID) +response = completion( + model="baseten/abcd1234", + messages=[{"role": "user", "content": "Hello!"}] +) ``` -### Baseten Models -Baseten provides infrastructure to deploy and serve ML models https://www.baseten.co/. Use liteLLM to easily call models deployed on Baseten. +## Examples -Example Baseten Usage - Note: liteLLM supports all models deployed on Baseten +### Basic Usage +```python +# Model API +response = completion( + model="baseten/openai/gpt-oss-120b", + messages=[{"role": "user", "content": "Explain quantum computing"}], + max_tokens=500, + temperature=0.7 +) -Usage: Pass `model=baseten/` +# Dedicated deployment +response = completion( + model="baseten/abcd1234", + messages=[{"role": "user", "content": "Explain quantum computing"}], + max_tokens=500, + temperature=0.7 +) +``` -| Model Name | Function Call | Required OS Variables | -|------------------|--------------------------------------------|------------------------------------| -| Falcon 7B | `completion(model='baseten/qvv0xeq', messages=messages)` | `os.environ['BASETEN_API_KEY']` | -| Wizard LM | `completion(model='baseten/q841o8w', messages=messages)` | `os.environ['BASETEN_API_KEY']` | -| MPT 7B Base | `completion(model='baseten/31dxrj3', messages=messages)` | `os.environ['BASETEN_API_KEY']` | +### Streaming (Model API only) +```python +response = completion( + model="baseten/openai/gpt-oss-120b", + messages=[{"role": "user", "content": "Write a poem"}], + stream=True, + stream_options={"include_usage": True} +) + +for chunk in response: + if chunk.choices and chunk.choices[0].delta.content: + print(chunk.choices[0].delta.content, end="") +``` + +## Usage with LiteLLM Proxy + +1. **Config**: +```yaml +model_list: + - model_name: baseten-model + litellm_params: + model: baseten/openai/gpt-oss-120b + api_key: your-baseten-api-key +``` + +2. **Request**: +```python +import openai +client = openai.OpenAI( + api_key="sk-1234", + base_url="http://0.0.0.0:4000" +) + +response = client.chat.completions.create( + model="baseten-model", + messages=[{"role": "user", "content": "Hello!"}] +) +``` diff --git a/docs/my-website/docs/providers/bedrock.md b/docs/my-website/docs/providers/bedrock.md index 9797d678ebb..1356ec1744e 100644 --- a/docs/my-website/docs/providers/bedrock.md +++ b/docs/my-website/docs/providers/bedrock.md @@ -584,6 +584,150 @@ Same as [Anthropic API response](../providers/anthropic#usage---thinking--reason Same as [Anthropic API response](../providers/anthropic#usage---thinking--reasoning_content). +## Usage - Anthropic Beta Features + +LiteLLM supports Anthropic's beta features on AWS Bedrock through the `anthropic-beta` header. This enables access to experimental features like: + +- **1M Context Window** - Up to 1 million tokens of context (Claude Sonnet 4) +- **Computer Use Tools** - AI that can interact with computer interfaces +- **Token-Efficient Tools** - More efficient tool usage patterns +- **Extended Output** - Up to 128K output tokens +- **Enhanced Thinking** - Advanced reasoning capabilities + +### Supported Beta Features + +| Beta Feature | Header Value | Compatible Models | Description | +|--------------|-------------|------------------|-------------| +| 1M Context Window | `context-1m-2025-08-07` | Claude Sonnet 4 | Enable 1 million token context window | +| Computer Use (Latest) | `computer-use-2025-01-24` | Claude 3.7 Sonnet | Latest computer use tools | +| Computer Use (Legacy) | `computer-use-2024-10-22` | Claude 3.5 Sonnet v2 | Computer use tools for Claude 3.5 | +| Token-Efficient Tools | `token-efficient-tools-2025-02-19` | Claude 3.7 Sonnet | More efficient tool usage | +| Interleaved Thinking | `interleaved-thinking-2025-05-14` | Claude 4 models | Enhanced thinking capabilities | +| Extended Output | `output-128k-2025-02-19` | Claude 3.7 Sonnet | Up to 128K output tokens | +| Developer Thinking | `dev-full-thinking-2025-05-14` | Claude 4 models | Raw thinking mode for developers | + + + + +**Single Beta Feature** + +```python +from litellm import completion +import os + +# set env +os.environ["AWS_ACCESS_KEY_ID"] = "" +os.environ["AWS_SECRET_ACCESS_KEY"] = "" +os.environ["AWS_REGION_NAME"] = "" + +# Use 1M context window with Claude Sonnet 4 +response = completion( + model="bedrock/anthropic.claude-sonnet-4-20250115-v1:0", + messages=[{"role": "user", "content": "Hello! Testing 1M context window."}], + max_tokens=100, + extra_headers={ + "anthropic-beta": "context-1m-2025-08-07" # 👈 Enable 1M context + } +) +``` + +**Multiple Beta Features** + +```python +from litellm import completion + +# Combine multiple beta features (comma-separated) +response = completion( + model="bedrock/converse/anthropic.claude-3-5-sonnet-20241022-v2:0", + messages=[{"role": "user", "content": "Testing multiple beta features"}], + max_tokens=100, + extra_headers={ + "anthropic-beta": "computer-use-2024-10-22,context-1m-2025-08-07" + } +) +``` + +**Computer Use Tools with Beta Features** + +```python +from litellm import completion + +# Computer use tools automatically add computer-use-2024-10-22 +# You can add additional beta features +response = completion( + model="bedrock/converse/anthropic.claude-3-5-sonnet-20241022-v2:0", + messages=[{"role": "user", "content": "Take a screenshot"}], + tools=[{ + "type": "computer_20241022", + "name": "computer", + "display_width_px": 1920, + "display_height_px": 1080 + }], + extra_headers={ + "anthropic-beta": "context-1m-2025-08-07" # Additional beta feature + } +) +``` + + + + +**Set on YAML Config** + +```yaml +model_list: + - model_name: claude-sonnet-4-1m + litellm_params: + model: bedrock/anthropic.claude-sonnet-4-20250115-v1:0 + extra_headers: + anthropic-beta: "context-1m-2025-08-07" # 👈 Enable 1M context + + - model_name: claude-computer-use + litellm_params: + model: bedrock/converse/anthropic.claude-3-5-sonnet-20241022-v2:0 + extra_headers: + anthropic-beta: "computer-use-2024-10-22,context-1m-2025-08-07" + +general_settings: + forward_client_headers_to_llm_api: true # 👈 Required for client-side header forwarding +``` + +**Set on Request** + +```python +import openai + +client = openai.OpenAI( + api_key="anything", + base_url="http://0.0.0.0:4000" +) + +response = client.chat.completions.create( + model="claude-sonnet-4-1m", + messages=[{ + "role": "user", + "content": "Testing 1M context window" + }], + extra_headers={ + "anthropic-beta": "context-1m-2025-08-07" + } +) +``` + +:::info +**For client-side header forwarding**: When using the proxy and sending `anthropic-beta` headers from the client (like the OpenAI SDK), you need to enable `forward_client_headers_to_llm_api: true` in your proxy's `general_settings`. This tells the proxy to extract headers from HTTP requests and forward them to the underlying LLM provider. +::: + + + + +:::info + +Beta features may require special access or permissions in your AWS account. Some features are only available in specific AWS regions. Check the [AWS Bedrock documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages-request-response.html) for availability and access requirements. + +::: + + ## Usage - Structured Output / JSON mode diff --git a/docs/my-website/docs/providers/cometapi.md b/docs/my-website/docs/providers/cometapi.md new file mode 100644 index 00000000000..1245bacfad4 --- /dev/null +++ b/docs/my-website/docs/providers/cometapi.md @@ -0,0 +1,144 @@ +# CometAPI +LiteLLM supports all AI models from [CometAPI](https://www.cometapi.com/). CometAPI provides access to 500+ AI models through a unified API interface, including cutting-edge models like GPT-5, Claude Opus 4.1, and various other state-of-the-art language models. + +## Authentication + +To use CometAPI models, you need to obtain an API key from [CometAPI Token Console](https://api.cometapi.com/console/token). CometAPI offers free tokens for new users - you can get your free API key instantly by registering. + +## Usage + +Set your CometAPI key as an environment variable and use the completion function: + +```python +import os +from litellm import completion + +# Set API key +os.environ["COMETAPI_KEY"] = "your_comet_api_key_here" + +# Define messages +messages = [{"content": "Hello, how are you?", "role": "user"}] + +# Method 1: Using environment variable (recommended) +response = completion( + model="cometapi/gpt-5", + messages=messages +) + +print(response.choices[0].message.content) +``` + +### Alternative Usage - Explicit API Key + +You can also pass the API key explicitly: + +```python +import os +from litellm import completion + +# Define messages +messages = [{"content": "Hello, how are you?", "role": "user"}] + +# Method 2: Explicitly passing API key +response = completion( + model="cometapi/gpt-4o", + messages=messages, + api_key="your_comet_api_key_here" +) + +print(response.choices[0].message.content) +``` + +## Usage - Streaming + +Just set `stream=True` when calling completion: + +```python +import os +from litellm import completion + +os.environ["COMETAPI_KEY"] = "your_comet_api_key_here" + +messages = [{"content": "Hello, how are you?", "role": "user"}] + +response = completion( + model="cometapi/gpt-5", + messages=messages, + stream=True +) + +for chunk in response: + print(chunk.choices[0].delta.content or "", end="") +``` + +## Usage - Async Streaming + +For async streaming, use `acompletion`: + +```python +from litellm import acompletion +import asyncio, os, traceback + +async def completion_call(): + try: + os.environ["COMETAPI_KEY"] = "your_comet_api_key_here" + + print("test acompletion + streaming") + response = await acompletion( + model="cometapi/chatgpt-4o-latest", + messages=[{"content": "Hello, how are you?", "role": "user"}], + stream=True + ) + print(f"response: {response}") + async for chunk in response: + print(chunk) + except: + print(f"error occurred: {traceback.format_exc()}") + pass + +# Run the async function +await completion_call() +``` + +## CometAPI Models + +CometAPI offers access to 500+ AI models through a unified API. Some popular models include: + +| Model Name | Function Call | +|------------|---------------| +| cometapi/gpt-5 | `completion('cometapi/gpt-5', messages)` | +| cometapi/gpt-5-mini | `completion('cometapi/gpt-5-mini', messages)` | +| cometapi/gpt-5-nano | `completion('cometapi/gpt-5-nano', messages)` | +| cometapi/gpt-oss-20b | `completion('cometapi/gpt-oss-20b', messages)` | +| cometapi/gpt-oss-120b | `completion('cometapi/gpt-oss-120b', messages)` | +| cometapi/chatgpt-4o-latest | `completion('cometapi/chatgpt-4o-latest', messages)` | + +For a complete list of available models, visit the [CometAPI Models page](https://www.cometapi.com/model/). + +## Environment Variables + +| Variable | Description | Required | +|----------|-------------|----------| +| `COMETAPI_KEY` | Your CometAPI API key | Yes | + +## Error Handling + +```python +import os +from litellm import completion + +try: + os.environ["COMETAPI_KEY"] = "your_comet_api_key_here" + + messages = [{"content": "Hello, how are you?", "role": "user"}] + + response = completion( + model="cometapi/gpt-5", + messages=messages + ) + + print(response.choices[0].message.content) + +except Exception as e: + print(f"Error: {e}") +``` diff --git a/docs/my-website/docs/providers/deepinfra.md b/docs/my-website/docs/providers/deepinfra.md index 1360117445f..ddf6122cac8 100644 --- a/docs/my-website/docs/providers/deepinfra.md +++ b/docs/my-website/docs/providers/deepinfra.md @@ -1,3 +1,6 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + # DeepInfra https://deepinfra.com/ @@ -7,6 +10,11 @@ https://deepinfra.com/ ::: +## Table of Contents + +- [API Key](#api-key) +- [Chat Models](#chat-models) +- [Rerank Endpoint](#rerank-endpoint) ## API Key ```python @@ -53,3 +61,135 @@ for chunk in response: | codellama/CodeLlama-34b-Instruct-hf | `completion(model="deepinfra/codellama/CodeLlama-34b-Instruct-hf", messages)` | | mistralai/Mistral-7B-Instruct-v0.1 | `completion(model="deepinfra/mistralai/Mistral-7B-Instruct-v0.1", messages)` | | jondurbin/airoboros-l2-70b-gpt4-1.4.1 | `completion(model="deepinfra/jondurbin/airoboros-l2-70b-gpt4-1.4.1", messages)` | + +## Rerank Endpoint + +LiteLLM provides a Cohere API compatible `/rerank` endpoint for DeepInfra rerank models. + +### Supported Rerank Models + +| Model Name | Description | +|------------|-------------| +| `deepinfra/Qwen/Qwen3-Reranker-0.6B` | Lightweight rerank model (0.6B parameters) | +| `deepinfra/Qwen/Qwen3-Reranker-4B` | Medium rerank model (4B parameters) | +| `deepinfra/Qwen/Qwen3-Reranker-8B` | Large rerank model (8B parameters) | + +### Usage - LiteLLM Python SDK + + + + +```python +from litellm import rerank +import os + +os.environ["DEEPINFRA_API_KEY"] = "your-api-key" + +response = rerank( + model="deepinfra/Qwen/Qwen3-Reranker-0.6B", + query="What is the capital of France?", + documents=[ + "Paris is the capital of France.", + "London is the capital of the United Kingdom.", + "Berlin is the capital of Germany.", + "Madrid is the capital of Spain.", + "Rome is the capital of Italy." + ] +) +print(response) +``` + + + + +1. Add to config.yaml +```yaml +model_list: + - model_name: Qwen/Qwen3-Reranker-0.6B + litellm_params: + model: deepinfra/Qwen/Qwen3-Reranker-0.6B + api_key: os.environ/DEEPINFRA_API_KEY +``` + +2. Start proxy + +```bash +litellm --config /path/to/config.yaml + +# RUNNING on http://0.0.0.0:4000/ +``` + +3. Test it! + +```bash +curl -L -X POST 'http://0.0.0.0:4000/rerank' \ +-H 'Authorization: Bearer sk-1234' \ +-H 'Content-Type: application/json' \ +-d '{ + "model": "Qwen/Qwen3-Reranker-0.6B", + "query": "What is the capital of France?", + "documents": [ + "Paris is the capital of France.", + "London is the capital of the United Kingdom.", + "Berlin is the capital of Germany.", + "Madrid is the capital of Spain.", + "Rome is the capital of Italy." + ] +}' +``` + + + + +### Supported Cohere Rerank API Params + +| Param | Type | Description | +| ------------------ | ----------- | ----------------------------------------------- | +| `query` | `str` | The query to rerank the documents against | +| `documents` | `list[str]` | The documents to rerank | + + +### Provider-specific parameters +Pass any deepinfra specific parameters as a keyword argument to the rerank function, e.g. + +``` +response = rerank( + model="deepinfra/Qwen/Qwen3-Reranker-0.6B", + query="What is the capital of France?", + documents=[ + "Paris is the capital of France.", + "London is the capital of the United Kingdom.", + "Berlin is the capital of Germany.", + "Madrid is the capital of Spain.", + "Rome is the capital of Italy." + ], + my_custom_param="my_custom_value", # any other deepinfra specific parameters +) +``` + +### Response Format + +```json +{ + "id": "request-id", + "results": [ + { + "index": 0, + "relevance_score": 0.9975274205207825 + }, + { + "index": 1, + "relevance_score": 0.011687257327139378 + } + ], + "meta": { + "billed_units": { + "total_tokens": 427 + }, + "tokens": { + "input_tokens": 427, + "output_tokens": 0 + } + } +} +``` diff --git a/docs/my-website/docs/providers/google_ai_studio/image_gen.md b/docs/my-website/docs/providers/google_ai_studio/image_gen.md index f4e96d5225a..31b1766e450 100644 --- a/docs/my-website/docs/providers/google_ai_studio/image_gen.md +++ b/docs/my-website/docs/providers/google_ai_studio/image_gen.md @@ -42,7 +42,7 @@ os.environ["GEMINI_API_KEY"] = "your-api-key-here" # Generate a single image response = litellm.image_generation( - model="gemini/imagen-4.0-generate-preview-06-06", + model="gemini/imagen-4.0-generate-001", prompt="A cute baby sea otter swimming in crystal clear water" ) @@ -64,7 +64,7 @@ async def generate_image(): # Generate image asynchronously response = await litellm.aimage_generation( - model="gemini/imagen-4.0-generate-preview-06-06", + model="gemini/imagen-4.0-generate-001", prompt="A beautiful sunset over mountains with vibrant colors", n=1, ) @@ -89,7 +89,7 @@ os.environ["GEMINI_API_KEY"] = "your-api-key-here" # Generate image with additional parameters response = litellm.image_generation( - model="gemini/imagen-4.0-generate-preview-06-06", + model="gemini/imagen-4.0-generate-001", prompt="A futuristic cityscape at night with neon lights", n=1, size="1024x1024", @@ -112,7 +112,7 @@ for image in response.data: model_list: - model_name: google-imagen litellm_params: - model: gemini/imagen-4.0-generate-preview-06-06 + model: gemini/imagen-4.0-generate-001 api_key: os.environ/GEMINI_API_KEY model_info: mode: image_generation @@ -198,7 +198,7 @@ Google AI Studio Image Generation supports the following OpenAI-compatible param | Parameter | Type | Description | Default | Example | |-----------|------|-------------|---------|---------| | `prompt` | string | Text description of the image to generate | Required | `"A sunset over the ocean"` | -| `model` | string | The model to use for generation | Required | `"gemini/imagen-4.0-generate-preview-06-06"` | +| `model` | string | The model to use for generation | Required | `"gemini/imagen-4.0-generate-001"` | | `n` | integer | Number of images to generate (1-4) | `1` | `2` | | `size` | string | Image dimensions | `"1024x1024"` | `"512x512"`, `"1024x1024"` | diff --git a/docs/my-website/docs/providers/litellm_proxy.md b/docs/my-website/docs/providers/litellm_proxy.md index efe61e15445..bfefc8a787c 100644 --- a/docs/my-website/docs/providers/litellm_proxy.md +++ b/docs/my-website/docs/providers/litellm_proxy.md @@ -9,7 +9,7 @@ import TabItem from '@theme/TabItem'; | Description | LiteLLM Proxy is an OpenAI-compatible gateway that allows you to interact with multiple LLM providers through a unified API. Simply use the `litellm_proxy/` prefix before the model name to route your requests through the proxy. | | Provider Route on LiteLLM | `litellm_proxy/` (add this prefix to the model name, to route any requests to litellm_proxy - e.g. `litellm_proxy/your-model-name`) | | Setup LiteLLM Gateway | [LiteLLM Gateway ↗](../simple_proxy) | -| Supported Endpoints |`/chat/completions`, `/completions`, `/embeddings`, `/audio/speech`, `/audio/transcriptions`, `/images`, `/rerank` | +| Supported Endpoints |`/chat/completions`, `/completions`, `/embeddings`, `/audio/speech`, `/audio/transcriptions`, `/images`, `/images/edits`, `/rerank` | @@ -111,6 +111,21 @@ response = litellm.image_generation( ) ``` +## Image Edit + +```python +import litellm + +with open("your-image.png", "rb") as f: + response = litellm.image_edit( + model="litellm_proxy/gpt-image-1", + prompt="Make this image a watercolor painting", + image=[f], + api_base="your-litellm-proxy-url", + api_key="your-litellm-proxy-api-key", + ) +``` + ## Audio Transcription ```python diff --git a/docs/my-website/docs/providers/vertex_image.md b/docs/my-website/docs/providers/vertex_image.md index 2434c3a9a57..27e584cb222 100644 --- a/docs/my-website/docs/providers/vertex_image.md +++ b/docs/my-website/docs/providers/vertex_image.md @@ -18,7 +18,7 @@ import litellm # Generate a single image response = await litellm.aimage_generation( prompt="An olympic size swimming pool with crystal clear water and modern architecture", - model="vertex_ai/imagen-4.0-generate-preview-06-06", + model="vertex_ai/imagen-4.0-generate-001", vertex_ai_project="your-project-id", vertex_ai_location="us-central1", ) @@ -34,7 +34,7 @@ print(response.data[0].url) model_list: - model_name: vertex-imagen litellm_params: - model: vertex_ai/imagen-4.0-generate-preview-06-06 + model: vertex_ai/imagen-4.0-generate-001 vertex_ai_project: "your-project-id" vertex_ai_location: "us-central1" vertex_ai_credentials: "path/to/service-account.json" # Optional if using environment auth diff --git a/docs/my-website/docs/providers/vertex_partner.md b/docs/my-website/docs/providers/vertex_partner.md index c6e324f2958..cf780e35dbd 100644 --- a/docs/my-website/docs/providers/vertex_partner.md +++ b/docs/my-website/docs/providers/vertex_partner.md @@ -14,6 +14,7 @@ import TabItem from '@theme/TabItem'; | Meta/Llama | `vertex_ai/meta/{MODEL}` | [Vertex AI - Meta Models](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/llama) | | Mistral | `vertex_ai/mistral-*` | [Vertex AI - Mistral Models](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/mistral) | | AI21 (Jamba) | `vertex_ai/jamba-*` | [Vertex AI - AI21 Models](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/ai21) | +| Qwen | `vertex_ai/qwen/*` | [Vertex AI - Qwen Models](https://cloud.google.com/vertex-ai/generative-ai/docs/maas/qwen) | | Model Garden | `vertex_ai/openai/{MODEL_ID}` or `vertex_ai/{MODEL_ID}` | [Vertex Model Garden](https://cloud.google.com/model-garden?hl=en) | ## Vertex AI - Anthropic (Claude) @@ -571,6 +572,92 @@ curl --location 'http://0.0.0.0:4000/chat/completions' \ +## VertexAI Qwen API + +| Property | Details | +|----------|---------| +| Provider Route | `vertex_ai/qwen/{MODEL}` | +| Vertex Documentation | [Vertex AI - Qwen Models](https://cloud.google.com/vertex-ai/generative-ai/docs/maas/qwen) | + +**LiteLLM Supports all Vertex AI Qwen Models.** Ensure you use the `vertex_ai/qwen/` prefix for all Vertex AI Qwen models. + +| Model Name | Usage | +|------------------|------------------------------| +| vertex_ai/qwen/qwen3-coder-480b-a35b-instruct-maas | `completion('vertex_ai/qwen/qwen3-coder-480b-a35b-instruct-maas', messages)` | +| vertex_ai/qwen/qwen3-235b-a22b-instruct-2507-maas | `completion('vertex_ai/qwen/qwen3-235b-a22b-instruct-2507-maas', messages)` | + +#### Usage + + + + +```python +from litellm import completion +import os + +os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "" + +model = "qwen/qwen3-coder-480b-a35b-instruct-maas" + +vertex_ai_project = "your-vertex-project" # can also set this as os.environ["VERTEXAI_PROJECT"] +vertex_ai_location = "your-vertex-location" # can also set this as os.environ["VERTEXAI_LOCATION"] + +response = completion( + model="vertex_ai/" + model, + messages=[{"role": "user", "content": "hi"}], + vertex_ai_project=vertex_ai_project, + vertex_ai_location=vertex_ai_location, +) +print("\nModel Response", response) +``` + + + +**1. Add to config** + +```yaml +model_list: + - model_name: vertex-qwen + litellm_params: + model: vertex_ai/qwen/qwen3-coder-480b-a35b-instruct-maas + vertex_ai_project: "my-test-project" + vertex_ai_location: "us-east-1" + - model_name: vertex-qwen + litellm_params: + model: vertex_ai/qwen/qwen3-coder-480b-a35b-instruct-maas + vertex_ai_project: "my-test-project" + vertex_ai_location: "us-west-1" +``` + +**2. Start proxy** + +```bash +litellm --config /path/to/config.yaml + +# RUNNING at http://0.0.0.0:4000 +``` + +**3. Test it!** + +```bash +curl --location 'http://0.0.0.0:4000/chat/completions' \ + --header 'Authorization: Bearer sk-1234' \ + --header 'Content-Type: application/json' \ + --data '{ + "model": "vertex-qwen", # 👈 the 'model_name' in config + "messages": [ + { + "role": "user", + "content": "what llm are you" + } + ], + }' +``` + + + + + ## Model Garden :::tip diff --git a/docs/my-website/docs/providers/vllm.md b/docs/my-website/docs/providers/vllm.md index d8b201956e2..5472f0602f4 100644 --- a/docs/my-website/docs/providers/vllm.md +++ b/docs/my-website/docs/providers/vllm.md @@ -104,6 +104,52 @@ Here's how to call an OpenAI-Compatible Endpoint with the LiteLLM Proxy Server + ## Reasoning Effort + + + + + ```python + from litellm import completion + + response = completion( + model="hosted_vllm/gpt-oss-120b", + messages=[{"role": "user", "content": "whats 2 + 2"}], + reasoning_effort="high", + api_base="https://hosted-vllm-api.co", + ) + print(response) + ``` + + + + 1. Setup config.yaml + + ```yaml + model_list: + - model_name: gpt-oss-120b + litellm_params: + model: hosted_vllm/gpt-oss-120b + api_base: https://hosted-vllm-api.co + ``` + + 2. Start the proxy + + ```bash + litellm --config /path/to/config.yaml + ``` + + 3. Test it! + + ```bash + curl http://0.0.0.0:4000/v1/chat/completions \ + -H "Content-Type: application/json" \ + -d '{"model": "gpt-oss-120b", "messages": [{"role": "user", "content": "whats 2 + 2"}], "reasoning_effort": "high"}' + ``` + + + + ## Embeddings diff --git a/docs/my-website/docs/proxy/config_settings.md b/docs/my-website/docs/proxy/config_settings.md index 3b903935a04..1fb4cd55aa2 100644 --- a/docs/my-website/docs/proxy/config_settings.md +++ b/docs/my-website/docs/proxy/config_settings.md @@ -335,12 +335,16 @@ router_settings: | ANTHROPIC_API_KEY | API key for Anthropic service | ANTHROPIC_API_BASE | Base URL for Anthropic API. Default is https://api.anthropic.com | AWS_ACCESS_KEY_ID | Access Key ID for AWS services +| AWS_DEFAULT_REGION | Default AWS region for service interactions when AWS_REGION is not set | AWS_PROFILE_NAME | AWS CLI profile name to be used +| AWS_REGION | AWS region for service interactions (takes precedence over AWS_DEFAULT_REGION) | AWS_REGION_NAME | Default AWS region for service interactions +| AWS_ROLE_ARN | ARN of the AWS IAM role to assume for authentication | AWS_ROLE_NAME | Role name for AWS IAM usage | AWS_SECRET_ACCESS_KEY | Secret Access Key for AWS services | AWS_SESSION_NAME | Name for AWS session | AWS_WEB_IDENTITY_TOKEN | Web identity token for AWS +| AWS_WEB_IDENTITY_TOKEN_FILE | Path to file containing web identity token for AWS | AZURE_API_VERSION | Version of the Azure API being used | AZURE_AUTHORITY_HOST | Azure authority host URL | AZURE_CERTIFICATE_PASSWORD | Password for Azure OpenAI certificate @@ -349,6 +353,7 @@ router_settings: | AZURE_CODE_INTERPRETER_COST_PER_SESSION | Cost per session for Azure Code Interpreter service | AZURE_COMPUTER_USE_INPUT_COST_PER_1K_TOKENS | Input cost per 1K tokens for Azure Computer Use service | AZURE_COMPUTER_USE_OUTPUT_COST_PER_1K_TOKENS | Output cost per 1K tokens for Azure Computer Use service +| AZURE_DEFAULT_RESPONSES_API_VERSION | Version of the Azure Default Responses API being used. Default is "preview" | AZURE_TENANT_ID | Tenant ID for Azure Active Directory | AZURE_USERNAME | Username for Azure services, use in conjunction with AZURE_PASSWORD for azure ad token with basic username/password workflow | AZURE_PASSWORD | Password for Azure services, use in conjunction with AZURE_USERNAME for azure ad token with basic username/password workflow @@ -565,6 +570,7 @@ router_settings: | LITELLM_LICENSE | License key for LiteLLM usage | LITELLM_LOCAL_MODEL_COST_MAP | Local configuration for model cost mapping in LiteLLM | LITELLM_LOG | Enable detailed logging for LiteLLM +| LITELLM_LOG_FILE | File path to write LiteLLM logs to. When set, logs will be written to both console and the specified file | LITELLM_MASTER_KEY | Master key for proxy authentication | LITELLM_MODE | Operating mode for LiteLLM (e.g., production, development) | LITELLM_RATE_LIMIT_WINDOW_SIZE | Rate limit window size for LiteLLM. Default is 60 diff --git a/docs/my-website/docs/proxy/deploy.md b/docs/my-website/docs/proxy/deploy.md index ddd88bb2904..7f893068645 100644 --- a/docs/my-website/docs/proxy/deploy.md +++ b/docs/my-website/docs/proxy/deploy.md @@ -127,6 +127,8 @@ CMD ["--port", "4000", "--config", "config.yaml", "--detailed_debug"] Follow these instructions to build a docker container from the litellm pip package. If your company has a strict requirement around security / building images you can follow these steps. +**Note:** You'll need to copy the `schema.prisma` file from the [litellm repository](https://github.com/BerriAI/litellm/blob/main/schema.prisma) to your build directory alongside the Dockerfile and requirements.txt. + Dockerfile ```shell @@ -149,6 +151,12 @@ COPY requirements.txt . RUN --mount=type=cache,target=${HOME}/.cache/pip \ ${HOME}/venv/bin/pip install -r requirements.txt +# Copy Prisma schema file +COPY schema.prisma . + +# Generate prisma client +RUN prisma generate + EXPOSE 4000/tcp ENTRYPOINT ["litellm"] @@ -1002,5 +1010,13 @@ User-agent: * Disallow: / ``` +## Deployment FAQ + +**Q: Is Postgres the only supported database, or do you support other ones (like Mongo)?** + +A: We explored MySQL but that was hard to maintain and led to bugs for customers. Currently, PostgreSQL is our primary supported database for production deployments. +**Q: If there is Postgres downtime, how does LiteLLM react? Does it fail-open or is there API downtime?** + +A: You can gracefully handle DB unavailability if it's on your VPC. See our production guide for more details: [Gracefully Handle DB Unavailability](https://docs.litellm.ai/docs/proxy/prod#6-if-running-litellm-on-vpc-gracefully-handle-db-unavailability) \ No newline at end of file diff --git a/docs/my-website/docs/proxy/docker_quick_start.md b/docs/my-website/docs/proxy/docker_quick_start.md index 99bf618b5a4..09f7dfbaf78 100644 --- a/docs/my-website/docs/proxy/docker_quick_start.md +++ b/docs/my-website/docs/proxy/docker_quick_start.md @@ -2,7 +2,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# Getting Started - E2E Tutorial +# E2E Tutorial End-to-End tutorial for LiteLLM Proxy to: - Add an Azure OpenAI model diff --git a/docs/my-website/docs/proxy/guardrails/custom_guardrail.md b/docs/my-website/docs/proxy/guardrails/custom_guardrail.md index 657ccab68e4..b8ba64d333a 100644 --- a/docs/my-website/docs/proxy/guardrails/custom_guardrail.md +++ b/docs/my-website/docs/proxy/guardrails/custom_guardrail.md @@ -23,15 +23,14 @@ A CustomGuardrail has 4 methods to enforce guardrails Create a new file called `custom_guardrail.py` and add this code to it ```python -from typing import Any, Dict, List, Literal, Optional, Union +from typing import Any, AsyncGenerator, Literal, Optional, Union import litellm from litellm._logging import verbose_proxy_logger from litellm.caching.caching import DualCache from litellm.integrations.custom_guardrail import CustomGuardrail from litellm.proxy._types import UserAPIKeyAuth -from litellm.proxy.guardrails.guardrail_helpers import should_proceed_based_on_metadata -from litellm.types.guardrails import GuardrailEventHooks +from litellm.types.utils import ModelResponseStream class myCustomGuardrail(CustomGuardrail): diff --git a/docs/my-website/docs/proxy/guardrails/noma_security.md b/docs/my-website/docs/proxy/guardrails/noma_security.md new file mode 100644 index 00000000000..3a50841d65e --- /dev/null +++ b/docs/my-website/docs/proxy/guardrails/noma_security.md @@ -0,0 +1,299 @@ +import Image from '@theme/IdealImage'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Noma Security + +Use [Noma Security](https://noma.security/) to protect your LLM applications with comprehensive AI content moderation and safety guardrails. + +## Quick Start + +### 1. Define Guardrails on your LiteLLM config.yaml + +Define your guardrails under the `guardrails` section: + +```yaml showLineNumbers title="litellm config.yaml" +model_list: + - model_name: gpt-4o-mini + litellm_params: + model: openai/gpt-4o-mini + api_key: os.environ/OPENAI_API_KEY + +guardrails: + - guardrail_name: "noma-guard" + litellm_params: + guardrail: noma + mode: "during_call" + api_key: os.environ/NOMA_API_KEY + api_base: os.environ/NOMA_API_BASE + - guardrail_name: "noma-pre-guard" + litellm_params: + guardrail: noma + mode: "pre_call" + api_key: os.environ/NOMA_API_KEY + api_base: os.environ/NOMA_API_BASE +``` + +#### Supported values for `mode` + +- `pre_call` Run **before** LLM call, on **input** +- `post_call` Run **after** LLM call, on **input & output** +- `during_call` Run **during** LLM call, on **input**. Same as `pre_call` but runs in parallel with the LLM call. Response not returned until guardrail check completes + +### 2. Start LiteLLM Gateway + +```shell +litellm --config config.yaml --detailed_debug +``` + +### 3. Test request + + + + +Expect this to fail since the request contains harmful content: + +```shell showLineNumbers title="Curl Request" +curl -i http://0.0.0.0:4000/v1/chat/completions \ + -H "Content-Type: application/json" \ + -d '{ + "model": "gpt-4o-mini", + "messages": [ + {"role": "user", "content": "Tell me how to hack into someone's email account"} + ] + }' +``` + +Expected response on failure: + +```json +{ + "error": { + "message": "{\n \"error\": \"Request blocked by Noma guardrail\",\n \"details\": {\n \"prompt\": {\n \"harmfulContent\": {\n \"result\": true,\n \"confidence\": 0.95\n }\n }\n }\n }", + "type": "None", + "param": "None", + "code": "400" + } +} +``` + + + + + +```shell showLineNumbers title="Curl Request" +curl -i http://0.0.0.0:4000/v1/chat/completions \ + -H "Content-Type: application/json" \ + -d '{ + "model": "gpt-4o-mini", + "messages": [ + {"role": "user", "content": "What is the capital of France?"} + ] + }' +``` + +Expected response: + +```json +{ + "id": "chatcmpl-123", + "object": "chat.completion", + "created": 1677652288, + "model": "gpt-4o-mini", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "The capital of France is Paris." + }, + "finish_reason": "stop" + } + ], + "usage": { + "prompt_tokens": 9, + "completion_tokens": 12, + "total_tokens": 21 + } +} +``` + + + + +## Supported Params + +```yaml +guardrails: + - guardrail_name: "noma-guard" + litellm_params: + guardrail: noma + mode: "pre_call" + api_key: os.environ/NOMA_API_KEY + api_base: os.environ/NOMA_API_BASE + ### OPTIONAL ### + # application_id: "my-app" + # monitor_mode: false + # block_failures: true +``` + +### Required Parameters + +- **`api_key`**: Your Noma Security API key (set as `os.environ/NOMA_API_KEY` in YAML config) + +### Optional Parameters + +- **`api_base`**: Noma API base URL (defaults to `https://api.noma.security/`) +- **`application_id`**: Your application identifier (defaults to `"litellm"`) +- **`monitor_mode`**: If `true`, logs violations without blocking (defaults to `false`) +- **`block_failures`**: If `true`, blocks requests when guardrail API failures occur (defaults to `true`) + +## Environment Variables + +You can set these environment variables instead of hardcoding values in your config: + +```shell +export NOMA_API_KEY="your-api-key-here" +export NOMA_API_BASE="https://api.noma.security/" # Optional +export NOMA_APPLICATION_ID="my-app" # Optional +export NOMA_MONITOR_MODE="false" # Optional +export NOMA_BLOCK_FAILURES="true" # Optional +``` + +## Advanced Configuration + +### Monitor Mode + +Use monitor mode to test your guardrails without blocking requests: + +```yaml +guardrails: + - guardrail_name: "noma-monitor" + litellm_params: + guardrail: noma + mode: "pre_call" + api_key: os.environ/NOMA_API_KEY + monitor_mode: true # Log violations but don't block +``` + +### Handling API Failures + +Control behavior when the Noma API is unavailable: + +```yaml +guardrails: + - guardrail_name: "noma-failopen" + litellm_params: + guardrail: noma + mode: "pre_call" + api_key: os.environ/NOMA_API_KEY + block_failures: false # Allow requests to proceed if guardrail API fails +``` + +### Multiple Guardrails + +Apply different configurations for input and output: + +```yaml +guardrails: + - guardrail_name: "noma-strict-input" + litellm_params: + guardrail: noma + mode: "pre_call" + api_key: os.environ/NOMA_API_KEY + block_failures: true + + - guardrail_name: "noma-monitor-output" + litellm_params: + guardrail: noma + mode: "post_call" + api_key: os.environ/NOMA_API_KEY + monitor_mode: true +``` + +## ✨ Pass Additional Parameters + +Use `extra_body` to pass additional parameters to the Noma Security API call, such as dynamically setting the application ID for specific requests. + + + + +```python +import openai +client = openai.OpenAI( + api_key="your-api-key", + base_url="http://0.0.0.0:4000" +) + +response = client.chat.completions.create( + model="gpt-4o-mini", + messages=[{"role": "user", "content": "Hello, how are you?"}], + extra_body={ + "guardrails": { + "noma-guard": { + "extra_body": { + "application_id": "my-specific-app-id" + } + } + } + } +) +``` + + + + +```shell +curl 'http://0.0.0.0:4000/v1/chat/completions' \ + -H 'Content-Type: application/json' \ + -d '{ + "model": "gpt-4o-mini", + "messages": [ + { + "role": "user", + "content": "Hello, how are you?" + } + ], + "guardrails": { + "noma-guard": { + "extra_body": { + "application_id": "my-specific-app-id" + } + } + } +}' +``` + + + +This allows you to override the default `application_id` parameter for specific requests, which is useful for tracking usage across different applications or components. + +## Response Details + +When content is blocked, Noma provides detailed information about the violations as JSON inside the `message` field, with the following structure: + +```json +{ + "error": "Request blocked by Noma guardrail", + "details": { + "prompt": { + "harmfulContent": { + "result": true, + "confidence": 0.95 + }, + "sensitiveData": { + "email": { + "result": true, + "entities": ["user@example.com"] + } + }, + "bannedTopics": { + "violence": { + "result": true, + "confidence": 0.88 + } + } + } + } +} +``` diff --git a/docs/my-website/docs/proxy/quick_start.md b/docs/my-website/docs/proxy/quick_start.md index 8f8de2a9fae..a343bb00e9b 100644 --- a/docs/my-website/docs/proxy/quick_start.md +++ b/docs/my-website/docs/proxy/quick_start.md @@ -2,8 +2,9 @@ import Image from '@theme/IdealImage'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# Quick Start -Quick start CLI, Config, Docker +# CLI - Quick Start + +Setup LiteLLM Proxy quickly via CLI. LiteLLM Server (LLM Gateway) manages: diff --git a/docs/my-website/docs/proxy/self_serve.md b/docs/my-website/docs/proxy/self_serve.md index 815231b59a2..dff55a8ac04 100644 --- a/docs/my-website/docs/proxy/self_serve.md +++ b/docs/my-website/docs/proxy/self_serve.md @@ -309,6 +309,37 @@ curl -X POST '/team/new' \ +### Team Member Rate Limits + +Set a default tpm/rpm limit for an individual team member. + +You can do this when creating a new team, or by updating an existing team. + + + + + + + + + + +```bash +curl -X POST '/team/new' \ +-H 'Authorization: Bearer ' \ +-H 'Content-Type: application/json' \ +-D '{ + "team_alias": "team_1", + "team_member_rpm_limit": 100, + "team_member_tpm_limit": 1000 +}' +``` + + + + + + ### Set default params for new teams When you connect litellm to your SSO provider, litellm can auto-create teams. Use this to set the default `models`, `max_budget`, `budget_duration` for these auto-created teams. diff --git a/docs/my-website/docs/proxy/team_budgets.md b/docs/my-website/docs/proxy/team_budgets.md index 854d6edf304..66ba679c65e 100644 --- a/docs/my-website/docs/proxy/team_budgets.md +++ b/docs/my-website/docs/proxy/team_budgets.md @@ -4,6 +4,12 @@ import TabItem from '@theme/TabItem'; # Setting Team Budgets + +# Pre-Requisites + +- You must set up a Postgres database (e.g. Supabase, Neon, etc.) +- To enable team member rate limits, set the environment variable `EXPERIMENTAL_MULTI_INSTANCE_RATE_LIMITING=true` **before starting the proxy server**. Without this, team member rate limits will not be enforced. + Track spend, set budgets for your Internal Team ## Setting Monthly Team Budgets diff --git a/docs/my-website/docs/proxy/users.md b/docs/my-website/docs/proxy/users.md index c812dccb199..d098e38de4a 100644 --- a/docs/my-website/docs/proxy/users.md +++ b/docs/my-website/docs/proxy/users.md @@ -58,6 +58,9 @@ You can: **Step-by step tutorial on setting, resetting budgets on Teams here (API or using Admin UI)** +> **Prerequisite:** +> To enable team member rate limits, you must set the environment variable `EXPERIMENTAL_MULTI_INSTANCE_RATE_LIMITING=true` before starting the proxy server. Without this, team member rate limits will not be enforced. + 👉 [https://docs.litellm.ai/docs/proxy/team_budgets](https://docs.litellm.ai/docs/proxy/team_budgets) ::: @@ -793,6 +796,11 @@ Expected Response: Enable multi-instance rate limiting with the env var `EXPERIMENTAL_MULTI_INSTANCE_RATE_LIMITING="True"` +**Important Notes:** +- Setting `EXPERIMENTAL_MULTI_INSTANCE_RATE_LIMITING="True"` is required for team member rate limits to function, not just for multi-instance scenarios. +- **Rate limits do not apply to proxy admin users.** +- When testing rate limits, use internal user roles (non-admin) to ensure limits are enforced as expected. + Changes: - This moves to using async_increment instead of async_set_cache when updating current requests/tokens. - The in-memory cache is synced with redis every 0.01s, to avoid calling redis for every request. diff --git a/docs/my-website/docs/rerank.md b/docs/my-website/docs/rerank.md index 11dcae777e4..c57eacbb224 100644 --- a/docs/my-website/docs/rerank.md +++ b/docs/my-website/docs/rerank.md @@ -118,4 +118,5 @@ curl http://0.0.0.0:4000/rerank \ | AWS Bedrock| [Usage](../docs/providers/bedrock#rerank-api) | | HuggingFace| [Usage](../docs/providers/huggingface_rerank) | | Infinity| [Usage](../docs/providers/infinity) | -| vLLM| [Usage](../docs/providers/vllm#rerank-endpoint) | \ No newline at end of file +| vLLM| [Usage](../docs/providers/vllm#rerank-endpoint) | +| DeepInfra| [Usage](../docs/providers/deepinfra#rerank-endpoint) | \ No newline at end of file diff --git a/docs/my-website/docs/response_api.md b/docs/my-website/docs/response_api.md index e64f922ac80..94d7c73be05 100644 --- a/docs/my-website/docs/response_api.md +++ b/docs/my-website/docs/response_api.md @@ -803,10 +803,18 @@ LiteLLM Proxy supports session management for non-OpenAI models. This allows you 1. Enable storing request / response content in the database -Set `store_prompts_in_spend_logs: true` in your proxy config.yaml. When this is enabled, LiteLLM will store the request and response content in the database. +Set `store_prompts_in_cold_storage: true` in your proxy config.yaml. When this is enabled, LiteLLM will store the request and response content in the s3 bucket you specify. + +```yaml showLineNumbers title="config.yaml with Session Continuity" +litellm_settings: + callbacks: ["s3_v2"] + cold_storage_custom_logger: s3_v2 + s3_callback_params: # learn more https://docs.litellm.ai/docs/proxy/logging#s3-buckets + s3_bucket_name: litellm-logs # AWS Bucket Name for S3 + s3_region_name: us-west-2 -```yaml general_settings: + store_prompts_in_cold_storage: true store_prompts_in_spend_logs: true ``` diff --git a/docs/my-website/docs/simple_proxy_old_doc.md b/docs/my-website/docs/simple_proxy_old_doc.md deleted file mode 100644 index 730fd0aab42..00000000000 --- a/docs/my-website/docs/simple_proxy_old_doc.md +++ /dev/null @@ -1,1353 +0,0 @@ -import Image from '@theme/IdealImage'; -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -# 💥 LiteLLM Proxy Server - -LiteLLM Server manages: - -* **Unified Interface**: Calling 100+ LLMs [Huggingface/Bedrock/TogetherAI/etc.](#other-supported-models) in the OpenAI `ChatCompletions` & `Completions` format -* **Load Balancing**: between [Multiple Models](#multiple-models---quick-start) + [Deployments of the same model](#multiple-instances-of-1-model) - LiteLLM proxy can handle 1.5k+ requests/second during load tests. -* **Cost tracking**: Authentication & Spend Tracking [Virtual Keys](#managing-auth---virtual-keys) - -[**See LiteLLM Proxy code**](https://github.com/BerriAI/litellm/tree/main/litellm/proxy) - -## Quick Start -View all the supported args for the Proxy CLI [here](https://docs.litellm.ai/docs/simple_proxy#proxy-cli-arguments) - -```shell -$ pip install 'litellm[proxy]' -``` - -```shell -$ litellm --model huggingface/bigcode/starcoder - -#INFO: Proxy running on http://0.0.0.0:4000 -``` - -### Test -In a new shell, run, this will make an `openai.chat.completions` request. Ensure you're using openai v1.0.0+ -```shell -litellm --test -``` - -This will now automatically route any requests for gpt-3.5-turbo to bigcode starcoder, hosted on huggingface inference endpoints. - -### Using LiteLLM Proxy - Curl Request, OpenAI Package - - - - -```shell -curl --location 'http://0.0.0.0:4000/chat/completions' \ ---header 'Content-Type: application/json' \ ---data ' { - "model": "gpt-3.5-turbo", - "messages": [ - { - "role": "user", - "content": "what llm are you" - } - ], - } -' -``` - - - -```python -import openai -client = openai.OpenAI( - api_key="anything", - base_url="http://0.0.0.0:4000" -) - -# request sent to model set on litellm proxy, `litellm --model` -response = client.chat.completions.create(model="gpt-3.5-turbo", messages = [ - { - "role": "user", - "content": "this is a test request, write a short poem" - } -]) - -print(response) - -``` - - - - -### Server Endpoints -- POST `/chat/completions` - chat completions endpoint to call 100+ LLMs -- POST `/completions` - completions endpoint -- POST `/embeddings` - embedding endpoint for Azure, OpenAI, Huggingface endpoints -- GET `/models` - available models on server -- POST `/key/generate` - generate a key to access the proxy - -### Supported LLMs -All LiteLLM supported LLMs are supported on the Proxy. Seel all [supported llms](https://docs.litellm.ai/docs/providers) - - - -```shell -$ export AWS_ACCESS_KEY_ID= -$ export AWS_REGION_NAME= -$ export AWS_SECRET_ACCESS_KEY= -``` - -```shell -$ litellm --model bedrock/anthropic.claude-v2 -``` - - - -```shell -$ export AZURE_API_KEY=my-api-key -$ export AZURE_API_BASE=my-api-base -``` -``` -$ litellm --model azure/my-deployment-name -``` - - - - -```shell -$ export OPENAI_API_KEY=my-api-key -``` - -```shell -$ litellm --model gpt-3.5-turbo -``` - - - -```shell -$ export HUGGINGFACE_API_KEY=my-api-key #[OPTIONAL] -``` -```shell -$ litellm --model huggingface/ --api_base https://k58ory32yinf1ly0.us-east-1.aws.endpoints.huggingface.cloud -``` - - - - -```shell -$ litellm --model huggingface/ --api_base http://0.0.0.0:8001 -``` - - - - -```shell -export AWS_ACCESS_KEY_ID= -export AWS_REGION_NAME= -export AWS_SECRET_ACCESS_KEY= -``` - -```shell -$ litellm --model sagemaker/jumpstart-dft-meta-textgeneration-llama-2-7b -``` - - - - -```shell -$ export ANTHROPIC_API_KEY=my-api-key -``` -```shell -$ litellm --model claude-instant-1 -``` - - - -Assuming you're running vllm locally - -```shell -$ litellm --model vllm/facebook/opt-125m -``` - - - -```shell -$ export TOGETHERAI_API_KEY=my-api-key -``` -```shell -$ litellm --model together_ai/lmsys/vicuna-13b-v1.5-16k -``` - - - - - -```shell -$ export REPLICATE_API_KEY=my-api-key -``` -```shell -$ litellm \ - --model replicate/meta/llama-2-70b-chat:02e509c789964a7ea8736978a43525956ef40397be9033abf9fd2badfe68c9e3 -``` - - - - - -```shell -$ litellm --model petals/meta-llama/Llama-2-70b-chat-hf -``` - - - - - -```shell -$ export PALM_API_KEY=my-palm-key -``` -```shell -$ litellm --model palm/chat-bison -``` - - - - - -```shell -$ export AI21_API_KEY=my-api-key -``` - -```shell -$ litellm --model j2-light -``` - - - - - -```shell -$ export COHERE_API_KEY=my-api-key -``` - -```shell -$ litellm --model command-nightly -``` - - - - - - -## Using with OpenAI compatible projects -Set `base_url` to the LiteLLM Proxy server - - - - -```python -import openai -client = openai.OpenAI( - api_key="anything", - base_url="http://0.0.0.0:4000" -) - -# request sent to model set on litellm proxy, `litellm --model` -response = client.chat.completions.create(model="gpt-3.5-turbo", messages = [ - { - "role": "user", - "content": "this is a test request, write a short poem" - } -]) - -print(response) - -``` - - - -#### Start the LiteLLM proxy -```shell -litellm --model gpt-3.5-turbo - -#INFO: Proxy running on http://0.0.0.0:4000 -``` - -#### 1. Clone the repo - -```shell -git clone https://github.com/danny-avila/LibreChat.git -``` - - -#### 2. Modify Librechat's `docker-compose.yml` -LiteLLM Proxy is running on port `4000`, set `4000` as the proxy below -```yaml -OPENAI_REVERSE_PROXY=http://host.docker.internal:4000/v1/chat/completions -``` - -#### 3. Save fake OpenAI key in Librechat's `.env` - -Copy Librechat's `.env.example` to `.env` and overwrite the default OPENAI_API_KEY (by default it requires the user to pass a key). -```env -OPENAI_API_KEY=sk-1234 -``` - -#### 4. Run LibreChat: -```shell -docker compose up -``` - - - - -Continue-Dev brings ChatGPT to VSCode. See how to [install it here](https://continue.dev/docs/quickstart). - -In the [config.py](https://continue.dev/docs/reference/Models/openai) set this as your default model. -```python - default=OpenAI( - api_key="IGNORED", - model="fake-model-name", - context_length=2048, # customize if needed for your model - api_base="http://localhost:4000" # your proxy server url - ), -``` - -Credits [@vividfog](https://github.com/ollama/ollama/issues/305#issuecomment-1751848077) for this tutorial. - - - - -```shell -$ pip install aider - -$ aider --openai-api-base http://0.0.0.0:4000 --openai-api-key fake-key -``` - - - -```python -pip install pyautogen -``` - -```python -from autogen import AssistantAgent, UserProxyAgent, oai -config_list=[ - { - "model": "my-fake-model", - "api_base": "http://localhost:4000", #litellm compatible endpoint - "api_type": "open_ai", - "api_key": "NULL", # just a placeholder - } -] - -response = oai.Completion.create(config_list=config_list, prompt="Hi") -print(response) # works fine - -llm_config={ - "config_list": config_list, -} - -assistant = AssistantAgent("assistant", llm_config=llm_config) -user_proxy = UserProxyAgent("user_proxy") -user_proxy.initiate_chat(assistant, message="Plot a chart of META and TESLA stock price change YTD.", config_list=config_list) -``` - -Credits [@victordibia](https://github.com/microsoft/autogen/issues/45#issuecomment-1749921972) for this tutorial. - - - -A guidance language for controlling large language models. -https://github.com/guidance-ai/guidance - -**NOTE:** Guidance sends additional params like `stop_sequences` which can cause some models to fail if they don't support it. - -**Fix**: Start your proxy using the `--drop_params` flag - -```shell -litellm --model ollama/codellama --temperature 0.3 --max_tokens 2048 --drop_params -``` - -```python -import guidance - -# set api_base to your proxy -# set api_key to anything -gpt4 = guidance.llms.OpenAI("gpt-4", api_base="http://0.0.0.0:4000", api_key="anything") - -experts = guidance(''' -{{#system~}} -You are a helpful and terse assistant. -{{~/system}} - -{{#user~}} -I want a response to the following question: -{{query}} -Name 3 world-class experts (past or present) who would be great at answering this? -Don't answer the question yet. -{{~/user}} - -{{#assistant~}} -{{gen 'expert_names' temperature=0 max_tokens=300}} -{{~/assistant}} -''', llm=gpt4) - -result = experts(query='How can I be more productive?') -print(result) -``` - - - -## Proxy Configs -The Config allows you to set the following params - -| Param Name | Description | -|----------------------|---------------------------------------------------------------| -| `model_list` | List of supported models on the server, with model-specific configs | -| `litellm_settings` | litellm Module settings, example `litellm.drop_params=True`, `litellm.set_verbose=True`, `litellm.api_base`, `litellm.cache` | -| `general_settings` | Server settings, example setting `master_key: sk-my_special_key` | -| `environment_variables` | Environment Variables example, `REDIS_HOST`, `REDIS_PORT` | - -#### Example Config -```yaml -model_list: - - model_name: gpt-3.5-turbo - litellm_params: - model: azure/gpt-turbo-small-eu - api_base: https://my-endpoint-europe-berri-992.openai.azure.com/ - api_key: - rpm: 6 # Rate limit for this deployment: in requests per minute (rpm) - - model_name: gpt-3.5-turbo - litellm_params: - model: azure/gpt-turbo-small-ca - api_base: https://my-endpoint-canada-berri992.openai.azure.com/ - api_key: - rpm: 6 - - model_name: gpt-3.5-turbo - litellm_params: - model: azure/gpt-turbo-large - api_base: https://openai-france-1234.openai.azure.com/ - api_key: - rpm: 1440 - -litellm_settings: - drop_params: True - set_verbose: True - -general_settings: - master_key: sk-1234 # [OPTIONAL] Only use this if you to require all calls to contain this key (Authorization: Bearer sk-1234) - - -environment_variables: - OPENAI_API_KEY: sk-123 - REPLICATE_API_KEY: sk-cohere-is-okay - REDIS_HOST: redis-16337.c322.us-east-1-2.ec2.cloud.redislabs.com - REDIS_PORT: "16337" - REDIS_PASSWORD: -``` - -### Config for Multiple Models - GPT-4, Claude-2 - -Here's how you can use multiple llms with one proxy `config.yaml`. - -#### Step 1: Setup Config -```yaml -model_list: - - model_name: zephyr-alpha # the 1st model is the default on the proxy - litellm_params: # params for litellm.completion() - https://docs.litellm.ai/docs/completion/input#input---request-body - model: huggingface/HuggingFaceH4/zephyr-7b-alpha - api_base: http://0.0.0.0:8001 - - model_name: gpt-4 - litellm_params: - model: gpt-4 - api_key: sk-1233 - - model_name: claude-2 - litellm_params: - model: claude-2 - api_key: sk-claude -``` - -:::info - -The proxy uses the first model in the config as the default model - in this config the default model is `zephyr-alpha` -::: - - -#### Step 2: Start Proxy with config - -```shell -$ litellm --config /path/to/config.yaml -``` - -#### Step 3: Use proxy -Curl Command -```shell -curl --location 'http://0.0.0.0:4000/chat/completions' \ ---header 'Content-Type: application/json' \ ---data ' { - "model": "zephyr-alpha", - "messages": [ - { - "role": "user", - "content": "what llm are you" - } - ], - } -' -``` - -### Load Balancing - Multiple Instances of 1 model -Use this config to load balance between multiple instances of the same model. The proxy will handle routing requests (using LiteLLM's Router). **Set `rpm` in the config if you want maximize throughput** - -#### Example config -requests with `model=gpt-3.5-turbo` will be routed across multiple instances of `azure/gpt-3.5-turbo` -```yaml -model_list: - - model_name: gpt-3.5-turbo - litellm_params: - model: azure/gpt-turbo-small-eu - api_base: https://my-endpoint-europe-berri-992.openai.azure.com/ - api_key: - rpm: 6 # Rate limit for this deployment: in requests per minute (rpm) - - model_name: gpt-3.5-turbo - litellm_params: - model: azure/gpt-turbo-small-ca - api_base: https://my-endpoint-canada-berri992.openai.azure.com/ - api_key: - rpm: 6 - - model_name: gpt-3.5-turbo - litellm_params: - model: azure/gpt-turbo-large - api_base: https://openai-france-1234.openai.azure.com/ - api_key: - rpm: 1440 -``` - -#### Step 2: Start Proxy with config - -```shell -$ litellm --config /path/to/config.yaml -``` - -#### Step 3: Use proxy -Curl Command -```shell -curl --location 'http://0.0.0.0:4000/chat/completions' \ ---header 'Content-Type: application/json' \ ---data ' { - "model": "gpt-3.5-turbo", - "messages": [ - { - "role": "user", - "content": "what llm are you" - } - ], - } -' -``` - -### Fallbacks + Cooldowns + Retries + Timeouts - -If a call fails after num_retries, fall back to another model group. - -If the error is a context window exceeded error, fall back to a larger model group (if given). - -[**See Code**](https://github.com/BerriAI/litellm/blob/main/litellm/router.py) - -**Set via config** -```yaml -model_list: - - model_name: zephyr-beta - litellm_params: - model: huggingface/HuggingFaceH4/zephyr-7b-beta - api_base: http://0.0.0.0:8001 - - model_name: zephyr-beta - litellm_params: - model: huggingface/HuggingFaceH4/zephyr-7b-beta - api_base: http://0.0.0.0:8002 - - model_name: zephyr-beta - litellm_params: - model: huggingface/HuggingFaceH4/zephyr-7b-beta - api_base: http://0.0.0.0:8003 - - model_name: gpt-3.5-turbo - litellm_params: - model: gpt-3.5-turbo - api_key: - - model_name: gpt-3.5-turbo-16k - litellm_params: - model: gpt-3.5-turbo-16k - api_key: - -litellm_settings: - num_retries: 3 # retry call 3 times on each model_name (e.g. zephyr-beta) - request_timeout: 10 # raise Timeout error if call takes longer than 10s - fallbacks: [{"zephyr-beta": ["gpt-3.5-turbo"]}] # fallback to gpt-3.5-turbo if call fails num_retries - context_window_fallbacks: [{"zephyr-beta": ["gpt-3.5-turbo-16k"]}, {"gpt-3.5-turbo": ["gpt-3.5-turbo-16k"]}] # fallback to gpt-3.5-turbo-16k if context window error - allowed_fails: 3 # cooldown model if it fails > 1 call in a minute. -``` - -**Set dynamically** - -```bash -curl --location 'http://0.0.0.0:4000/chat/completions' \ ---header 'Content-Type: application/json' \ ---data ' { - "model": "zephyr-beta", - "messages": [ - { - "role": "user", - "content": "what llm are you" - } - ], - "fallbacks": [{"zephyr-beta": ["gpt-3.5-turbo"]}], - "context_window_fallbacks": [{"zephyr-beta": ["gpt-3.5-turbo"]}], - "num_retries": 2, - "request_timeout": 10 - } -' -``` - -### Config for Embedding Models - xorbitsai/inference - -Here's how you can use multiple llms with one proxy `config.yaml`. -Here is how [LiteLLM calls OpenAI Compatible Embedding models](https://docs.litellm.ai/docs/embedding/supported_embedding#openai-compatible-embedding-models) - -#### Config -```yaml -model_list: - - model_name: custom_embedding_model - litellm_params: - model: openai/custom_embedding # the `openai/` prefix tells litellm it's openai compatible - api_base: http://0.0.0.0:4000/ - - model_name: custom_embedding_model - litellm_params: - model: openai/custom_embedding # the `openai/` prefix tells litellm it's openai compatible - api_base: http://0.0.0.0:8001/ -``` - -Run the proxy using this config -```shell -$ litellm --config /path/to/config.yaml -``` - - -### Managing Auth - Virtual Keys - -Grant other's temporary access to your proxy, with keys that expire after a set duration. - -Requirements: - -- Need to a postgres database (e.g. [Supabase](https://supabase.com/), [Neon](https://neon.tech/), etc) - -You can then generate temporary keys by hitting the `/key/generate` endpoint. - -[**See code**](https://github.com/BerriAI/litellm/blob/7a669a36d2689c7f7890bc9c93e04ff3c2641299/litellm/proxy/proxy_server.py#L672) - -**Step 1: Save postgres db url** - -```yaml -model_list: - - model_name: gpt-4 - litellm_params: - model: ollama/llama2 - - model_name: gpt-3.5-turbo - litellm_params: - model: ollama/llama2 - -general_settings: - master_key: sk-1234 # [OPTIONAL] if set all calls to proxy will require either this key or a valid generated token - database_url: "postgresql://:@:/" -``` - -**Step 2: Start litellm** - -```shell -litellm --config /path/to/config.yaml -``` - -**Step 3: Generate temporary keys** - -```shell -curl 'http://0.0.0.0:4000/key/generate' \ ---h 'Authorization: Bearer sk-1234' \ ---d '{"models": ["gpt-3.5-turbo", "gpt-4", "claude-2"], "duration": "20m"}' -``` - -- `models`: *list or null (optional)* - Specify the models a token has access too. If null, then token has access to all models on server. - -- `duration`: *str or null (optional)* Specify the length of time the token is valid for. If null, default is set to 1 hour. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d"). - -Expected response: - -```python -{ - "key": "sk-kdEXbIqZRwEeEiHwdg7sFA", # Bearer token - "expires": "2023-11-19T01:38:25.838000+00:00" # datetime object -} -``` - -### Managing Auth - Upgrade/Downgrade Models - -If a user is expected to use a given model (i.e. gpt3-5), and you want to: - -- try to upgrade the request (i.e. GPT4) -- or downgrade it (i.e. Mistral) -- OR rotate the API KEY (i.e. open AI) -- OR access the same model through different end points (i.e. openAI vs openrouter vs Azure) - -Here's how you can do that: - -**Step 1: Create a model group in config.yaml (save model name, api keys, etc.)** - -```yaml -model_list: - - model_name: my-free-tier - litellm_params: - model: huggingface/HuggingFaceH4/zephyr-7b-beta - api_base: http://0.0.0.0:8001 - - model_name: my-free-tier - litellm_params: - model: huggingface/HuggingFaceH4/zephyr-7b-beta - api_base: http://0.0.0.0:8002 - - model_name: my-free-tier - litellm_params: - model: huggingface/HuggingFaceH4/zephyr-7b-beta - api_base: http://0.0.0.0:8003 - - model_name: my-paid-tier - litellm_params: - model: gpt-4 - api_key: my-api-key -``` - -**Step 2: Generate a user key - enabling them access to specific models, custom model aliases, etc.** - -```bash -curl -X POST "https://0.0.0.0:4000/key/generate" \ --H "Authorization: Bearer sk-1234" \ --H "Content-Type: application/json" \ --d '{ - "models": ["my-free-tier"], - "aliases": {"gpt-3.5-turbo": "my-free-tier"}, - "duration": "30min" -}' -``` - -- **How to upgrade / downgrade request?** Change the alias mapping -- **How are routing between diff keys/api bases done?** litellm handles this by shuffling between different models in the model list with the same model_name. [**See Code**](https://github.com/BerriAI/litellm/blob/main/litellm/router.py) - -### Managing Auth - Tracking Spend - -You can get spend for a key by using the `/key/info` endpoint. - -```bash -curl 'http://0.0.0.0:4000/key/info?key=' \ - -X GET \ - -H 'Authorization: Bearer ' -``` - -This is automatically updated (in USD) when calls are made to /completions, /chat/completions, /embeddings using litellm's completion_cost() function. [**See Code**](https://github.com/BerriAI/litellm/blob/1a6ea20a0bb66491968907c2bfaabb7fe45fc064/litellm/utils.py#L1654). - -**Sample response** - -```python -{ - "key": "sk-tXL0wt5-lOOVK9sfY2UacA", - "info": { - "token": "sk-tXL0wt5-lOOVK9sfY2UacA", - "spend": 0.0001065, - "expires": "2023-11-24T23:19:11.131000Z", - "models": [ - "gpt-3.5-turbo", - "gpt-4", - "claude-2" - ], - "aliases": { - "mistral-7b": "gpt-3.5-turbo" - }, - "config": {} - } -} -``` - -### Save Model-specific params (API Base, API Keys, Temperature, Headers etc.) -You can use the config to save model-specific information like api_base, api_key, temperature, max_tokens, etc. - -**Step 1**: Create a `config.yaml` file -```yaml -model_list: - - model_name: gpt-4-team1 - litellm_params: # params for litellm.completion() - https://docs.litellm.ai/docs/completion/input#input---request-body - model: azure/chatgpt-v-2 - api_base: https://openai-gpt-4-test-v-1.openai.azure.com/ - api_version: "2023-05-15" - azure_ad_token: eyJ0eXAiOiJ - - model_name: gpt-4-team2 - litellm_params: - model: azure/gpt-4 - api_key: sk-123 - api_base: https://openai-gpt-4-test-v-2.openai.azure.com/ - - model_name: mistral-7b - litellm_params: - model: ollama/mistral - api_base: your_ollama_api_base -``` - -**Step 2**: Start server with config - -```shell -$ litellm --config /path/to/config.yaml -``` - -### Load API Keys from Vault - -If you have secrets saved in Azure Vault, etc. and don't want to expose them in the config.yaml, here's how to load model-specific keys from the environment. - -```python -os.environ["AZURE_NORTH_AMERICA_API_KEY"] = "your-azure-api-key" -``` - -```yaml -model_list: - - model_name: gpt-4-team1 - litellm_params: # params for litellm.completion() - https://docs.litellm.ai/docs/completion/input#input---request-body - model: azure/chatgpt-v-2 - api_base: https://openai-gpt-4-test-v-1.openai.azure.com/ - api_version: "2023-05-15" - api_key: os.environ/AZURE_NORTH_AMERICA_API_KEY -``` - -[**See Code**](https://github.com/BerriAI/litellm/blob/c12d6c3fe80e1b5e704d9846b246c059defadce7/litellm/utils.py#L2366) - -s/o to [@David Manouchehri](https://www.linkedin.com/in/davidmanouchehri/) for helping with this. - -### Config for setting Model Aliases - -Set a model alias for your deployments. - -In the `config.yaml` the model_name parameter is the user-facing name to use for your deployment. - -In the config below requests with `model=gpt-4` will route to `ollama/llama2` - -```yaml -model_list: - - model_name: text-davinci-003 - litellm_params: - model: ollama/zephyr - - model_name: gpt-4 - litellm_params: - model: ollama/llama2 - - model_name: gpt-3.5-turbo - litellm_params: - model: ollama/llama2 -``` -### Caching Responses -Caching can be enabled by adding the `cache` key in the `config.yaml` -#### Step 1: Add `cache` to the config.yaml -```yaml -model_list: - - model_name: gpt-3.5-turbo - litellm_params: - model: gpt-3.5-turbo - -litellm_settings: - set_verbose: True - cache: # init cache - type: redis # tell litellm to use redis caching -``` - -#### Step 2: Add Redis Credentials to .env -LiteLLM requires the following REDIS credentials in your env to enable caching - - ```shell - REDIS_HOST = "" # REDIS_HOST='redis-18841.c274.us-east-1-3.ec2.cloud.redislabs.com' - REDIS_PORT = "" # REDIS_PORT='18841' - REDIS_PASSWORD = "" # REDIS_PASSWORD='liteLlmIsAmazing' - ``` -#### Step 3: Run proxy with config -```shell -$ litellm --config /path/to/config.yaml -``` - -#### Using Caching -Send the same request twice: -```shell -curl http://0.0.0.0:4000/v1/chat/completions \ - -H "Content-Type: application/json" \ - -d '{ - "model": "gpt-3.5-turbo", - "messages": [{"role": "user", "content": "write a poem about litellm!"}], - "temperature": 0.7 - }' - -curl http://0.0.0.0:4000/v1/chat/completions \ - -H "Content-Type: application/json" \ - -d '{ - "model": "gpt-3.5-turbo", - "messages": [{"role": "user", "content": "write a poem about litellm!"}], - "temperature": 0.7 - }' -``` - -#### Control caching per completion request -Caching can be switched on/off per `/chat/completions` request -- Caching **on** for completion - pass `caching=True`: - ```shell - curl http://0.0.0.0:4000/v1/chat/completions \ - -H "Content-Type: application/json" \ - -d '{ - "model": "gpt-3.5-turbo", - "messages": [{"role": "user", "content": "write a poem about litellm!"}], - "temperature": 0.7, - "caching": true - }' - ``` -- Caching **off** for completion - pass `caching=False`: - ```shell - curl http://0.0.0.0:4000/v1/chat/completions \ - -H "Content-Type: application/json" \ - -d '{ - "model": "gpt-3.5-turbo", - "messages": [{"role": "user", "content": "write a poem about litellm!"}], - "temperature": 0.7, - "caching": false - }' - ``` - -### Set Custom Prompt Templates - -LiteLLM by default checks if a model has a [prompt template and applies it](./completion/prompt_formatting.md) (e.g. if a huggingface model has a saved chat template in it's tokenizer_config.json). However, you can also set a custom prompt template on your proxy in the `config.yaml`: - -**Step 1**: Save your prompt template in a `config.yaml` -```yaml -# Model-specific parameters -model_list: - - model_name: mistral-7b # model alias - litellm_params: # actual params for litellm.completion() - model: "huggingface/mistralai/Mistral-7B-Instruct-v0.1" - api_base: "" - api_key: "" # [OPTIONAL] for hf inference endpoints - initial_prompt_value: "\n" - roles: {"system":{"pre_message":"<|im_start|>system\n", "post_message":"<|im_end|>"}, "assistant":{"pre_message":"<|im_start|>assistant\n","post_message":"<|im_end|>"}, "user":{"pre_message":"<|im_start|>user\n","post_message":"<|im_end|>"}} - final_prompt_value: "\n" - bos_token: "" - eos_token: "" - max_tokens: 4096 -``` - -**Step 2**: Start server with config - -```shell -$ litellm --config /path/to/config.yaml -``` - -## Debugging Proxy -Run the proxy with `--debug` to easily view debug logs -```shell -litellm --model gpt-3.5-turbo --debug -``` - -### Detailed Debug Logs - -Run the proxy with `--detailed_debug` to view detailed debug logs -```shell -litellm --model gpt-3.5-turbo --detailed_debug -``` - -When making requests you should see the POST request sent by LiteLLM to the LLM on the Terminal output -```shell -POST Request Sent from LiteLLM: -curl -X POST \ -https://api.openai.com/v1/chat/completions \ --H 'content-type: application/json' -H 'Authorization: Bearer sk-qnWGUIW9****************************************' \ --d '{"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "this is a test request, write a short poem"}]}' -``` - -## Health Check LLMs on Proxy -Use this to health check all LLMs defined in your config.yaml -#### Request -```shell -curl --location 'http://0.0.0.0:4000/health' -``` - -You can also run `litellm -health` it makes a `get` request to `http://0.0.0.0:4000/health` for you -``` -litellm --health -``` -#### Response -```shell -{ - "healthy_endpoints": [ - { - "model": "azure/gpt-35-turbo", - "api_base": "https://my-endpoint-canada-berri992.openai.azure.com/" - }, - { - "model": "azure/gpt-35-turbo", - "api_base": "https://my-endpoint-europe-berri-992.openai.azure.com/" - } - ], - "unhealthy_endpoints": [ - { - "model": "azure/gpt-35-turbo", - "api_base": "https://openai-france-1234.openai.azure.com/" - } - ] -} -``` - -## Logging Proxy Input/Output - OpenTelemetry - -### Step 1 Start OpenTelemetry Collector Docker Container -This container sends logs to your selected destination - -#### Install OpenTelemetry Collector Docker Image -```shell -docker pull otel/opentelemetry-collector:0.90.0 -docker run -p 127.0.0.1:4317:4317 -p 127.0.0.1:55679:55679 otel/opentelemetry-collector:0.90.0 -``` - -#### Set Destination paths on OpenTelemetry Collector - -Here's the OpenTelemetry yaml config to use with Elastic Search -```yaml -receivers: - otlp: - protocols: - grpc: - endpoint: 0.0.0.0:4317 - -processors: - batch: - timeout: 1s - send_batch_size: 1024 - -exporters: - logging: - loglevel: debug - otlphttp/elastic: - endpoint: "" - headers: - Authorization: "Bearer " - -service: - pipelines: - metrics: - receivers: [otlp] - exporters: [logging, otlphttp/elastic] - traces: - receivers: [otlp] - exporters: [logging, otlphttp/elastic] - logs: - receivers: [otlp] - exporters: [logging,otlphttp/elastic] -``` - -#### Start the OpenTelemetry container with config -Run the following command to start your docker container. We pass `otel_config.yaml` from the previous step - -```shell -docker run -p 4317:4317 \ - -v $(pwd)/otel_config.yaml:/etc/otel-collector-config.yaml \ - otel/opentelemetry-collector:latest \ - --config=/etc/otel-collector-config.yaml -``` - -### Step 2 Configure LiteLLM proxy to log on OpenTelemetry - -#### Pip install opentelemetry -```shell -pip install opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp -U -``` - -#### Set (OpenTelemetry) `otel=True` on the proxy `config.yaml` -**Example config.yaml** - -```yaml -model_list: - - model_name: gpt-3.5-turbo - litellm_params: - model: azure/gpt-turbo-small-eu - api_base: https://my-endpoint-europe-berri-992.openai.azure.com/ - api_key: - rpm: 6 # Rate limit for this deployment: in requests per minute (rpm) - -general_settings: - otel: True # set OpenTelemetry=True, on litellm Proxy - -``` - -#### Set OTEL collector endpoint -LiteLLM will read the `OTEL_ENDPOINT` environment variable to send data to your OTEL collector - -```python -os.environ['OTEL_ENDPOINT'] # defaults to 127.0.0.1:4317 if not provided -``` - -#### Start LiteLLM Proxy -```shell -litellm -config config.yaml -``` - -#### Run a test request to Proxy -```shell -curl --location 'http://0.0.0.0:4000/chat/completions' \ - --header 'Authorization: Bearer sk-1244' \ - --data ' { - "model": "gpt-3.5-turbo", - "messages": [ - { - "role": "user", - "content": "request from LiteLLM testing" - } - ] - }' -``` - - -#### Test & View Logs on OpenTelemetry Collector -On successful logging you should be able to see this log on your `OpenTelemetry Collector` Docker Container -```shell -Events: -SpanEvent #0 - -> Name: LiteLLM: Request Input - -> Timestamp: 2023-12-02 05:05:53.71063 +0000 UTC - -> DroppedAttributesCount: 0 - -> Attributes:: - -> type: Str(http) - -> asgi: Str({'version': '3.0', 'spec_version': '2.3'}) - -> http_version: Str(1.1) - -> server: Str(('127.0.0.1', 8000)) - -> client: Str(('127.0.0.1', 62796)) - -> scheme: Str(http) - -> method: Str(POST) - -> root_path: Str() - -> path: Str(/chat/completions) - -> raw_path: Str(b'/chat/completions') - -> query_string: Str(b'') - -> headers: Str([(b'host', b'0.0.0.0:8000'), (b'user-agent', b'curl/7.88.1'), (b'accept', b'*/*'), (b'authorization', b'Bearer sk-1244'), (b'content-length', b'147'), (b'content-type', b'application/x-www-form-urlencoded')]) - -> state: Str({}) - -> app: Str() - -> fastapi_astack: Str() - -> router: Str() - -> endpoint: Str() - -> path_params: Str({}) - -> route: Str(APIRoute(path='/chat/completions', name='chat_completion', methods=['POST'])) -SpanEvent #1 - -> Name: LiteLLM: Request Headers - -> Timestamp: 2023-12-02 05:05:53.710652 +0000 UTC - -> DroppedAttributesCount: 0 - -> Attributes:: - -> host: Str(0.0.0.0:8000) - -> user-agent: Str(curl/7.88.1) - -> accept: Str(*/*) - -> authorization: Str(Bearer sk-1244) - -> content-length: Str(147) - -> content-type: Str(application/x-www-form-urlencoded) -SpanEvent #2 -``` - -### View Log on Elastic Search -Here's the log view on Elastic Search. You can see the request `input`, `output` and `headers` - - - -## Logging Proxy Input/Output - Langfuse -We will use the `--config` to set `litellm.success_callback = ["langfuse"]` this will log all successful LLM calls to langfuse - -**Step 1** Install langfuse - -```shell -pip install langfuse -``` - -**Step 2**: Create a `config.yaml` file and set `litellm_settings`: `success_callback` -```yaml -model_list: - - model_name: gpt-3.5-turbo - litellm_params: - model: gpt-3.5-turbo -litellm_settings: - success_callback: ["langfuse"] -``` - -**Step 3**: Start the proxy, make a test request - -Start proxy -```shell -litellm --config config.yaml --debug -``` - -Test Request -``` -litellm --test -``` - -Expected output on Langfuse - - - -## Deploying LiteLLM Proxy - -### Deploy on Render https://render.com/ - - - -## LiteLLM Proxy Performance - -### Throughput - 30% Increase -LiteLLM proxy + Load Balancer gives **30% increase** in throughput compared to Raw OpenAI API - - -### Latency Added - 0.00325 seconds -LiteLLM proxy adds **0.00325 seconds** latency as compared to using the Raw OpenAI API - - - - - -## Proxy CLI Arguments - -#### --host - - **Default:** `'0.0.0.0'` - - The host for the server to listen on. - - **Usage:** - ```shell - litellm --host 127.0.0.1 - ``` - -#### --port - - **Default:** `4000` - - The port to bind the server to. - - **Usage:** - ```shell - litellm --port 8080 - ``` - -#### --num_workers - - **Default:** `1` - - The number of uvicorn workers to spin up. - - **Usage:** - ```shell - litellm --num_workers 4 - ``` - -#### --api_base - - **Default:** `None` - - The API base for the model litellm should call. - - **Usage:** - ```shell - litellm --model huggingface/tinyllama --api_base https://k58ory32yinf1ly0.us-east-1.aws.endpoints.huggingface.cloud - ``` - -#### --api_version - - **Default:** `None` - - For Azure services, specify the API version. - - **Usage:** - ```shell - litellm --model azure/gpt-deployment --api_version 2023-08-01 --api_base https://" - ``` - -#### --model or -m - - **Default:** `None` - - The model name to pass to Litellm. - - **Usage:** - ```shell - litellm --model gpt-3.5-turbo - ``` - -#### --test - - **Type:** `bool` (Flag) - - Proxy chat completions URL to make a test request. - - **Usage:** - ```shell - litellm --test - ``` - -#### --health - - **Type:** `bool` (Flag) - - Runs a health check on all models in config.yaml - - **Usage:** - ```shell - litellm --health - ``` - -#### --alias - - **Default:** `None` - - An alias for the model, for user-friendly reference. - - **Usage:** - ```shell - litellm --alias my-gpt-model - ``` - -#### --debug - - **Default:** `False` - - **Type:** `bool` (Flag) - - Enable debugging mode for the input. - - **Usage:** - ```shell - litellm --debug - ``` -#### --detailed_debug - - **Default:** `False` - - **Type:** `bool` (Flag) - - Enable debugging mode for the input. - - **Usage:** - ```shell - litellm --detailed_debug - ``` - -#### --temperature - - **Default:** `None` - - **Type:** `float` - - Set the temperature for the model. - - **Usage:** - ```shell - litellm --temperature 0.7 - ``` - -#### --max_tokens - - **Default:** `None` - - **Type:** `int` - - Set the maximum number of tokens for the model output. - - **Usage:** - ```shell - litellm --max_tokens 50 - ``` - -#### --request_timeout - - **Default:** `6000` - - **Type:** `int` - - Set the timeout in seconds for completion calls. - - **Usage:** - ```shell - litellm --request_timeout 300 - ``` - -#### --drop_params - - **Type:** `bool` (Flag) - - Drop any unmapped params. - - **Usage:** - ```shell - litellm --drop_params - ``` - -#### --add_function_to_prompt - - **Type:** `bool` (Flag) - - If a function passed but unsupported, pass it as a part of the prompt. - - **Usage:** - ```shell - litellm --add_function_to_prompt - ``` - -#### --config - - Configure Litellm by providing a configuration file path. - - **Usage:** - ```shell - litellm --config path/to/config.yaml - ``` - -#### --telemetry - - **Default:** `True` - - **Type:** `bool` - - Help track usage of this feature. - - **Usage:** - ```shell - litellm --telemetry False - ``` diff --git a/docs/my-website/docs/tutorials/claude_responses_api.md b/docs/my-website/docs/tutorials/claude_responses_api.md index a06be87409b..09b352a7663 100644 --- a/docs/my-website/docs/tutorials/claude_responses_api.md +++ b/docs/my-website/docs/tutorials/claude_responses_api.md @@ -4,11 +4,11 @@ import TabItem from '@theme/TabItem'; # Claude Code -This tutorial shows how to call the Responses API models like `codex-mini` and `o3-pro` from the Claude Code endpoint on LiteLLM. +This tutorial shows how to call Claude models through LiteLLM proxy from Claude Code. :::info -This tutorial is based on [Anthropic's official LiteLLM configuration documentation](https://docs.anthropic.com/en/docs/claude-code/llm-gateway#litellm-configuration). This integration allows you to use any LiteLLM supported model through Claude Code. +This tutorial is based on [Anthropic's official LiteLLM configuration documentation](https://docs.anthropic.com/en/docs/claude-code/llm-gateway#litellm-configuration). This integration allows you to use any LiteLLM supported model through Claude Code with centralized authentication, usage tracking, and cost controls. ::: @@ -31,19 +31,18 @@ Create a secure configuration using environment variables: ```yaml model_list: - # Responses API models - - model_name: codex-mini + # Claude models + - model_name: claude-3-5-sonnet-20241022 litellm_params: - model: openai/codex-mini - api_key: os.environ/OPENAI_API_KEY - api_base: https://api.openai.com/v1 + model: anthropic/claude-3-5-sonnet-20241022 + api_key: os.environ/ANTHROPIC_API_KEY - - model_name: o3-pro + - model_name: claude-3-5-haiku-20241022 litellm_params: - model: openai/o3-pro - api_key: os.environ/OPENAI_API_KEY - api_base: https://api.openai.com/v1 + model: anthropic/claude-3-5-haiku-20241022 + api_key: os.environ/ANTHROPIC_API_KEY + litellm_settings: master_key: os.environ/LITELLM_MASTER_KEY ``` @@ -51,7 +50,7 @@ litellm_settings: Set your environment variables: ```bash -export OPENAI_API_KEY="your-openai-api-key" +export ANTHROPIC_API_KEY="your-anthropic-api-key" export LITELLM_MASTER_KEY="sk-1234567890" # Generate a secure key ``` @@ -72,31 +71,43 @@ curl -X POST http://0.0.0.0:4000/v1/messages \ -H "Authorization: Bearer $LITELLM_MASTER_KEY" \ -H "Content-Type: application/json" \ -d '{ - "model": "codex-mini", + "model": "claude-3-5-sonnet-20241022", + "max_tokens": 1000, "messages": [{"role": "user", "content": "What is the capital of France?"}] }' ``` ### 4. Configure Claude Code -Setup Claude Code to use your LiteLLM proxy: +#### Method 1: Unified Endpoint (Recommended) + +Configure Claude Code to use LiteLLM's unified endpoint: ```bash export ANTHROPIC_BASE_URL="http://0.0.0.0:4000" export ANTHROPIC_AUTH_TOKEN="$LITELLM_MASTER_KEY" ``` -### 5. Use Claude Code +#### Method 2: Provider-specific Pass-through Endpoint -Start Claude Code with any configured model: +Alternatively, use the Anthropic pass-through endpoint: ```bash -# Use Responses API models -claude --model codex-mini -claude --model o3-pro +export ANTHROPIC_BASE_URL="http://0.0.0.0:4000/anthropic" +export ANTHROPIC_AUTH_TOKEN="$LITELLM_MASTER_KEY" +``` -# Or use the latest model alias -claude --model codex-mini-latest +### 5. Use Claude Code + +Start Claude Code and it will automatically use your configured models: + +```bash +# Claude Code will use the models configured in your LiteLLM proxy +claude + +# Or specify a model if you have multiple configured +claude --model claude-3-5-sonnet-20241022 +claude --model claude-3-5-haiku-20241022 ``` Example conversation: @@ -112,7 +123,8 @@ Common issues and solutions: **Authentication errors:** - Verify your environment variables are set: `echo $LITELLM_MASTER_KEY` -- Check that your OpenAI API key is valid and has sufficient credits +- Check that your API keys are valid and have sufficient credits +- Ensure the `ANTHROPIC_AUTH_TOKEN` matches your LiteLLM master key **Model not found:** - Ensure the model name in Claude Code matches exactly with your `config.yaml` @@ -123,33 +135,47 @@ Common issues and solutions: Expand your configuration to support multiple providers and models: - + ```yaml model_list: - # Responses API models + # OpenAI models - model_name: codex-mini - litellm_params: + litellm_params: model: openai/codex-mini api_key: os.environ/OPENAI_API_KEY api_base: https://api.openai.com/v1 - + - model_name: o3-pro litellm_params: model: openai/o3-pro api_key: os.environ/OPENAI_API_KEY api_base: https://api.openai.com/v1 - # Standard models - model_name: gpt-4o litellm_params: model: openai/gpt-4o api_key: os.environ/OPENAI_API_KEY + api_base: https://api.openai.com/v1 - - model_name: claude-3-5-sonnet + # Anthropic models + - model_name: claude-3-5-sonnet-20241022 litellm_params: model: anthropic/claude-3-5-sonnet-20241022 api_key: os.environ/ANTHROPIC_API_KEY + + - model_name: claude-3-5-haiku-20241022 + litellm_params: + model: anthropic/claude-3-5-haiku-20241022 + api_key: os.environ/ANTHROPIC_API_KEY + + # AWS Bedrock + - model_name: claude-bedrock + litellm_params: + model: bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0 + aws_access_key_id: os.environ/AWS_ACCESS_KEY_ID + aws_secret_access_key: os.environ/AWS_SECRET_ACCESS_KEY + aws_region_name: us-east-1 litellm_settings: master_key: os.environ/LITELLM_MASTER_KEY @@ -158,13 +184,14 @@ litellm_settings: Switch between models seamlessly: ```bash -# Use Responses API models for advanced reasoning -claude --model o3-pro -claude --model codex-mini +# Use Claude for complex reasoning +claude --model claude-3-5-sonnet-20241022 -# Use standard models for general tasks -claude --model gpt-4o -claude --model claude-3-5-sonnet +# Use Haiku for fast responses +claude --model claude-3-5-haiku-20241022 + +# Use Bedrock deployment +claude --model claude-bedrock ``` diff --git a/docs/my-website/img/create_team_member_rate_limits.png b/docs/my-website/img/create_team_member_rate_limits.png new file mode 100644 index 00000000000..0c5eba04461 Binary files /dev/null and b/docs/my-website/img/create_team_member_rate_limits.png differ diff --git a/docs/my-website/img/release_notes/faster_caching_calls.png b/docs/my-website/img/release_notes/faster_caching_calls.png new file mode 100644 index 00000000000..fb7409aec28 Binary files /dev/null and b/docs/my-website/img/release_notes/faster_caching_calls.png differ diff --git a/docs/my-website/img/release_notes/responses_api_session_mgt_images.jpg b/docs/my-website/img/release_notes/responses_api_session_mgt_images.jpg new file mode 100644 index 00000000000..852d2fdd6d0 Binary files /dev/null and b/docs/my-website/img/release_notes/responses_api_session_mgt_images.jpg differ diff --git a/docs/my-website/img/release_notes/team_member_rate_limits.png b/docs/my-website/img/release_notes/team_member_rate_limits.png new file mode 100644 index 00000000000..ec0affb1271 Binary files /dev/null and b/docs/my-website/img/release_notes/team_member_rate_limits.png differ diff --git a/docs/my-website/package-lock.json b/docs/my-website/package-lock.json index f77acc138ca..4b37e2be11d 100644 --- a/docs/my-website/package-lock.json +++ b/docs/my-website/package-lock.json @@ -12933,9 +12933,9 @@ } }, "node_modules/mermaid": { - "version": "11.9.0", - "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.9.0.tgz", - "integrity": "sha512-YdPXn9slEwO0omQfQIsW6vS84weVQftIyyTGAZCwM//MGhPzL1+l6vO6bkf0wnP4tHigH1alZ5Ooy3HXI2gOag==", + "version": "11.10.0", + "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.10.0.tgz", + "integrity": "sha512-oQsFzPBy9xlpnGxUqLbVY8pvknLlsNIJ0NWwi8SUJjhbP1IT0E0o1lfhU4iYV3ubpy+xkzkaOyDUQMn06vQElQ==", "dependencies": { "@braintree/sanitize-url": "^7.0.4", "@iconify/utils": "^2.1.33", diff --git a/docs/my-website/package.json b/docs/my-website/package.json index 6519a395844..955e63c2d84 100644 --- a/docs/my-website/package.json +++ b/docs/my-website/package.json @@ -49,6 +49,7 @@ }, "overrides": { "webpack-dev-server": ">=5.2.1", - "form-data": ">=4.0.4" + "form-data": ">=4.0.4", + "mermaid": ">=11.10.0" } } diff --git a/docs/my-website/release_notes/v1.74.15-stable/index.md b/docs/my-website/release_notes/v1.74.15-stable/index.md index dd748f18ffa..9807a00b7e7 100644 --- a/docs/my-website/release_notes/v1.74.15-stable/index.md +++ b/docs/my-website/release_notes/v1.74.15-stable/index.md @@ -86,9 +86,9 @@ This is great to central AI Platform teams looking to track how they are helping | Provider | Model | Context Window | Input ($/1M tokens) | Output ($/1M tokens) | Cost per Image | | ----------- | -------------------------------------- | -------------- | ------------------- | -------------------- | -------------- | | OpenRouter | `openrouter/x-ai/grok-4` | 256k | $3 | $15 | N/A | -| Google AI Studio | `gemini/imagen-4.0-generate-preview-06-06` | N/A | N/A | N/A | $0.04 | -| Google AI Studio | `gemini/imagen-4.0-ultra-generate-preview-06-06` | N/A | N/A | N/A | $0.06 | -| Google AI Studio | `gemini/imagen-4.0-fast-generate-preview-06-06` | N/A | N/A | N/A | $0.02 | +| Google AI Studio | `gemini/imagen-4.0-generate-001` | N/A | N/A | N/A | $0.04 | +| Google AI Studio | `gemini/imagen-4.0-ultra-generate-001` | N/A | N/A | N/A | $0.06 | +| Google AI Studio | `gemini/imagen-4.0-fast-generate-001` | N/A | N/A | N/A | $0.02 | | Google AI Studio | `gemini/imagen-3.0-generate-002` | N/A | N/A | N/A | $0.04 | | Google AI Studio | `gemini/imagen-3.0-generate-001` | N/A | N/A | N/A | $0.04 | | Google AI Studio | `gemini/imagen-3.0-fast-generate-001` | N/A | N/A | N/A | $0.02 | diff --git a/docs/my-website/release_notes/v1.75.5-stable/index.md b/docs/my-website/release_notes/v1.75.5-stable/index.md index de3945cef6e..270be64190e 100644 --- a/docs/my-website/release_notes/v1.75.5-stable/index.md +++ b/docs/my-website/release_notes/v1.75.5-stable/index.md @@ -1,5 +1,5 @@ --- -title: "[PRE-RELEASE]v1.75.5-stable" +title: "v1.75.5-stable - Redis latency improvements" slug: "v1-75-5" date: 2025-08-10T10:00:00 authors: @@ -28,14 +28,14 @@ import TabItem from '@theme/TabItem'; docker run \ -e STORE_MODEL_IN_DB=True \ -p 4000:4000 \ -ghcr.io/berriai/litellm:v1.75.5.rc.1 +ghcr.io/berriai/litellm:v1.75.5-stable ``` ``` showLineNumbers title="pip install litellm" -pip install litellm==1.75.5.post1 +pip install litellm==1.75.5.post2 ``` @@ -43,8 +43,49 @@ pip install litellm==1.75.5.post1 --- +## Key Highlights + +- **Redis - Latency Improvements** - Reduces P99 latency by 50% with Redis enabled. +- **Responses API Session Management** - Support for managing responses API sessions with images. +- **Oracle Cloud Infrastructure** - New LLM provider for calling models on Oracle Cloud Infrastructure. +- **Digital Ocean's Gradient AI** - New LLM provider for calling models on Digital Ocean's Gradient AI platform. + + +### Risk of Upgrade + +If you build the proxy from the pip package, you should hold off on upgrading. This version makes `prisma migrate deploy` our default for managing the DB. This is safer, as it doesn't reset the DB, but it requires a manual `prisma generate` step. + +Users of our Docker image, are **not** affected by this change. + --- +## Redis Latency Improvements + + + +
+ +This release adds in-memory caching for Redis requests, enabling faster response times in high-traffic. Now, LiteLLM instances will check their in-memory cache for a cache hit, before checking Redis. This reduces caching-related latency from 100ms for LLM API calls to sub-1ms, on cache hits. + +--- + +## Responses API Session Management w/ Images + + + +
+ +LiteLLM now supports session management for Responses API requests with images. This is great for use-cases like chatbots, that are using the Responses API to track the state of a conversation. LiteLLM session management works across **ALL** LLM API's (including Anthropic, Bedrock, OpenAI, etc). LiteLLM session management works by storing the request and response content in an s3 bucket, you can specify. + +--- + + ## New Models / Updated Models #### New Model Support diff --git a/docs/my-website/release_notes/v1.75.8/index.md b/docs/my-website/release_notes/v1.75.8/index.md new file mode 100644 index 00000000000..d7d4f37c4ee --- /dev/null +++ b/docs/my-website/release_notes/v1.75.8/index.md @@ -0,0 +1,247 @@ +--- +title: "v1.75.8-stable - Team Member Rate Limits" +slug: "v1-75-8" +date: 2025-08-16T10:00:00 +authors: + - name: Krrish Dholakia + title: CEO, LiteLLM + url: https://www.linkedin.com/in/krish-d/ + image_url: https://pbs.twimg.com/profile_images/1298587542745358340/DZv3Oj-h_400x400.jpg + - name: Ishaan Jaffer + title: CTO, LiteLLM + url: https://www.linkedin.com/in/reffajnaahsi/ + image_url: https://pbs.twimg.com/profile_images/1613813310264340481/lz54oEiB_400x400.jpg + +hide_table_of_contents: false +--- + +import Image from '@theme/IdealImage'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +## Deploy this version + + + + +``` showLineNumbers title="docker run litellm" +docker run \ +-e STORE_MODEL_IN_DB=True \ +-p 4000:4000 \ +ghcr.io/berriai/litellm:v1.75.8-stable +``` + + + + +``` showLineNumbers title="pip install litellm" +pip install litellm==1.75.8 +``` + + + + +--- + +## Key Highlights + +- **Team Member Rate Limits** - Individual rate limiting for team members with JWT authentication support. +- **Performance Improvements** - New experimental HTTP handler flag for 100+ RPS improvement on OpenAI calls. +- **GPT-5 Model Family Support** - Full support for OpenAI's GPT-5 models with `reasoning_effort` parameter and Azure OpenAI integration. +- **Azure AI Flux Image Generation** - Support for Azure AI's Flux image generation models. + +--- + +## Team Member Rate Limits + + +

+ LiteLLM MCP Architecture: Use MCP tools with all LiteLLM supported models +

+ + +This release adds support for setting rate limits on individual members (including machine users) within a team. Teams can now give each agent its own rate limits—so that heavy-traffic agents don’t impact other agents or human users. + +Agents can authenticate with LiteLLM using JWT and the same team role as human users, while still enforcing per-agent rate limits. + + +## New Models / Updated Models + +#### New Model Support + +| Provider | Model | Context Window | Input ($/1M tokens) | Output ($/1M tokens) | Features | +| ----------- | -------------------------------------- | -------------- | ------------------- | -------------------- | -------- | +| Azure AI | `azure_ai/FLUX-1.1-pro` | - | - | $40/image | Image generation | +| Azure AI | `azure_ai/FLUX.1-Kontext-pro` | - | - | $40/image | Image generation | +| Vertex AI | `vertex_ai/deepseek-ai/deepseek-r1-0528-maas` | 65k | $1.35 | $5.4 | Chat completions + reasoning | +| OpenRouter | `openrouter/deepseek/deepseek-chat-v3-0324` | 65k | $0.14 | $0.28 | Chat completions | + + +#### Features + +- **[OpenAI](../../docs/providers/openai)** + - Added `reasoning_effort` parameter support for GPT-5 model family - [PR #13475](https://github.com/BerriAI/litellm/pull/13475), [Get Started](../../docs/providers/openai#openai-chat-completion-models) + - Support for `reasoning` parameter in Responses API - [PR #13475](https://github.com/BerriAI/litellm/pull/13475), [Get Started](../../docs/response_api) +- **[Azure OpenAI](../../docs/providers/azure/azure)** + - GPT-5 support with max_tokens and `reasoning` parameter - [PR #13510](https://github.com/BerriAI/litellm/pull/13510), [Get Started](../../docs/providers/azure/azure#gpt-5-models) +- **[AWS Bedrock](../../docs/providers/bedrock)** + - Streaming support for bedrock gpt-oss model family - [PR #13346](https://github.com/BerriAI/litellm/pull/13346), [Get Started](../../docs/providers/bedrock#openai-gpt-oss) + - `/messages` endpoint compatibility with `bedrock/converse/` - [PR #13627](https://github.com/BerriAI/litellm/pull/13627) + - Cache point support for assistant and tool messages - [PR #13640](https://github.com/BerriAI/litellm/pull/13640) +- **[Azure AI](../../docs/providers/azure)** + - New Azure AI Flux Image Generation provider - [PR #13592](https://github.com/BerriAI/litellm/pull/13592), [Get Started](../../docs/providers/azure_ai_img) + - Fixed Content-Type header for image generation - [PR #13584](https://github.com/BerriAI/litellm/pull/13584) +- **[CometAPI](../../docs/providers/comet)** + - New provider support with chat completions and streaming - [PR #13458](https://github.com/BerriAI/litellm/pull/13458) +- **[SambaNova](../../docs/providers/sambanova)** + - Added embedding model support - [PR #13308](https://github.com/BerriAI/litellm/pull/13308), [Get Started](../../docs/providers/sambanova#sambanova---embeddings) +- **[Vertex AI](../../docs/providers/vertex)** + - Added `/countTokens` endpoint support for Gemini CLI integration - [PR #13545](https://github.com/BerriAI/litellm/pull/13545) + - Token counter support for VertexAI models - [PR #13558](https://github.com/BerriAI/litellm/pull/13558) +- **[hosted_vllm](../../docs/providers/vllm)** + - Added `reasoning_effort` parameter support - [PR #13620](https://github.com/BerriAI/litellm/pull/13620), [Get Started](../../docs/providers/vllm#reasoning-effort) + +#### Bugs + +- **[OCI](../../docs/providers/oci)** + - Fixed streaming issues - [PR #13437](https://github.com/BerriAI/litellm/pull/13437) +- **[Ollama](../../docs/providers/ollama)** + - Fixed GPT-OSS streaming with 'thinking' field - [PR #13375](https://github.com/BerriAI/litellm/pull/13375) +- **[VolcEngine](../../docs/providers/volcengine)** + - Fixed thinking disabled parameter handling - [PR #13598](https://github.com/BerriAI/litellm/pull/13598) +- **[Streaming](../../docs/completion/stream)** + - Consistent 'finish_reason' chunk indexing - [PR #13560](https://github.com/BerriAI/litellm/pull/13560) +--- + +## LLM API Endpoints + +#### Features + +- **[/messages](../../docs/anthropic/messages)** + - Tool use arguments properly returned for non-anthropic models - [PR #13638](https://github.com/BerriAI/litellm/pull/13638) + +#### Bugs + +- **[Real-time API](../../docs/realtime)** + - Fixed endpoint for no intent scenarios - [PR #13476](https://github.com/BerriAI/litellm/pull/13476) +- **[Responses API](../../docs/response_api)** + - Fixed `stream=True` + `background=True` with Responses API - [PR #13654](https://github.com/BerriAI/litellm/pull/13654) + +--- + +## [MCP Gateway](../../docs/mcp) + +#### Features + +- **Access Control & Configuration** + - Enhanced MCPServerManager with access groups and description support - [PR #13549](https://github.com/BerriAI/litellm/pull/13549) + +#### Bugs + +- **Authentication** + - Fixed MCP gateway key authentication - [PR #13630](https://github.com/BerriAI/litellm/pull/13630) + +[Read More](../../docs/mcp) + +--- + +## Management Endpoints / UI + +#### Features + +- **Team Management** + - Team Member Rate Limits implementation - [PR #13601](https://github.com/BerriAI/litellm/pull/13601) + - JWT authentication support for team member rate limits - [PR #13601](https://github.com/BerriAI/litellm/pull/13601) + - Show team member TPM/RPM limits in UI - [PR #13662](https://github.com/BerriAI/litellm/pull/13662) + - Allow editing team member RPM/TPM limits - [PR #13669](https://github.com/BerriAI/litellm/pull/13669) + - Allow unsetting TPM and RPM in Teams Settings - [PR #13430](https://github.com/BerriAI/litellm/pull/13430) + - Team Member Permissions Page access column changes - [PR #13145](https://github.com/BerriAI/litellm/pull/13145) +- **Key Management** + - Display errors from backend on the UI Keys page - [PR #13435](https://github.com/BerriAI/litellm/pull/13435) + - Added confirmation modal before deleting keys - [PR #13655](https://github.com/BerriAI/litellm/pull/13655) + - Support for `user` parameter in LiteLLM SDK to Proxy communication - [PR #13555](https://github.com/BerriAI/litellm/pull/13555) +- **UI Improvements** + - Fixed internal users table overflow - [PR #12736](https://github.com/BerriAI/litellm/pull/12736) + - Enhanced chart readability with short-form notation for large numbers - [PR #12370](https://github.com/BerriAI/litellm/pull/12370) + - Fixed image overflow in LiteLLM model display - [PR #13639](https://github.com/BerriAI/litellm/pull/13639) + - Removed ambiguous network response errors - [PR #13582](https://github.com/BerriAI/litellm/pull/13582) +- **Credentials** + - Added CredentialDeleteModal component and integration with CredentialsPanel - [PR #13550](https://github.com/BerriAI/litellm/pull/13550) +- **Admin & Permissions** + - Allow routes for admin viewer - [PR #13588](https://github.com/BerriAI/litellm/pull/13588) + +#### Bugs + +- **SCIM Integration** + - Fixed SCIM Team Memberships metadata handling - [PR #13553](https://github.com/BerriAI/litellm/pull/13553) +- **Authentication** + - Fixed incorrect key info endpoint - [PR #13633](https://github.com/BerriAI/litellm/pull/13633) + +--- + +## Logging / Guardrail Integrations + +#### Features + +- **[Langfuse OTEL](../../docs/proxy/logging#langfuse)** + - Added key/team logging for Langfuse OTEL Logger - [PR #13512](https://github.com/BerriAI/litellm/pull/13512) + - Fixed LangfuseOtelSpanAttributes constants to match expected values - [PR #13659](https://github.com/BerriAI/litellm/pull/13659) +- **[MLflow](../../docs/proxy/logging#mlflow)** + - Updated MLflow logger usage span attributes - [PR #13561](https://github.com/BerriAI/litellm/pull/13561) + +#### Bugs + +- **Security** + - Hide sensitive data in `/model/info` - azure entra client_secret - [PR #13577](https://github.com/BerriAI/litellm/pull/13577) + - Fixed trivy/secrets false positives - [PR #13631](https://github.com/BerriAI/litellm/pull/13631) + +--- + +## Performance / Loadbalancing / Reliability improvements + +#### Features + +- **HTTP Performance** + - New 'EXPERIMENTAL_OPENAI_BASE_LLM_HTTP_HANDLER' flag for +100 RPS improvement on OpenAI calls - [PR #13625](https://github.com/BerriAI/litellm/pull/13625) +- **Database Monitoring** + - Added DB metrics to Prometheus - [PR #13626](https://github.com/BerriAI/litellm/pull/13626) +- **Error Handling** + - Added safe divide by 0 protection to prevent crashes - [PR #13624](https://github.com/BerriAI/litellm/pull/13624) + +#### Bugs + +- **Dependencies** + - Updated boto3 to 1.36.0 and aioboto3 to 13.4.0 - [PR #13665](https://github.com/BerriAI/litellm/pull/13665) + +--- + +## General Proxy Improvements + +#### Features + +- **Database** + - Removed redundant `use_prisma_migrate` flag - now default - [PR #13555](https://github.com/BerriAI/litellm/pull/13555) +- **LLM Translation** + - Added model ID check - [PR #13507](https://github.com/BerriAI/litellm/pull/13507) + - Refactored Anthropic configurations and added support for `anthropic_beta` headers - [PR #13590](https://github.com/BerriAI/litellm/pull/13590) + + +--- + +## New Contributors +* @TensorNull made their first contribution in [PR #13458](https://github.com/BerriAI/litellm/pull/13458) +* @MajorD00m made their first contribution in [PR #13577](https://github.com/BerriAI/litellm/pull/13577) +* @VerunicaM made their first contribution in [PR #13584](https://github.com/BerriAI/litellm/pull/13584) +* @huangyafei made their first contribution in [PR #13607](https://github.com/BerriAI/litellm/pull/13607) +* @TomeHirata made their first contribution in [PR #13561](https://github.com/BerriAI/litellm/pull/13561) +* @willfinnigan made their first contribution in [PR #13659](https://github.com/BerriAI/litellm/pull/13659) +* @dcbark01 made their first contribution in [PR #13633](https://github.com/BerriAI/litellm/pull/13633) +* @javacruft made their first contribution in [PR #13631](https://github.com/BerriAI/litellm/pull/13631) + +--- + +## **[Full Changelog](https://github.com/BerriAI/litellm/compare/v1.75.5-stable.rc-draft...v1.75.8-nightly)** + diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js index 419afcd5466..5e3de92ba83 100644 --- a/docs/my-website/sidebars.js +++ b/docs/my-website/sidebars.js @@ -40,6 +40,7 @@ const sidebars = { "proxy/guardrails/guardrails_ai", "proxy/guardrails/lakera_ai", "proxy/guardrails/model_armor", + "proxy/guardrails/noma_security", "proxy/guardrails/openai_moderation", "proxy/guardrails/pangea", "proxy/guardrails/pillar_security", @@ -108,6 +109,7 @@ const sidebars = { type: "category", label: "Setup & Deployment", items: [ + "proxy/quick_start", "proxy/deploy", "proxy/prod", "proxy/cli", @@ -372,7 +374,14 @@ const sidebars = { "providers/azure/azure_embedding", ] }, - "providers/azure_ai", + { + type: "category", + label: "Azure AI", + items: [ + "providers/azure_ai", + "providers/azure_ai_img", + ] + }, { type: "category", label: "Vertex AI", @@ -484,6 +493,7 @@ const sidebars = { "guides/finetuned_models", "guides/security_settings", "completion/audio", + "completion/image_generation_chat", "completion/web_search", "completion/document_understanding", "completion/vision", diff --git a/enterprise/litellm_enterprise/proxy/management_endpoints/internal_user_endpoints.py b/enterprise/litellm_enterprise/proxy/management_endpoints/internal_user_endpoints.py index d17946171bb..e60b4d69905 100644 --- a/enterprise/litellm_enterprise/proxy/management_endpoints/internal_user_endpoints.py +++ b/enterprise/litellm_enterprise/proxy/management_endpoints/internal_user_endpoints.py @@ -2,6 +2,8 @@ Enterprise internal user management endpoints """ +import os + from fastapi import APIRouter, Depends, HTTPException from litellm.proxy._types import UserAPIKeyAuth @@ -21,7 +23,7 @@ async def available_enterprise_users( """ For keys with `max_users` set, return the list of users that are allowed to use the key. """ - from litellm.proxy._types import CommonProxyErrors + from litellm.proxy._types import CommonProxyErrors, EnterpriseLicenseData from litellm.proxy.proxy_server import ( premium_user, premium_user_data, @@ -34,10 +36,14 @@ async def available_enterprise_users( detail={"error": CommonProxyErrors.db_not_connected_error.value}, ) - if premium_user is None: - raise HTTPException( - status_code=500, detail={"error": CommonProxyErrors.not_premium_user.value} - ) + if not premium_user: + # check if SSO is enabled - show 5 user limit + from litellm.proxy.auth.auth_utils import _has_user_setup_sso + + if _has_user_setup_sso(): + premium_user_data = EnterpriseLicenseData( + max_users=5, + ) # Count number of rows in LiteLLM_UserTable user_count = await prisma_client.db.litellm_usertable.count() diff --git a/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.17-py3-none-any.whl b/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.17-py3-none-any.whl new file mode 100644 index 00000000000..71160d51a7e Binary files /dev/null and b/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.17-py3-none-any.whl differ diff --git a/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.17.tar.gz b/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.17.tar.gz new file mode 100644 index 00000000000..7bab2b9c8b6 Binary files /dev/null and b/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.17.tar.gz differ diff --git a/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.18-py3-none-any.whl b/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.18-py3-none-any.whl new file mode 100644 index 00000000000..fca66b532ff Binary files /dev/null and b/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.18-py3-none-any.whl differ diff --git a/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.18.tar.gz b/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.18.tar.gz new file mode 100644 index 00000000000..ddd00e8439e Binary files /dev/null and b/litellm-proxy-extras/dist/litellm_proxy_extras-0.2.18.tar.gz differ diff --git a/litellm-proxy-extras/litellm_proxy_extras/utils.py b/litellm-proxy-extras/litellm_proxy_extras/utils.py index c194c49765c..ece2b496bf6 100644 --- a/litellm-proxy-extras/litellm_proxy_extras/utils.py +++ b/litellm-proxy-extras/litellm_proxy_extras/utils.py @@ -298,7 +298,7 @@ class ProxyExtrasDBManager: and "database schema is not empty" in e.stderr ): logger.info( - "Database schema is not empty, creating baseline migration" + "Database schema is not empty, creating baseline migration. In read-only file system, please set an environment variable `LITELLM_MIGRATION_DIR` to a writable directory to enable migrations. Learn more - https://docs.litellm.ai/docs/proxy/prod#read-only-file-system" ) ProxyExtrasDBManager._create_baseline_migration(schema_path) logger.info( diff --git a/litellm-proxy-extras/pyproject.toml b/litellm-proxy-extras/pyproject.toml index 86307e08238..0cb9c35fa62 100644 --- a/litellm-proxy-extras/pyproject.toml +++ b/litellm-proxy-extras/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm-proxy-extras" -version = "0.2.16" +version = "0.2.18" description = "Additional files for the LiteLLM Proxy. Reduces the size of the main litellm package." authors = ["BerriAI"] readme = "README.md" @@ -22,7 +22,7 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.commitizen] -version = "0.2.16" +version = "0.2.18" version_files = [ "pyproject.toml:version", "../requirements.txt:litellm-proxy-extras==", diff --git a/litellm/__init__.py b/litellm/__init__.py index 06d71ff4328..c405d3cdeb2 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -146,6 +146,7 @@ _custom_logger_compatible_callbacks_literal = Literal[ "vector_store_pre_call_hook", "dotprompt", ] +configured_cold_storage_logger: Optional[_custom_logger_compatible_callbacks_literal] = None logged_real_time_event_types: Optional[Union[List[str], Literal["*"]]] = None _known_custom_logger_compatible_callbacks: List = list( get_args(_custom_logger_compatible_callbacks_literal) @@ -303,7 +304,6 @@ default_in_memory_ttl: Optional[float] = None default_redis_ttl: Optional[float] = None default_redis_batch_cache_expiry: Optional[float] = None model_alias_map: Dict[str, str] = {} -model_group_alias_map: Dict[str, str] = {} model_group_settings: Optional["ModelGroupSettings"] = None max_budget: float = 0.0 # set the max budget across all providers budget_duration: Optional[str] = ( @@ -467,78 +467,81 @@ BEDROCK_CONVERSE_MODELS = [ ] ####### COMPLETION MODELS ################### -open_ai_chat_completion_models: List = [] -open_ai_text_completion_models: List = [] -cohere_models: List = [] -cohere_chat_models: List = [] -mistral_chat_models: List = [] -text_completion_codestral_models: List = [] -anthropic_models: List = [] -openrouter_models: List = [] -datarobot_models: List = [] -vertex_language_models: List = [] -vertex_vision_models: List = [] -vertex_chat_models: List = [] -vertex_code_chat_models: List = [] -vertex_ai_image_models: List = [] -vertex_text_models: List = [] -vertex_code_text_models: List = [] -vertex_embedding_models: List = [] -vertex_anthropic_models: List = [] -vertex_llama3_models: List = [] -vertex_ai_ai21_models: List = [] -vertex_mistral_models: List = [] -ai21_models: List = [] -ai21_chat_models: List = [] -nlp_cloud_models: List = [] -aleph_alpha_models: List = [] -bedrock_models: List = [] -bedrock_converse_models: List = BEDROCK_CONVERSE_MODELS -fireworks_ai_models: List = [] -fireworks_ai_embedding_models: List = [] -deepinfra_models: List = [] -perplexity_models: List = [] -watsonx_models: List = [] -gemini_models: List = [] -xai_models: List = [] -deepseek_models: List = [] -azure_ai_models: List = [] -jina_ai_models: List = [] -voyage_models: List = [] -infinity_models: List = [] -databricks_models: List = [] -cloudflare_models: List = [] -codestral_models: List = [] -friendliai_models: List = [] -featherless_ai_models: List = [] -palm_models: List = [] -groq_models: List = [] -azure_models: List = [] -azure_text_models: List = [] -anyscale_models: List = [] -cerebras_models: List = [] -galadriel_models: List = [] -sambanova_models: List = [] -sambanova_embedding_models: List = [] -novita_models: List = [] -assemblyai_models: List = [] -snowflake_models: List = [] -gradient_ai_models: List = [] -llama_models: List = [] -nscale_models: List = [] -nebius_models: List = [] -nebius_embedding_models: List = [] -deepgram_models: List = [] -elevenlabs_models: List = [] -dashscope_models: List = [] -moonshot_models: List = [] -v0_models: List = [] -morph_models: List = [] -lambda_ai_models: List = [] -hyperbolic_models: List = [] -recraft_models: List = [] -cometapi_models: List = [] -oci_models: List = [] +from typing import Set +open_ai_chat_completion_models: Set = set() +open_ai_text_completion_models: Set = set() +cohere_models: Set = set() +cohere_chat_models: Set = set() +mistral_chat_models: Set = set() +text_completion_codestral_models: Set = set() +anthropic_models: Set = set() +openrouter_models: Set = set() +datarobot_models: Set = set() +vertex_language_models: Set = set() +vertex_vision_models: Set = set() +vertex_chat_models: Set = set() +vertex_code_chat_models: Set = set() +vertex_ai_image_models: Set = set() +vertex_text_models: Set = set() +vertex_code_text_models: Set = set() +vertex_embedding_models: Set = set() +vertex_anthropic_models: Set = set() +vertex_llama3_models: Set = set() +vertex_deepseek_models: Set = set() +vertex_ai_ai21_models: Set = set() +vertex_mistral_models: Set = set() +ai21_models: Set = set() +ai21_chat_models: Set = set() +nlp_cloud_models: Set = set() +aleph_alpha_models: Set = set() +bedrock_models: Set = set() +bedrock_converse_models: Set = set(BEDROCK_CONVERSE_MODELS) +fireworks_ai_models: Set = set() +fireworks_ai_embedding_models: Set = set() +deepinfra_models: Set = set() +perplexity_models: Set = set() +watsonx_models: Set = set() +gemini_models: Set = set() +xai_models: Set = set() +deepseek_models: Set = set() +azure_ai_models: Set = set() +jina_ai_models: Set = set() +voyage_models: Set = set() +infinity_models: Set = set() +databricks_models: Set = set() +cloudflare_models: Set = set() +codestral_models: Set = set() +friendliai_models: Set = set() +featherless_ai_models: Set = set() +palm_models: Set = set() +groq_models: Set = set() +azure_models: Set = set() +azure_text_models: Set = set() +anyscale_models: Set = set() +cerebras_models: Set = set() +galadriel_models: Set = set() +sambanova_models: Set = set() +sambanova_embedding_models: Set = set() +novita_models: Set = set() +assemblyai_models: Set = set() +snowflake_models: Set = set() +gradient_ai_models: Set = set() +llama_models: Set = set() +nscale_models: Set = set() +nebius_models: Set = set() +nebius_embedding_models: Set = set() +aiml_models: Set = set() +deepgram_models: Set = set() +elevenlabs_models: Set = set() +dashscope_models: Set = set() +moonshot_models: Set = set() +v0_models: Set = set() +morph_models: Set = set() +lambda_ai_models: Set = set() +hyperbolic_models: Set = set() +recraft_models: Set = set() +cometapi_models: Set = set() +oci_models: Set = set() def is_bedrock_pricing_only_model(key: str) -> bool: @@ -579,163 +582,168 @@ def add_known_models(): if value.get("litellm_provider") == "openai" and not is_openai_finetune_model( key ): - open_ai_chat_completion_models.append(key) + open_ai_chat_completion_models.add(key) elif value.get("litellm_provider") == "text-completion-openai": - open_ai_text_completion_models.append(key) + open_ai_text_completion_models.add(key) elif value.get("litellm_provider") == "azure_text": - azure_text_models.append(key) + azure_text_models.add(key) elif value.get("litellm_provider") == "cohere": - cohere_models.append(key) + cohere_models.add(key) elif value.get("litellm_provider") == "cohere_chat": - cohere_chat_models.append(key) + cohere_chat_models.add(key) elif value.get("litellm_provider") == "mistral": - mistral_chat_models.append(key) + mistral_chat_models.add(key) elif value.get("litellm_provider") == "anthropic": - anthropic_models.append(key) + anthropic_models.add(key) elif value.get("litellm_provider") == "empower": - empower_models.append(key) + empower_models.add(key) elif value.get("litellm_provider") == "openrouter": - openrouter_models.append(key) + openrouter_models.add(key) elif value.get("litellm_provider") == "datarobot": - datarobot_models.append(key) + datarobot_models.add(key) elif value.get("litellm_provider") == "vertex_ai-text-models": - vertex_text_models.append(key) + vertex_text_models.add(key) elif value.get("litellm_provider") == "vertex_ai-code-text-models": - vertex_code_text_models.append(key) + vertex_code_text_models.add(key) elif value.get("litellm_provider") == "vertex_ai-language-models": - vertex_language_models.append(key) + vertex_language_models.add(key) elif value.get("litellm_provider") == "vertex_ai-vision-models": - vertex_vision_models.append(key) + vertex_vision_models.add(key) elif value.get("litellm_provider") == "vertex_ai-chat-models": - vertex_chat_models.append(key) + vertex_chat_models.add(key) elif value.get("litellm_provider") == "vertex_ai-code-chat-models": - vertex_code_chat_models.append(key) + vertex_code_chat_models.add(key) elif value.get("litellm_provider") == "vertex_ai-embedding-models": - vertex_embedding_models.append(key) + vertex_embedding_models.add(key) elif value.get("litellm_provider") == "vertex_ai-anthropic_models": key = key.replace("vertex_ai/", "") - vertex_anthropic_models.append(key) + vertex_anthropic_models.add(key) elif value.get("litellm_provider") == "vertex_ai-llama_models": key = key.replace("vertex_ai/", "") - vertex_llama3_models.append(key) + vertex_llama3_models.add(key) + elif value.get("litellm_provider") == "vertex_ai-deepseek_models": + key = key.replace("vertex_ai/", "") + vertex_deepseek_models.add(key) elif value.get("litellm_provider") == "vertex_ai-mistral_models": key = key.replace("vertex_ai/", "") - vertex_mistral_models.append(key) + vertex_mistral_models.add(key) elif value.get("litellm_provider") == "vertex_ai-ai21_models": key = key.replace("vertex_ai/", "") - vertex_ai_ai21_models.append(key) + vertex_ai_ai21_models.add(key) elif value.get("litellm_provider") == "vertex_ai-image-models": key = key.replace("vertex_ai/", "") - vertex_ai_image_models.append(key) + vertex_ai_image_models.add(key) elif value.get("litellm_provider") == "ai21": if value.get("mode") == "chat": - ai21_chat_models.append(key) + ai21_chat_models.add(key) else: - ai21_models.append(key) + ai21_models.add(key) elif value.get("litellm_provider") == "nlp_cloud": - nlp_cloud_models.append(key) + nlp_cloud_models.add(key) elif value.get("litellm_provider") == "aleph_alpha": - aleph_alpha_models.append(key) + aleph_alpha_models.add(key) elif value.get( "litellm_provider" ) == "bedrock" and not is_bedrock_pricing_only_model(key): - bedrock_models.append(key) + bedrock_models.add(key) elif value.get("litellm_provider") == "bedrock_converse": - bedrock_converse_models.append(key) + bedrock_converse_models.add(key) elif value.get("litellm_provider") == "deepinfra": - deepinfra_models.append(key) + deepinfra_models.add(key) elif value.get("litellm_provider") == "perplexity": - perplexity_models.append(key) + perplexity_models.add(key) elif value.get("litellm_provider") == "watsonx": - watsonx_models.append(key) + watsonx_models.add(key) elif value.get("litellm_provider") == "gemini": - gemini_models.append(key) + gemini_models.add(key) elif value.get("litellm_provider") == "fireworks_ai": # ignore the 'up-to', '-to-' model names -> not real models. just for cost tracking based on model params. if "-to-" not in key and "fireworks-ai-default" not in key: - fireworks_ai_models.append(key) + fireworks_ai_models.add(key) elif value.get("litellm_provider") == "fireworks_ai-embedding-models": # ignore the 'up-to', '-to-' model names -> not real models. just for cost tracking based on model params. if "-to-" not in key: - fireworks_ai_embedding_models.append(key) + fireworks_ai_embedding_models.add(key) elif value.get("litellm_provider") == "text-completion-codestral": - text_completion_codestral_models.append(key) + text_completion_codestral_models.add(key) elif value.get("litellm_provider") == "xai": - xai_models.append(key) + xai_models.add(key) elif value.get("litellm_provider") == "deepseek": - deepseek_models.append(key) + deepseek_models.add(key) elif value.get("litellm_provider") == "meta_llama": - llama_models.append(key) + llama_models.add(key) elif value.get("litellm_provider") == "nscale": - nscale_models.append(key) + nscale_models.add(key) elif value.get("litellm_provider") == "azure_ai": - azure_ai_models.append(key) + azure_ai_models.add(key) elif value.get("litellm_provider") == "voyage": - voyage_models.append(key) + voyage_models.add(key) elif value.get("litellm_provider") == "infinity": - infinity_models.append(key) + infinity_models.add(key) elif value.get("litellm_provider") == "databricks": - databricks_models.append(key) + databricks_models.add(key) elif value.get("litellm_provider") == "cloudflare": - cloudflare_models.append(key) + cloudflare_models.add(key) elif value.get("litellm_provider") == "codestral": - codestral_models.append(key) + codestral_models.add(key) elif value.get("litellm_provider") == "friendliai": - friendliai_models.append(key) + friendliai_models.add(key) elif value.get("litellm_provider") == "palm": - palm_models.append(key) + palm_models.add(key) elif value.get("litellm_provider") == "groq": - groq_models.append(key) + groq_models.add(key) elif value.get("litellm_provider") == "azure": - azure_models.append(key) + azure_models.add(key) elif value.get("litellm_provider") == "anyscale": - anyscale_models.append(key) + anyscale_models.add(key) elif value.get("litellm_provider") == "cerebras": - cerebras_models.append(key) + cerebras_models.add(key) elif value.get("litellm_provider") == "galadriel": - galadriel_models.append(key) + galadriel_models.add(key) elif value.get("litellm_provider") == "sambanova": - sambanova_models.append(key) + sambanova_models.add(key) elif value.get("litellm_provider") == "sambanova-embedding-models": - sambanova_embedding_models.append(key) + sambanova_embedding_models.add(key) elif value.get("litellm_provider") == "novita": - novita_models.append(key) + novita_models.add(key) elif value.get("litellm_provider") == "nebius-chat-models": - nebius_models.append(key) + nebius_models.add(key) elif value.get("litellm_provider") == "nebius-embedding-models": - nebius_embedding_models.append(key) + nebius_embedding_models.add(key) + elif value.get("litellm_provider") == "aiml": + aiml_models.add(key) elif value.get("litellm_provider") == "assemblyai": - assemblyai_models.append(key) + assemblyai_models.add(key) elif value.get("litellm_provider") == "jina_ai": - jina_ai_models.append(key) + jina_ai_models.add(key) elif value.get("litellm_provider") == "snowflake": - snowflake_models.append(key) + snowflake_models.add(key) elif value.get("litellm_provider") == "gradient_ai": - gradient_ai_models.append(key) + gradient_ai_models.add(key) elif value.get("litellm_provider") == "featherless_ai": - featherless_ai_models.append(key) + featherless_ai_models.add(key) elif value.get("litellm_provider") == "deepgram": - deepgram_models.append(key) + deepgram_models.add(key) elif value.get("litellm_provider") == "elevenlabs": - elevenlabs_models.append(key) + elevenlabs_models.add(key) elif value.get("litellm_provider") == "dashscope": - dashscope_models.append(key) + dashscope_models.add(key) elif value.get("litellm_provider") == "moonshot": - moonshot_models.append(key) + moonshot_models.add(key) elif value.get("litellm_provider") == "v0": - v0_models.append(key) + v0_models.add(key) elif value.get("litellm_provider") == "morph": - morph_models.append(key) + morph_models.add(key) elif value.get("litellm_provider") == "lambda_ai": - lambda_ai_models.append(key) + lambda_ai_models.add(key) elif value.get("litellm_provider") == "hyperbolic": - hyperbolic_models.append(key) + hyperbolic_models.add(key) elif value.get("litellm_provider") == "recraft": - recraft_models.append(key) + recraft_models.add(key) elif value.get("litellm_provider") == "cometapi": - cometapi_models.append(key) + cometapi_models.add(key) elif value.get("litellm_provider") == "oci": - oci_models.append(key) + oci_models.add(key) add_known_models() @@ -765,68 +773,68 @@ ollama_models = ["llama2"] maritalk_models = ["maritalk"] -model_list = ( +model_list = list( open_ai_chat_completion_models - + open_ai_text_completion_models - + cohere_models - + cohere_chat_models - + anthropic_models - + replicate_models - + openrouter_models - + datarobot_models - + huggingface_models - + vertex_chat_models - + vertex_text_models - + ai21_models - + ai21_chat_models - + together_ai_models - + baseten_models - + aleph_alpha_models - + nlp_cloud_models - + ollama_models - + bedrock_models - + deepinfra_models - + perplexity_models - + maritalk_models - + vertex_language_models - + watsonx_models - + gemini_models - + text_completion_codestral_models - + xai_models - + deepseek_models - + azure_ai_models - + voyage_models - + infinity_models - + databricks_models - + cloudflare_models - + codestral_models - + friendliai_models - + palm_models - + groq_models - + azure_models - + anyscale_models - + cerebras_models - + galadriel_models - + sambanova_models - + azure_text_models - + novita_models - + assemblyai_models - + jina_ai_models - + snowflake_models - + gradient_ai_models - + llama_models - + featherless_ai_models - + nscale_models - + deepgram_models - + elevenlabs_models - + dashscope_models - + moonshot_models - + v0_models - + morph_models - + lambda_ai_models - + recraft_models - + cometapi_models - + oci_models + | open_ai_text_completion_models + | cohere_models + | cohere_chat_models + | anthropic_models + | set(replicate_models) + | openrouter_models + | datarobot_models + | set(huggingface_models) + | vertex_chat_models + | vertex_text_models + | ai21_models + | ai21_chat_models + | set(together_ai_models) + | set(baseten_models) + | aleph_alpha_models + | nlp_cloud_models + | set(ollama_models) + | bedrock_models + | deepinfra_models + | perplexity_models + | set(maritalk_models) + | vertex_language_models + | watsonx_models + | gemini_models + | text_completion_codestral_models + | xai_models + | deepseek_models + | azure_ai_models + | voyage_models + | infinity_models + | databricks_models + | cloudflare_models + | codestral_models + | friendliai_models + | palm_models + | groq_models + | azure_models + | anyscale_models + | cerebras_models + | galadriel_models + | sambanova_models + | azure_text_models + | novita_models + | assemblyai_models + | jina_ai_models + | snowflake_models + | gradient_ai_models + | llama_models + | featherless_ai_models + | nscale_models + | deepgram_models + | elevenlabs_models + | dashscope_models + | moonshot_models + | v0_models + | morph_models + | lambda_ai_models + | recraft_models + | cometapi_models + | oci_models ) model_list_set = set(model_list) @@ -835,9 +843,9 @@ provider_list: List[Union[LlmProviders, str]] = list(LlmProviders) models_by_provider: dict = { - "openai": open_ai_chat_completion_models + open_ai_text_completion_models, + "openai": open_ai_chat_completion_models | open_ai_text_completion_models, "text-completion-openai": open_ai_text_completion_models, - "cohere": cohere_models + cohere_chat_models, + "cohere": cohere_models | cohere_chat_models, "cohere_chat": cohere_chat_models, "anthropic": anthropic_models, "replicate": replicate_models, @@ -846,13 +854,9 @@ models_by_provider: dict = { "baseten": baseten_models, "openrouter": openrouter_models, "datarobot": datarobot_models, - "vertex_ai": vertex_chat_models - + vertex_text_models - + vertex_anthropic_models - + vertex_vision_models - + vertex_language_models, + "vertex_ai": vertex_chat_models | vertex_text_models | vertex_anthropic_models | vertex_vision_models | vertex_language_models | vertex_deepseek_models, "ai21": ai21_models, - "bedrock": bedrock_models + bedrock_converse_models, + "bedrock": bedrock_models | bedrock_converse_models, "petals": petals_models, "ollama": ollama_models, "ollama_chat": ollama_models, @@ -861,7 +865,7 @@ models_by_provider: dict = { "maritalk": maritalk_models, "watsonx": watsonx_models, "gemini": gemini_models, - "fireworks_ai": fireworks_ai_models + fireworks_ai_embedding_models, + "fireworks_ai": fireworks_ai_models | fireworks_ai_embedding_models, "aleph_alpha": aleph_alpha_models, "text-completion-codestral": text_completion_codestral_models, "xai": xai_models, @@ -877,14 +881,15 @@ models_by_provider: dict = { "friendliai": friendliai_models, "palm": palm_models, "groq": groq_models, - "azure": azure_models + azure_text_models, + "azure": azure_models | azure_text_models, "azure_text": azure_text_models, "anyscale": anyscale_models, "cerebras": cerebras_models, "galadriel": galadriel_models, - "sambanova": sambanova_models + sambanova_embedding_models, + "sambanova": sambanova_models | sambanova_embedding_models, "novita": novita_models, - "nebius": nebius_models + nebius_embedding_models, + "nebius": nebius_models | nebius_embedding_models, + "aiml": aiml_models, "assemblyai": assemblyai_models, "jina_ai": jina_ai_models, "snowflake": snowflake_models, @@ -931,12 +936,12 @@ longer_context_model_fallback_dict: dict = { all_embedding_models = ( open_ai_embedding_models - + cohere_embedding_models - + bedrock_embedding_models - + vertex_embedding_models - + fireworks_ai_embedding_models - + nebius_embedding_models - + sambanova_embedding_models + | set(cohere_embedding_models) + | set(bedrock_embedding_models) + | vertex_embedding_models + | fireworks_ai_embedding_models + | nebius_embedding_models + | sambanova_embedding_models ) ####### IMAGE GENERATION MODELS ################### @@ -1034,6 +1039,7 @@ from .llms.cohere.rerank_v2.transformation import CohereRerankV2Config from .llms.azure_ai.rerank.transformation import AzureAIRerankConfig from .llms.infinity.rerank.transformation import InfinityRerankConfig from .llms.jina_ai.rerank.transformation import JinaAIRerankConfig +from .llms.deepinfra.rerank.transformation import DeepinfraRerankConfig from .llms.clarifai.chat.transformation import ClarifaiConfig from .llms.ai21.chat.transformation import AI21ChatConfig, AI21ChatConfig as AI21Config from .llms.meta_llama.chat.transformation import LlamaAPIConfig @@ -1041,7 +1047,7 @@ from .llms.anthropic.experimental_pass_through.messages.transformation import ( AnthropicMessagesConfig, ) from .llms.bedrock.messages.invoke_transformations.anthropic_claude3_transformation import ( - AmazonAnthropicClaude3MessagesConfig, + AmazonAnthropicClaudeMessagesConfig, ) from .llms.together_ai.chat import TogetherAIConfig from .llms.together_ai.completion.transformation import TogetherAITextCompletionConfig @@ -1101,7 +1107,7 @@ from .llms.bedrock.chat.invoke_transformations.anthropic_claude2_transformation AmazonAnthropicConfig, ) from .llms.bedrock.chat.invoke_transformations.anthropic_claude3_transformation import ( - AmazonAnthropicClaude3Config, + AmazonAnthropicClaudeConfig, ) from .llms.bedrock.chat.invoke_transformations.amazon_cohere_transformation import ( AmazonCohereConfig, @@ -1145,12 +1151,15 @@ from .llms.topaz.image_variations.transformation import TopazImageVariationConfi from litellm.llms.openai.completion.transformation import OpenAITextCompletionConfig from .llms.groq.chat.transformation import GroqChatConfig from .llms.voyage.embedding.transformation import VoyageEmbeddingConfig +from .llms.voyage.embedding.transformation_contextual import VoyageContextualEmbeddingConfig from .llms.infinity.embedding.transformation import InfinityEmbeddingConfig from .llms.azure_ai.chat.transformation import AzureAIStudioConfig from .llms.mistral.chat.transformation import MistralConfig from .llms.openai.responses.transformation import OpenAIResponsesAPIConfig from .llms.azure.responses.transformation import AzureOpenAIResponsesAPIConfig -from .llms.azure.responses.o_series_transformation import AzureOpenAIOSeriesResponsesAPIConfig +from .llms.azure.responses.o_series_transformation import ( + AzureOpenAIOSeriesResponsesAPIConfig, +) from .llms.openai.chat.o_series_transformation import ( OpenAIOSeriesConfig as OpenAIO1Config, # maintain backwards compatibility OpenAIOSeriesConfig, @@ -1158,6 +1167,7 @@ from .llms.openai.chat.o_series_transformation import ( from .llms.snowflake.chat.transformation import SnowflakeConfig from .llms.gradient_ai.chat.transformation import GradientAIConfig + openaiOSeriesConfig = OpenAIOSeriesConfig() from .llms.openai.chat.gpt_transformation import ( OpenAIGPTConfig, @@ -1188,6 +1198,7 @@ nvidiaNimEmbeddingConfig = NvidiaNimEmbeddingConfig() from .llms.featherless_ai.chat.transformation import FeatherlessAIConfig from .llms.cerebras.chat import CerebrasConfig +from .llms.baseten.chat import BasetenConfig from .llms.sambanova.chat import SambanovaConfig from .llms.sambanova.embedding.transformation import SambaNovaEmbeddingConfig from .llms.ai21.chat.transformation import AI21ChatConfig @@ -1203,6 +1214,7 @@ from .llms.friendliai.chat.transformation import FriendliaiChatConfig from .llms.jina_ai.embedding.transformation import JinaAIEmbeddingConfig from .llms.xai.chat.transformation import XAIChatConfig from .llms.xai.common_utils import XAIModelInfo +from .llms.aiml.chat.transformation import AIMLChatConfig from .llms.volcengine import VolcEngineConfig from .llms.codestral.completion.transformation import CodestralTextCompletionConfig from .llms.azure.azure import ( diff --git a/litellm/_logging.py b/litellm/_logging.py index 8c23994f92a..73902d2fc5a 100644 --- a/litellm/_logging.py +++ b/litellm/_logging.py @@ -108,6 +108,7 @@ verbose_router_logger.addHandler(handler) verbose_proxy_logger.addHandler(handler) verbose_logger.addHandler(handler) + def _suppress_loggers(): """Suppress noisy loggers at INFO level""" # Suppress httpx request logging at INFO level @@ -120,6 +121,7 @@ def _suppress_loggers(): apscheduler_scheduler_logger = logging.getLogger("apscheduler.scheduler") apscheduler_scheduler_logger.setLevel(logging.WARNING) + # Call the suppression function _suppress_loggers() @@ -187,6 +189,4 @@ def _is_debugging_on() -> bool: """ Returns True if debugging is on """ - if verbose_logger.isEnabledFor(logging.DEBUG) or set_verbose is True: - return True - return False + return verbose_logger.isEnabledFor(logging.DEBUG) or set_verbose is True diff --git a/litellm/caching/caching.py b/litellm/caching/caching.py index 0a8b6ef18d1..82fc37e0cb4 100644 --- a/litellm/caching/caching.py +++ b/litellm/caching/caching.py @@ -774,11 +774,9 @@ class Cache: """ Internal method to check if the cache type supports async get/set operations - Only S3 Cache Does NOT support async operations + All cache types now support async operations """ - if self.type and self.type == LiteLLMCacheType.S3: - return False return True diff --git a/litellm/caching/caching_handler.py b/litellm/caching/caching_handler.py index 7580752c307..1dcc0f1fdb2 100644 --- a/litellm/caching/caching_handler.py +++ b/litellm/caching/caching_handler.py @@ -599,7 +599,7 @@ class LLMCachingHandler: cached_result = await litellm.cache.async_get_cache( dynamic_cache_object=self.dual_cache, **new_kwargs ) - else: # for s3 caching. [NOT RECOMMENDED IN PROD - this will slow down responses since boto3 is sync] + else: # fallback for caches that don't support async cached_result = litellm.cache.get_cache( dynamic_cache_object=self.dual_cache, **new_kwargs ) @@ -806,12 +806,6 @@ class LLMCachingHandler: result, dynamic_cache_object=self.dual_cache, **new_kwargs ) ) - elif isinstance(litellm.cache.cache, S3Cache): - threading.Thread( - target=litellm.cache.add_cache, - args=(result,), - kwargs=new_kwargs, - ).start() else: asyncio.create_task( litellm.cache.async_add_cache( diff --git a/litellm/caching/in_memory_cache.py b/litellm/caching/in_memory_cache.py index 47f911894a3..63869474d47 100644 --- a/litellm/caching/in_memory_cache.py +++ b/litellm/caching/in_memory_cache.py @@ -112,14 +112,15 @@ class InMemoryCache(BaseCache): - 3. the size of in-memory cache is bounded """ - for key in list(self.ttl_dict.keys()): - if self._is_key_expired(key): - self._remove_key(key) + current_time = time.time() + expired_keys = [key for key, ttl in self.ttl_dict.items() if current_time > ttl] + for key in expired_keys: + self._remove_key(key) - # de-reference the removed item - # https://www.geeksforgeeks.org/diagnosing-and-fixing-memory-leaks-in-python/ - # One of the most common causes of memory leaks in Python is the retention of objects that are no longer being used. - # This can occur when an object is referenced by another object, but the reference is never removed. + # de-reference the removed item + # https://www.geeksforgeeks.org/diagnosing-and-fixing-memory-leaks-in-python/ + # One of the most common causes of memory leaks in Python is the retention of objects that are no longer being used. + # This can occur when an object is referenced by another object, but the reference is never removed. def allow_ttl_override(self, key: str) -> bool: """ diff --git a/litellm/caching/s3_cache.py b/litellm/caching/s3_cache.py index c02e1091369..180964605f6 100644 --- a/litellm/caching/s3_cache.py +++ b/litellm/caching/s3_cache.py @@ -1,18 +1,19 @@ """ S3 Cache implementation -WARNING: DO NOT USE THIS IN PRODUCTION - This is not ASYNC Has 4 methods: - set_cache - get_cache - - async_set_cache - - async_get_cache + - async_set_cache (uses run_in_executor) + - async_get_cache (uses run_in_executor) """ import ast import asyncio import json +from functools import partial from typing import Optional +from datetime import datetime, timezone, timedelta from litellm._logging import print_verbose, verbose_logger @@ -55,21 +56,23 @@ class S3Cache(BaseCache): **kwargs, ) + def _to_s3_key(self, key: str) -> str: + """Convert cache key to S3 key""" + return self.key_prefix + key.replace(":", "/") + def set_cache(self, key, value, **kwargs): try: print_verbose(f"LiteLLM SET Cache - S3. Key={key}. Value={value}") ttl = kwargs.get("ttl", None) # Convert value to JSON before storing in S3 serialized_value = json.dumps(value) - key = self.key_prefix + key + key = self._to_s3_key(key) if ttl is not None: cache_control = f"immutable, max-age={ttl}, s-maxage={ttl}" - import datetime # Calculate expiration time - expiration_time = datetime.datetime.now() + ttl - + expiration_time = datetime.now(timezone.utc) + timedelta(seconds=ttl) # Upload the data to S3 with the calculated expiration time self.s3_client.put_object( Bucket=self.bucket_name, @@ -94,17 +97,26 @@ class S3Cache(BaseCache): ContentDisposition=f'inline; filename="{key}.json"', ) except Exception as e: - # NON blocking - notify users S3 is throwing an exception print_verbose(f"S3 Caching: set_cache() - Got exception from S3: {e}") async def async_set_cache(self, key, value, **kwargs): - self.set_cache(key=key, value=value, **kwargs) + """ + Asynchronously set cache using run_in_executor to avoid blocking the event loop. + Compatible with Python 3.8+. + """ + try: + verbose_logger.debug(f"Set ASYNC S3 Cache: Key={key}. Value={value}") + loop = asyncio.get_event_loop() + func = partial(self.set_cache, key, value, **kwargs) + await loop.run_in_executor(None, func) + except Exception as e: + verbose_logger.error(f"S3 Caching: async_set_cache() - Got exception from S3: {e}") def get_cache(self, key, **kwargs): import botocore try: - key = self.key_prefix + key + key = self._to_s3_key(key) print_verbose(f"Get S3 Cache: key: {key}") # Download the data from S3 @@ -113,6 +125,13 @@ class S3Cache(BaseCache): ) if cached_response is not None: + if "Expires" in cached_response: + expires_time = cached_response['Expires'] + current_time = datetime.now(expires_time.tzinfo) + + if current_time > expires_time: + return None + # cached_response is in `b{} convert it to ModelResponse cached_response = ( cached_response["Body"].read().decode("utf-8") @@ -138,13 +157,26 @@ class S3Cache(BaseCache): return None except Exception as e: - # NON blocking - notify users S3 is throwing an exception verbose_logger.error( f"S3 Caching: get_cache() - Got exception from S3: {e}" ) async def async_get_cache(self, key, **kwargs): - return self.get_cache(key=key, **kwargs) + """ + Asynchronously get cache using run_in_executor to avoid blocking the event loop. + Compatible with Python 3.8+. + """ + try: + verbose_logger.debug(f"Get ASYNC S3 Cache: key: {key}") + loop = asyncio.get_event_loop() + func = partial(self.get_cache, key, **kwargs) + result = await loop.run_in_executor(None, func) + return result + except Exception as e: + verbose_logger.error( + f"S3 Caching: async_get_cache() - Got exception from S3: {e}" + ) + return None def flush_cache(self): pass diff --git a/litellm/constants.py b/litellm/constants.py index 18f384b4ffb..78d5e5760d1 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -1,6 +1,9 @@ import os from typing import List, Literal +AZURE_DEFAULT_RESPONSES_API_VERSION = str( + os.getenv("AZURE_DEFAULT_RESPONSES_API_VERSION", "preview") +) ROUTER_MAX_FALLBACKS = int(os.getenv("ROUTER_MAX_FALLBACKS", 5)) DEFAULT_BATCH_SIZE = int(os.getenv("DEFAULT_BATCH_SIZE", 512)) DEFAULT_FLUSH_INTERVAL_SECONDS = int(os.getenv("DEFAULT_FLUSH_INTERVAL_SECONDS", 5)) @@ -248,6 +251,7 @@ LITELLM_CHAT_PROVIDERS = [ "groq", "nvidia_nim", "cerebras", + "baseten", "ai21_chat", "volcengine", "codestral", @@ -424,6 +428,7 @@ openai_compatible_providers: List = [ "groq", "nvidia_nim", "cerebras", + "baseten", "sambanova", "ai21_chat", "ai21", @@ -457,6 +462,7 @@ openai_compatible_providers: List = [ "morph", "lambda_ai", "hyperbolic", + "aiml", ] openai_text_completion_compatible_providers: List = ( [ # providers that support `/v1/completions` @@ -480,7 +486,7 @@ _openai_like_providers: List = [ "watsonx", ] # private helper. similar to openai but require some custom auth / endpoint handling, so can't use the openai sdk # well supported replicate llms -replicate_models: List = [ +replicate_models: set = set([ # llama replicate supported LLMs "replicate/llama-2-70b-chat:2796ee9483c3fd7aa2e171d38f4ca12251a30609463dcfd4cd76703f22e96cdf", "a16z-infra/llama-2-13b-chat:2a7f981751ec7fdf87b5b91ad4db53683a98082e9ff7bfd12c8cd5ea85980a52", @@ -493,9 +499,9 @@ replicate_models: List = [ # Others "replicate/dolly-v2-12b:ef0e1aefc61f8e096ebe4db6b2bacc297daf2ef6899f0f7e001ec445893500e5", "replit/replit-code-v1-3b:b84f4c074b807211cd75e3e8b1589b6399052125b4c27106e43d47189e8415ad", -] +]) -clarifai_models: List = [ +clarifai_models: set = set([ "clarifai/meta.Llama-3.Llama-3-8B-Instruct", "clarifai/gcp.generate.gemma-1_1-7b-it", "clarifai/mistralai.completion.mixtral-8x22B", @@ -559,10 +565,10 @@ clarifai_models: List = [ "clarifai/gcp.generate.gemini-1_5-pro", "clarifai/gcp.generate.imagen-2", "clarifai/salesforce.blip.general-english-image-caption-blip-2", -] +]) -huggingface_models: List = [ +huggingface_models: set = set([ "meta-llama/Llama-2-7b-hf", "meta-llama/Llama-2-7b-chat-hf", "meta-llama/Llama-2-13b-hf", @@ -575,13 +581,13 @@ huggingface_models: List = [ "meta-llama/Llama-2-13b-chat", "meta-llama/Llama-2-70b", "meta-llama/Llama-2-70b-chat", -] # these have been tested on extensively. But by default all text2text-generation and text-generation models are supported by liteLLM. - https://docs.litellm.ai/docs/providers -empower_models = [ +]) # these have been tested on extensively. But by default all text2text-generation and text-generation models are supported by liteLLM. - https://docs.litellm.ai/docs/providers +empower_models = set([ "empower/empower-functions", "empower/empower-functions-small", -] +]) -together_ai_models: List = [ +together_ai_models: set = set([ # llama llms - chat "togethercomputer/llama-2-70b-chat", # llama llms - language / instruct @@ -609,16 +615,17 @@ together_ai_models: List = [ "Austism/chronos-hermes-13b", "upstage/SOLAR-0-70b-16bit", "WizardLM/WizardLM-70B-V1.0", -] # supports all together ai models, just pass in the model id e.g. completion(model="together_computer/replit_code_3b",...) +]) + # supports all together ai models, just pass in the model id e.g. completion(model="together_computer/replit_code_3b",...) -baseten_models: List = [ +baseten_models: set = set([ "qvv0xeq", "q841o8w", "31dxrj3", -] # FALCON 7B # WizardLM # Mosaic ML +]) # FALCON 7B # WizardLM # Mosaic ML -featherless_ai_models: List = [ +featherless_ai_models: set = set([ "featherless-ai/Qwerky-72B", "featherless-ai/Qwerky-QwQ-32B", "Qwen/Qwen2.5-72B-Instruct", @@ -628,24 +635,61 @@ featherless_ai_models: List = [ "mistralai/Mistral-Small-24B-Instruct-2501", "mistralai/Mistral-Nemo-Instruct-2407", "ProdeusUnity/Stellar-Odyssey-12b-v0.0", -] +]) -nebius_models: List = [ +nebius_models: set = set([ + # deepseek models + "deepseek-ai/DeepSeek-R1-0528", + "deepseek-ai/DeepSeek-V3-0324", + "deepseek-ai/DeepSeek-V3", + "deepseek-ai/DeepSeek-R1", + "deepseek-ai/DeepSeek-R1-Distill-Llama-70B", + # google models + "google/gemma-2-2b-it", + "google/gemma-2-9b-it-fast", + # llama models + "meta-llama/Llama-3.3-70B-Instruct", + "meta-llama/Meta-Llama-3.1-70B-Instruct", + "meta-llama/Meta-Llama-3.1-8B-Instruct", + "meta-llama/Meta-Llama-3.1-405B-Instruct", + "NousResearch/Hermes-3-Llama-405B", + # microsoft models + "microsoft/phi-4", + # mistral models + "mistralai/Mistral-Nemo-Instruct-2407", + "mistralai/Devstral-Small-2505", + # moonshot models + "moonshotai/Kimi-K2-Instruct", + # nvidia models + "nvidia/Llama-3_1-Nemotron-Ultra-253B-v1", + "nvidia/Llama-3_3-Nemotron-Super-49B-v1", + # openai models + "openai/gpt-oss-120b", + "openai/gpt-oss-20b", + # qwen models + "Qwen/Qwen3-Coder-480B-A35B-Instruct", + "Qwen/Qwen3-235B-A22B-Instruct-2507", "Qwen/Qwen3-235B-A22B", - "Qwen/Qwen3-30B-A3B-fast", + "Qwen/Qwen3-30B-A3B", "Qwen/Qwen3-32B", "Qwen/Qwen3-14B", - "nvidia/Llama-3_1-Nemotron-Ultra-253B-v1", - "deepseek-ai/DeepSeek-V3-0324", - "deepseek-ai/DeepSeek-V3-0324-fast", - "deepseek-ai/DeepSeek-R1", - "deepseek-ai/DeepSeek-R1-fast", - "meta-llama/Llama-3.3-70B-Instruct-fast", - "Qwen/Qwen2.5-32B-Instruct-fast", - "Qwen/Qwen2.5-Coder-32B-Instruct-fast", -] + "Qwen/Qwen3-4B-fast", + "Qwen/Qwen2.5-Coder-7B", + "Qwen/Qwen2.5-Coder-32B-Instruct", + "Qwen/Qwen2.5-72B-Instruct", + "Qwen/QwQ-32B", + "Qwen/Qwen3-30B-A3B-Thinking-2507", + "Qwen/Qwen3-30B-A3B-Instruct-2507", + # zai models + "zai-org/GLM-4.5", + "zai-org/GLM-4.5-Air", + # other models + "aaditya/Llama3-OpenBioLLM-70B", + "ProdeusUnity/Stellar-Odyssey-12b-v0.0", + "all-hands/openhands-lm-32b-v0.1", +]) -dashscope_models: List = [ +dashscope_models: set = set([ "qwen-turbo", "qwen-plus", "qwen-max", @@ -656,13 +700,13 @@ dashscope_models: List = [ "qwen3-235b-a22b", "qwen3-32b", "qwen3-30b-a3b", -] +]) -nebius_embedding_models: List = [ +nebius_embedding_models: set = set([ "BAAI/bge-en-icl", "BAAI/bge-multilingual-gemma2", "intfloat/e5-mistral-7b-instruct", -] +]) BEDROCK_INVOKE_PROVIDERS_LITERAL = Literal[ "cohere", @@ -676,8 +720,8 @@ BEDROCK_INVOKE_PROVIDERS_LITERAL = Literal[ "deepseek_r1", ] -open_ai_embedding_models: List = ["text-embedding-ada-002"] -cohere_embedding_models: List = [ +open_ai_embedding_models: set = set(["text-embedding-ada-002"]) +cohere_embedding_models: set = set([ "embed-v4.0", "embed-english-v3.0", "embed-english-light-v3.0", @@ -685,12 +729,12 @@ cohere_embedding_models: List = [ "embed-english-v2.0", "embed-english-light-v2.0", "embed-multilingual-v2.0", -] -bedrock_embedding_models: List = [ +]) +bedrock_embedding_models: set = set([ "amazon.titan-embed-text-v1", "cohere.embed-english-v3", "cohere.embed-multilingual-v3", -] +]) known_tokenizer_config = { "mistralai/Mistral-7B-Instruct-v0.1": { diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py index 9956a9d314a..6c6a09cd73e 100644 --- a/litellm/cost_calculator.py +++ b/litellm/cost_calculator.py @@ -32,9 +32,6 @@ from litellm.llms.azure.cost_calculation import ( from litellm.llms.bedrock.cost_calculation import ( cost_per_token as bedrock_cost_per_token, ) -from litellm.llms.bedrock.image.cost_calculator import ( - cost_calculator as bedrock_image_cost_calculator, -) from litellm.llms.databricks.cost_calculator import ( cost_per_token as databricks_cost_per_token, ) @@ -60,9 +57,6 @@ from litellm.llms.vertex_ai.cost_calculator import ( cost_per_token as google_cost_per_token, ) from litellm.llms.vertex_ai.cost_calculator import cost_router as google_cost_router -from litellm.llms.vertex_ai.image_generation.cost_calculator import ( - cost_calculator as vertex_ai_image_cost_calculator, -) from litellm.responses.utils import ResponseAPILoggingUtils from litellm.types.llms.openai import ( HttpxBinaryResponseContent, @@ -768,50 +762,15 @@ def completion_cost( # noqa: PLR0915 ) if CostCalculatorUtils._call_type_has_image_response(call_type): ### IMAGE GENERATION COST CALCULATION ### - if custom_llm_provider == "vertex_ai": - if isinstance(completion_response, ImageResponse): - return vertex_ai_image_cost_calculator( - model=model, - image_response=completion_response, - ) - elif custom_llm_provider == "bedrock": - if isinstance(completion_response, ImageResponse): - return bedrock_image_cost_calculator( - model=model, - size=size, - image_response=completion_response, - optional_params=optional_params, - ) - raise TypeError( - "completion_response must be of type ImageResponse for bedrock image cost calculation" - ) - elif custom_llm_provider == litellm.LlmProviders.RECRAFT.value: - from litellm.llms.recraft.cost_calculator import ( - cost_calculator as recraft_image_cost_calculator, - ) - - return recraft_image_cost_calculator( - model=model, - image_response=completion_response, - ) - elif custom_llm_provider == litellm.LlmProviders.GEMINI.value: - from litellm.llms.gemini.image_generation.cost_calculator import ( - cost_calculator as gemini_image_cost_calculator, - ) - - return gemini_image_cost_calculator( - model=model, - image_response=completion_response, - ) - else: - return default_image_cost_calculator( - model=model, - quality=quality, - custom_llm_provider=custom_llm_provider, - n=n, - size=size, - optional_params=optional_params, - ) + return CostCalculatorUtils.route_image_generation_cost_calculator( + model=model, + custom_llm_provider=custom_llm_provider, + completion_response=completion_response, + quality=quality, + n=n, + size=size, + optional_params=optional_params, + ) elif ( call_type == CallTypes.speech.value or call_type == CallTypes.aspeech.value diff --git a/litellm/images/main.py b/litellm/images/main.py index b808388d83e..4993a48c724 100644 --- a/litellm/images/main.py +++ b/litellm/images/main.py @@ -1,7 +1,7 @@ import asyncio import contextvars from functools import partial -from typing import Any, Coroutine, Dict, Literal, Optional, Union, cast, overload +from typing import Any, Coroutine, Dict, List, Literal, Optional, Union, cast, overload import httpx @@ -311,7 +311,7 @@ def image_generation( # noqa: PLR0915 ) or get_secret_str("AZURE_AD_TOKEN") default_headers = { - "Content-Type": "application/json;", + "Content-Type": "application/json", "api-key": api_key, } for k, v in default_headers.items(): @@ -335,8 +335,64 @@ def image_generation( # noqa: PLR0915 headers=headers, litellm_params=litellm_params_dict, ) + ######################################################### + # Providers using llm_http_handler + ######################################################### + elif custom_llm_provider in ( + litellm.LlmProviders.RECRAFT, + litellm.LlmProviders.AIML, + litellm.LlmProviders.GEMINI, + ): + if image_generation_config is None: + raise ValueError(f"image generation config is not supported for {custom_llm_provider}") + + return llm_http_handler.image_generation_handler( + api_key=api_key, + model=model, + prompt=prompt, + image_generation_provider_config=image_generation_config, + image_generation_optional_request_params=optional_params, + custom_llm_provider=custom_llm_provider, + litellm_params=litellm_params_dict, + logging_obj=litellm_logging_obj, + timeout=timeout, + client=client, + ) + elif custom_llm_provider == "azure_ai": + from litellm.llms.azure_ai.common_utils import AzureFoundryModelInfo + api_base = AzureFoundryModelInfo.get_api_base(api_base) + api_key = AzureFoundryModelInfo.get_api_key(api_key) + if extra_headers is not None: + optional_params["extra_headers"] = extra_headers + + default_headers = { + "Content-Type": "application/json", + "api-key": api_key, + } + for k, v in default_headers.items(): + if k not in headers: + headers[k] = v + + model_response = azure_chat_completions.image_generation( + model=model, + prompt=prompt, + timeout=timeout, + api_key=api_key, + api_base=api_base, + azure_ad_token=None, + azure_ad_token_provider=azure_ad_token_provider, + logging_obj=litellm_logging_obj, + optional_params=optional_params, + model_response=model_response, + api_version=api_version, + aimg_generation=aimg_generation, + client=client, + headers=headers, + litellm_params=litellm_params_dict, + ) elif ( custom_llm_provider == "openai" + or custom_llm_provider == LlmProviders.LITELLM_PROXY.value or custom_llm_provider in litellm.openai_compatible_providers ): model_response = openai_chat_completions.image_generation( @@ -406,28 +462,6 @@ def image_generation( # noqa: PLR0915 api_base=api_base, client=client, ) - ######################################################### - # Providers using llm_http_handler - ######################################################### - elif custom_llm_provider in ( - litellm.LlmProviders.RECRAFT, - litellm.LlmProviders.GEMINI, - - ): - if image_generation_config is None: - raise ValueError(f"image generation config is not supported for {custom_llm_provider}") - - return llm_http_handler.image_generation_handler( - model=model, - prompt=prompt, - image_generation_provider_config=image_generation_config, - image_generation_optional_request_params=optional_params, - custom_llm_provider=custom_llm_provider, - litellm_params=litellm_params_dict, - logging_obj=litellm_logging_obj, - timeout=timeout, - client=client, - ) elif ( custom_llm_provider in litellm._custom_providers ): # Assume custom LLM provider @@ -643,7 +677,7 @@ def image_variation( @client def image_edit( - image: FileTypes, + image: Union[FileTypes, List[FileTypes]], prompt: str, model: Optional[str] = None, mask: Optional[str] = None, @@ -671,6 +705,9 @@ def image_edit( litellm_call_id: Optional[str] = kwargs.get("litellm_call_id", None) _is_async = kwargs.pop("async_call", False) is True + #add images / or return a single image + images = image if isinstance(image, list) else [image] + # get llm provider logic litellm_params = GenericLiteLLMParams(**kwargs) model, custom_llm_provider, _, _ = get_llm_provider( @@ -719,7 +756,7 @@ def image_edit( # Call the handler with _is_async flag instead of directly calling the async handler return base_llm_http_handler.image_edit_handler( model=model, - image=image, + image=images, prompt=prompt, image_edit_provider_config=image_edit_provider_config, image_edit_optional_request_params=image_edit_request_params, @@ -745,7 +782,7 @@ def image_edit( @client async def aimage_edit( - image: FileTypes, + image: Union[FileTypes, List[FileTypes]], model: str, prompt: str, mask: Optional[str] = None, @@ -785,9 +822,11 @@ async def aimage_edit( model=model, api_base=local_vars.get("base_url", None) ) + images = image if isinstance(image, list) else [image] + func = partial( image_edit, - image=image, + image=images, prompt=prompt, mask=mask, model=model, diff --git a/litellm/integrations/braintrust_logging.py b/litellm/integrations/braintrust_logging.py index 8149a6131e8..531da933fcc 100644 --- a/litellm/integrations/braintrust_logging.py +++ b/litellm/integrations/braintrust_logging.py @@ -19,10 +19,6 @@ from litellm.llms.custom_httpx.http_handler import ( ) from litellm.utils import print_verbose -global_braintrust_http_handler = get_async_httpx_client( - llm_provider=httpxSpecialProvider.LoggingCallback -) -global_braintrust_sync_http_handler = HTTPHandler() API_BASE = "https://api.braintrustdata.com/v1" @@ -52,6 +48,10 @@ class BraintrustLogger(CustomLogger): self._project_id_cache: Dict[ str, str ] = {} # Cache mapping project names to IDs + self.global_braintrust_http_handler = get_async_httpx_client( + llm_provider=httpxSpecialProvider.LoggingCallback + ) + self.global_braintrust_sync_http_handler = HTTPHandler() def validate_environment(self, api_key: Optional[str]): """ @@ -76,7 +76,7 @@ class BraintrustLogger(CustomLogger): return self._project_id_cache[project_name] try: - response = global_braintrust_sync_http_handler.post( + response = self.global_braintrust_sync_http_handler.post( f"{self.api_base}/project", headers=self.headers, json={"name": project_name}, @@ -96,7 +96,7 @@ class BraintrustLogger(CustomLogger): return self._project_id_cache[project_name] try: - response = await global_braintrust_http_handler.post( + response = await self.global_braintrust_http_handler.post( f"{self.api_base}/project/register", headers=self.headers, json={"name": project_name}, @@ -146,7 +146,7 @@ class BraintrustLogger(CustomLogger): return metadata async def create_default_project_and_experiment(self): - project = await global_braintrust_http_handler.post( + project = await self.global_braintrust_http_handler.post( f"{self.api_base}/project", headers=self.headers, json={"name": "litellm"} ) @@ -155,7 +155,7 @@ class BraintrustLogger(CustomLogger): self.default_project_id = project_dict["id"] def create_sync_default_project_and_experiment(self): - project = global_braintrust_sync_http_handler.post( + project = self.global_braintrust_sync_http_handler.post( f"{self.api_base}/project", headers=self.headers, json={"name": "litellm"} ) @@ -274,12 +274,15 @@ class BraintrustLogger(CustomLogger): "end": end_time.timestamp(), } + # Allow metadata override for span name + span_name = metadata.get("span_name", "Chat Completion") + request_data = { "id": litellm_call_id, "input": prompt["messages"], "metadata": clean_metadata, "tags": tags, - "span_attributes": {"name": "Chat Completion", "type": "llm"}, + "span_attributes": {"name": span_name, "type": "llm"}, } if choices is not None: request_data["output"] = [choice.dict() for choice in choices] @@ -291,9 +294,9 @@ class BraintrustLogger(CustomLogger): try: print_verbose( - f"global_braintrust_sync_http_handler.post: {global_braintrust_sync_http_handler.post}" + f"self.global_braintrust_sync_http_handler.post: {self.global_braintrust_sync_http_handler.post}" ) - global_braintrust_sync_http_handler.post( + self.global_braintrust_sync_http_handler.post( url=f"{self.api_base}/project_logs/{project_id}/insert", json={"events": [request_data]}, headers=self.headers, @@ -426,13 +429,16 @@ class BraintrustLogger(CustomLogger): - api_call_start_time.timestamp() ) + # Allow metadata override for span name + span_name = metadata.get("span_name", "Chat Completion") + request_data = { "id": litellm_call_id, "input": prompt["messages"], "output": output, "metadata": clean_metadata, "tags": tags, - "span_attributes": {"name": "Chat Completion", "type": "llm"}, + "span_attributes": {"name": span_name, "type": "llm"}, } if choices is not None: request_data["output"] = [choice.dict() for choice in choices] @@ -446,7 +452,7 @@ class BraintrustLogger(CustomLogger): request_data["metrics"] = metrics try: - await global_braintrust_http_handler.post( + await self.global_braintrust_http_handler.post( url=f"{self.api_base}/project_logs/{project_id}/insert", json={"events": [request_data]}, headers=self.headers, diff --git a/litellm/integrations/datadog/datadog_llm_obs.py b/litellm/integrations/datadog/datadog_llm_obs.py index 2577ed3ddf0..4f9c6409770 100644 --- a/litellm/integrations/datadog/datadog_llm_obs.py +++ b/litellm/integrations/datadog/datadog_llm_obs.py @@ -27,7 +27,12 @@ from litellm.llms.custom_httpx.http_handler import ( httpxSpecialProvider, ) from litellm.types.integrations.datadog_llm_obs import * -from litellm.types.utils import CallTypes, StandardLoggingPayload +from litellm.types.utils import ( + CallTypes, + StandardLoggingGuardrailInformation, + StandardLoggingPayload, + StandardLoggingPayloadErrorInformation, +) class DataDogLLMObsLogger(DataDogLogger, CustomBatchLogger): @@ -102,6 +107,24 @@ class DataDogLLMObsLogger(DataDogLogger, CustomBatchLogger): verbose_logger.exception( f"DataDogLLMObs: Error logging success event - {str(e)}" ) + + async def async_log_failure_event(self, kwargs, response_obj, start_time, end_time): + try: + verbose_logger.debug( + f"DataDogLLMObs: Logging failure event for model {kwargs.get('model', 'unknown')}" + ) + payload = self.create_llm_obs_payload( + kwargs, start_time, end_time + ) + verbose_logger.debug(f"DataDogLLMObs: Payload: {payload}") + self.log_queue.append(payload) + + if len(self.log_queue) >= self.batch_size: + await self.async_send_batch() + except Exception as e: + verbose_logger.exception( + f"DataDogLLMObs: Error logging failure event - {str(e)}" + ) async def async_send_batch(self): try: @@ -174,11 +197,14 @@ class DataDogLLMObsLogger(DataDogLogger, CustomBatchLogger): call_type=standard_logging_payload.get("call_type") )) + error_info = self._assemble_error_info(standard_logging_payload) + meta = Meta( kind=self._get_datadog_span_kind(standard_logging_payload.get("call_type")), input=input_meta, output=output_meta, metadata=self._get_dd_llm_obs_payload_metadata(standard_logging_payload), + error=error_info, ) # Calculate metrics (you may need to adjust these based on available data) @@ -199,11 +225,31 @@ class DataDogLLMObsLogger(DataDogLogger, CustomBatchLogger): start_ns=int(start_time.timestamp() * 1e9), duration=int((end_time - start_time).total_seconds() * 1e9), metrics=metrics, + status="error" if error_info else "ok", tags=[ self._get_datadog_tags(standard_logging_object=standard_logging_payload) ], ) + def _assemble_error_info(self, standard_logging_payload: StandardLoggingPayload) -> Optional[DDLLMObsError]: + """ + Assemble error information for failure cases according to DD LLM Obs API spec + """ + # Handle error information for failure cases according to DD LLM Obs API spec + error_info: Optional[DDLLMObsError] = None + + if standard_logging_payload.get("status") == "failure": + # Try to get structured error information first + error_information: Optional[StandardLoggingPayloadErrorInformation] = standard_logging_payload.get("error_information") + + if error_information: + error_info = DDLLMObsError( + message=error_information.get("error_message") or standard_logging_payload.get("error_str") or "Unknown error", + type=error_information.get("error_class"), + stack=error_information.get("traceback") + ) + return error_info + def _get_time_to_first_token_seconds(self, standard_logging_payload: StandardLoggingPayload) -> float: """ Get the time to first token in seconds @@ -232,8 +278,20 @@ class DataDogLLMObsLogger(DataDogLogger, CustomBatchLogger): for now this handles logging /chat/completions responses """ + if response_obj is None: + return [] + if call_type in [CallTypes.completion.value, CallTypes.acompletion.value]: - return [response_obj["choices"][0]["message"]] + try: + # Safely extract message from response_obj, handle failure cases + if isinstance(response_obj, dict) and "choices" in response_obj: + choices = response_obj["choices"] + if choices and len(choices) > 0 and "message" in choices[0]: + return [choices[0]["message"]] + return [] + except (KeyError, IndexError, TypeError): + # In case of any error accessing the response structure, return empty list + return [] return [] def _get_datadog_span_kind(self, call_type: Optional[str]) -> Literal["llm", "tool", "task", "embedding", "retrieval"]: @@ -350,11 +408,11 @@ class DataDogLLMObsLogger(DataDogLogger, CustomBatchLogger): def _get_dd_llm_obs_payload_metadata( self, standard_logging_payload: StandardLoggingPayload - ) -> Dict: + ) -> Dict[str, Any]: """ Fields to track in DD LLM Observability metadata from litellm standard logging payload """ - _metadata = { + _metadata: Dict[str, Any] = { "model_name": standard_logging_payload.get("model", "unknown"), "model_provider": standard_logging_payload.get( "custom_llm_provider", "unknown" @@ -364,9 +422,44 @@ class DataDogLLMObsLogger(DataDogLogger, CustomBatchLogger): "cache_hit": standard_logging_payload.get("cache_hit", "unknown"), "cache_key": standard_logging_payload.get("cache_key", "unknown"), "saved_cache_cost": standard_logging_payload.get("saved_cache_cost", 0), + "guardrail_information": standard_logging_payload.get("guardrail_information", None), } + + ######################################################### + # Add latency metrics to metadata + ######################################################### + latency_metrics = self._get_latency_metrics(standard_logging_payload) + _metadata.update({"latency_metrics": dict(latency_metrics)}) + _standard_logging_metadata: dict = ( dict(standard_logging_payload.get("metadata", {})) or {} ) _metadata.update(_standard_logging_metadata) return _metadata + + def _get_latency_metrics(self, standard_logging_payload: StandardLoggingPayload) -> DDLLMObsLatencyMetrics: + """ + Get the latency metrics from the standard logging payload + """ + latency_metrics: DDLLMObsLatencyMetrics = DDLLMObsLatencyMetrics() + # Add latency metrics to metadata + # Time to first token (convert from seconds to milliseconds for consistency) + time_to_first_token_seconds = self._get_time_to_first_token_seconds(standard_logging_payload) + if time_to_first_token_seconds > 0: + latency_metrics["time_to_first_token_ms"] = time_to_first_token_seconds * 1000 + + # LiteLLM overhead time + hidden_params = standard_logging_payload.get("hidden_params", {}) + litellm_overhead_ms = hidden_params.get("litellm_overhead_time_ms") + if litellm_overhead_ms is not None: + latency_metrics["litellm_overhead_time_ms"] = litellm_overhead_ms + + # Guardrail overhead latency + guardrail_info: Optional[StandardLoggingGuardrailInformation] = standard_logging_payload.get("guardrail_information") + if guardrail_info is not None: + _guardrail_duration_seconds: Optional[float] = guardrail_info.get("duration") + if _guardrail_duration_seconds is not None: + # Convert from seconds to milliseconds for consistency + latency_metrics["guardrail_overhead_time_ms"] = _guardrail_duration_seconds * 1000 + + return latency_metrics \ No newline at end of file diff --git a/litellm/integrations/langfuse/langfuse_otel.py b/litellm/integrations/langfuse/langfuse_otel.py index 8b90e123371..fbe480be95f 100644 --- a/litellm/integrations/langfuse/langfuse_otel.py +++ b/litellm/integrations/langfuse/langfuse_otel.py @@ -141,6 +141,17 @@ class LangfuseOtelLogger(OpenTelemetry): value = str(value) safe_set_attribute(span, enum_attr.value, value) + @staticmethod + def _get_langfuse_otel_host() -> Optional[str]: + """ + Returns the Langfuse OTEL host based on environment variables. + + Returned in the following order of precedence: + 1. LANGFUSE_OTEL_HOST + 2. LANGFUSE_HOST + """ + return os.environ.get("LANGFUSE_OTEL_HOST") or os.environ.get("LANGFUSE_HOST") + @staticmethod def get_langfuse_otel_config() -> LangfuseOtelConfig: """ @@ -166,7 +177,7 @@ class LangfuseOtelLogger(OpenTelemetry): ) # Determine endpoint - default to US cloud - langfuse_host = os.environ.get("LANGFUSE_HOST", None) + langfuse_host = LangfuseOtelLogger._get_langfuse_otel_host() if langfuse_host: # If LANGFUSE_HOST is provided, construct OTEL endpoint from it diff --git a/litellm/integrations/mlflow.py b/litellm/integrations/mlflow.py index ea9051db4de..86af800d732 100644 --- a/litellm/integrations/mlflow.py +++ b/litellm/integrations/mlflow.py @@ -60,10 +60,7 @@ class MlflowLogger(CustomLogger): inputs = self._construct_input(kwargs) input_messages = inputs.get("messages", []) - output_messages = [ - c.message.model_dump(exclude_none=True) - for c in getattr(response_obj, "choices", []) - ] + output_messages = [c.message.model_dump(exclude_none=True) for c in getattr(response_obj, "choices", [])] if messages := [*input_messages, *output_messages]: set_span_chat_messages(span, messages) if tools := inputs.get("tools"): @@ -168,6 +165,10 @@ class MlflowLogger(CustomLogger): for key in ["functions", "tools", "stream", "tool_choice", "user"]: if value := kwargs.get("optional_params", {}).pop(key, None): inputs[key] = value + + if prediction := kwargs.get("prediction"): + inputs["prediction"] = prediction + return inputs def _extract_attributes(self, kwargs): @@ -189,9 +190,9 @@ class MlflowLogger(CustomLogger): { "api_base": standard_obj.get("api_base"), "cache_hit": standard_obj.get("cache_hit"), - "usage": { - "completion_tokens": standard_obj.get("completion_tokens"), - "prompt_tokens": standard_obj.get("prompt_tokens"), + "mlflow.chat.tokenUsage": { + "input_tokens": standard_obj.get("prompt_tokens"), + "output_tokens": standard_obj.get("completion_tokens"), "total_tokens": standard_obj.get("total_tokens"), }, "raw_llm_response": standard_obj.get("response"), @@ -232,7 +233,6 @@ class MlflowLogger(CustomLogger): """ import mlflow - call_type = kwargs.get("call_type", "completion") span_name = f"litellm-{call_type}" span_type = self._get_span_type(call_type) @@ -260,6 +260,7 @@ class MlflowLogger(CustomLogger): tags=self._transform_tag_list_to_dict(attributes.get("request_tags", [])), start_time_ns=start_time_ns, ) + def _transform_tag_list_to_dict(self, tag_list: list) -> dict: return {tag: "" for tag in tag_list} diff --git a/litellm/litellm_core_utils/core_helpers.py b/litellm/litellm_core_utils/core_helpers.py index 13a2e554f12..4aeb9d4d640 100644 --- a/litellm/litellm_core_utils/core_helpers.py +++ b/litellm/litellm_core_utils/core_helpers.py @@ -37,6 +37,27 @@ def safe_divide_seconds( return float(seconds / denominator) +def safe_divide( + numerator: Union[int, float], + denominator: Union[int, float], + default: Union[int, float] = 0 +) -> Union[int, float]: + """ + Safely divide two numbers, returning a default value if denominator is zero. + + Args: + numerator: The number to divide + denominator: The number to divide by + default: Value to return if denominator is zero (defaults to 0) + + Returns: + The result of numerator/denominator, or default if denominator is zero + """ + if denominator == 0: + return default + return numerator / denominator + + def map_finish_reason( finish_reason: str, ): # openai supports 5 stop sequences - 'stop', 'length', 'function_call', 'content_filter', 'null' diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.py index e9a1eba719e..2d511741ec6 100644 --- a/litellm/litellm_core_utils/get_llm_provider_logic.py +++ b/litellm/litellm_core_utils/get_llm_provider_logic.py @@ -196,6 +196,9 @@ def get_llm_provider( # noqa: PLR0915 elif endpoint == "https://api.cerebras.ai/v1": custom_llm_provider = "cerebras" dynamic_api_key = get_secret_str("CEREBRAS_API_KEY") + elif endpoint == "https://inference.baseten.co/v1": + custom_llm_provider = "baseten" + dynamic_api_key = get_secret_str("BASETEN_API_KEY") elif endpoint == "https://api.sambanova.ai/v1": custom_llm_provider = "sambanova" dynamic_api_key = get_secret_str("SAMBANOVA_API_KEY") @@ -478,6 +481,13 @@ def _get_openai_compatible_provider_info( # noqa: PLR0915 api_base or get_secret("CEREBRAS_API_BASE") or "https://api.cerebras.ai/v1" ) # type: ignore dynamic_api_key = api_key or get_secret_str("CEREBRAS_API_KEY") + elif custom_llm_provider == "baseten": + # Use BasetenConfig to determine the appropriate API base URL + if api_base is None: + api_base = litellm.BasetenConfig.get_api_base_for_model(model) + else: + api_base = api_base or get_secret_str("BASETEN_API_BASE") or "https://inference.baseten.co/v1" + dynamic_api_key = api_key or get_secret_str("BASETEN_API_KEY") elif custom_llm_provider == "sambanova": api_base = ( api_base @@ -732,6 +742,13 @@ def _get_openai_compatible_provider_info( # noqa: PLR0915 ) = litellm.HyperbolicChatConfig()._get_openai_compatible_provider_info( api_base, api_key ) + elif custom_llm_provider == "aiml": + ( + api_base, + dynamic_api_key, + ) = litellm.AIMLChatConfig()._get_openai_compatible_provider_info( + api_base, api_key + ) if api_base is not None and not isinstance(api_base, str): raise Exception("api base needs to be a string. api_base={}".format(api_base)) diff --git a/litellm/litellm_core_utils/get_provider_specific_headers.py b/litellm/litellm_core_utils/get_provider_specific_headers.py new file mode 100644 index 00000000000..cf9165cfda9 --- /dev/null +++ b/litellm/litellm_core_utils/get_provider_specific_headers.py @@ -0,0 +1,23 @@ +from typing import Dict, Optional + +from litellm.types.utils import ProviderSpecificHeader + + +class ProviderSpecificHeaderUtils: + @staticmethod + def get_provider_specific_headers( + provider_specific_header: Optional[ProviderSpecificHeader], + custom_llm_provider: Optional[str], + ) -> Dict: + """ + Get the provider specific headers for the given custom llm provider + + Returns: + Optional[Dict]: The provider specific headers for the given custom llm provider + """ + if ( + provider_specific_header is not None + and provider_specific_header.get("custom_llm_provider") == custom_llm_provider + ): + return provider_specific_header.get("extra_headers", {}) + return {} \ No newline at end of file diff --git a/litellm/litellm_core_utils/get_supported_openai_params.py b/litellm/litellm_core_utils/get_supported_openai_params.py index 5fcd2ddb70a..cf39411f663 100644 --- a/litellm/litellm_core_utils/get_supported_openai_params.py +++ b/litellm/litellm_core_utils/get_supported_openai_params.py @@ -78,6 +78,8 @@ def get_supported_openai_params( # noqa: PLR0915 return litellm.nvidiaNimEmbeddingConfig.get_supported_openai_params() elif custom_llm_provider == "cerebras": return litellm.CerebrasConfig().get_supported_openai_params(model=model) + elif custom_llm_provider == "baseten": + return litellm.BasetenConfig().get_supported_openai_params(model=model) elif custom_llm_provider == "xai": return litellm.XAIChatConfig().get_supported_openai_params(model=model) elif custom_llm_provider == "ai21_chat" or custom_llm_provider == "ai21": @@ -266,10 +268,9 @@ def get_supported_openai_params( # noqa: PLR0915 from litellm.llms.elevenlabs.audio_transcription.transformation import ( ElevenLabsAudioTranscriptionConfig, ) - return ( - ElevenLabsAudioTranscriptionConfig().get_supported_openai_params( - model=model - ) + + return ElevenLabsAudioTranscriptionConfig().get_supported_openai_params( + model=model ) elif custom_llm_provider in litellm._custom_providers: if request_type == "chat_completion": diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 8e4aa43c9ce..7bc7702684d 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -811,7 +811,7 @@ class Logging(LiteLLMLoggingBaseClass): str(e) ) ) - if self.logger_fn and callable(self.logger_fn): + if getattr(self, "logger_fn", None) and callable(self.logger_fn): try: self.logger_fn( self.model_call_details @@ -999,7 +999,7 @@ class Logging(LiteLLMLoggingBaseClass): ) ) ) - if self.logger_fn and callable(self.logger_fn): + if getattr(self, "logger_fn", None) and callable(self.logger_fn): try: self.logger_fn( self.model_call_details @@ -3919,10 +3919,12 @@ class StandardLoggingPayloadSetup: # Generate cold storage object key if cold storage is configured if start_time is not None and response_id is not None: - cold_storage_object_key = StandardLoggingPayloadSetup._generate_cold_storage_object_key( - start_time=start_time, - response_id=response_id, - team_alias=clean_metadata.get("user_api_key_team_alias"), + cold_storage_object_key = ( + StandardLoggingPayloadSetup._generate_cold_storage_object_key( + start_time=start_time, + response_id=response_id, + team_alias=clean_metadata.get("user_api_key_team_alias"), + ) ) if cold_storage_object_key: clean_metadata["cold_storage_object_key"] = cold_storage_object_key @@ -4093,45 +4095,33 @@ class StandardLoggingPayloadSetup: ) -> Optional[str]: """ Generate cold storage object key in the same format as S3Logger. - + Args: start_time: The start time of the request - response_id: The response ID + response_id: The response ID team_alias: Optional team alias for team-based prefixing - + Returns: Optional[str]: The generated object key or None if cold storage not configured """ # Generate object key in same format as S3Logger from litellm.integrations.s3 import get_s3_object_key - from litellm.proxy.spend_tracking.cold_storage_handler import ColdStorageHandler # Only generate object key if cold storage is configured - try: - configured_cold_storage_logger = ( - ColdStorageHandler._get_configured_cold_storage_custom_logger() - ) - except Exception as e: - verbose_logger.debug( - f"Cold storage custom logger unavailable: {e}" - ) + if litellm.configured_cold_storage_logger is None: return None - if configured_cold_storage_logger is None: - return None - try: # Generate file name in same format as litellm.utils.get_logging_id s3_file_name = f"time-{start_time.strftime('%H-%M-%S-%f')}_{response_id}" - s3_object_key = get_s3_object_key( - s3_path="", # Use empty path as default - team_alias_prefix="", # Don't split by team alias for cold storage + s3_path="", # Use empty path as default + team_alias_prefix="", # Don't split by team alias for cold storage start_time=start_time, s3_file_name=s3_file_name, ) - + return s3_object_key except Exception: # If any error occurs in generating the key, return None diff --git a/litellm/litellm_core_utils/llm_cost_calc/utils.py b/litellm/litellm_core_utils/llm_cost_calc/utils.py index 737e3f7f982..c851ec06a6b 100644 --- a/litellm/litellm_core_utils/llm_cost_calc/utils.py +++ b/litellm/litellm_core_utils/llm_cost_calc/utils.py @@ -1,11 +1,17 @@ # What is this? ## Helper utilities for cost_per_token() -from typing import Literal, Optional, Tuple, cast +from typing import Any, Literal, Optional, Tuple, cast import litellm from litellm._logging import verbose_logger -from litellm.types.utils import CallTypes, ModelInfo, PassthroughCallTypes, Usage +from litellm.types.utils import ( + CallTypes, + ImageResponse, + ModelInfo, + PassthroughCallTypes, + Usage, +) from litellm.utils import get_model_info @@ -107,15 +113,20 @@ def _generic_cost_per_character( return prompt_cost, completion_cost -def _get_token_base_cost(model_info: ModelInfo, usage: Usage) -> Tuple[float, float]: +def _get_token_base_cost(model_info: ModelInfo, usage: Usage) -> Tuple[float, float, float, float]: """ - Return prompt cost for a given model and usage. + Return prompt cost, completion cost, and cache costs for a given model and usage. If input_tokens > threshold and `input_cost_per_token_above_[x]k_tokens` or `input_cost_per_token_above_[x]_tokens` is set, - then we use the corresponding threshold cost. + then we use the corresponding threshold cost for all token types. + + Returns: + Tuple[float, float, float, float] - (prompt_cost, completion_cost, cache_creation_cost, cache_read_cost) """ prompt_base_cost = cast(float, _get_cost_per_unit(model_info, "input_cost_per_token")) completion_base_cost = cast(float, _get_cost_per_unit(model_info, "output_cost_per_token")) + cache_creation_cost = cast(float, _get_cost_per_unit(model_info, "cache_creation_input_token_cost")) + cache_read_cost = cast(float, _get_cost_per_unit(model_info, "cache_read_input_token_cost")) ## CHECK IF ABOVE THRESHOLD threshold: Optional[float] = None @@ -135,13 +146,28 @@ def _get_token_base_cost(model_info: ModelInfo, usage: Usage) -> Tuple[float, fl f"output_cost_per_token_above_{threshold_str}_tokens", completion_base_cost, )) + + # Apply tiered pricing to cache costs + cache_creation_tiered_key = f"cache_creation_input_token_cost_above_{threshold_str}_tokens" + cache_read_tiered_key = f"cache_read_input_token_cost_above_{threshold_str}_tokens" + + if cache_creation_tiered_key in model_info: + cache_creation_cost = cast(float, _get_cost_per_unit( + model_info, cache_creation_tiered_key, cache_creation_cost + )) + + if cache_read_tiered_key in model_info: + cache_read_cost = cast(float, _get_cost_per_unit( + model_info, cache_read_tiered_key, cache_read_cost + )) + break except (IndexError, ValueError): continue except Exception: continue - return prompt_base_cost, completion_base_cost + return prompt_base_cost, completion_base_cost, cache_creation_cost, cache_read_cost def calculate_cost_component( @@ -256,28 +282,22 @@ def generic_cost_per_token( if text_tokens == 0: text_tokens = usage.prompt_tokens - cache_hit_tokens - audio_tokens - prompt_base_cost, completion_base_cost = _get_token_base_cost( + prompt_base_cost, completion_base_cost, cache_creation_cost, cache_read_cost = _get_token_base_cost( model_info=model_info, usage=usage ) prompt_cost = float(text_tokens) * prompt_base_cost - ### CACHE READ COST - prompt_cost += calculate_cost_component( - model_info, "cache_read_input_token_cost", cache_hit_tokens - ) + ### CACHE READ COST - Now uses tiered pricing + prompt_cost += float(cache_hit_tokens) * cache_read_cost ### AUDIO COST prompt_cost += calculate_cost_component( model_info, "input_cost_per_audio_token", audio_tokens ) - ### CACHE WRITING COST - prompt_cost += calculate_cost_component( - model_info, - "cache_creation_input_token_cost", - usage._cache_creation_input_tokens, - ) + ### CACHE WRITING COST - Now uses tiered pricing + prompt_cost += float(usage._cache_creation_input_tokens or 0) * cache_creation_cost ### CHARACTER COST @@ -377,3 +397,93 @@ class CostCalculatorUtils: ]: return True return False + + @staticmethod + def route_image_generation_cost_calculator( + model: str, + completion_response: Any, + custom_llm_provider: Optional[str] = None, + quality: Optional[str] = None, + n: Optional[int] = None, + size: Optional[str] = None, + optional_params: Optional[dict] = None, + ) -> float: + """ + Route the image generation cost calculator based on the custom_llm_provider + """ + from litellm.cost_calculator import default_image_cost_calculator + from litellm.llms.azure_ai.image_generation.cost_calculator import ( + cost_calculator as azure_ai_image_cost_calculator, + ) + from litellm.llms.bedrock.image.cost_calculator import ( + cost_calculator as bedrock_image_cost_calculator, + ) + from litellm.llms.gemini.image_generation.cost_calculator import ( + cost_calculator as gemini_image_cost_calculator, + ) + from litellm.llms.recraft.cost_calculator import ( + cost_calculator as recraft_image_cost_calculator, + ) + from litellm.llms.vertex_ai.image_generation.cost_calculator import ( + cost_calculator as vertex_ai_image_cost_calculator, + ) + + if custom_llm_provider == litellm.LlmProviders.VERTEX_AI.value: + if isinstance(completion_response, ImageResponse): + return vertex_ai_image_cost_calculator( + model=model, + image_response=completion_response, + ) + elif custom_llm_provider == litellm.LlmProviders.BEDROCK.value: + if isinstance(completion_response, ImageResponse): + return bedrock_image_cost_calculator( + model=model, + size=size, + image_response=completion_response, + optional_params=optional_params, + ) + raise TypeError( + "completion_response must be of type ImageResponse for bedrock image cost calculation" + ) + elif custom_llm_provider == litellm.LlmProviders.RECRAFT.value: + from litellm.llms.recraft.cost_calculator import ( + cost_calculator as recraft_image_cost_calculator, + ) + + return recraft_image_cost_calculator( + model=model, + image_response=completion_response, + ) + elif custom_llm_provider == litellm.LlmProviders.AIML.value: + from litellm.llms.aiml.image_generation.cost_calculator import ( + cost_calculator as aiml_image_cost_calculator, + ) + + return aiml_image_cost_calculator( + model=model, + image_response=completion_response, + ) + elif custom_llm_provider == litellm.LlmProviders.GEMINI.value: + from litellm.llms.gemini.image_generation.cost_calculator import ( + cost_calculator as gemini_image_cost_calculator, + ) + + return gemini_image_cost_calculator( + model=model, + image_response=completion_response, + ) + elif custom_llm_provider == litellm.LlmProviders.AZURE_AI.value: + return azure_ai_image_cost_calculator( + model=model, + image_response=completion_response, + ) + else: + return default_image_cost_calculator( + model=model, + quality=quality, + custom_llm_provider=custom_llm_provider, + n=n, + size=size, + optional_params=optional_params, + ) + return 0.0 diff --git a/litellm/litellm_core_utils/logging_utils.py b/litellm/litellm_core_utils/logging_utils.py index c7512ea146b..bf43519afc6 100644 --- a/litellm/litellm_core_utils/logging_utils.py +++ b/litellm/litellm_core_utils/logging_utils.py @@ -1,5 +1,6 @@ import asyncio import functools +import time from datetime import datetime from typing import TYPE_CHECKING, Any, List, Optional, Union @@ -11,15 +12,19 @@ from litellm.types.utils import ( ) if TYPE_CHECKING: + from opentelemetry.trace import Span as _Span + from litellm import ModelResponse as _ModelResponse from litellm.litellm_core_utils.litellm_logging import ( Logging as LiteLLMLoggingObject, ) LiteLLMModelResponse = _ModelResponse + Span = Union[_Span, Any] else: LiteLLMModelResponse = Any LiteLLMLoggingObject = Any + Span = Any import litellm @@ -28,9 +33,52 @@ import litellm Helper utils used for logging callbacks """ +# Global service logger instance to avoid recreating it +_service_logger = None + + +def _get_service_logger(): + """Get or create the global ServiceLogging instance""" + global _service_logger + if _service_logger is None: + from litellm._service_logger import ServiceLogging + + _service_logger = ServiceLogging() + return _service_logger + + +def _get_parent_otel_span_from_logging_obj( + logging_obj: Optional[LiteLLMLoggingObject] = None, +) -> Optional[Span]: + """ + Extract the parent OTEL span from the logging object using existing helper. + + Args: + logging_obj: The LiteLLM logging object containing model call details + + Returns: + The parent OTEL span if found, None otherwise + """ + try: + if logging_obj is None or not hasattr(logging_obj, "model_call_details"): + return None + + # Reuse existing function by passing model_call_details as kwargs + from litellm.litellm_core_utils.core_helpers import ( + _get_parent_otel_span_from_kwargs, + ) + + return _get_parent_otel_span_from_kwargs(logging_obj.model_call_details) + + except Exception as e: + verbose_logger.exception( + f"Error in _get_parent_otel_span_from_logging_obj: {str(e)}" + ) + return None + def convert_litellm_response_object_to_str( - response_obj: Union[Any, LiteLLMModelResponse] + response_obj: Union[Any, LiteLLMModelResponse], ) -> Optional[str]: """ Get the string of the response object from LiteLLM @@ -125,37 +173,102 @@ def track_llm_api_timing(): """ Decorator to track LLM API call timing for both sync and async functions. The logging_obj is expected to be passed as an argument to the decorated function. + Logs timing using ServiceLogging similar to Redis cache. """ def decorator(func): @functools.wraps(func) async def async_wrapper(*args, **kwargs): start_time = datetime.now() + start_time_float = time.time() + logging_obj = kwargs.get("logging_obj", None) + + # Extract parent OTEL span from logging object + parent_otel_span = _get_parent_otel_span_from_logging_obj(logging_obj) + try: result = await func(*args, **kwargs) return result finally: end_time = datetime.now() + end_time_float = time.time() + duration = end_time_float - start_time_float + + # Set duration in model call details _set_duration_in_model_call_details( - logging_obj=kwargs.get("logging_obj", None), + logging_obj=logging_obj, start_time=start_time, end_time=end_time, ) + # Log timing using ServiceLogging (like Redis cache) + try: + from litellm.types.services import ServiceTypes + + service_logger = _get_service_logger() + + # Get function name for call_type + call_type = f"{func.__name__} <- track_llm_api_timing" + + # Create async task for service logging (similar to Redis cache pattern) + asyncio.create_task( + service_logger.async_service_success_hook( + service=ServiceTypes.LITELLM, + duration=duration, + call_type=call_type, + start_time=start_time_float, + end_time=end_time_float, + parent_otel_span=parent_otel_span, + ) + ) + except Exception as e: + verbose_logger.debug(f"Error in service logging: {str(e)}") + @functools.wraps(func) def sync_wrapper(*args, **kwargs): start_time = datetime.now() + start_time_float = time.time() + logging_obj = kwargs.get("logging_obj", None) + + # Extract parent OTEL span from logging object + parent_otel_span = _get_parent_otel_span_from_logging_obj(logging_obj) + try: result = func(*args, **kwargs) return result finally: end_time = datetime.now() + end_time_float = time.time() + duration = end_time_float - start_time_float + + # Set duration in model call details _set_duration_in_model_call_details( - logging_obj=kwargs.get("logging_obj", None), + logging_obj=logging_obj, start_time=start_time, end_time=end_time, ) + # Log timing using ServiceLogging (like Redis cache) + try: + from litellm.types.services import ServiceTypes + + service_logger = _get_service_logger() + + # Get function name for call_type + call_type = f"{func.__name__} <- track_llm_api_timing" + + # Use sync service logging for sync functions + service_logger.service_success_hook( + service=ServiceTypes.LITELLM, + duration=duration, + call_type=call_type, + start_time=start_time_float, + end_time=end_time_float, + parent_otel_span=parent_otel_span, + ) + except Exception as e: + verbose_logger.debug(f"Error in service logging: {str(e)}") + # Check if the function is async or sync if asyncio.iscoroutinefunction(func): return async_wrapper diff --git a/litellm/litellm_core_utils/logging_worker.py b/litellm/litellm_core_utils/logging_worker.py new file mode 100644 index 00000000000..faf8413bd57 --- /dev/null +++ b/litellm/litellm_core_utils/logging_worker.py @@ -0,0 +1,131 @@ +import asyncio +import contextlib +from typing import Coroutine, Optional + +from litellm._logging import verbose_logger + + +class LoggingWorker: + """ + A simple, async logging worker that processes log coroutines in the background. + Designed to be best-effort with bounded queues to prevent backpressure. + + This leads to a +200 RPS performance improvement when using LiteLLM Python SDK or Proxy Server. + - Use this to queue coroutine tasks that are not critical to the main flow of the application. e.g Success/Error callbacks, logging, etc. + """ + LOGGING_WORKER_MAX_QUEUE_SIZE = 50_000 + LOGGING_WORKER_MAX_TIME_PER_COROUTINE = 20.0 + + MAX_ITERATIONS_TO_CLEAR_QUEUE = 200 + MAX_TIME_TO_CLEAR_QUEUE = 5.0 + + def __init__( + self, + timeout: float = LOGGING_WORKER_MAX_TIME_PER_COROUTINE, + max_queue_size: int = LOGGING_WORKER_MAX_QUEUE_SIZE, + ): + self.timeout = timeout + self.max_queue_size = max_queue_size + self._queue: Optional[asyncio.Queue] = None + self._worker_task: Optional[asyncio.Task] = None + + def _ensure_queue(self) -> None: + """Initialize the queue if it doesn't exist.""" + if self._queue is None: + self._queue = asyncio.Queue(maxsize=self.max_queue_size) + + def start(self) -> None: + """Start the logging worker. Idempotent - safe to call multiple times.""" + self._ensure_queue() + if self._worker_task is None or self._worker_task.done(): + self._worker_task = asyncio.create_task(self._worker_loop()) + + async def _worker_loop(self) -> None: + """Main worker loop that processes log coroutines sequentially.""" + try: + if self._queue is None: + return + + while True: + # Process one coroutine at a time to keep event loop load predictable + coroutine = await self._queue.get() + try: + await asyncio.wait_for(coroutine, timeout=self.timeout) + except Exception as e: + verbose_logger.exception(f"LoggingWorker error: {e}") + pass + finally: + self._queue.task_done() + + except asyncio.CancelledError as e: + verbose_logger.exception(f"LoggingWorker cancelled: {e}") + pass + + def enqueue(self, coroutine: Coroutine) -> None: + """ + Add a coroutine to the logging queue. + Hot path: never blocks, drops logs if queue is full. + """ + if self._queue is None: + return + + try: + self._queue.put_nowait(coroutine) + except asyncio.QueueFull as e: + verbose_logger.exception(f"LoggingWorker queue is full: {e}") + # Drop logs on overload to protect request throughput + pass + + def ensure_initialized_and_enqueue(self, async_coroutine: Coroutine): + """ + Ensure the logging worker is initialized and enqueue the coroutine. + """ + self.start() + self.enqueue(async_coroutine) + + async def stop(self) -> None: + """Stop the logging worker and clean up resources.""" + if self._worker_task: + self._worker_task.cancel() + with contextlib.suppress(Exception): + await self._worker_task + self._worker_task = None + + async def flush(self) -> None: + """Flush the logging queue.""" + if self._queue is None: + return + while not self._queue.empty(): + await self._queue.join() + + async def clear_queue(self): + """ + Clear the queue with a maximum time limit. + """ + if self._queue is None: + return + + start_time = asyncio.get_event_loop().time() + + for _ in range(self.MAX_ITERATIONS_TO_CLEAR_QUEUE): + # Check if we've exceeded the maximum time + if asyncio.get_event_loop().time() - start_time >= self.MAX_TIME_TO_CLEAR_QUEUE: + verbose_logger.warning(f"clear_queue exceeded max_time of {self.MAX_TIME_TO_CLEAR_QUEUE}s, stopping early") + break + + try: + coroutine = self._queue.get_nowait() + # Await the coroutine to properly execute and avoid "never awaited" warnings + try: + await asyncio.wait_for(coroutine, timeout=self.timeout) + except Exception: + # Suppress errors during cleanup + pass + self._queue.task_done() # If you're using join() elsewhere + except asyncio.QueueEmpty: + break + + +# Global instance for backward compatibility +GLOBAL_LOGGING_WORKER = LoggingWorker() + diff --git a/litellm/litellm_core_utils/model_response_utils.py b/litellm/litellm_core_utils/model_response_utils.py new file mode 100644 index 00000000000..5f6fced9d44 --- /dev/null +++ b/litellm/litellm_core_utils/model_response_utils.py @@ -0,0 +1,213 @@ +""" +Utility functions for ModelResponse and ModelResponseStream objects. +""" + +from typing import Any + +from litellm.types.utils import Delta, ModelResponseBase, ModelResponseStream + + +def is_model_response_stream_empty(model_response: ModelResponseStream) -> bool: + """ + Check if a ModelResponseStream is empty based on: + - If finish_reason is set -> it's non empty + - If any field in choices is set (e.g. content, tool calls, etc.) it's non empty + - If usage exists -> it's non empty + + This function is robust and ignores fields that are always set (from ModelResponseBase) + and checks for any meaningful content in other fields. + + Args: + model_response: The ModelResponseStream to check + + Returns: + bool: True if the stream is empty, False if it contains meaningful data + """ + # Fields that are always set in ModelResponseBase and should be ignored + # These are structural fields that don't indicate content + BASE_FIELDS = ModelResponseBase.model_fields.keys() + + # Check if usage exists - this indicates meaningful data + if getattr(model_response, "usage", None) is not None: + return False + + # Check provider_specific_fields at the top level + if ( + hasattr(model_response, "provider_specific_fields") + and model_response.provider_specific_fields is not None + and model_response.provider_specific_fields != {} + ): + return False + + # Check model_extra for dynamically added fields (this is where Pydantic stores them) + if hasattr(model_response, "model_extra") and model_response.model_extra: + for extra_field_name, extra_field_value in model_response.model_extra.items(): + if _has_meaningful_content(extra_field_value): + return False + + # Check for any non-base fields that are set + for model_response_field in model_response.model_fields.keys(): + # Skip base fields that are always set + if model_response_field in BASE_FIELDS: + continue + + # Skip choices - we'll handle them separately with deep inspection + if model_response_field == "choices": + continue + + # Check if any other field has meaningful content + model_response_value = getattr(model_response, model_response_field, None) + if _has_meaningful_content(model_response_value): + return False + + # Deep check of choices for any meaningful content + if hasattr(model_response, "choices") and model_response.choices: + for choice in model_response.choices: + if _is_choice_non_empty(choice): + return False + + # If we get here, the stream is empty + return True + + +def _has_meaningful_content(value: Any) -> bool: + """ + Check if a value contains meaningful content. + + Args: + value: The value to check + + Returns: + bool: True if the value has meaningful content, False otherwise + """ + if value is None: + return False + + if isinstance(value, str): + return len(value.strip()) > 0 + + if isinstance(value, (list, dict)): + return len(value) > 0 + + if isinstance(value, bool): + return True # Any boolean value is meaningful + + if isinstance(value, (int, float)): + return True # Any numeric value is meaningful + + # For other types (objects), consider them meaningful if they exist + return True + + +def _is_choice_non_empty(choice: Any) -> bool: + """ + Deep check if a choice contains any meaningful content. + + Args: + choice: The choice object to check + + Returns: + bool: True if the choice has meaningful content, False otherwise + """ + # Check finish_reason + if hasattr(choice, "finish_reason") and choice.finish_reason is not None: + + return True + + # Check logprobs + if hasattr(choice, "logprobs") and choice.logprobs is not None: + + return True + + # Check enhancements (if present) + if hasattr(choice, "enhancements") and choice.enhancements is not None: + + return True + + # Deep check delta object + if hasattr(choice, "delta") and choice.delta is not None: + if _is_delta_non_empty(choice.delta): + + return True + + # Check model_extra for dynamically added fields on the choice + if hasattr(choice, "model_extra") and choice.model_extra: + for extra_field_name, extra_field_value in choice.model_extra.items(): + # Skip certain structural fields that are just default/None placeholders + if extra_field_name == "index" and extra_field_value == 0: + + continue + if ( + extra_field_name in {"finish_reason", "logprobs"} + and extra_field_value is None + ): + + continue + if extra_field_name == "delta": + + continue + if _has_meaningful_content(extra_field_value): + + return True + + # Check for any other non-standard fields on the choice + for attr_name in dir(choice): + # Skip private attributes, methods, and known empty fields + if ( + attr_name.startswith("_") + or callable(getattr(choice, attr_name)) + or attr_name.startswith("model_") + or attr_name + in { + "finish_reason", + "index", + "delta", + "logprobs", + "enhancements", + } + ): + + continue + + attr_value = getattr(choice, attr_name, None) + if _has_meaningful_content(attr_value): + + return True + + return False + + +def _is_delta_non_empty(delta: Delta) -> bool: + """ + Deep check if a delta object contains any meaningful content. + + Args: + delta: The delta object to check + + Returns: + bool: True if the delta has meaningful content, False otherwise + """ + # Check model_extra for dynamically added fields (this is where Pydantic stores them) + if hasattr(delta, "model_extra") and delta.model_extra: + for extra_field_name, extra_field_value in delta.model_extra.items(): + # Even structural fields are meaningful if they have actual content + if _has_meaningful_content(extra_field_value): + + return True + + # Check all regular attributes of the delta object + for attr_name in dir(delta): + # Skip private attributes, methods, and Pydantic-specific fields + if ( + attr_name.startswith("_") + or callable(getattr(delta, attr_name)) + or attr_name.startswith("model_") + ): + continue + + attr_value = getattr(delta, attr_name, None) + if _has_meaningful_content(attr_value): + + return True + + return False diff --git a/litellm/litellm_core_utils/prompt_templates/common_utils.py b/litellm/litellm_core_utils/prompt_templates/common_utils.py index 9ba547b3600..a99883ef7b6 100644 --- a/litellm/litellm_core_utils/prompt_templates/common_utils.py +++ b/litellm/litellm_core_utils/prompt_templates/common_utils.py @@ -18,6 +18,7 @@ from typing import ( cast, ) +from litellm.router_utils.batch_utils import InMemoryFile from litellm.types.llms.openai import ( AllMessageValues, ChatCompletionAssistantMessage, @@ -453,6 +454,10 @@ def extract_file_data(file_data: FileTypes) -> ExtractedFileData: filename, file_content, content_type = file_data elif len(file_data) == 4: filename, file_content, content_type, file_headers = file_data + elif isinstance(file_data, InMemoryFile): + filename = file_data.name + file_content = file_data + content_type = file_data.content_type else: file_content = file_data # Convert content to bytes diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py index 26388dc2362..77cbe4c9a8e 100644 --- a/litellm/litellm_core_utils/prompt_templates/factory.py +++ b/litellm/litellm_core_utils/prompt_templates/factory.py @@ -17,6 +17,7 @@ from litellm.llms.custom_httpx.http_handler import HTTPHandler, get_async_httpx_ from litellm.types.files import get_file_extension_from_mime_type from litellm.types.llms.anthropic import * from litellm.types.llms.bedrock import MessageBlock as BedrockMessageBlock +from litellm.types.llms.bedrock import CachePointBlock from litellm.types.llms.custom_http import httpxSpecialProvider from litellm.types.llms.ollama import OllamaVisionModelObject from litellm.types.llms.openai import ( @@ -2685,6 +2686,11 @@ def _convert_to_bedrock_tool_call_invoke( ) bedrock_content_block = BedrockContentBlock(toolUse=bedrock_tool) _parts_list.append(bedrock_content_block) + + # Check for cache_control and add a separate cachePoint block + if tool.get("cache_control", None) is not None: + cache_point_block = BedrockContentBlock(cachePoint=CachePointBlock(type="default")) + _parts_list.append(cache_point_block) return _parts_list except Exception as e: raise Exception( @@ -2745,6 +2751,7 @@ def _convert_to_bedrock_tool_call_result( for content in content_list: if content["type"] == "text": content_str += content["text"] + message.get("name", "") id = str(message.get("tool_call_id", str(uuid.uuid4()))) @@ -2753,6 +2760,7 @@ def _convert_to_bedrock_tool_call_result( content=[tool_result_content_block], toolUseId=id, ) + content_block = BedrockContentBlock(toolResult=tool_result) return content_block @@ -3185,9 +3193,30 @@ class BedrockConverseMessagesProcessor: ## MERGE CONSECUTIVE TOOL CALL MESSAGES ## tool_content: List[BedrockContentBlock] = [] while msg_i < len(messages) and messages[msg_i]["role"] == "tool": - tool_call_result = _convert_to_bedrock_tool_call_result(messages[msg_i]) - + current_message = messages[msg_i] + tool_call_result = _convert_to_bedrock_tool_call_result(current_message) tool_content.append(tool_call_result) + + # Check if we need to add a separate cachePoint block + has_cache_control = False + + # Check for message-level cache_control + if current_message.get("cache_control", None) is not None: + has_cache_control = True + # Check for content-level cache_control in list content + elif isinstance(current_message.get("content"), list): + for content_element in current_message["content"]: + if (isinstance(content_element, dict) and + content_element.get("cache_control", None) is not None): + has_cache_control = True + break + + # Add a separate cachePoint block if cache_control is present + if has_cache_control: + cache_point_block = BedrockContentBlock(cachePoint=CachePointBlock(type="default")) + tool_content.append(cache_point_block) + + msg_i += 1 if tool_content: # if last message was a 'user' message, then add a blank assistant message (bedrock requires alternating roles) @@ -3267,13 +3296,29 @@ class BedrockConverseMessagesProcessor: image_url=image_url ) assistants_parts.append(assistants_part) + # Add cache point block for assistant content elements + _cache_point_block = ( + litellm.AmazonConverseConfig()._get_cache_point_block( + message_block=cast( + OpenAIMessageContentListBlock, element + ), + block_type="content_block", + ) + ) + if _cache_point_block is not None: + assistants_parts.append(_cache_point_block) assistant_content.extend(assistants_parts) - elif _assistant_content is not None and isinstance( - _assistant_content, str - ): - assistant_content.append( - BedrockContentBlock(text=_assistant_content) + elif _assistant_content is not None and isinstance(_assistant_content, str): + assistant_content.append(BedrockContentBlock(text=_assistant_content)) + # Add cache point block for assistant string content + _cache_point_block = ( + litellm.AmazonConverseConfig()._get_cache_point_block( + assistant_message_block, block_type="content_block" + ) ) + if _cache_point_block is not None: + assistant_content.append(_cache_point_block) + _tool_calls = assistant_message_block.get("tool_calls", []) if _tool_calls: assistant_content.extend( @@ -3516,8 +3561,30 @@ def _bedrock_converse_messages_pt( # noqa: PLR0915 tool_content: List[BedrockContentBlock] = [] while msg_i < len(messages) and messages[msg_i]["role"] == "tool": tool_call_result = _convert_to_bedrock_tool_call_result(messages[msg_i]) - + current_message = messages[msg_i] + + # Add the tool result first tool_content.append(tool_call_result) + + # Check if we need to add a separate cachePoint block + has_cache_control = False + + # Check for message-level cache_control + if current_message.get("cache_control", None) is not None: + has_cache_control = True + # Check for content-level cache_control in list content + elif isinstance(current_message.get("content"), list): + for content_element in current_message["content"]: + if (isinstance(content_element, dict) and + content_element.get("cache_control", None) is not None): + has_cache_control = True + break + + # Add a separate cachePoint block if cache_control is present + if has_cache_control: + cache_point_block = BedrockContentBlock(cachePoint=CachePointBlock(type="default")) + tool_content.append(cache_point_block) + msg_i += 1 if tool_content: # if last message was a 'user' message, then add a blank assistant message (bedrock requires alternating roles) @@ -3589,9 +3656,28 @@ def _bedrock_converse_messages_pt( # noqa: PLR0915 image_url=image_url ) assistants_parts.append(assistants_part) + # Add cache point block for assistant content elements + _cache_point_block = ( + litellm.AmazonConverseConfig()._get_cache_point_block( + message_block=cast( + OpenAIMessageContentListBlock, element + ), + block_type="content_block", + ) + ) + if _cache_point_block is not None: + assistants_parts.append(_cache_point_block) assistant_content.extend(assistants_parts) elif _assistant_content is not None and isinstance(_assistant_content, str): assistant_content.append(BedrockContentBlock(text=_assistant_content)) + # Add cache point block for assistant string content + _cache_point_block = ( + litellm.AmazonConverseConfig()._get_cache_point_block( + assistant_message_block, block_type="content_block" + ) + ) + if _cache_point_block is not None: + assistant_content.append(_cache_point_block) _tool_calls = assistant_message_block.get("tool_calls", []) if _tool_calls: assistant_content.extend( diff --git a/litellm/litellm_core_utils/sensitive_data_masker.py b/litellm/litellm_core_utils/sensitive_data_masker.py index 900239602df..07f652ecb9b 100644 --- a/litellm/litellm_core_utils/sensitive_data_masker.py +++ b/litellm/litellm_core_utils/sensitive_data_masker.py @@ -33,7 +33,12 @@ class SensitiveDataMasker: value_str = str(value) masked_length = len(value_str) - (self.visible_prefix + self.visible_suffix) - return f"{value_str[:self.visible_prefix]}{self.mask_char * masked_length}{value_str[-self.visible_suffix:]}" + + # Handle the case where visible_suffix is 0 to avoid showing the entire string + if self.visible_suffix == 0: + return f"{value_str[:self.visible_prefix]}{self.mask_char * masked_length}" + else: + return f"{value_str[:self.visible_prefix]}{self.mask_char * masked_length}{value_str[-self.visible_suffix:]}" def is_sensitive_key(self, key: str) -> bool: key_lower = str(key).lower() diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index 3721851a38f..01b2609d31d 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -13,11 +13,16 @@ from pydantic import BaseModel import litellm from litellm import verbose_logger +from litellm.litellm_core_utils.model_response_utils import ( + is_model_response_stream_empty, +) from litellm.litellm_core_utils.redact_messages import LiteLLMLoggingObject from litellm.litellm_core_utils.thread_pool_executor import executor from litellm.types.llms.openai import ChatCompletionChunk from litellm.types.router import GenericLiteLLMParams -from litellm.types.utils import Delta +from litellm.types.utils import ( + Delta, +) from litellm.types.utils import GenericStreamingChunk as GChunk from litellm.types.utils import ( ModelResponse, @@ -32,6 +37,12 @@ from .exception_mapping_utils import exception_type from .llm_response_utils.get_api_base import get_api_base from .rules import Rules +# Constants for special delta attribute names +AUDIO_ATTRIBUTE = "audio" +IMAGE_ATTRIBUTE = "image" +TOOL_CALLS_ATTRIBUTE = "tool_calls" +FUNCTION_CALL_ATTRIBUTE = "function_call" + def is_async_iterable(obj: Any) -> bool: """ @@ -763,6 +774,66 @@ class CustomStreamWrapper: model_response.choices[0].delta = Delta(**_initial_delta) return model_response + def _has_special_delta_content(self, model_response: ModelResponseStream) -> bool: + """ + Check if the delta contains special content types (tool_calls, function_call, audio, or image). + """ + if len(model_response.choices) == 0: + return False + + delta = model_response.choices[0].delta + + # Check for tool_calls or function_call + if getattr(delta, TOOL_CALLS_ATTRIBUTE, None) is not None or getattr(delta, FUNCTION_CALL_ATTRIBUTE, None) is not None: + return True + + # Check for audio + if hasattr(delta, AUDIO_ATTRIBUTE) and getattr(delta, AUDIO_ATTRIBUTE, None) is not None: + return True + + # Check for image + if hasattr(delta, IMAGE_ATTRIBUTE) and getattr(delta, IMAGE_ATTRIBUTE, None) is not None: + return True + + return False + + def _handle_special_delta_content(self, model_response: ModelResponseStream) -> ModelResponseStream: + """ + Handle special delta content types by stripping role and returning the response. + """ + return self.strip_role_from_delta(model_response) + + def _has_special_delta_attribute(self, delta, attribute_name: str) -> bool: + """ + Check if delta has a specific attribute and it's not None. + """ + return delta is not None and getattr(delta, attribute_name, None) is not None + + def _copy_delta_attribute(self, source_delta, target_delta, attribute_name: str) -> None: + """ + Copy a specific attribute from source delta to target delta. + """ + setattr(target_delta, attribute_name, getattr(source_delta, attribute_name)) + + def _has_any_special_delta_attributes(self, delta) -> bool: + """ + Check if delta has any special attributes (audio, image). + """ + special_attributes = [AUDIO_ATTRIBUTE, IMAGE_ATTRIBUTE] + for attribute in special_attributes: + if self._has_special_delta_attribute(delta, attribute): + return True + return False + + def _handle_special_delta_attributes(self, delta, model_response: "ModelResponseStream") -> None: + """ + Handle special delta attributes (audio, image) by copying them to model_response. + """ + special_attributes = [AUDIO_ATTRIBUTE, IMAGE_ATTRIBUTE] + for attribute in special_attributes: + if self._has_special_delta_attribute(delta, attribute): + self._copy_delta_attribute(delta, model_response.choices[0].delta, attribute) + def return_processed_chunk_logic( # noqa self, completion_obj: Dict[str, Any], @@ -885,20 +956,8 @@ class CustomStreamWrapper: self.sent_last_chunk = True return model_response - elif ( - model_response.choices[0].delta.tool_calls is not None - or model_response.choices[0].delta.function_call is not None - ): - model_response = self.strip_role_from_delta(model_response) - - return model_response - elif ( - len(model_response.choices) > 0 - and hasattr(model_response.choices[0].delta, "audio") - and model_response.choices[0].delta.audio is not None - ): - model_response = self.strip_role_from_delta(model_response) - return model_response + elif self._has_special_delta_content(model_response): + return self._handle_special_delta_content(model_response) else: if hasattr(model_response, "usage"): self.chunks.append(model_response) @@ -1371,10 +1430,8 @@ class CustomStreamWrapper: ) ) model_response.choices[0].delta = Delta() - elif ( - delta is not None and getattr(delta, "audio", None) is not None - ): - model_response.choices[0].delta.audio = delta.audio + elif self._has_any_special_delta_attributes(delta): + self._handle_special_delta_attributes(delta, model_response) else: try: delta = ( @@ -1574,6 +1631,13 @@ class CustomStreamWrapper: response = self.model_response_creator( chunk=obj_dict, hidden_params=response._hidden_params ) + ## check if empty + is_empty = is_model_response_stream_empty( + model_response=cast(ModelResponseStream, response) + ) + + if is_empty: + continue # add usage as hidden param if self.sent_last_chunk is True and self.stream_options is None: usage = calculate_total_usage(chunks=self.chunks) @@ -1730,7 +1794,18 @@ class CustomStreamWrapper: # Create a new object without the removed attribute processed_chunk = self.model_response_creator(chunk=obj_dict) + is_empty = is_model_response_stream_empty( + model_response=cast(ModelResponseStream, processed_chunk) + ) + + if is_empty: + continue print_verbose(f"final returned processed chunk: {processed_chunk}") + + # add usage as hidden param + if self.sent_last_chunk is True and self.stream_options is None: + usage = calculate_total_usage(chunks=self.chunks) + processed_chunk._hidden_params["usage"] = usage return processed_chunk raise StopAsyncIteration else: # temporary patch for non-aiohttp async calls @@ -1774,6 +1849,7 @@ class CustomStreamWrapper: messages=self.messages, logging_obj=self.logging_obj, ) + response = self.model_response_creator() if complete_streaming_response is not None: setattr( diff --git a/litellm/litellm_core_utils/token_counter.py b/litellm/litellm_core_utils/token_counter.py index 4df944edbaa..fab2c1e76ee 100644 --- a/litellm/litellm_core_utils/token_counter.py +++ b/litellm/litellm_core_utils/token_counter.py @@ -529,7 +529,7 @@ def _get_count_function( encoding = tiktoken.get_encoding("cl100k_base") def count_tokens(text: str) -> int: - return len(encoding.encode(text)) + return len(encoding.encode(text, disallowed_special=())) else: raise ValueError("Unsupported tokenizer type") diff --git a/litellm/llms/aiml/__init__.py b/litellm/llms/aiml/__init__.py new file mode 100644 index 00000000000..42482760cda --- /dev/null +++ b/litellm/llms/aiml/__init__.py @@ -0,0 +1,5 @@ +from .image_generation import get_aiml_image_generation_config + +__all__ = [ + "get_aiml_image_generation_config", +] diff --git a/litellm/llms/aiml/chat/transformation.py b/litellm/llms/aiml/chat/transformation.py new file mode 100644 index 00000000000..0f3e333343d --- /dev/null +++ b/litellm/llms/aiml/chat/transformation.py @@ -0,0 +1,23 @@ +from typing import Optional, Tuple + +from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig +from litellm.secret_managers.main import get_secret_str + + +class AIMLChatConfig(OpenAIGPTConfig): + @property + def custom_llm_provider(self) -> Optional[str]: + return "aiml" + + def _get_openai_compatible_provider_info( + self, api_base: Optional[str], api_key: Optional[str] + ) -> Tuple[Optional[str], Optional[str]]: + # AIML is openai compatible, we just need to set the api_base + api_base = ( + api_base + or get_secret_str("AIML_API_BASE") + or "https://api.aimlapi.com/v1" # Default AIML API base URL + ) # type: ignore + dynamic_api_key = api_key or get_secret_str("AIML_API_KEY") + return api_base, dynamic_api_key + pass \ No newline at end of file diff --git a/litellm/llms/aiml/image_generation/__init__.py b/litellm/llms/aiml/image_generation/__init__.py new file mode 100644 index 00000000000..4548bd1b3f8 --- /dev/null +++ b/litellm/llms/aiml/image_generation/__init__.py @@ -0,0 +1,13 @@ +from litellm.llms.base_llm.image_generation.transformation import ( + BaseImageGenerationConfig, +) + +from .transformation import AimlImageGenerationConfig + +__all__ = [ + "AimlImageGenerationConfig", +] + + +def get_aiml_image_generation_config(model: str) -> BaseImageGenerationConfig: + return AimlImageGenerationConfig() diff --git a/litellm/llms/aiml/image_generation/cost_calculator.py b/litellm/llms/aiml/image_generation/cost_calculator.py new file mode 100644 index 00000000000..1fecfb6a9a5 --- /dev/null +++ b/litellm/llms/aiml/image_generation/cost_calculator.py @@ -0,0 +1,25 @@ +from typing import Any + +import litellm +from litellm.types.utils import ImageResponse + + +def cost_calculator( + model: str, + image_response: Any, +) -> float: + """ + AI/ML flux image generation cost calculator + """ + _model_info = litellm.get_model_info( + model=model, + custom_llm_provider=litellm.LlmProviders.AIML.value, + ) + output_cost_per_image: float = _model_info.get("output_cost_per_image") or 0.0 + num_images: int = 0 + if isinstance(image_response, ImageResponse): + if image_response.data: + num_images = len(image_response.data) + return output_cost_per_image * num_images + else: + raise ValueError(f"image_response must be of type ImageResponse got type={type(image_response)}") diff --git a/litellm/llms/aiml/image_generation/transformation.py b/litellm/llms/aiml/image_generation/transformation.py new file mode 100644 index 00000000000..3b586689ea7 --- /dev/null +++ b/litellm/llms/aiml/image_generation/transformation.py @@ -0,0 +1,204 @@ +from typing import TYPE_CHECKING, Any, List, Optional + +import httpx + +from litellm.llms.base_llm.image_generation.transformation import ( + BaseImageGenerationConfig, +) +from litellm.secret_managers.main import get_secret_str +from litellm.types.llms.aiml import AimlImageGenerationRequestParams +from litellm.types.llms.openai import ( + AllMessageValues, + OpenAIImageGenerationOptionalParams, +) +from litellm.types.utils import ImageObject, ImageResponse + +if TYPE_CHECKING: + from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj + + LiteLLMLoggingObj = _LiteLLMLoggingObj +else: + LiteLLMLoggingObj = Any + + +class AimlImageGenerationConfig(BaseImageGenerationConfig): + DEFAULT_BASE_URL: str = "https://api.aimlapi.com" + IMAGE_GENERATION_ENDPOINT: str = "v1/images/generations" + + def get_supported_openai_params( + self, model: str + ) -> List[OpenAIImageGenerationOptionalParams]: + """ + https://api.aimlapi.com/v1/images/generations + """ + return [ + "n", + "response_format", + "size" + ] + + def map_openai_params( + self, + non_default_params: dict, + optional_params: dict, + model: str, + drop_params: bool, + ) -> dict: + supported_params = self.get_supported_openai_params(model) + + for k in non_default_params.keys(): + if k not in optional_params.keys(): + if k in supported_params: + # Map OpenAI params to AI/ML params + if k == "n": + optional_params["num_images"] = non_default_params[k] + elif k == "response_format": + optional_params["output_format"] = non_default_params[k] + elif k == "size": + # Map OpenAI size format to AI/ML image_size + size_value = non_default_params[k] + if isinstance(size_value, str): + # Handle standard OpenAI sizes like "1024x1024" + if "x" in size_value: + width, height = map(int, size_value.split("x")) + optional_params["image_size"] = {"width": width, "height": height} + else: + # Pass through predefined sizes + optional_params["image_size"] = size_value + else: + optional_params["image_size"] = size_value + else: + optional_params[k] = non_default_params[k] + elif drop_params: + pass + else: + raise ValueError( + f"Parameter {k} is not supported for model {model}. Supported parameters are {supported_params}. Set drop_params=True to drop unsupported parameters." + ) + + return optional_params + + def get_complete_url( + self, + api_base: Optional[str], + api_key: Optional[str], + model: str, + optional_params: dict, + litellm_params: dict, + stream: Optional[bool] = None, + ) -> str: + """ + Get the complete url for the request + """ + complete_url: str = ( + api_base + or get_secret_str("AIML_API_BASE") + or self.DEFAULT_BASE_URL + ) + + complete_url = complete_url.rstrip("/") + complete_url = f"{complete_url}/{self.IMAGE_GENERATION_ENDPOINT}" + return complete_url + + def validate_environment( + self, + headers: dict, + model: str, + messages: List[AllMessageValues], + optional_params: dict, + litellm_params: dict, + api_key: Optional[str] = None, + api_base: Optional[str] = None, + ) -> dict: + final_api_key: Optional[str] = ( + api_key or + get_secret_str("AIML_API_KEY") or + get_secret_str("AIMLAPI_KEY") # Alternative name + ) + if not final_api_key: + raise ValueError("AIML_API_KEY or AIMLAPI_KEY is not set") + + headers["Authorization"] = f"Bearer {final_api_key}" + headers["Content-Type"] = "application/json" + return headers + + def transform_image_generation_request( + self, + model: str, + prompt: str, + optional_params: dict, + litellm_params: dict, + headers: dict, + ) -> dict: + """ + Transform the image generation request to the AI/ML flux image generation request body + + https://api.aimlapi.com/v1/images/generations + """ + aiml_image_generation_request_body: AimlImageGenerationRequestParams = AimlImageGenerationRequestParams( + prompt=prompt, + model=model, + **optional_params, + ) + return dict(aiml_image_generation_request_body) + + def transform_image_generation_response( + self, + model: str, + raw_response: httpx.Response, + model_response: ImageResponse, + logging_obj: LiteLLMLoggingObj, + request_data: dict, + optional_params: dict, + litellm_params: dict, + encoding: Any, + api_key: Optional[str] = None, + json_mode: Optional[bool] = None, + ) -> ImageResponse: + """ + Transform the image generation response to the litellm image response + + https://api.aimlapi.com/v1/images/generations + """ + try: + response_data = raw_response.json() + except Exception as e: + raise self.get_error_class( + error_message=f"Error transforming image generation response: {e}", + status_code=raw_response.status_code, + headers=raw_response.headers, + ) + + if not model_response.data: + model_response.data = [] + + # AI/ML API can return images in two different formats: + # 1. output.choices array with image_base64 + # 2. images array with url (and optional width, height, content_type) + + if "output" in response_data and "choices" in response_data["output"]: + for choice in response_data["output"]["choices"]: + if "image_base64" in choice: + model_response.data.append(ImageObject( + b64_json=choice["image_base64"], + url=None, # AI/ML API returns base64, not URLs + )) + elif "url" in choice: + model_response.data.append(ImageObject( + b64_json=None, + url=choice["url"], + )) + elif "images" in response_data: + # Handle alternative format: {"images": [{"url": "...", "width": 1024, "height": 768, "content_type": "image/jpeg"}]} + for image in response_data["images"]: + if "url" in image: + model_response.data.append(ImageObject( + b64_json=None, + url=image["url"], + )) + elif "image_base64" in image: + model_response.data.append(ImageObject( + b64_json=image["image_base64"], + url=None, + )) + return model_response diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py index 990d613ecf0..d38e7adc231 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py @@ -489,7 +489,7 @@ class LiteLLMAnthropicMessagesAdapter: text: str = "" partial_json: Optional[str] = None for choice in choices: - if choice.delta.content is not None: + if choice.delta.content is not None and len(choice.delta.content) > 0: text += choice.delta.content elif choice.delta.tool_calls is not None: partial_json = "" @@ -499,7 +499,6 @@ class LiteLLMAnthropicMessagesAdapter: and tool.function.arguments is not None ): partial_json += tool.function.arguments - if partial_json is not None: return "input_json_delta", ContentJsonBlockDelta( type="input_json_delta", partial_json=partial_json diff --git a/litellm/llms/azure/chat/gpt_5_transformation.py b/litellm/llms/azure/chat/gpt_5_transformation.py index b8c032f4e9d..d563a2889ca 100644 --- a/litellm/llms/azure/chat/gpt_5_transformation.py +++ b/litellm/llms/azure/chat/gpt_5_transformation.py @@ -10,6 +10,7 @@ from .gpt_transformation import AzureOpenAIConfig class AzureOpenAIGPT5Config(AzureOpenAIConfig, OpenAIGPT5Config): """Azure specific handling for gpt-5 models.""" + GPT5_SERIES_ROUTE = "gpt5_series/" @classmethod @@ -23,7 +24,7 @@ class AzureOpenAIGPT5Config(AzureOpenAIConfig, OpenAIGPT5Config): def get_supported_openai_params(self, model: str) -> List[str]: return OpenAIGPT5Config.get_supported_openai_params(self, model=model) - + def map_openai_params( self, non_default_params: dict, diff --git a/litellm/llms/azure/common_utils.py b/litellm/llms/azure/common_utils.py index 94abd2f814e..09b1888e04d 100644 --- a/litellm/llms/azure/common_utils.py +++ b/litellm/llms/azure/common_utils.py @@ -365,14 +365,16 @@ def get_azure_ad_token( azure_ad_token_provider = get_azure_ad_token_provider(azure_scope=scope) except ValueError: verbose_logger.debug("Azure AD Token Provider could not be used.") - + ######################################################### # If litellm.enable_azure_ad_token_refresh is True and no other token provider is available, # try to get DefaultAzureCredential provider ######################################################### if azure_ad_token_provider is None and azure_ad_token is None: - azure_ad_token_provider = BaseAzureLLM._try_get_default_azure_credential_provider( - scope=scope, + azure_ad_token_provider = ( + BaseAzureLLM._try_get_default_azure_credential_provider( + scope=scope, + ) ) # Execute the token provider to get the token if available @@ -403,27 +405,27 @@ class BaseAzureLLM(BaseOpenAILLM): ) -> Optional[Callable[[], str]]: """ Try to get DefaultAzureCredential provider - + Args: scope: Azure scope for the token - + Returns: Token provider callable if DefaultAzureCredential is enabled and available, None otherwise """ from litellm.types.secret_managers.get_azure_ad_token_provider import ( AzureCredentialType, ) - - verbose_logger.debug( - "Attempting to use DefaultAzureCredential for Azure Auth" - ) - + + verbose_logger.debug("Attempting to use DefaultAzureCredential for Azure Auth") + try: azure_ad_token_provider = get_azure_ad_token_provider( azure_scope=scope, azure_credential=AzureCredentialType.DefaultAzureCredential, ) - verbose_logger.debug("Successfully obtained Azure AD token provider using DefaultAzureCredential") + verbose_logger.debug( + "Successfully obtained Azure AD token provider using DefaultAzureCredential" + ) return azure_ad_token_provider except Exception as e: verbose_logger.debug(f"DefaultAzureCredential failed: {str(e)}") @@ -656,17 +658,17 @@ class BaseAzureLLM(BaseOpenAILLM): else: client = AzureOpenAI(**azure_client_params) # type: ignore return client - + @staticmethod def _base_validate_azure_environment( - headers: dict, litellm_params: Optional[GenericLiteLLMParams] + headers: dict, litellm_params: Optional[GenericLiteLLMParams] ) -> dict: litellm_params = litellm_params or GenericLiteLLMParams() - + # If api-key is already in headers, preserve it if "api-key" in headers: return headers - + api_key = ( litellm_params.api_key or litellm.api_key @@ -686,13 +688,24 @@ class BaseAzureLLM(BaseOpenAILLM): headers["Authorization"] = f"Bearer {azure_ad_token}" return headers - + @staticmethod def _get_base_azure_url( api_base: Optional[str], litellm_params: Optional[Union[GenericLiteLLMParams, Dict[str, Any]]], - route: Literal["/openai/responses", "/openai/vector_stores"] + route: Literal["/openai/responses", "/openai/vector_stores"], + default_api_version: Optional[Union[str, Literal["latest", "preview"]]] = None, ) -> str: + """ + Get the base Azure URL for the given route and API version. + + Args: + api_base: The base URL of the Azure API. + litellm_params: The litellm parameters. + route: The route to the API. + default_api_version: The default API version to use if no api_version is provided. If 'latest', it will use `openai/v1/...` route. + """ + api_base = api_base or litellm.api_base or get_secret_str("AZURE_API_BASE") if api_base is None: raise ValueError( @@ -702,7 +715,10 @@ class BaseAzureLLM(BaseOpenAILLM): # Extract api_version or use default litellm_params = litellm_params or {} - api_version = cast(Optional[str], litellm_params.get("api_version")) + api_version = ( + cast(Optional[str], litellm_params.get("api_version")) + or default_api_version + ) # Create a new dictionary with existing params query_params = dict(original_url.params) @@ -710,27 +726,28 @@ class BaseAzureLLM(BaseOpenAILLM): # Add api_version if needed if "api-version" not in query_params and api_version: query_params["api-version"] = api_version - + # Add the path to the base URL if route not in api_base: - new_url = _add_path_to_api_base( - api_base=api_base, ending_path=route - ) + new_url = _add_path_to_api_base(api_base=api_base, ending_path=route) else: new_url = api_base - + if BaseAzureLLM._is_azure_v1_api_version(api_version): # ensure the request go to /openai/v1 and not just /openai if "/openai/v1" not in new_url: parsed_url = httpx.URL(new_url) - new_url = str(parsed_url.copy_with(path=parsed_url.path.replace("/openai", "/openai/v1"))) - + new_url = str( + parsed_url.copy_with( + path=parsed_url.path.replace("/openai", "/openai/v1") + ) + ) # Use the new query_params dictionary final_url = httpx.URL(new_url).copy_with(params=query_params) return str(final_url) - + @staticmethod def _is_azure_v1_api_version(api_version: Optional[str]) -> bool: if api_version is None: diff --git a/litellm/llms/azure/responses/transformation.py b/litellm/llms/azure/responses/transformation.py index e3d37c8a15a..488a711669d 100644 --- a/litellm/llms/azure/responses/transformation.py +++ b/litellm/llms/azure/responses/transformation.py @@ -6,6 +6,7 @@ from litellm.llms.openai.responses.transformation import OpenAIResponsesAPIConfi from litellm.types.llms.openai import * from litellm.types.responses.main import * from litellm.types.router import GenericLiteLLMParams +from litellm.types.utils import LlmProviders if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj @@ -16,6 +17,10 @@ else: class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig): + @property + def custom_llm_provider(self) -> LlmProviders: + return LlmProviders.AZURE + def validate_environment( self, headers: dict, model: str, litellm_params: Optional[GenericLiteLLMParams] ) -> dict: @@ -70,8 +75,13 @@ class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig): - A complete URL string, e.g., "https://litellm8397336933.openai.azure.com/openai/responses?api-version=2024-05-01-preview" """ + from litellm.constants import AZURE_DEFAULT_RESPONSES_API_VERSION + return BaseAzureLLM._get_base_azure_url( - api_base=api_base, litellm_params=litellm_params, route="/openai/responses" + api_base=api_base, + litellm_params=litellm_params, + route="/openai/responses", + default_api_version=AZURE_DEFAULT_RESPONSES_API_VERSION, ) ######################################################### diff --git a/litellm/llms/azure_ai/common_utils.py b/litellm/llms/azure_ai/common_utils.py new file mode 100644 index 00000000000..dcc9335e42d --- /dev/null +++ b/litellm/llms/azure_ai/common_utils.py @@ -0,0 +1,56 @@ +from typing import List, Optional + +import litellm +from litellm.llms.base_llm.base_utils import BaseLLMModelInfo +from litellm.secret_managers.main import get_secret_str +from litellm.types.llms.openai import AllMessageValues + + +class AzureFoundryModelInfo(BaseLLMModelInfo): + @staticmethod + def get_api_base(api_base: Optional[str] = None) -> Optional[str]: + return ( + api_base + or litellm.api_base + or get_secret_str("AZURE_AI_API_BASE") + ) + + @staticmethod + def get_api_key(api_key: Optional[str] = None) -> Optional[str]: + return ( + api_key + or litellm.api_key + or litellm.openai_key + or get_secret_str("AZURE_AI_API_KEY") + ) + + @property + def api_version(self, api_version: Optional[str] = None) -> Optional[str]: + api_version = ( + api_version + or litellm.api_version + or get_secret_str("AZURE_API_VERSION") + ) + return api_version + + ######################################################### + # Not implemented methods + ######################################################### + + + @staticmethod + def get_base_model(model: str) -> Optional[str]: + raise NotImplementedError("Azure Foundry does not support base model") + + def validate_environment( + self, + headers: dict, + model: str, + messages: List[AllMessageValues], + optional_params: dict, + litellm_params: dict, + api_key: Optional[str] = None, + api_base: Optional[str] = None, + ) -> dict: + """Azure Foundry sends api key in query params""" + raise NotImplementedError("Azure Foundry does not support environment validation") diff --git a/litellm/llms/azure_ai/image_generation/__init__.py b/litellm/llms/azure_ai/image_generation/__init__.py new file mode 100644 index 00000000000..cebab3de16e --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/__init__.py @@ -0,0 +1,33 @@ +from litellm._logging import verbose_logger +from litellm.llms.base_llm.image_generation.transformation import ( + BaseImageGenerationConfig, +) + +from .dall_e_2_transformation import AzureFoundryDallE2ImageGenerationConfig +from .dall_e_3_transformation import AzureFoundryDallE3ImageGenerationConfig +from .flux_transformation import AzureFoundryFluxImageGenerationConfig +from .gpt_transformation import AzureFoundryGPTImageGenerationConfig + +__all__ = [ + "AzureFoundryFluxImageGenerationConfig", + "AzureFoundryGPTImageGenerationConfig", + "AzureFoundryDallE2ImageGenerationConfig", + "AzureFoundryDallE3ImageGenerationConfig", +] + + +def get_azure_ai_image_generation_config(model: str) -> BaseImageGenerationConfig: + model = model.lower() + model = model.replace("-", "") + model = model.replace("_", "") + if model == "" or "dalle2" in model: # empty model is dall-e-2 + return AzureFoundryDallE2ImageGenerationConfig() + elif "dalle3" in model: + return AzureFoundryDallE3ImageGenerationConfig() + elif "flux" in model: + return AzureFoundryFluxImageGenerationConfig() + else: + verbose_logger.debug( + f"Using AzureGPTImageGenerationConfig for model: {model}. This follows the gpt-image-1 model format." + ) + return AzureFoundryGPTImageGenerationConfig() diff --git a/litellm/llms/azure_ai/image_generation/cost_calculator.py b/litellm/llms/azure_ai/image_generation/cost_calculator.py new file mode 100644 index 00000000000..2fc7c554a34 --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/cost_calculator.py @@ -0,0 +1,25 @@ +from typing import Any + +import litellm +from litellm.types.utils import ImageResponse + + +def cost_calculator( + model: str, + image_response: Any, +) -> float: + """ + Recraft image generation cost calculator + """ + _model_info = litellm.get_model_info( + model=model, + custom_llm_provider=litellm.LlmProviders.AZURE_AI.value, + ) + output_cost_per_image: float = _model_info.get("output_cost_per_image") or 0.0 + num_images: int = 0 + if isinstance(image_response, ImageResponse): + if image_response.data: + num_images = len(image_response.data) + return output_cost_per_image * num_images + else: + raise ValueError(f"image_response must be of type ImageResponse got type={type(image_response)}") diff --git a/litellm/llms/azure_ai/image_generation/dall_e_2_transformation.py b/litellm/llms/azure_ai/image_generation/dall_e_2_transformation.py new file mode 100644 index 00000000000..1ef93366f71 --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/dall_e_2_transformation.py @@ -0,0 +1,9 @@ +from litellm.llms.openai.image_generation import DallE2ImageGenerationConfig + + +class AzureFoundryDallE2ImageGenerationConfig(DallE2ImageGenerationConfig): + """ + Azure dall-e-2 image generation config + """ + + pass diff --git a/litellm/llms/azure_ai/image_generation/dall_e_3_transformation.py b/litellm/llms/azure_ai/image_generation/dall_e_3_transformation.py new file mode 100644 index 00000000000..4688a5c3caa --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/dall_e_3_transformation.py @@ -0,0 +1,9 @@ +from litellm.llms.openai.image_generation import DallE3ImageGenerationConfig + + +class AzureFoundryDallE3ImageGenerationConfig(DallE3ImageGenerationConfig): + """ + Azure dall-e-3 image generation config + """ + + pass diff --git a/litellm/llms/azure_ai/image_generation/flux_transformation.py b/litellm/llms/azure_ai/image_generation/flux_transformation.py new file mode 100644 index 00000000000..5325f32ef63 --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/flux_transformation.py @@ -0,0 +1,14 @@ +from litellm.llms.openai.image_generation import GPTImageGenerationConfig + + +class AzureFoundryFluxImageGenerationConfig(GPTImageGenerationConfig): + """ + Azure Foundry flux image generation config + + From manual testing it follows the gpt-image-1 image generation config + + (Azure Foundry does not have any docs on supported params at the time of writing) + + From our test suite - following GPTImageGenerationConfig is working for this model + """ + pass diff --git a/litellm/llms/azure_ai/image_generation/gpt_transformation.py b/litellm/llms/azure_ai/image_generation/gpt_transformation.py new file mode 100644 index 00000000000..3eead307463 --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/gpt_transformation.py @@ -0,0 +1,9 @@ +from litellm.llms.openai.image_generation import GPTImageGenerationConfig + + +class AzureFoundryGPTImageGenerationConfig(GPTImageGenerationConfig): + """ + Azure gpt-image-1 image generation config + """ + + pass diff --git a/litellm/llms/base_llm/responses/transformation.py b/litellm/llms/base_llm/responses/transformation.py index e2f89da5e86..4da4f7652e0 100644 --- a/litellm/llms/base_llm/responses/transformation.py +++ b/litellm/llms/base_llm/responses/transformation.py @@ -12,6 +12,7 @@ from litellm.types.llms.openai import ( ) from litellm.types.responses.main import * from litellm.types.router import GenericLiteLLMParams +from litellm.types.utils import LlmProviders if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj @@ -29,6 +30,11 @@ class BaseResponsesAPIConfig(ABC): def __init__(self): pass + @property + @abstractmethod + def custom_llm_provider(self) -> LlmProviders: + pass + @classmethod def get_config(cls): return { diff --git a/litellm/llms/baseten.py b/litellm/llms/baseten.py deleted file mode 100644 index e1d513d6d11..00000000000 --- a/litellm/llms/baseten.py +++ /dev/null @@ -1,172 +0,0 @@ -import json -import time -from typing import Callable - -import litellm -from litellm.types.utils import ModelResponse, Usage - - -class BasetenError(Exception): - def __init__(self, status_code, message): - self.status_code = status_code - self.message = message - super().__init__( - self.message - ) # Call the base class constructor with the parameters it needs - - -def validate_environment(api_key): - headers = { - "accept": "application/json", - "content-type": "application/json", - } - if api_key: - headers["Authorization"] = f"Api-Key {api_key}" - return headers - - -def completion( - model: str, - messages: list, - model_response: ModelResponse, - print_verbose: Callable, - encoding, - api_key, - logging_obj, - optional_params: dict, - litellm_params=None, - logger_fn=None, -): - headers = validate_environment(api_key) - completion_url_fragment_1 = "https://app.baseten.co/models/" - completion_url_fragment_2 = "/predict" - model = model - prompt = "" - for message in messages: - if "role" in message: - if message["role"] == "user": - prompt += f"{message['content']}" - else: - prompt += f"{message['content']}" - else: - prompt += f"{message['content']}" - data = { - "inputs": prompt, - "prompt": prompt, - "parameters": optional_params, - "stream": ( - True - if "stream" in optional_params and optional_params["stream"] is True - else False - ), - } - - ## LOGGING - logging_obj.pre_call( - input=prompt, - api_key=api_key, - additional_args={"complete_input_dict": data}, - ) - ## COMPLETION CALL - response = litellm.module_level_client.post( - completion_url_fragment_1 + model + completion_url_fragment_2, - headers=headers, - data=json.dumps(data), - stream=( - True - if "stream" in optional_params and optional_params["stream"] is True - else False - ), - ) - if "text/event-stream" in response.headers["Content-Type"] or ( - "stream" in optional_params and optional_params["stream"] is True - ): - return response.iter_lines() - else: - ## LOGGING - logging_obj.post_call( - input=prompt, - api_key=api_key, - original_response=response.text, - additional_args={"complete_input_dict": data}, - ) - print_verbose(f"raw model_response: {response.text}") - ## RESPONSE OBJECT - completion_response = response.json() - if "error" in completion_response: - raise BasetenError( - message=completion_response["error"], - status_code=response.status_code, - ) - else: - if "model_output" in completion_response: - if ( - isinstance(completion_response["model_output"], dict) - and "data" in completion_response["model_output"] - and isinstance(completion_response["model_output"]["data"], list) - ): - model_response.choices[0].message.content = completion_response[ # type: ignore - "model_output" - ][ - "data" - ][ - 0 - ] - elif isinstance(completion_response["model_output"], str): - model_response.choices[0].message.content = completion_response[ # type: ignore - "model_output" - ] - elif "completion" in completion_response and isinstance( - completion_response["completion"], str - ): - model_response.choices[0].message.content = completion_response[ # type: ignore - "completion" - ] - elif isinstance(completion_response, list) and len(completion_response) > 0: - if "generated_text" not in completion_response: - raise BasetenError( - message=f"Unable to parse response. Original response: {response.text}", - status_code=response.status_code, - ) - model_response.choices[0].message.content = completion_response[0][ # type: ignore - "generated_text" - ] - ## GETTING LOGPROBS - if ( - "details" in completion_response[0] - and "tokens" in completion_response[0]["details"] - ): - model_response.choices[0].finish_reason = completion_response[0][ - "details" - ]["finish_reason"] - sum_logprob = 0 - for token in completion_response[0]["details"]["tokens"]: - sum_logprob += token["logprob"] - model_response.choices[0].logprobs = sum_logprob # type: ignore - else: - raise BasetenError( - message=f"Unable to parse response. Original response: {response.text}", - status_code=response.status_code, - ) - - ## CALCULATING USAGE - baseten charges on time, not tokens - have some mapping of cost here. - prompt_tokens = len(encoding.encode(prompt)) - completion_tokens = len( - encoding.encode(model_response["choices"][0]["message"]["content"]) - ) - - model_response.created = int(time.time()) - model_response.model = model - usage = Usage( - prompt_tokens=prompt_tokens, - completion_tokens=completion_tokens, - total_tokens=prompt_tokens + completion_tokens, - ) - - setattr(model_response, "usage", usage) - return model_response - - -def embedding(): - # logic for parsing in - calling - parsing out model embedding calls - pass diff --git a/litellm/llms/baseten/chat.py b/litellm/llms/baseten/chat.py new file mode 100644 index 00000000000..05fc9961ac5 --- /dev/null +++ b/litellm/llms/baseten/chat.py @@ -0,0 +1,118 @@ +from typing import Optional +from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig + + +class BasetenConfig(OpenAIGPTConfig): + """ + Reference: https://inference.baseten.co/v1 + + Below are the parameters: + """ + + max_tokens: Optional[int] = None + response_format: Optional[dict] = None + seed: Optional[int] = None + stream: Optional[bool] = None + top_p: Optional[int] = None + tool_choice: Optional[str] = None + tools: Optional[list] = None + user: Optional[str] = None + presence_penalty: Optional[int] = None + frequency_penalty: Optional[int] = None + stream_options: Optional[dict] = None + + def __init__( + self, + max_tokens: Optional[int] = None, + response_format: Optional[dict] = None, + seed: Optional[int] = None, + stop: Optional[list] = None, + stream: Optional[bool] = None, + temperature: Optional[float] = None, + top_p: Optional[int] = None, + tool_choice: Optional[str] = None, + tools: Optional[list] = None, + user: Optional[str] = None, + presence_penalty: Optional[int] = None, + frequency_penalty: Optional[int] = None, + stream_options: Optional[dict] = None, + ) -> None: + locals_ = locals().copy() + for key, value in locals_.items(): + if key != "self" and value is not None: + setattr(self.__class__, key, value) + + @classmethod + def get_config(cls): + return super().get_config() + + def get_supported_openai_params(self, model: str) -> list: + """ + Get the supported OpenAI params for the given model + """ + return [ + "max_tokens", + "max_completion_tokens", + "response_format", + "seed", + "stop", + "stream", + "temperature", + "top_p", + "tool_choice", + "tools", + "user", + "presence_penalty", + "frequency_penalty", + "stream_options", + ] + + def map_openai_params( + self, + non_default_params: dict, + optional_params: dict, + model: str, + drop_params: bool, + ) -> dict: + supported_openai_params = self.get_supported_openai_params(model=model) + for param, value in non_default_params.items(): + if param == "max_completion_tokens": + optional_params["max_tokens"] = value + elif param in supported_openai_params: + optional_params[param] = value + return optional_params + + def _get_openai_compatible_provider_info(self, api_base: str, api_key: str) -> tuple: + """ + Get the OpenAI compatible provider info for Baseten + """ + # Default to Model API + default_api_base = "https://inference.baseten.co/v1" + default_api_key = api_key or "BASETEN_API_KEY" + + return default_api_base, default_api_key + + @staticmethod + def is_dedicated_deployment(model: str) -> bool: + """ + Check if the model is a dedicated deployment (8-digit alphanumeric code) + """ + # Remove 'baseten/' prefix if present + model_id = model.replace("baseten/", "") + + # Check if it's an 8-digit alphanumeric code + import re + return bool(re.match(r'^[a-zA-Z0-9]{8}$', model_id)) + + @staticmethod + def get_api_base_for_model(model: str) -> str: + """ + Get the appropriate API base URL for the given model + """ + if BasetenConfig.is_dedicated_deployment(model): + # Extract the model ID (remove 'baseten/' prefix if present) + model_id = model.replace("baseten/", "") + return f"https://model-{model_id}.api.baseten.co/environments/production/sync/v1" + else: + # Use Model API + return "https://inference.baseten.co/v1" \ No newline at end of file diff --git a/litellm/llms/bedrock/base_aws_llm.py b/litellm/llms/bedrock/base_aws_llm.py index cc205e62dc9..ce196757f94 100644 --- a/litellm/llms/bedrock/base_aws_llm.py +++ b/litellm/llms/bedrock/base_aws_llm.py @@ -179,15 +179,33 @@ class BaseAWSLLM: aws_sts_endpoint=aws_sts_endpoint, ) elif aws_role_name is not None: - # If aws_session_name is not provided, generate a default one - if aws_session_name is None: - aws_session_name = f"litellm-session-{int(datetime.now().timestamp())}" - credentials, _cache_ttl = self._auth_with_aws_role( - aws_access_key_id=aws_access_key_id, - aws_secret_access_key=aws_secret_access_key, - aws_role_name=aws_role_name, - aws_session_name=aws_session_name, - ) + # Check if we're in IRSA and trying to assume the same role we already have + current_role_arn = os.getenv("AWS_ROLE_ARN") + web_identity_token_file = os.getenv("AWS_WEB_IDENTITY_TOKEN_FILE") + + # In IRSA environments, we should skip role assumption if we're already running as the target role + # This is true when: + # 1. We have AWS_ROLE_ARN set (current role) + # 2. We have AWS_WEB_IDENTITY_TOKEN_FILE set (IRSA environment) + # 3. The current role matches the requested role + if (current_role_arn and web_identity_token_file and + current_role_arn == aws_role_name): + verbose_logger.debug("Using IRSA same-role optimization: calling _auth_with_env_vars") + # We're already running as this role via IRSA, no need to assume it again + # Use the default boto3 credentials (which will use the IRSA credentials) + credentials, _cache_ttl = self._auth_with_env_vars() + else: + verbose_logger.debug("Using role assumption: calling _auth_with_aws_role") + # If aws_session_name is not provided, generate a default one + if aws_session_name is None: + aws_session_name = f"litellm-session-{int(datetime.now().timestamp())}" + credentials, _cache_ttl = self._auth_with_aws_role( + aws_access_key_id=aws_access_key_id, + aws_secret_access_key=aws_secret_access_key, + aws_session_token=aws_session_token, + aws_role_name=aws_role_name, + aws_session_name=aws_session_name, + ) elif aws_profile_name is not None: ### CHECK SESSION ### credentials, _cache_ttl = self._auth_with_aws_profile(aws_profile_name) @@ -446,11 +464,98 @@ class BaseAWSLLM: iam_creds = session.get_credentials() return iam_creds, self._get_default_ttl_for_boto3_credentials() + def _handle_irsa_cross_account(self, irsa_role_arn: str, aws_role_name: str, + aws_session_name: str, region: str, web_identity_token_file: str) -> dict: + """Handle cross-account role assumption for IRSA.""" + import boto3 + + verbose_logger.debug("Cross-account role assumption detected") + + # Read the web identity token + with open(web_identity_token_file, 'r') as f: + web_identity_token = f.read().strip() + + # Create an STS client without credentials + with tracer.trace("boto3.client(sts) for manual IRSA"): + sts_client = boto3.client('sts', region_name=region) + + # Manually assume the IRSA role with the session name + verbose_logger.debug(f"Manually assuming IRSA role {irsa_role_arn} with session {aws_session_name}") + irsa_response = sts_client.assume_role_with_web_identity( + RoleArn=irsa_role_arn, + RoleSessionName=aws_session_name, + WebIdentityToken=web_identity_token + ) + + # Extract the credentials from the IRSA assumption + irsa_creds = irsa_response["Credentials"] + + # Create a new STS client with the IRSA credentials + with tracer.trace("boto3.client(sts) with manual IRSA credentials"): + sts_client_with_creds = boto3.client( + 'sts', + region_name=region, + aws_access_key_id=irsa_creds["AccessKeyId"], + aws_secret_access_key=irsa_creds["SecretAccessKey"], + aws_session_token=irsa_creds["SessionToken"] + ) + + # Get current caller identity for debugging + try: + caller_identity = sts_client_with_creds.get_caller_identity() + verbose_logger.debug(f"Current identity after manual IRSA assumption: {caller_identity.get('Arn', 'unknown')}") + except Exception as e: + verbose_logger.debug(f"Failed to get caller identity: {e}") + + # Now assume the target role + verbose_logger.debug(f"Attempting to assume target role: {aws_role_name} with session: {aws_session_name}") + return sts_client_with_creds.assume_role( + RoleArn=aws_role_name, RoleSessionName=aws_session_name + ) + + def _handle_irsa_same_account(self, aws_role_name: str, aws_session_name: str, region: str) -> dict: + """Handle same-account role assumption for IRSA.""" + import boto3 + + verbose_logger.debug("Same account role assumption, using automatic IRSA") + with tracer.trace("boto3.client(sts) with automatic IRSA"): + sts_client = boto3.client("sts", region_name=region) + + # Get current caller identity for debugging + try: + caller_identity = sts_client.get_caller_identity() + verbose_logger.debug(f"Current IRSA identity: {caller_identity.get('Arn', 'unknown')}") + except Exception as e: + verbose_logger.debug(f"Failed to get caller identity: {e}") + + # Assume the role + verbose_logger.debug(f"Attempting to assume role: {aws_role_name} with session: {aws_session_name}") + return sts_client.assume_role( + RoleArn=aws_role_name, RoleSessionName=aws_session_name + ) + + def _extract_credentials_and_ttl(self, sts_response: dict) -> Tuple[Credentials, Optional[int]]: + """Extract credentials and TTL from STS response.""" + from botocore.credentials import Credentials + + sts_credentials = sts_response["Credentials"] + credentials = Credentials( + access_key=sts_credentials["AccessKeyId"], + secret_key=sts_credentials["SecretAccessKey"], + token=sts_credentials["SessionToken"], + ) + + expiration_time = sts_credentials["Expiration"] + ttl = int((expiration_time - datetime.now(expiration_time.tzinfo)).total_seconds()) + + return credentials, ttl + @tracer.wrap() def _auth_with_aws_role( self, aws_access_key_id: Optional[str], aws_secret_access_key: Optional[str], + aws_session_token: Optional[str], aws_role_name: str, aws_session_name: str, ) -> Tuple[Credentials, Optional[int]]: @@ -460,12 +565,59 @@ class BaseAWSLLM: import boto3 from botocore.credentials import Credentials - with tracer.trace("boto3.client(sts)"): - sts_client = boto3.client( - "sts", - aws_access_key_id=aws_access_key_id, # [OPTIONAL] - aws_secret_access_key=aws_secret_access_key, # [OPTIONAL] - ) + # Check if we're in an EKS/IRSA environment + web_identity_token_file = os.getenv("AWS_WEB_IDENTITY_TOKEN_FILE") + irsa_role_arn = os.getenv("AWS_ROLE_ARN") + + # If we have IRSA environment variables and no explicit credentials, + # we need to use the web identity token flow + if (web_identity_token_file and irsa_role_arn and + aws_access_key_id is None and aws_secret_access_key is None): + # For cross-account role assumption with specific session names, + # we need to manually assume the IRSA role first with the correct session name + verbose_logger.debug(f"IRSA detected: using web identity token from {web_identity_token_file}") + + try: + # Get region from environment + region = os.getenv("AWS_REGION") or os.getenv("AWS_DEFAULT_REGION") or "us-east-1" + + # Check if we need to do cross-account role assumption + if aws_role_name != irsa_role_arn: + sts_response = self._handle_irsa_cross_account( + irsa_role_arn, aws_role_name, aws_session_name, region, web_identity_token_file + ) + else: + sts_response = self._handle_irsa_same_account( + aws_role_name, aws_session_name, region + ) + + return self._extract_credentials_and_ttl(sts_response) + + except Exception as e: + verbose_logger.debug(f"Failed to assume role via IRSA: {e}") + if "AccessDenied" in str(e) and "is not authorized to perform: sts:AssumeRole" in str(e): + # Provide a more helpful error message for trust policy issues + verbose_logger.error( + f"Access denied when trying to assume role {aws_role_name}. " + f"Please ensure the trust policy of {aws_role_name} allows " + f"the current role to assume it. Current identity: check logs with verbose mode." + ) + # Re-raise the exception instead of falling through + raise + + # In EKS/IRSA environments, use ambient credentials (no explicit keys needed) + # This allows the web identity token to work automatically + if aws_access_key_id is None and aws_secret_access_key is None: + with tracer.trace("boto3.client(sts)"): + sts_client = boto3.client("sts") + else: + with tracer.trace("boto3.client(sts)"): + sts_client = boto3.client( + "sts", + aws_access_key_id=aws_access_key_id, + aws_secret_access_key=aws_secret_access_key, + aws_session_token=aws_session_token, + ) sts_response = sts_client.assume_role( RoleArn=aws_role_name, RoleSessionName=aws_session_name diff --git a/litellm/llms/bedrock/chat/converse_handler.py b/litellm/llms/bedrock/chat/converse_handler.py index cd351ca16a7..15a5002f0e4 100644 --- a/litellm/llms/bedrock/chat/converse_handler.py +++ b/litellm/llms/bedrock/chat/converse_handler.py @@ -119,6 +119,7 @@ class BedrockConverseLLM(BaseAWSLLM): messages=messages, optional_params=optional_params, litellm_params=litellm_params, + headers=headers, ) data = json.dumps(request_data) @@ -185,8 +186,10 @@ class BedrockConverseLLM(BaseAWSLLM): messages=messages, optional_params=optional_params, litellm_params=litellm_params, + headers=headers, ) data = json.dumps(request_data) + prepped = self.get_request_headers( credentials=credentials, aws_region_name=litellm_params.get("aws_region_name") or "us-west-2", @@ -390,8 +393,10 @@ class BedrockConverseLLM(BaseAWSLLM): messages=messages, optional_params=optional_params, litellm_params=litellm_params, + headers=extra_headers, ) data = json.dumps(_data) + prepped = self.get_request_headers( credentials=credentials, aws_region_name=aws_region_name, diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py index 84762e0b99a..b93ca94bed4 100644 --- a/litellm/llms/bedrock/chat/converse_transformation.py +++ b/litellm/llms/bedrock/chat/converse_transformation.py @@ -25,6 +25,7 @@ from litellm.llms.base_llm.chat.transformation import BaseConfig, BaseLLMExcepti from litellm.types.llms.bedrock import * from litellm.types.llms.openai import ( AllMessageValues, + ChatCompletionAssistantMessage, ChatCompletionRedactedThinkingBlock, ChatCompletionResponseMessage, ChatCompletionSystemMessage, @@ -47,7 +48,7 @@ from litellm.types.utils import ( ) from litellm.utils import add_dummy_tool, has_tool_call_blocks, supports_reasoning -from ..common_utils import BedrockError, BedrockModelInfo, get_bedrock_tool_name +from ..common_utils import BedrockError, BedrockModelInfo, get_bedrock_tool_name, get_anthropic_beta_from_headers # Computer use tool prefixes supported by Bedrock BEDROCK_COMPUTER_USE_TOOLS = [ @@ -505,6 +506,7 @@ class AmazonConverseConfig(BaseConfig): OpenAIMessageContentListBlock, ChatCompletionUserMessage, ChatCompletionSystemMessage, + ChatCompletionAssistantMessage, ], block_type: Literal["system"], ) -> Optional[SystemContentBlock]: @@ -517,6 +519,7 @@ class AmazonConverseConfig(BaseConfig): OpenAIMessageContentListBlock, ChatCompletionUserMessage, ChatCompletionSystemMessage, + ChatCompletionAssistantMessage, ], block_type: Literal["content_block"], ) -> Optional[ContentBlock]: @@ -528,6 +531,7 @@ class AmazonConverseConfig(BaseConfig): OpenAIMessageContentListBlock, ChatCompletionUserMessage, ChatCompletionSystemMessage, + ChatCompletionAssistantMessage, ], block_type: Literal["system", "content_block"], ) -> Optional[Union[SystemContentBlock, ContentBlock]]: @@ -593,12 +597,14 @@ class AmazonConverseConfig(BaseConfig): return {} + def _transform_request_helper( self, model: str, system_content_blocks: List[SystemContentBlock], optional_params: dict, messages: Optional[List[AllMessageValues]] = None, + headers: Optional[dict] = None, ) -> CommonRequestObject: ## VALIDATE REQUEST """ @@ -651,6 +657,12 @@ class AmazonConverseConfig(BaseConfig): # Initialize bedrock_tools bedrock_tools: List[ToolBlock] = [] + # Collect anthropic_beta values from user headers + anthropic_beta_list = [] + if headers: + user_betas = get_anthropic_beta_from_headers(headers) + anthropic_beta_list.extend(user_betas) + # Only separate tools if computer use tools are actually present if original_tools and self.is_computer_use_tool_used(original_tools, model): # Separate computer use tools from regular function tools @@ -663,7 +675,7 @@ class AmazonConverseConfig(BaseConfig): # Add computer use tools and anthropic_beta if needed (only when computer use tools are present) if computer_use_tools: - additional_request_params["anthropic_beta"] = ["computer-use-2024-10-22"] + anthropic_beta_list.append("computer-use-2024-10-22") # Transform computer use tools to proper Bedrock format transformed_computer_tools = self._transform_computer_use_tools(computer_use_tools) additional_request_params["tools"] = transformed_computer_tools @@ -671,6 +683,17 @@ class AmazonConverseConfig(BaseConfig): # No computer use tools, process all tools as regular tools bedrock_tools = _bedrock_tools_pt(original_tools) + # Set anthropic_beta in additional_request_params if we have any beta features + if anthropic_beta_list: + # Remove duplicates while preserving order + unique_betas = [] + seen = set() + for beta in anthropic_beta_list: + if beta not in seen: + unique_betas.append(beta) + seen.add(beta) + additional_request_params["anthropic_beta"] = unique_betas + bedrock_tool_config: Optional[ToolConfigBlock] = None if len(bedrock_tools) > 0: tool_choice_values: ToolChoiceValuesBlock = inference_params.pop( @@ -708,6 +731,7 @@ class AmazonConverseConfig(BaseConfig): messages: List[AllMessageValues], optional_params: dict, litellm_params: dict, + headers: Optional[dict] = None, ) -> RequestObject: messages, system_content_blocks = self._transform_system_message(messages) ## TRANSFORMATION ## @@ -717,6 +741,7 @@ class AmazonConverseConfig(BaseConfig): system_content_blocks=system_content_blocks, optional_params=optional_params, messages=messages, + headers=headers, ) bedrock_messages = ( @@ -747,6 +772,7 @@ class AmazonConverseConfig(BaseConfig): messages=messages, optional_params=optional_params, litellm_params=litellm_params, + headers=headers, ), ) @@ -756,6 +782,7 @@ class AmazonConverseConfig(BaseConfig): messages: List[AllMessageValues], optional_params: dict, litellm_params: dict, + headers: Optional[dict] = None, ) -> RequestObject: messages, system_content_blocks = self._transform_system_message(messages) @@ -764,6 +791,7 @@ class AmazonConverseConfig(BaseConfig): system_content_blocks=system_content_blocks, optional_params=optional_params, messages=messages, + headers=headers, ) ## TRANSFORMATION ## diff --git a/litellm/llms/bedrock/chat/invoke_handler.py b/litellm/llms/bedrock/chat/invoke_handler.py index b8dac7c3cd7..42cdb34fc1a 100644 --- a/litellm/llms/bedrock/chat/invoke_handler.py +++ b/litellm/llms/bedrock/chat/invoke_handler.py @@ -831,7 +831,7 @@ class BedrockLLM(BaseAWSLLM): model=model, messages=messages, custom_llm_provider="anthropic_xml" ) # type: ignore ## LOAD CONFIG - config = litellm.AmazonAnthropicClaude3Config.get_config() + config = litellm.AmazonAnthropicClaudeConfig.get_config() for k, v in config.items(): if ( k not in inference_params diff --git a/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py index 738490aa7bb..9b13d3df08e 100644 --- a/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py +++ b/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py @@ -6,6 +6,7 @@ from litellm.llms.anthropic.chat.transformation import AnthropicConfig from litellm.llms.bedrock.chat.invoke_transformations.base_invoke_transformation import ( AmazonInvokeConfig, ) +from litellm.llms.bedrock.common_utils import get_anthropic_beta_from_headers from litellm.types.llms.openai import AllMessageValues from litellm.types.utils import ModelResponse @@ -17,13 +18,22 @@ else: LiteLLMLoggingObj = Any -class AmazonAnthropicClaude3Config(AmazonInvokeConfig, AnthropicConfig): +class AmazonAnthropicClaudeConfig(AmazonInvokeConfig, AnthropicConfig): """ Reference: https://us-west-2.console.aws.amazon.com/bedrock/home?region=us-west-2#/providers?model=claude https://docs.anthropic.com/claude/docs/models-overview#model-comparison + https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages-request-response.html - Supported Params for the Amazon / Anthropic Claude 3 models: + Supported Params for the Amazon / Anthropic Claude models (Claude 3, Claude 4, etc.): + Supports anthropic_beta parameter for beta features like: + - computer-use-2025-01-24 (Claude 3.7 Sonnet) + - computer-use-2024-10-22 (Claude 3.5 Sonnet v2) + - token-efficient-tools-2025-02-19 (Claude 3.7 Sonnet) + - interleaved-thinking-2025-05-14 (Claude 4 models) + - output-128k-2025-02-19 (Claude 3.7 Sonnet) + - dev-full-thinking-2025-05-14 (Claude 4 models) + - context-1m-2025-08-07 (Claude Sonnet 4) """ anthropic_version: str = "bedrock-2023-05-31" @@ -50,6 +60,7 @@ class AmazonAnthropicClaude3Config(AmazonInvokeConfig, AnthropicConfig): drop_params, ) + def transform_request( self, model: str, @@ -72,6 +83,11 @@ class AmazonAnthropicClaude3Config(AmazonInvokeConfig, AnthropicConfig): if "anthropic_version" not in _anthropic_request: _anthropic_request["anthropic_version"] = self.anthropic_version + # Handle anthropic_beta from user headers + anthropic_beta_list = get_anthropic_beta_from_headers(headers) + if anthropic_beta_list: + _anthropic_request["anthropic_beta"] = anthropic_beta_list + return _anthropic_request def transform_response( diff --git a/litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.py b/litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.py index 16f146206b1..08a0690716b 100644 --- a/litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.py +++ b/litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.py @@ -190,13 +190,15 @@ class AmazonInvokeConfig(BaseConfig, BaseAWSLLM): ] = True # cohere requires stream = True in inference params request_data = {"prompt": prompt, **inference_params} elif provider == "anthropic": - return litellm.AmazonAnthropicClaude3Config().transform_request( + transformed_request = litellm.AmazonAnthropicClaudeConfig().transform_request( model=model, messages=messages, optional_params=optional_params, litellm_params=litellm_params, headers=headers, ) + + return transformed_request elif provider == "nova": return litellm.AmazonInvokeNovaConfig().transform_request( model=model, @@ -293,7 +295,7 @@ class AmazonInvokeConfig(BaseConfig, BaseAWSLLM): completion_response["generations"][0]["finish_reason"] ) elif provider == "anthropic": - return litellm.AmazonAnthropicClaude3Config().transform_response( + return litellm.AmazonAnthropicClaudeConfig().transform_response( model=model, raw_response=raw_response, model_response=model_response, diff --git a/litellm/llms/bedrock/common_utils.py b/litellm/llms/bedrock/common_utils.py index 2a8fdc148bd..c76fc0a80c3 100644 --- a/litellm/llms/bedrock/common_utils.py +++ b/litellm/llms/bedrock/common_utils.py @@ -4,11 +4,14 @@ Common utilities used across bedrock chat/embedding/image generation import json import os -from typing import TYPE_CHECKING, List, Literal, Optional, Union +from typing import TYPE_CHECKING, Dict, List, Literal, Optional, Union import httpx import litellm +from litellm.llms.base_llm.anthropic_messages.transformation import ( + BaseAnthropicMessagesConfig, +) from litellm.llms.base_llm.base_utils import BaseLLMModelInfo from litellm.llms.base_llm.chat.transformation import BaseLLMException from litellm.secret_managers.main import get_secret @@ -443,23 +446,82 @@ class BedrockModelInfo(BaseLLMModelInfo): """ Get the bedrock route for the given model. """ + route_mappings: Dict[str, Literal["invoke", "converse_like", "converse", "agent"]] = { + "invoke/": "invoke", + "converse_like/": "converse_like", + "converse/": "converse", + "agent/": "agent" + } + + # Check explicit routes first + for prefix, route_type in route_mappings.items(): + if prefix in model: + return route_type + base_model = BedrockModelInfo.get_base_model(model) alt_model = BedrockModelInfo.get_non_litellm_routing_model_name(model=model) - if "invoke/" in model: - return "invoke" - elif "converse_like" in model: - return "converse_like" - elif "converse/" in model: - return "converse" - elif "agent/" in model: - return "agent" - elif ( + if ( base_model in litellm.bedrock_converse_models or alt_model in litellm.bedrock_converse_models ): return "converse" return "invoke" + + @staticmethod + def _explicit_converse_route(model: str) -> bool: + """ + Check if the model is an explicit converse route. + """ + return "converse/" in model + + @staticmethod + def _explicit_invoke_route(model: str) -> bool: + """ + Check if the model is an explicit invoke route. + """ + return "invoke/" in model + + @staticmethod + def _explicit_agent_route(model: str) -> bool: + """ + Check if the model is an explicit agent route. + """ + return "agent/" in model + + @staticmethod + def _explicit_converse_like_route(model: str) -> bool: + """ + Check if the model is an explicit converse like route. + """ + return "converse_like/" in model + + @staticmethod + def get_bedrock_provider_config_for_messages_api(model: str) -> Optional[BaseAnthropicMessagesConfig]: + """ + Get the bedrock provider config for the given model. + + Only route to AmazonAnthropicClaude3MessagesConfig() for BaseMessagesConfig + + All other routes should return None since they will go through litellm.completion + """ + + ######################################################### + # Converse routes should go through litellm.completion() + if BedrockModelInfo._explicit_converse_route(model): + return None + + ######################################################### + # This goes through litellm.AmazonAnthropicClaude3MessagesConfig() + # Since bedrock Invoke supports Native Anthropic Messages API + ######################################################### + if "claude" in model: + return litellm.AmazonAnthropicClaudeMessagesConfig() + + ######################################################### + # These routes will go through litellm.completion() + ######################################################### + return None class BedrockEventStreamDecoderBase: """ @@ -524,3 +586,25 @@ class BedrockEventStreamDecoderBase: return None return chunk.decode() # type: ignore[no-any-return] + + +def get_anthropic_beta_from_headers(headers: dict) -> List[str]: + """ + Extract anthropic-beta header values and convert them to a list. + Supports comma-separated values from user headers. + + Used by both converse and invoke transformations for consistent handling + of anthropic-beta headers that should be passed to AWS Bedrock. + + Args: + headers (dict): Request headers dictionary + + Returns: + List[str]: List of anthropic beta feature strings, empty list if no header + """ + anthropic_beta_header = headers.get("anthropic-beta") + if not anthropic_beta_header: + return [] + + # Split comma-separated values and strip whitespace + return [beta.strip() for beta in anthropic_beta_header.split(",")] diff --git a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py index 09c6673cc5d..4fa8517a090 100644 --- a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py +++ b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py @@ -12,6 +12,7 @@ from litellm.llms.bedrock.chat.invoke_handler import AWSEventStreamDecoder from litellm.llms.bedrock.chat.invoke_transformations.base_invoke_transformation import ( AmazonInvokeConfig, ) +from litellm.llms.bedrock.common_utils import get_anthropic_beta_from_headers from litellm.types.router import GenericLiteLLMParams from litellm.types.utils import GenericStreamingChunk from litellm.types.utils import GenericStreamingChunk as GChunk @@ -25,12 +26,13 @@ else: LiteLLMLoggingObj = Any -class AmazonAnthropicClaude3MessagesConfig( +class AmazonAnthropicClaudeMessagesConfig( AnthropicMessagesConfig, AmazonInvokeConfig, ): """ Call Claude model family in the /v1/messages API spec + Supports anthropic_beta parameter for beta features. """ DEFAULT_BEDROCK_ANTHROPIC_API_VERSION = "bedrock-2023-05-31" @@ -127,6 +129,12 @@ class AmazonAnthropicClaude3MessagesConfig( # 3. `model` is not allowed in request body for bedrock invoke if "model" in anthropic_messages_request: anthropic_messages_request.pop("model", None) + + # 4. Handle anthropic_beta from user headers + anthropic_beta_list = get_anthropic_beta_from_headers(headers) + if anthropic_beta_list: + anthropic_messages_request["anthropic_beta"] = anthropic_beta_list + return anthropic_messages_request def get_async_streaming_response_iterator( diff --git a/litellm/llms/custom_httpx/aiohttp_transport.py b/litellm/llms/custom_httpx/aiohttp_transport.py index 3ed7d04bde6..ab69ea1f8c3 100644 --- a/litellm/llms/custom_httpx/aiohttp_transport.py +++ b/litellm/llms/custom_httpx/aiohttp_transport.py @@ -3,7 +3,7 @@ import contextlib import os import typing import urllib.request -from typing import Callable, Dict, Union +from typing import Callable, Dict, Optional, Union import aiohttp import aiohttp.client_exceptions @@ -115,6 +115,12 @@ class AiohttpTransport(httpx.AsyncBaseTransport): ) -> None: self.client = client + ######################################################### + # Class variables for proxy settings + ######################################################### + self.proxy: Optional[str] = None + self.checked_proxy_env_settings: bool = False + async def aclose(self) -> None: if isinstance(self.client, ClientSession): await self.client.close() @@ -249,7 +255,22 @@ class LiteLLMAiohttpTransport(AiohttpTransport): def _proxy_from_env(self, url: httpx.URL) -> typing.Optional[str]: - """Return proxy URL from env for the given request URL.""" + """ + Return proxy URL from env for the given request URL + + Only check the proxy env settings once, this is a costly operation for CPU % usage + + .""" + ######################################################### + # Check if we've already checked the proxy env settings + ######################################################### + if self.checked_proxy_env_settings is True: + return self.proxy + + ######################################################### + # set self.checked_proxy_env_settings to True + ######################################################### + self.checked_proxy_env_settings = True proxies = urllib.request.getproxies() if urllib.request.proxy_bypass(url.host): return None @@ -257,4 +278,5 @@ class LiteLLMAiohttpTransport(AiohttpTransport): proxy = proxies.get(url.scheme) or proxies.get("all") if proxy and "://" not in proxy: proxy = f"http://{proxy}" - return proxy + self.proxy = proxy + return self.proxy diff --git a/litellm/llms/custom_httpx/http_handler.py b/litellm/llms/custom_httpx/http_handler.py index cf2187153a9..4d8781fff2a 100644 --- a/litellm/llms/custom_httpx/http_handler.py +++ b/litellm/llms/custom_httpx/http_handler.py @@ -40,7 +40,9 @@ headers = { _DEFAULT_TIMEOUT = httpx.Timeout(timeout=5.0, connect=5.0) -def get_ssl_configuration(ssl_verify: Optional[VerifyTypes] = None) -> Union[bool, str, ssl.SSLContext]: +def get_ssl_configuration( + ssl_verify: Optional[VerifyTypes] = None, +) -> Union[bool, str, ssl.SSLContext]: """ Unified SSL configuration function that handles ssl_context and ssl_verify logic. @@ -59,7 +61,7 @@ def get_ssl_configuration(ssl_verify: Optional[VerifyTypes] = None) -> Union[boo - False: Disable SSL verification - True: Enable SSL verification - str: Path to CA bundle file - + Returns: Union[bool, str, ssl.SSLContext]: Appropriate SSL configuration """ @@ -72,7 +74,9 @@ def get_ssl_configuration(ssl_verify: Optional[VerifyTypes] = None) -> Union[boo # Get ssl_verify from environment or litellm settings if not provided if ssl_verify is None: ssl_verify = os.getenv("SSL_VERIFY", litellm.ssl_verify) - ssl_verify_bool = str_to_bool(ssl_verify) if isinstance(ssl_verify, str) else ssl_verify + ssl_verify_bool = ( + str_to_bool(ssl_verify) if isinstance(ssl_verify, str) else ssl_verify + ) if ssl_verify_bool is not None: ssl_verify = ssl_verify_bool @@ -89,14 +93,9 @@ def get_ssl_configuration(ssl_verify: Optional[VerifyTypes] = None) -> Union[boo cafile = certifi.where() if ssl_verify is not False: - custom_ssl_context = ssl.create_default_context( - cafile=cafile - ) + custom_ssl_context = ssl.create_default_context(cafile=cafile) # If security level is set, apply it to the SSL context - if ( - ssl_security_level - and isinstance(ssl_security_level, str) - ): + if ssl_security_level and isinstance(ssl_security_level, str): # Create a custom SSL context with reduced security level custom_ssl_context.set_ciphers(ssl_security_level) @@ -260,6 +259,7 @@ class AsyncHTTPHandler: files: Optional[RequestFiles] = None, content: Any = None, ): + start_time = time.time() try: if timeout is None: @@ -586,7 +586,7 @@ class AsyncHTTPHandler: ) -> Dict[str, Any]: """ Helper method to get SSL connector initialization arguments for aiohttp TCPConnector. - + SSL Configuration Priority: 1. If ssl_context is provided -> use the custom SSL context 2. If ssl_verify is False -> disable SSL verification (ssl=False) @@ -597,14 +597,14 @@ class AsyncHTTPHandler: connector_kwargs: Dict[str, Any] = { "local_addr": ("0.0.0.0", 0) if litellm.force_ipv4 else None, } - + if ssl_context is not None: # Priority 1: Use the provided custom SSL context connector_kwargs["ssl"] = ssl_context elif ssl_verify is False: # Priority 2: Explicitly disable SSL verification connector_kwargs["verify_ssl"] = False - + return connector_kwargs @staticmethod diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py index 3e7dff91820..2faea53901c 100644 --- a/litellm/llms/custom_httpx/llm_http_handler.py +++ b/litellm/llms/custom_httpx/llm_http_handler.py @@ -111,6 +111,7 @@ class BaseLLMHTTPHandler: response: Optional[httpx.Response] = None for i in range(max(max_retry_on_unprocessable_entity_error, 1)): try: + response = await async_httpx_client.post( url=api_base, headers=headers, @@ -1256,6 +1257,10 @@ class BaseLLMHTTPHandler: stream: Optional[bool] = False, kwargs: Optional[Dict[str, Any]] = None, ) -> Union[AnthropicMessagesResponse, AsyncIterator]: + from litellm.litellm_core_utils.get_provider_specific_headers import ( + ProviderSpecificHeaderUtils, + ) + if client is None or not isinstance(client, AsyncHTTPHandler): async_httpx_client = get_async_httpx_client( llm_provider=litellm.LlmProviders.ANTHROPIC @@ -1269,10 +1274,9 @@ class BaseLLMHTTPHandler: Optional[litellm.types.utils.ProviderSpecificHeader], kwargs.get("provider_specific_header", None), ) - extra_headers = ( - provider_specific_header.get("extra_headers", {}) - if provider_specific_header - else {} + extra_headers = ProviderSpecificHeaderUtils.get_provider_specific_headers( + provider_specific_header=provider_specific_header, + custom_llm_provider=custom_llm_provider, ) ( headers, @@ -2677,6 +2681,7 @@ class BaseLLMHTTPHandler: _is_async: bool = False, fake_stream: bool = False, litellm_metadata: Optional[Dict[str, Any]] = None, + api_key: Optional[str] = None, ) -> Union[ ImageResponse, Coroutine[Any, Any, ImageResponse], @@ -2701,6 +2706,7 @@ class BaseLLMHTTPHandler: client=client if isinstance(client, AsyncHTTPHandler) else None, fake_stream=fake_stream, litellm_metadata=litellm_metadata, + api_key=api_key, ) if client is None or not isinstance(client, HTTPHandler): @@ -2711,8 +2717,9 @@ class BaseLLMHTTPHandler: sync_httpx_client = client headers = image_generation_provider_config.validate_environment( - api_key=litellm_params.get("api_key", None), - headers=image_generation_optional_request_params.get("extra_headers", {}) or {}, + api_key=api_key, + headers=image_generation_optional_request_params.get("extra_headers", {}) + or {}, model=model, messages=[], optional_params=image_generation_optional_request_params, @@ -2763,15 +2770,17 @@ class BaseLLMHTTPHandler: provider_config=image_generation_provider_config, ) - model_response: ImageResponse = image_generation_provider_config.transform_image_generation_response( - model=model, - raw_response=response, - model_response=litellm.ImageResponse(), - logging_obj=logging_obj, - request_data=data, - optional_params=image_generation_optional_request_params, - litellm_params=dict(litellm_params), - encoding=None, + model_response: ImageResponse = ( + image_generation_provider_config.transform_image_generation_response( + model=model, + raw_response=response, + model_response=litellm.ImageResponse(), + logging_obj=logging_obj, + request_data=data, + optional_params=image_generation_optional_request_params, + litellm_params=dict(litellm_params), + encoding=None, + ) ) return model_response @@ -2791,6 +2800,7 @@ class BaseLLMHTTPHandler: client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None, fake_stream: bool = False, litellm_metadata: Optional[Dict[str, Any]] = None, + api_key: Optional[str] = None, ) -> ImageResponse: """ Async version of the image generation handler. @@ -2804,10 +2814,10 @@ class BaseLLMHTTPHandler: else: async_httpx_client = client - headers = image_generation_provider_config.validate_environment( - api_key=litellm_params.get("api_key", None), - headers=image_generation_optional_request_params.get("extra_headers", {}) or {}, + api_key=api_key, + headers=image_generation_optional_request_params.get("extra_headers", {}) + or {}, model=model, messages=[], optional_params=image_generation_optional_request_params, @@ -2858,17 +2868,19 @@ class BaseLLMHTTPHandler: provider_config=image_generation_provider_config, ) - model_response: ImageResponse = image_generation_provider_config.transform_image_generation_response( - model=model, - raw_response=response, - model_response=litellm.ImageResponse(), - logging_obj=logging_obj, - request_data=data, - optional_params=image_generation_optional_request_params, - litellm_params=dict(litellm_params), - encoding=None, + model_response: ImageResponse = ( + image_generation_provider_config.transform_image_generation_response( + model=model, + raw_response=response, + model_response=litellm.ImageResponse(), + logging_obj=logging_obj, + request_data=data, + optional_params=image_generation_optional_request_params, + litellm_params=dict(litellm_params), + encoding=None, + ) ) - + return model_response ###### VECTOR STORE HANDLER ###### @@ -2936,7 +2948,9 @@ class BaseLLMHTTPHandler: }, ) - request_data = json.dumps(request_body) if signed_json_body is None else signed_json_body + request_data = ( + json.dumps(request_body) if signed_json_body is None else signed_json_body + ) try: response = await async_httpx_client.post( @@ -3035,7 +3049,9 @@ class BaseLLMHTTPHandler: }, ) - request_data = json.dumps(request_body) if signed_json_body is None else signed_json_body + request_data = ( + json.dumps(request_body) if signed_json_body is None else signed_json_body + ) try: response = sync_httpx_client.post( diff --git a/litellm/llms/datarobot/chat/transformation.py b/litellm/llms/datarobot/chat/transformation.py index e334c94e517..23ce63c25b2 100644 --- a/litellm/llms/datarobot/chat/transformation.py +++ b/litellm/llms/datarobot/chat/transformation.py @@ -6,8 +6,11 @@ Calls done in OpenAI/openai.py as DataRobot is openai-compatible. from typing import Optional, Tuple from litellm.secret_managers.main import get_secret_str +from urllib.parse import urlparse, urlunparse from ...openai_like.chat.transformation import OpenAILikeChatConfig +LLMGW_PATH = "/genai/llmgw/chat/completions" + class DataRobotConfig(OpenAILikeChatConfig): @staticmethod @@ -32,22 +35,28 @@ class DataRobotConfig(OpenAILikeChatConfig): if api_base is None: api_base = "https://app.datarobot.com" - # If the api_base is a deployment URL, we do not append the chat completions path - if "api/v2/deployments" not in api_base: - # If the api_base is not a deployment URL, we need to append the chat completions path - if "api/v2/genai/llmgw/chat/completions" not in api_base: - api_base += "/api/v2/genai/llmgw/chat/completions" + parsed = urlparse(api_base) + path = parsed.path + + if not path or path == "/": # Add full path to LLMGW + path += f"/api/v2/{LLMGW_PATH}" + elif "api/v2/deployments" in path: # Dedicated deployment, leave it + pass + elif ( + "api/v2" in path and LLMGW_PATH not in path + ): # Standard ENDPOINT path, add LLMGW + path += LLMGW_PATH # Ensure the url ends with a trailing slash - if not api_base.endswith("/"): - api_base += "/" + if not path.endswith("/"): + path += "/" + path = path.replace("//", "/") + updated_parsed = parsed._replace(path=path) - return api_base # type: ignore + return urlunparse(updated_parsed) def _get_openai_compatible_provider_info( - self, - api_base: Optional[str], - api_key: Optional[str] + self, api_base: Optional[str], api_key: Optional[str] ) -> Tuple[Optional[str], Optional[str]]: """Attempts to ensure that the API base and key are set, preferring user-provided values, before falling back to secret manager values (``DATAROBOT_ENDPOINT`` and ``DATAROBOT_API_TOKEN`` diff --git a/litellm/llms/deepinfra/rerank/transformation.py b/litellm/llms/deepinfra/rerank/transformation.py new file mode 100644 index 00000000000..8259c6075bb --- /dev/null +++ b/litellm/llms/deepinfra/rerank/transformation.py @@ -0,0 +1,239 @@ +""" +Translate between Cohere's `/rerank` format and Deepinfra's `/rerank` format. +""" + +import uuid +from typing import Any, Dict, List, Optional, Union + +import httpx + +from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj +from litellm.llms.base_llm.rerank.transformation import ( + BaseLLMException, + BaseRerankConfig, +) +from litellm.secret_managers.main import get_secret_str +from litellm.types.rerank import ( + OptionalRerankParams, + RerankBilledUnits, + RerankResponse, + RerankResponseMeta, + RerankResponseResult, + RerankTokens, +) + + +class DeepinfraRerankConfig(BaseRerankConfig): + """ + Deepinfra Rerank - Follows the same Spec as Cohere Rerank + """ + + def get_complete_url(self, api_base: Optional[str], model: str) -> str: + """ + Constructs the complete DeepInfra inference endpoint URL for rerank. + + Args: + api_base (Optional[str]): The base URL for the DeepInfra API. + model (str): The model identifier. + + Returns: + str: The complete URL for the DeepInfra rerank inference endpoint. + + Raises: + ValueError: If api_base is None. + """ + if not api_base: + raise ValueError( + "Deepinfra API Base is required. api_base=None. Set in call or via `DEEPINFRA_API_BASE` env var." + ) + + # Remove 'openai' from the base if present + api_base_clean = ( + api_base.replace("openai", "") if "openai" in api_base else api_base + ) + + # Remove any trailing slashes for consistency, then add one + api_base_clean = api_base_clean.rstrip("/") + "/" + + # Compose the full endpoint + return f"{api_base_clean}inference/{model}" + + def validate_environment( + self, + headers: dict, + model: str, + api_key: Optional[str] = None, + ) -> dict: + if api_key is None: + api_key = get_secret_str("DEEPINFRA_API_KEY") + + if api_key is None: + raise ValueError( + "Deepinfra API key is required. Please set 'DEEPINFRA_API_KEY' environment variable" + ) + + default_headers = { + "Authorization": f"Bearer {api_key}", + "accept": "application/json", + "content-type": "application/json", + } + + # If 'Authorization' is provided in headers, it overrides the default. + if "Authorization" in headers: + default_headers["Authorization"] = headers["Authorization"] + + # Merge other headers, overriding any default ones except Authorization + return {**default_headers, **headers} + + def map_cohere_rerank_params( + self, + non_default_params: dict, + model: str, + drop_params: bool, + query: str, + documents: List[Union[str, Dict[str, Any]]], + custom_llm_provider: Optional[str] = None, + top_n: Optional[int] = None, + rank_fields: Optional[List[str]] = None, + return_documents: Optional[bool] = True, + max_chunks_per_doc: Optional[int] = None, + max_tokens_per_doc: Optional[int] = None, + ) -> OptionalRerankParams: + # Start with the basic parameters + optional_rerank_params = {} + if query: + optional_rerank_params["queries"] = [query] * len( + documents + ) # Deepinfra rerank requires queries to be of same length as documents + + if non_default_params is not None: + for k, v in non_default_params.items(): + if k == "queries" and v is not None: + # This should override the query parameter if it is provided + optional_rerank_params["queries"] = v + elif k == "documents" and v is not None: + optional_rerank_params["documents"] = v + elif k == "service_tier" and v is not None: + optional_rerank_params["service_tier"] = v + elif k == "instruction" and v is not None: + optional_rerank_params["instruction"] = v + elif k == "webhook" and v is not None: + optional_rerank_params["webhook"] = v + return OptionalRerankParams(**optional_rerank_params) # type: ignore + + def transform_rerank_request( + self, + model: str, + optional_rerank_params: OptionalRerankParams, + headers: dict, + ) -> dict: + # Convert OptionalRerankParams to dict as expected by parent class + if optional_rerank_params is None: + return {} + return dict(optional_rerank_params) + + def transform_rerank_response( + self, + model: str, + raw_response: httpx.Response, + model_response: RerankResponse, + logging_obj: LiteLLMLoggingObj, + api_key: Optional[str] = None, + request_data: dict = {}, + optional_params: dict = {}, + litellm_params: dict = {}, + ) -> RerankResponse: + try: + response_json = raw_response.json() + logging_obj.post_call(original_response=raw_response.text) + + # Extract the scores from the response + scores = response_json.get("scores", []) + input_tokens = response_json.get("input_tokens", 0) + request_id = response_json.get("request_id") + + # Create inference status information + inference_status = response_json.get("inference_status", {}) + status = inference_status.get("status", "unknown") + runtime_ms = inference_status.get("runtime_ms", 0) + cost = inference_status.get("cost", 0.0) + tokens_generated = inference_status.get("tokens_generated", 0) + tokens_input = inference_status.get("tokens_input", 0) + + # Create RerankResponse + results = [] + for i, score in enumerate(scores): + results.append( + RerankResponseResult(index=i, relevance_score=float(score)) + ) + + # Create metadata for the response + tokens = RerankTokens( + input_tokens=input_tokens, + output_tokens=0, # DeepInfra doesn't provide output tokens for rerank + ) + billed_units = RerankBilledUnits(total_tokens=input_tokens) + meta = RerankResponseMeta(tokens=tokens, billed_units=billed_units) + + rerank_response = RerankResponse( + id=request_id or str(uuid.uuid4()), results=results, meta=meta + ) + + # Store additional information in hidden params + rerank_response._hidden_params = { + "status": status, + "runtime_ms": runtime_ms, + "cost": cost, + "tokens_generated": tokens_generated, + "tokens_input": tokens_input, + "model": model, + } + + return rerank_response + + except Exception: + # If there's an error parsing the response, fall back to the parent implementation + rerank_response = super().transform_rerank_response( + model=model, + raw_response=raw_response, + model_response=model_response, + logging_obj=logging_obj, + api_key=api_key, + request_data=request_data, + optional_params=optional_params, + litellm_params=litellm_params, + ) + + rerank_response._hidden_params["model"] = model + return rerank_response + + def get_supported_cohere_rerank_params(self, model: str) -> list: + return ["query", "documents"] + + def get_error_class( + self, error_message: str, status_code: int, headers: Union[dict, httpx.Headers] + ) -> BaseLLMException: + # Deepinfra errors may come as JSON: {"detail": {"error": "..."}} + import json + + # Try to extract a more specific error message if possible + try: + error_data = error_message + if isinstance(error_message, str): + error_data = json.loads(error_message) + if isinstance(error_data, dict): + # Check for {"detail": {"error": "..."}} + detail = error_data.get("detail") + if isinstance(detail, dict) and "error" in detail: + error_message = detail["error"] + elif isinstance(detail, str): + error_message = detail + except Exception: + # If parsing fails, just use the original error_message + pass + + raise BaseLLMException( + status_code=status_code, + message=error_message, + headers=headers, + ) diff --git a/litellm/llms/github_copilot/chat/transformation.py b/litellm/llms/github_copilot/chat/transformation.py index 4526e6247b4..66227ac21d8 100644 --- a/litellm/llms/github_copilot/chat/transformation.py +++ b/litellm/llms/github_copilot/chat/transformation.py @@ -75,8 +75,36 @@ class GithubCopilotConfig(OpenAIConfig): initiator = self._determine_initiator(messages) validated_headers["X-Initiator"] = initiator + # Add Copilot-Vision-Request header if request contains images + if self._has_vision_content(messages): + validated_headers["Copilot-Vision-Request"] = "true" + return validated_headers + def get_supported_openai_params(self, model: str) -> list: + """ + Get supported OpenAI parameters for GitHub Copilot. + + For Claude models that support extended thinking (Claude 4 family and Claude 3-7), includes thinking and reasoning_effort parameters. + For other models, returns standard OpenAI parameters (which may include reasoning_effort for o-series models). + """ + from litellm.utils import supports_reasoning + + # Get base OpenAI parameters + base_params = super().get_supported_openai_params(model) + + # Add Claude-specific parameters for models that support extended thinking + if "claude" in model.lower() and supports_reasoning( + model=model.lower(), + ): + if "thinking" not in base_params: + base_params.append("thinking") + # reasoning_effort is not included by parent for Claude models, so add it + if "reasoning_effort" not in base_params: + base_params.append("reasoning_effort") + + return base_params + def _determine_initiator(self, messages: List[AllMessageValues]) -> str: """ Determine if request is user or agent initiated based on message roles. @@ -87,3 +115,27 @@ class GithubCopilotConfig(OpenAIConfig): if role in ["tool", "assistant"]: return "agent" return "user" + + def _has_vision_content(self, messages: List[AllMessageValues]) -> bool: + """ + Check if any message contains vision content (images). + Returns True if any message has content with vision-related types, otherwise False. + + Checks for: + - image_url content type (OpenAI format) + - Content items with type 'image_url' + """ + for message in messages: + content = message.get("content") + if isinstance(content, list): + # Check if any content item indicates vision content + for content_item in content: + if isinstance(content_item, dict): + # Check for image_url field (direct image URL) + if "image_url" in content_item: + return True + # Check for type field indicating image content + content_type = content_item.get("type") + if content_type == "image_url": + return True + return False diff --git a/litellm/llms/github_copilot/common_utils.py b/litellm/llms/github_copilot/common_utils.py index 4c9a4b6dad0..86fbb706e52 100644 --- a/litellm/llms/github_copilot/common_utils.py +++ b/litellm/llms/github_copilot/common_utils.py @@ -28,7 +28,6 @@ class GithubCopilotError(BaseLLMException): ) - class GetDeviceCodeError(GithubCopilotError): pass diff --git a/litellm/llms/hosted_vllm/chat/transformation.py b/litellm/llms/hosted_vllm/chat/transformation.py index 529354f80eb..1d21490ea31 100644 --- a/litellm/llms/hosted_vllm/chat/transformation.py +++ b/litellm/llms/hosted_vllm/chat/transformation.py @@ -21,6 +21,11 @@ from ...openai.chat.gpt_transformation import OpenAIGPTConfig class HostedVLLMChatConfig(OpenAIGPTConfig): + def get_supported_openai_params(self, model: str) -> List[str]: + params = super().get_supported_openai_params(model) + params.append("reasoning_effort") + return params + def map_openai_params( self, non_default_params: dict, diff --git a/litellm/llms/litellm_proxy/image_edit/transformation.py b/litellm/llms/litellm_proxy/image_edit/transformation.py new file mode 100644 index 00000000000..5f5e2bdb24d --- /dev/null +++ b/litellm/llms/litellm_proxy/image_edit/transformation.py @@ -0,0 +1,26 @@ +from typing import Optional + +from litellm.llms.openai.image_edit.transformation import OpenAIImageEditConfig +from litellm.secret_managers.main import get_secret_str + + +class LiteLLMProxyImageEditConfig(OpenAIImageEditConfig): + """Configuration for image edit requests routed through LiteLLM Proxy.""" + + def validate_environment( + self, headers: dict, model: str, api_key: Optional[str] = None + ) -> dict: + api_key = api_key or get_secret_str("LITELLM_PROXY_API_KEY") + headers.update({"Authorization": f"Bearer {api_key}"}) + return headers + + def get_complete_url( + self, model: str, api_base: Optional[str], litellm_params: dict + ) -> str: + api_base = api_base or get_secret_str("LITELLM_PROXY_API_BASE") + if api_base is None: + raise ValueError( + "api_base not set for LiteLLM Proxy route. Set in env via `LITELLM_PROXY_API_BASE`" + ) + api_base = api_base.rstrip("/") + return f"{api_base}/images/edits" diff --git a/litellm/llms/litellm_proxy/image_generation/transformation.py b/litellm/llms/litellm_proxy/image_generation/transformation.py new file mode 100644 index 00000000000..6174424154d --- /dev/null +++ b/litellm/llms/litellm_proxy/image_generation/transformation.py @@ -0,0 +1,40 @@ +from typing import Optional + +from litellm.llms.openai.image_generation.gpt_transformation import ( + GPTImageGenerationConfig, +) +from litellm.secret_managers.main import get_secret_str + + +class LiteLLMProxyImageGenerationConfig(GPTImageGenerationConfig): + """Configuration for image generation requests routed through LiteLLM Proxy.""" + def validate_environment( + self, + headers: dict, + model: str, + messages, + optional_params: dict, + litellm_params: dict, + api_key: Optional[str] = None, + api_base: Optional[str] = None, + ) -> dict: + api_key = api_key or get_secret_str("LITELLM_PROXY_API_KEY") + headers.update({"Authorization": f"Bearer {api_key}"}) + return headers + + def get_complete_url( + self, + api_base: Optional[str], + api_key: Optional[str], + model: str, + optional_params: dict, + litellm_params: dict, + stream: Optional[bool] = None, + ) -> str: + api_base = api_base or get_secret_str("LITELLM_PROXY_API_BASE") + if api_base is None: + raise ValueError( + "api_base not set for LiteLLM Proxy route. Set in env via `LITELLM_PROXY_API_BASE`" + ) + api_base = api_base.rstrip("/") + return f"{api_base}/images/generations" diff --git a/litellm/llms/mistral/chat/transformation.py b/litellm/llms/mistral/chat/transformation.py index b38a4982471..51fa65244a0 100644 --- a/litellm/llms/mistral/chat/transformation.py +++ b/litellm/llms/mistral/chat/transformation.py @@ -6,7 +6,18 @@ Why separate file? Make it easy to see how transformation works Docs - https://docs.mistral.ai/api/ """ -from typing import Any, Coroutine, List, Literal, Optional, Tuple, Union, cast, overload +from typing import ( + Any, + Coroutine, + List, + Literal, + Optional, + Tuple, + Union, + cast, + get_type_hints, + overload, +) import httpx @@ -17,7 +28,7 @@ from litellm.litellm_core_utils.prompt_templates.common_utils import ( ) from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig from litellm.secret_managers.main import get_secret_str -from litellm.types.llms.mistral import MistralToolCallMessage +from litellm.types.llms.mistral import MistralThinkingBlock, MistralToolCallMessage from litellm.types.llms.openai import AllMessageValues from litellm.types.utils import ModelResponse from litellm.utils import convert_to_model_response_object @@ -145,7 +156,9 @@ class MistralConfig(OpenAIGPTConfig): for param, value in non_default_params.items(): if param == "max_tokens": optional_params["max_tokens"] = value - if param == "max_completion_tokens": # max_completion_tokens should take priority + if ( + param == "max_completion_tokens" + ): # max_completion_tokens should take priority optional_params["max_tokens"] = value if param == "tools": # Clean tools to remove problematic schema fields for Mistral API @@ -159,7 +172,9 @@ class MistralConfig(OpenAIGPTConfig): if param == "stop": optional_params["stop"] = value if param == "tool_choice" and isinstance(value, str): - optional_params["tool_choice"] = self._map_tool_choice(tool_choice=value) + optional_params["tool_choice"] = self._map_tool_choice( + tool_choice=value + ) if param == "seed": optional_params["extra_body"] = {"random_seed": value} if param == "response_format": @@ -185,7 +200,9 @@ class MistralConfig(OpenAIGPTConfig): ) # type: ignore # if api_base does not end with /v1 we add it - if api_base is not None and not api_base.endswith("/v1"): # Mistral always needs a /v1 at the end + if api_base is not None and not api_base.endswith( + "/v1" + ): # Mistral always needs a /v1 at the end api_base = api_base + "/v1" dynamic_api_key = ( api_key @@ -194,10 +211,12 @@ class MistralConfig(OpenAIGPTConfig): ) return api_base, dynamic_api_key + # fmt: off + @overload def _transform_messages( self, messages: List[AllMessageValues], model: str, is_async: Literal[True] - ) -> Coroutine[Any, Any, List[AllMessageValues]]: + ) -> Coroutine[Any, Any, List[AllMessageValues]]: ... @overload @@ -206,8 +225,9 @@ class MistralConfig(OpenAIGPTConfig): messages: List[AllMessageValues], model: str, is_async: Literal[False] = False, - ) -> List[AllMessageValues]: + ) -> List[AllMessageValues]: ... + # fmt: on def _transform_messages( self, messages: List[AllMessageValues], model: str, is_async: bool = False @@ -218,18 +238,20 @@ class MistralConfig(OpenAIGPTConfig): - if image passed in, then just return as is (user-intended) - if `name` is passed, then drop it for mistral API: https://github.com/BerriAI/litellm/issues/6696 - Motivation: mistral api doesn't support content as a list + Motivation: mistral api doesn't support content as a list. + The above statement is not valid now. Need to plan to remove all the #1,2,3 + Mistral API supports content as a list. """ - ## 1. If 'image_url' in content, then return as is + ## 1. If 'image_url' or 'file' in content, then transform with base class and mistral-specific handling for m in messages: _content_block = m.get("content") if _content_block and isinstance(_content_block, list): - for c in _content_block: - if c.get("type") == "image_url": - if is_async: - return super()._transform_messages(messages, model, True) - else: - return super()._transform_messages(messages, model, False) + if any(c.get("type") in ["image_url", "file"] for c in _content_block): + if is_async: + return self._transform_messages_async(messages, model) + else: + messages = self._transform_messages_sync(messages, model) + return messages ## 2. If content is list, then convert to string messages = handle_messages_with_content_list_to_str_conversion(messages) @@ -239,6 +261,8 @@ class MistralConfig(OpenAIGPTConfig): for m in messages: m = MistralConfig._handle_name_in_message(m) m = MistralConfig._handle_tool_call_message(m) + if MistralConfig._is_empty_assistant_message(m): + continue m = strip_none_values_from_message(m) # prevents 'extra_forbidden' error new_messages.append(m) @@ -247,6 +271,51 @@ class MistralConfig(OpenAIGPTConfig): else: return super()._transform_messages(new_messages, model, False) + async def _transform_messages_async(self, + messages: List[AllMessageValues], model: str + ) -> List[AllMessageValues]: + """ + Handle modification of messages for Mistral API in an async context. + """ + # Call parent async method to handle basic transformations + # and then apply Mistral-specific handling for files + messages = await super()._transform_messages(messages, model, True) + messages = self._handle_message_with_file(messages) + return messages + + def _transform_messages_sync(self, + messages: List[AllMessageValues], model: str + ) -> List[AllMessageValues]: + """ Handle modification of messages for Mistral API in a sync context. + """ + # Call parent sync method to handle basic transformations + # and then apply Mistral-specific handling for files + # This is the sync version of the async method above + messages = super()._transform_messages(messages, model, False) + messages = self._handle_message_with_file(messages) + return messages + + def _handle_message_with_file( + self, + messages: List[AllMessageValues]) -> List[AllMessageValues]: + """ + Mistral API supports only 'file_id' in message content with type 'file'. + """ + for m in messages: + _content_block = m.get("content") + if _content_block and isinstance(_content_block, list): + if any(c.get("type") == "file" for c in _content_block): + # If file content is present, we get file_id from 'file' attribute of content block + # then replace 'file' with 'file_id' and assign the value of 'file_id' attribute to it. + file_contents = [c for c in _content_block if c.get("type") == "file"] + for file_content in file_contents: + file_id = file_content.get("file", {}).get("file_id") + if file_id: + # Replace 'file' with 'file_id' + file_content["file_id"] = file_id # type: ignore + file_content.pop("file", None) + return messages + def _add_reasoning_system_prompt_if_needed( self, messages: List[AllMessageValues], optional_params: dict ) -> List[AllMessageValues]: @@ -269,20 +338,30 @@ class MistralConfig(OpenAIGPTConfig): # Handle both string and list content, preserving original format if isinstance(existing_content, str): # String content - prepend reasoning prompt - new_content: Union[str, list] = f"{reasoning_prompt}\n\n{existing_content}" + new_content: Union[str, list] = ( + f"{reasoning_prompt}\n\n{existing_content}" + ) elif isinstance(existing_content, list): # List content - prepend reasoning prompt as text block - new_content = [{"type": "text", "text": reasoning_prompt + "\n\n"}] + existing_content + new_content = [ + {"type": "text", "text": reasoning_prompt + "\n\n"} + ] + existing_content else: # Fallback for any other type - convert to string new_content = f"{reasoning_prompt}\n\n{str(existing_content)}" - messages[i] = cast(AllMessageValues, {**msg, "content": new_content}) + messages[i] = cast( + AllMessageValues, {**msg, "content": new_content} + ) break else: # Add new system message with reasoning instructions reasoning_message: AllMessageValues = cast( - AllMessageValues, {"role": "system", "content": self._get_mistral_reasoning_system_prompt()} + AllMessageValues, + { + "role": "system", + "content": self._get_mistral_reasoning_system_prompt(), + }, ) messages = [reasoning_message] + messages @@ -294,32 +373,34 @@ class MistralConfig(OpenAIGPTConfig): def _clean_tool_schema_for_mistral(cls, tools: list) -> list: """ Clean tool schemas to remove fields that cause issues with Mistral API. - + Removes: - $id and $schema fields (cause grammar validation errors) - additionalProperties=False (causes OpenAI API schema errors) - strict field (not supported by Mistral) - + Args: tools: List of tool definitions max_depth: Maximum recursion depth for schema cleaning (default: 10) - + Returns: Cleaned tools list """ if not tools: return tools - + import copy from litellm.constants import DEFAULT_MAX_RECURSE_DEPTH from litellm.utils import _remove_json_schema_refs cleaned_tools = copy.deepcopy(tools) - + # Apply all cleaning functions with max_depth protection - cleaned_tools = _remove_json_schema_refs(cleaned_tools, max_depth=DEFAULT_MAX_RECURSE_DEPTH) - + cleaned_tools = _remove_json_schema_refs( + cleaned_tools, max_depth=DEFAULT_MAX_RECURSE_DEPTH + ) + return cleaned_tools @classmethod @@ -360,6 +441,25 @@ class MistralConfig(OpenAIGPTConfig): message["tool_calls"] = mistral_tool_calls # type: ignore return message + @classmethod + def _is_empty_assistant_message(cls, message: AllMessageValues) -> bool: + """ + Mistral API does not support empty string in assistant content. + """ + from litellm.types.llms.openai import ChatCompletionAssistantMessage + + set_keys = get_type_hints(ChatCompletionAssistantMessage).keys() + + all_expected_values_are_empty = True + for key in set_keys: + if key != "role" and message.get(key) is not None: + if key == "content" and message.get(key) == "": + continue + else: + all_expected_values_are_empty = False + break + return all_expected_values_are_empty + @staticmethod def _handle_empty_content_response(response_data: dict) -> dict: """ @@ -380,6 +480,58 @@ class MistralConfig(OpenAIGPTConfig): choice["message"]["content"] = None return response_data + @staticmethod + def _convert_thinking_block_to_reasoning_content( + thinking_blocks: MistralThinkingBlock, + ) -> str: + """ + Convert Mistral thinking blocks to reasoning content. + """ + return "\n".join( + [block.get("text", "") for block in thinking_blocks["thinking"]] + ) + + @staticmethod + def _handle_content_list_to_str_conversion(response_data: dict) -> dict: + """ + Handle Mistral's content list format and extract thinking content. + + Map mistral's content list to string and extract thinking blocks: + - Thinking block -> reasoning_content field + - Text block -> content field + """ + + if response_data.get("choices") and len(response_data["choices"]) > 0: + for choice in response_data["choices"]: + if choice.get("message") and choice["message"].get("content"): + content = choice["message"]["content"] + + # Only process if content is a list + if isinstance(content, list): + thinking_content = "" + text_content = "" + + # Process each content block + for block in content: + if block.get("type") == "thinking": + thinking_blocks = block.get("thinking", []) + thinking_texts = [] + for thinking_block in thinking_blocks: + if thinking_block.get("type") == "text": + thinking_texts.append( + thinking_block.get("text", "") + ) + thinking_content = "\n".join(thinking_texts) + elif block.get("type") == "text": + text_content = block.get("text", "") + + # Set the extracted content + choice["message"]["content"] = text_content + if thinking_content: + choice["message"]["reasoning_content"] = thinking_content + + return response_data + def transform_request( self, model: str, @@ -396,8 +548,12 @@ class MistralConfig(OpenAIGPTConfig): dict: The transformed request. Sent as the body of the API call. """ # Add reasoning system prompt if needed (for magistral models) - if "magistral" in model.lower() and optional_params.get("_add_reasoning_prompt", False): - messages = self._add_reasoning_system_prompt_if_needed(messages, optional_params) + if "magistral" in model.lower() and optional_params.get( + "_add_reasoning_prompt", False + ): + messages = self._add_reasoning_system_prompt_if_needed( + messages, optional_params + ) # Call parent transform_request which handles _transform_messages return super().transform_request( @@ -424,14 +580,16 @@ class MistralConfig(OpenAIGPTConfig): ) -> ModelResponse: """ Transform the raw response from Mistral API. - Handles Mistral-specific behavior like converting empty string content to None. + Handles Mistral-specific behavior like converting empty string content to None + and extracting thinking content from content lists. """ logging_obj.post_call(original_response=raw_response.text) logging_obj.model_call_details["response_headers"] = raw_response.headers - # Handle Mistral-specific empty string content conversion to None + # Handle Mistral-specific response transformations response_data = raw_response.json() response_data = self._handle_empty_content_response(response_data) + response_data = self._handle_content_list_to_str_conversion(response_data) final_response_obj = cast( ModelResponse, diff --git a/litellm/llms/ollama/completion/transformation.py b/litellm/llms/ollama/completion/transformation.py index aa1da616d89..4f7be507cc2 100644 --- a/litellm/llms/ollama/completion/transformation.py +++ b/litellm/llms/ollama/completion/transformation.py @@ -24,6 +24,8 @@ from litellm.types.utils import ( ModelResponse, ModelResponseStream, ProviderField, + StreamingChoices, + Delta, ) from ..common_utils import OllamaError, _convert_image @@ -260,38 +262,52 @@ class OllamaConfig(BaseConfig): ## RESPONSE OBJECT model_response.choices[0].finish_reason = "stop" if request_data.get("format", "") == "json": - response_content = json.loads(response_json["response"]) - - # Check if this is a function call format with name/arguments structure - if ( - isinstance(response_content, dict) - and "name" in response_content - and "arguments" in response_content - ): - # Handle as function call (original behavior) - function_call = response_content - message = litellm.Message( - content=None, - tool_calls=[ - { - "id": f"call_{str(uuid.uuid4())}", - "function": { - "name": function_call["name"], - "arguments": json.dumps(function_call["arguments"]), - }, - "type": "function", - } - ], - ) - model_response.choices[0].message = message # type: ignore - model_response.choices[0].finish_reason = "tool_calls" - else: - # Handle as regular JSON (new behavior) - message = litellm.Message( - content=json.dumps(response_content), - ) + # Check if response field exists and is not empty before parsing JSON + response_text = response_json.get("response", "") + if not response_text or not response_text.strip(): + # Handle empty response gracefully - set empty content + message = litellm.Message(content="") model_response.choices[0].message = message # type: ignore model_response.choices[0].finish_reason = "stop" + else: + try: + response_content = json.loads(response_text) + + # Check if this is a function call format with name/arguments structure + if ( + isinstance(response_content, dict) + and "name" in response_content + and "arguments" in response_content + ): + # Handle as function call (original behavior) + function_call = response_content + message = litellm.Message( + content=None, + tool_calls=[ + { + "id": f"call_{str(uuid.uuid4())}", + "function": { + "name": function_call["name"], + "arguments": json.dumps(function_call["arguments"]), + }, + "type": "function", + } + ], + ) + model_response.choices[0].message = message # type: ignore + model_response.choices[0].finish_reason = "tool_calls" + else: + # Handle as regular JSON (new behavior) + message = litellm.Message( + content=json.dumps(response_content), + ) + model_response.choices[0].message = message # type: ignore + model_response.choices[0].finish_reason = "stop" + except json.JSONDecodeError: + # If JSON parsing fails, treat as regular text response + message = litellm.Message(content=response_text) + model_response.choices[0].message = message # type: ignore + model_response.choices[0].finish_reason = "stop" else: model_response.choices[0].message.content = response_json["response"] # type: ignore model_response.created = int(time.time()) @@ -423,7 +439,7 @@ class OllamaTextCompletionResponseIterator(BaseModelResponseIterator): ) -> Union[GenericStreamingChunk, ModelResponseStream]: return self.chunk_parser(json.loads(str_line)) - def chunk_parser(self, chunk: dict) -> GenericStreamingChunk: + def chunk_parser(self, chunk: dict) -> Union[GenericStreamingChunk, ModelResponseStream]: try: if "error" in chunk: raise Exception(f"Ollama Error - {chunk}") @@ -459,6 +475,17 @@ class OllamaTextCompletionResponseIterator(BaseModelResponseIterator): finish_reason="stop", usage=None, ) + elif "thinking" in chunk and not chunk["response"]: + # Return reasoning content as ModelResponseStream so UIs can render it + thinking_content = chunk.get("thinking") or "" + return ModelResponseStream( + choices=[ + StreamingChoices( + index=0, + delta=Delta(reasoning_content=thinking_content), + ) + ] + ) else: raise Exception(f"Unable to parse ollama chunk - {chunk}") except Exception as e: diff --git a/litellm/llms/openai/chat/gpt_5_transformation.py b/litellm/llms/openai/chat/gpt_5_transformation.py index a0b76abb20b..9a8bb74d447 100644 --- a/litellm/llms/openai/chat/gpt_5_transformation.py +++ b/litellm/llms/openai/chat/gpt_5_transformation.py @@ -15,14 +15,19 @@ class OpenAIGPT5Config(OpenAIGPTConfig): - Mapping ``max_tokens`` -> ``max_completion_tokens``. - Dropping unsupported ``temperature`` values when requested. """ + @classmethod def is_model_gpt_5_model(cls, model: str) -> bool: return "gpt-5" in model - + def get_supported_openai_params(self, model: str) -> list: + from litellm.utils import supports_tool_choice + base_gpt_series_params = super().get_supported_openai_params(model=model) gpt_5_only_params = ["reasoning_effort"] base_gpt_series_params.extend(gpt_5_only_params) + if not supports_tool_choice(model=model): + base_gpt_series_params.remove("tool_choice") return base_gpt_series_params def map_openai_params( @@ -61,4 +66,3 @@ class OpenAIGPT5Config(OpenAIGPTConfig): model=model, drop_params=drop_params, ) - diff --git a/litellm/llms/openai/chat/gpt_transformation.py b/litellm/llms/openai/chat/gpt_transformation.py index 396d59145ff..be0ca3a7086 100644 --- a/litellm/llms/openai/chat/gpt_transformation.py +++ b/litellm/llms/openai/chat/gpt_transformation.py @@ -348,6 +348,7 @@ class OpenAIGPTConfig(BaseLLMModelInfo, BaseConfig): for message in messages: message_content = message.get("content") message_role = message.get("role") + if ( message_role == "user" and message_content @@ -428,6 +429,8 @@ class OpenAIGPTConfig(BaseLLMModelInfo, BaseConfig): if tools is not None and len(tools) > 0: optional_params["tools"] = tools + optional_params.pop("max_retries", None) + return { "model": model, "messages": messages, diff --git a/litellm/llms/openai/image_edit/transformation.py b/litellm/llms/openai/image_edit/transformation.py index c8a1e8f0e1c..be1aeb1b8a4 100644 --- a/litellm/llms/openai/image_edit/transformation.py +++ b/litellm/llms/openai/image_edit/transformation.py @@ -80,24 +80,49 @@ class OpenAIImageEditConfig(BaseImageEditConfig): request_dict = cast(Dict, request) ######################################################### - # Separate images as `files` and send other parameters as `data` + # Separate images and masks as `files` and send other parameters as `data` ######################################################### - _images = request_dict.get("image") or [] - data_without_images = {k: v for k, v in request_dict.items() if k != "image"} + _image = request_dict.get("image") + _mask = request_dict.get("mask") + data_without_files = { + k: v for k, v in request_dict.items() if k not in ["image", "mask"] + } files_list: List[Tuple[str, Any]] = [] - for _image in _images: - image_content_type: str = ImageEditRequestUtils.get_image_content_type( - _image - ) - if isinstance(_image, BufferedReader): - files_list.append( - ("image[]", (_image.name, _image, image_content_type)) + + # Handle image parameter + if _image is not None: + # Handle case where image can be a list (extract first image) + if isinstance(_image, list): + _image = _image[0] if _image else None + + if _image is not None: + image_content_type: str = ImageEditRequestUtils.get_image_content_type( + _image ) - else: - files_list.append( - ("image[]", ("image.png", _image, image_content_type)) + if isinstance(_image, BufferedReader): + files_list.append( + ("image", (_image.name, _image, image_content_type)) + ) + else: + files_list.append( + ("image", ("image.png", _image, image_content_type)) + ) + + # Handle mask parameter if provided + if _mask is not None: + # Handle case where mask can be a list (extract first mask) + if isinstance(_mask, list): + _mask = _mask[0] if _mask else None + + if _mask is not None: + mask_content_type: str = ImageEditRequestUtils.get_image_content_type( + _mask ) - return data_without_images, files_list + if isinstance(_mask, BufferedReader): + files_list.append(("mask", (_mask.name, _mask, mask_content_type))) + else: + files_list.append(("mask", ("mask.png", _mask, mask_content_type))) + return data_without_files, files_list def transform_image_edit_response( self, diff --git a/litellm/llms/openai/realtime/handler.py b/litellm/llms/openai/realtime/handler.py index aca32e1404a..e0c85d18178 100644 --- a/litellm/llms/openai/realtime/handler.py +++ b/litellm/llms/openai/realtime/handler.py @@ -1,5 +1,5 @@ """ -This file contains the calling Azure OpenAI's `/openai/realtime` endpoint. +This file contains the calling OpenAI's `/v1/realtime` endpoint. This requires websockets, and is currently only supported on LiteLLM Proxy. """ @@ -15,7 +15,7 @@ from litellm.types.realtime import RealtimeQueryParams class OpenAIRealtime(OpenAIChatCompletion): def _construct_url(self, api_base: str, query_params: RealtimeQueryParams) -> str: """ - Construct the backend websocket URL with all query parameters (excluding 'model' if present). + Construct the backend websocket URL with all query parameters (including 'model'). """ from httpx import URL @@ -24,10 +24,9 @@ class OpenAIRealtime(OpenAIChatCompletion): url = URL(api_base) # Set the correct path url = url.copy_with(path="/v1/realtime") - # Build query dict excluding 'model' - query_dict = {k: v for k, v in query_params.items() if k != "model"} - if query_dict: - url = url.copy_with(params=query_dict) + # Include all query parameters including 'model' + if query_params: + url = url.copy_with(params=query_params) return str(url) async def async_realtime( @@ -43,11 +42,10 @@ class OpenAIRealtime(OpenAIChatCompletion): ): import websockets from websockets.asyncio.client import ClientConnection - if api_base is None: - raise ValueError("api_base is required for Azure OpenAI calls") + api_base = "https://api.openai.com/" if api_key is None: - raise ValueError("api_key is required for Azure OpenAI calls") + raise ValueError("api_key is required for OpenAI realtime calls") # Use all query params if provided, else fallback to just model if query_params is None: diff --git a/litellm/llms/openai/responses/transformation.py b/litellm/llms/openai/responses/transformation.py index 501941fdc59..e70cadddaf7 100644 --- a/litellm/llms/openai/responses/transformation.py +++ b/litellm/llms/openai/responses/transformation.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast, get_type_hints import httpx from pydantic import BaseModel @@ -13,6 +13,7 @@ from litellm.secret_managers.main import get_secret_str from litellm.types.llms.openai import * from litellm.types.responses.main import * from litellm.types.router import GenericLiteLLMParams +from litellm.types.utils import LlmProviders from ..common_utils import OpenAIError @@ -25,38 +26,28 @@ else: class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): + @property + def custom_llm_provider(self) -> LlmProviders: + return LlmProviders.OPENAI + def get_supported_openai_params(self, model: str) -> list: """ All OpenAI Responses API params are supported """ - return [ - "input", - "model", - "include", - "instructions", - "max_output_tokens", - "metadata", - "parallel_tool_calls", - "previous_response_id", - "reasoning", - "store", - "background", - "stream", - "prompt", - "temperature", - "text", - "tool_choice", - "tools", - "top_p", - "truncation", - "user", - "service_tier", - "safety_identifier", - "extra_headers", - "extra_query", - "extra_body", - "timeout", - ] + supported_params = get_type_hints(ResponsesAPIRequestParams).keys() + return list( + set( + [ + "input", + "model", + "extra_headers", + "extra_query", + "extra_body", + "timeout", + ] + + list(supported_params) + ) + ) def map_openai_params( self, @@ -85,8 +76,10 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): ) return final_request_params - - def _validate_input_param(self, input: Union[str, ResponseInputParam]) -> Union[str, ResponseInputParam]: + + def _validate_input_param( + self, input: Union[str, ResponseInputParam] + ) -> Union[str, ResponseInputParam]: """ Ensure all input fields if pydantic are converted to dict @@ -114,7 +107,9 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): """No transform applied since outputs are in OpenAI spec already""" try: raw_response_json = raw_response.json() - raw_response_json["created_at"] = _safe_convert_created_field(raw_response_json["created_at"]) + raw_response_json["created_at"] = _safe_convert_created_field( + raw_response_json["created_at"] + ) except Exception: raise OpenAIError( message=raw_response.text, status_code=raw_response.status_code diff --git a/litellm/llms/vertex_ai/gemini/transformation.py b/litellm/llms/vertex_ai/gemini/transformation.py index 85e3f15364b..8ab212e2558 100644 --- a/litellm/llms/vertex_ai/gemini/transformation.py +++ b/litellm/llms/vertex_ai/gemini/transformation.py @@ -35,6 +35,7 @@ from litellm.types.llms.openai import ( ChatCompletionFileObject, ChatCompletionImageObject, ChatCompletionTextObject, + ChatCompletionUserMessage, ) from litellm.types.llms.vertex_ai import * from litellm.types.llms.vertex_ai import ( @@ -475,6 +476,13 @@ async def async_transform_request_body( optional_params=optional_params, ) +def _default_user_message_when_system_message_passed() -> ChatCompletionUserMessage: + """ + Returns a default user message when a "system" message is passed in gemini fails. + + This adds a blank user message to the messages list, to ensure that gemini doesn't fail the request. + """ + return ChatCompletionUserMessage(content=".", role="user") def _transform_system_message( supports_system_message: bool, messages: List[AllMessageValues] @@ -510,6 +518,13 @@ def _transform_system_message( messages.pop(idx) if len(system_content_blocks) > 0: + ######################################################### + # If no messages are passed in, add a blank user message + # Relevant Issue - https://github.com/BerriAI/litellm/issues/13769 + ######################################################### + if len(messages) == 0: + messages.append(_default_user_message_when_system_message_passed()) + ######################################################### return SystemInstructions(parts=system_content_blocks), messages return None, messages diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py index 37a4ab84dda..923e140a262 100644 --- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py +++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py @@ -46,6 +46,7 @@ from litellm.types.llms.openai import ( ChatCompletionToolCallChunk, ChatCompletionToolCallFunctionChunk, ChatCompletionToolParamFunctionChunk, + ImageURLObject, OpenAIChatCompletionFinishReason, ) from litellm.types.llms.vertex_ai import ( @@ -89,11 +90,12 @@ from .transformation import ( if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj - from litellm.types.utils import ModelResponseStream + from litellm.types.utils import ModelResponseStream, StreamingChoices LoggingClass = LiteLLMLoggingObj else: LoggingClass = Any + StreamingChoices = Any class VertexAIBaseConfig: @@ -305,9 +307,9 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): return None for tool in value: - openai_function_object: Optional[ - ChatCompletionToolParamFunctionChunk - ] = None + openai_function_object: Optional[ChatCompletionToolParamFunctionChunk] = ( + None + ) if "function" in tool: # tools list _openai_function_object = ChatCompletionToolParamFunctionChunk( # type: ignore **tool["function"] @@ -597,14 +599,14 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): elif param == "seed": optional_params["seed"] = value elif param == "reasoning_effort" and isinstance(value, str): - optional_params[ - "thinkingConfig" - ] = VertexGeminiConfig._map_reasoning_effort_to_thinking_budget(value) + optional_params["thinkingConfig"] = ( + VertexGeminiConfig._map_reasoning_effort_to_thinking_budget(value) + ) elif param == "thinking": - optional_params[ - "thinkingConfig" - ] = VertexGeminiConfig._map_thinking_param( - cast(AnthropicThinkingParam, value) + optional_params["thinkingConfig"] = ( + VertexGeminiConfig._map_thinking_param( + cast(AnthropicThinkingParam, value) + ) ) elif param == "modalities" and isinstance(value, list): response_modalities = self.map_response_modalities(value) @@ -774,8 +776,9 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): elif "inlineData" in part: mime_type = part["inlineData"]["mimeType"] data = part["inlineData"]["data"] - # Check if inline data is audio - if so, exclude from text content - if mime_type.startswith("audio/"): + # Check if inline data is audio or image - if so, exclude from text content + # Images and audio are now handled separately in their respective response fields + if mime_type.startswith("audio/") or mime_type.startswith("image/"): continue _content_str += "data:{};base64,{}".format(mime_type, data) @@ -790,6 +793,23 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): content_str += _content_str return content_str, reasoning_content_str + + def _extract_image_response_from_parts( + self, parts: List[HttpxPartType] + ) -> Optional[ImageURLObject]: + """Extract image response from parts if present""" + for part in parts: + if "inlineData" in part: + mime_type = part["inlineData"]["mimeType"] + data = part["inlineData"]["data"] + if mime_type.startswith("image/"): + # Convert base64 data to data URI format + data_uri = f"data:{mime_type};base64,{data}" + return ImageURLObject( + url=data_uri, + detail="auto" + ) + return None def _extract_audio_response_from_parts( self, parts: List[HttpxPartType] @@ -1000,6 +1020,7 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): GenerateContentResponseBody, BidiGenerateContentServerMessage ], ) -> Usage: + if ( completion_response is not None and "usageMetadata" not in completion_response @@ -1038,6 +1059,16 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): text_tokens = detail.get("tokenCount", 0) if "thoughtsTokenCount" in usage_metadata: reasoning_tokens = usage_metadata["thoughtsTokenCount"] + + ## adjust 'text_tokens' to subtract cached tokens + if ( + (audio_tokens is None or audio_tokens == 0) + and text_tokens is not None + and text_tokens > 0 + and cached_tokens is not None + ): + text_tokens = text_tokens - cached_tokens + prompt_tokens_details = PromptTokensDetailsWrapper( cached_tokens=cached_tokens, audio_tokens=audio_tokens, @@ -1097,6 +1128,75 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): elif web_search_queries: web_search_requests = len(grounding_metadata) return web_search_requests + + @staticmethod + def _create_streaming_choice( + chat_completion_message: ChatCompletionResponseMessage, + candidate: Candidates, + idx: int, + tools: Optional[List[ChatCompletionToolCallChunk]], + functions: Optional[ChatCompletionToolCallFunctionChunk], + chat_completion_logprobs: Optional[ChoiceLogprobs], + image_response: Optional[ImageURLObject], + ) -> StreamingChoices: + """ + Helper method to create a streaming choice object for Vertex AI + """ + from litellm.types.utils import Delta, StreamingChoices + + # create a streaming choice object + choice = StreamingChoices( + finish_reason=VertexGeminiConfig._check_finish_reason( + chat_completion_message, candidate.get("finishReason") + ), + index=candidate.get("index", idx), + delta=Delta( + content=chat_completion_message.get("content"), + reasoning_content=chat_completion_message.get( + "reasoning_content" + ), + tool_calls=tools, + image=image_response, + function_call=functions, + ), + logprobs=chat_completion_logprobs, + enhancements=None, + ) + return choice + + @staticmethod + def _extract_candidate_metadata(candidate: Candidates) -> Tuple[List[dict], List[dict], List, List]: + """ + Extract metadata from a single candidate response. + + Returns: + grounding_metadata: List[dict] + url_context_metadata: List[dict] + safety_ratings: List + citation_metadata: List + """ + grounding_metadata: List[dict] = [] + url_context_metadata: List[dict] = [] + safety_ratings: List = [] + citation_metadata: List = [] + + if "groundingMetadata" in candidate: + if isinstance(candidate["groundingMetadata"], list): + grounding_metadata.extend(candidate["groundingMetadata"]) # type: ignore + else: + grounding_metadata.append(candidate["groundingMetadata"]) # type: ignore + + if "safetyRatings" in candidate: + safety_ratings.append(candidate["safetyRatings"]) + + if "citationMetadata" in candidate: + citation_metadata.append(candidate["citationMetadata"]) + + if "urlContextMetadata" in candidate: + # Add URL context metadata to grounding metadata + url_context_metadata.append(cast(dict, candidate["urlContextMetadata"])) + + return grounding_metadata, url_context_metadata, safety_ratings, citation_metadata @staticmethod def _process_candidates( @@ -1120,6 +1220,7 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): grounding_metadata: List[dict] = [] url_context_metadata: List[dict] = [] + image_response: Optional[ImageURLObject] = None safety_ratings: List = [] citation_metadata: List = [] chat_completion_message: ChatCompletionResponseMessage = {"role": "assistant"} @@ -1132,21 +1233,18 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): if "content" not in candidate: continue - if "groundingMetadata" in candidate: - if isinstance(candidate["groundingMetadata"], list): - grounding_metadata.extend(candidate["groundingMetadata"]) # type: ignore - else: - grounding_metadata.append(candidate["groundingMetadata"]) # type: ignore - - if "safetyRatings" in candidate: - safety_ratings.append(candidate["safetyRatings"]) - - if "citationMetadata" in candidate: - citation_metadata.append(candidate["citationMetadata"]) - - if "urlContextMetadata" in candidate: - # Add URL context metadata to grounding metadata - url_context_metadata.append(cast(dict, candidate["urlContextMetadata"])) + # Extract metadata using helper function + ( + candidate_grounding_metadata, + candidate_url_context_metadata, + candidate_safety_ratings, + candidate_citation_metadata, + ) = VertexGeminiConfig._extract_candidate_metadata(candidate) + + grounding_metadata.extend(candidate_grounding_metadata) + url_context_metadata.extend(candidate_url_context_metadata) + safety_ratings.extend(candidate_safety_ratings) + citation_metadata.extend(candidate_citation_metadata) if "parts" in candidate["content"]: ( @@ -1161,18 +1259,25 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): parts=candidate["content"]["parts"] ) ) + image_response = ( + VertexGeminiConfig()._extract_image_response_from_parts( + parts=candidate["content"]["parts"] + ) + ) if audio_response is not None: cast(Dict[str, Any], chat_completion_message)[ "audio" ] = audio_response chat_completion_message["content"] = None # OpenAI spec + elif image_response is not None: + # Handle image response - combine with text content into structured format + cast(Dict[str, Any], chat_completion_message)["image"] = image_response elif content is not None: chat_completion_message["content"] = content if reasoning_content is not None: chat_completion_message["reasoning_content"] = reasoning_content - ( functions, tools, @@ -1195,24 +1300,14 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): chat_completion_message["function_call"] = functions if isinstance(model_response, ModelResponseStream): - from litellm.types.utils import Delta, StreamingChoices - - # create a streaming choice object - choice = StreamingChoices( - finish_reason=VertexGeminiConfig._check_finish_reason( - chat_completion_message, candidate.get("finishReason") - ), - index=candidate.get("index", idx), - delta=Delta( - content=chat_completion_message.get("content"), - reasoning_content=chat_completion_message.get( - "reasoning_content" - ), - tool_calls=tools, - function_call=functions, - ), - logprobs=chat_completion_logprobs, - enhancements=None, + choice = VertexGeminiConfig._create_streaming_choice( + chat_completion_message=chat_completion_message, + candidate=candidate, + idx=idx, + tools=tools, + functions=functions, + chat_completion_logprobs=chat_completion_logprobs, + image_response=image_response ) model_response.choices.append(choice) elif isinstance(model_response, ModelResponse): @@ -1344,28 +1439,28 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): ## ADD METADATA TO RESPONSE ## setattr(model_response, "vertex_ai_grounding_metadata", grounding_metadata) - model_response._hidden_params[ - "vertex_ai_grounding_metadata" - ] = grounding_metadata + model_response._hidden_params["vertex_ai_grounding_metadata"] = ( + grounding_metadata + ) setattr( model_response, "vertex_ai_url_context_metadata", url_context_metadata ) - model_response._hidden_params[ - "vertex_ai_url_context_metadata" - ] = url_context_metadata + model_response._hidden_params["vertex_ai_url_context_metadata"] = ( + url_context_metadata + ) setattr(model_response, "vertex_ai_safety_results", safety_ratings) - model_response._hidden_params[ - "vertex_ai_safety_results" - ] = safety_ratings # older approach - maintaining to prevent regressions + model_response._hidden_params["vertex_ai_safety_results"] = ( + safety_ratings # older approach - maintaining to prevent regressions + ) ## ADD CITATION METADATA ## setattr(model_response, "vertex_ai_citation_metadata", citation_metadata) - model_response._hidden_params[ - "vertex_ai_citation_metadata" - ] = citation_metadata # older approach - maintaining to prevent regressions + model_response._hidden_params["vertex_ai_citation_metadata"] = ( + citation_metadata # older approach - maintaining to prevent regressions + ) except Exception as e: raise VertexAIError( diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.py index 7e965313a0b..748a5f5fb40 100644 --- a/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.py +++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.py @@ -113,10 +113,10 @@ class VertexAILlama3Config(OpenAIGPTConfig): status_code=raw_response.status_code, headers=response_headers, ) - model_response.model = completion_response["model"] - model_response.id = completion_response["id"] - model_response.created = completion_response["created"] - setattr(model_response, "usage", Usage(**completion_response["usage"])) + model_response.model = completion_response.get("model", model) + model_response.id = completion_response.get("id", "") + model_response.created = completion_response.get("created", 0) + setattr(model_response, "usage", Usage(**completion_response.get("usage", {}))) model_response.choices = self._transform_choices( # type: ignore choices=completion_response["choices"], diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py index 7303ab0786c..f281cab3b58 100644 --- a/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py +++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py @@ -48,9 +48,21 @@ class VertexAIPartnerModels(VertexBase): or model.startswith("codestral") or model.startswith("jamba") or model.startswith("claude") + or model.startswith("qwen") ): return True return False + + @staticmethod + def should_use_openai_handler(model: str): + OPENAI_LIKE_VERTEX_PROVIDERS = [ + "llama", + "deepseek-ai", + "qwen", + ] + if any(provider in model for provider in OPENAI_LIKE_VERTEX_PROVIDERS): + return True + return False def completion( self, @@ -115,7 +127,7 @@ class VertexAIPartnerModels(VertexBase): optional_params["stream"] = stream - if "llama" in model or "deepseek-ai" in model: + if self.should_use_openai_handler(model): partner = VertexPartnerProvider.llama elif "mistral" in model or "codestral" in model: partner = VertexPartnerProvider.mistralai @@ -191,7 +203,7 @@ class VertexAIPartnerModels(VertexBase): client=client, custom_llm_provider=LlmProviders.VERTEX_AI.value, ) - elif "llama" in model: + elif self.should_use_openai_handler(model): return base_llm_http_handler.completion( model=model, stream=stream, diff --git a/litellm/llms/volcengine.py b/litellm/llms/volcengine.py index 58d2371af53..c878aaf933c 100644 --- a/litellm/llms/volcengine.py +++ b/litellm/llms/volcengine.py @@ -81,8 +81,18 @@ class VolcEngineConfig(OpenAILikeChatConfig): ) if "thinking" in optional_params: - optional_params.setdefault("extra_body", {})["thinking"] = ( - optional_params.pop("thinking") - ) + thinking_value = optional_params.pop("thinking") + + # Handle disabled thinking case - don't add to extra_body if disabled + if ( + thinking_value is not None + and isinstance(thinking_value, dict) + and thinking_value.get("type") == "disabled" + ): + # Skip adding thinking parameter when it's disabled + pass + else: + # Add thinking parameter to extra_body for all other cases + optional_params.setdefault("extra_body", {})["thinking"] = thinking_value return optional_params diff --git a/litellm/llms/voyage/embedding/transformation_contextual.py b/litellm/llms/voyage/embedding/transformation_contextual.py new file mode 100644 index 00000000000..4df2fa4ba31 --- /dev/null +++ b/litellm/llms/voyage/embedding/transformation_contextual.py @@ -0,0 +1,153 @@ +""" +This module is used to transform the request and response for the Voyage contextualized embeddings API. +This would be used for all the contextualized embeddings models in Voyage. +""" +from typing import List, Optional, Union + +import httpx + +from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj +from litellm.llms.base_llm.chat.transformation import BaseLLMException +from litellm.llms.base_llm.embedding.transformation import BaseEmbeddingConfig +from litellm.secret_managers.main import get_secret_str +from litellm.types.llms.openai import AllEmbeddingInputValues, AllMessageValues +from litellm.types.utils import EmbeddingResponse, Usage + + +class VoyageError(BaseLLMException): + def __init__( + self, + status_code: int, + message: str, + headers: Union[dict, httpx.Headers] = {}, + ): + self.status_code = status_code + self.message = message + self.request = httpx.Request( + method="POST", url="https://api.voyageai.com/v1/contextualizedembeddings" + ) + self.response = httpx.Response(status_code=status_code, request=self.request) + super().__init__( + status_code=status_code, + message=message, + headers=headers, + ) + + +class VoyageContextualEmbeddingConfig(BaseEmbeddingConfig): + """ + Reference: https://docs.voyageai.com/reference/embeddings-api + """ + + def __init__(self) -> None: + pass + + def get_complete_url( + self, + api_base: Optional[str], + api_key: Optional[str], + model: str, + optional_params: dict, + litellm_params: dict, + stream: Optional[bool] = None, + ) -> str: + if api_base: + if not api_base.endswith("/contextualizedembeddings"): + api_base = f"{api_base}/contextualizedembeddings" + return api_base + return "https://api.voyageai.com/v1/contextualizedembeddings" + + def get_supported_openai_params(self, model: str) -> list: + return ["encoding_format", "dimensions"] + + def map_openai_params( + self, + non_default_params: dict, + optional_params: dict, + model: str, + drop_params: bool, + ) -> dict: + """ + Map OpenAI params to Voyage params + + Reference: https://docs.voyageai.com/reference/contextualized-embeddings-api + """ + if "encoding_format" in non_default_params: + optional_params["encoding_format"] = non_default_params["encoding_format"] + if "dimensions" in non_default_params: + optional_params["output_dimension"] = non_default_params["dimensions"] + return optional_params + + def validate_environment( + self, + headers: dict, + model: str, + messages: List[AllMessageValues], + optional_params: dict, + litellm_params: dict, + api_key: Optional[str] = None, + api_base: Optional[str] = None, + ) -> dict: + if api_key is None: + api_key = ( + get_secret_str("VOYAGE_API_KEY") + or get_secret_str("VOYAGE_AI_API_KEY") + or get_secret_str("VOYAGE_AI_TOKEN") + ) + return { + "Authorization": f"Bearer {api_key}", + } + + def transform_embedding_request( + self, + model: str, + input: Union[AllEmbeddingInputValues, List[List[str]]], + optional_params: dict, + headers: dict, + ) -> dict: + return { + "inputs": input, + "model": model, + **optional_params, + } + + def transform_embedding_response( + self, + model: str, + raw_response: httpx.Response, + model_response: EmbeddingResponse, + logging_obj: LiteLLMLoggingObj, + api_key: Optional[str] = None, + request_data: dict = {}, + optional_params: dict = {}, + litellm_params: dict = {}, + ) -> EmbeddingResponse: + try: + raw_response_json = raw_response.json() + except Exception: + raise VoyageError( + message=raw_response.text, status_code=raw_response.status_code + ) + + # model_response.usage + model_response.model = raw_response_json.get("model") + model_response.data = raw_response_json.get("data") + model_response.object = raw_response_json.get("object") + + usage = Usage( + prompt_tokens=raw_response_json.get("usage", {}).get("total_tokens", 0), + total_tokens=raw_response_json.get("usage", {}).get("total_tokens", 0), + ) + model_response.usage = usage + return model_response + + def get_error_class( + self, error_message: str, status_code: int, headers: Union[dict, httpx.Headers] + ) -> BaseLLMException: + return VoyageError( + message=error_message, status_code=status_code, headers=headers + ) + + @staticmethod + def is_contextualized_embeddings(model: str) -> bool: + return "context" in model.lower() diff --git a/litellm/main.py b/litellm/main.py index 339d9e14406..70f55125507 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -61,6 +61,9 @@ from litellm.exceptions import LiteLLMUnknownProvider from litellm.integrations.custom_logger import CustomLogger from litellm.litellm_core_utils.audio_utils.utils import get_audio_file_for_health_check from litellm.litellm_core_utils.dd_tracing import tracer +from litellm.litellm_core_utils.get_provider_specific_headers import ( + ProviderSpecificHeaderUtils, +) from litellm.litellm_core_utils.health_check_utils import ( _create_health_check_response, _filter_model_params, @@ -77,7 +80,7 @@ from litellm.llms.base_llm import BaseConfig, BaseImageGenerationConfig from litellm.llms.bedrock.common_utils import BedrockModelInfo from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler from litellm.realtime_api.main import _realtime_health_check -from litellm.secret_managers.main import get_secret_str +from litellm.secret_managers.main import get_secret_bool, get_secret_str from litellm.types.router import GenericLiteLLMParams from litellm.types.utils import RawRequestTypedDict from litellm.utils import ( @@ -130,7 +133,6 @@ from .litellm_core_utils.prompt_templates.factory import ( stringify_json_tool_call_content, ) from .litellm_core_utils.streaming_chunk_builder_utils import ChunkProcessor -from .llms import baseten from .llms.anthropic.chat import AnthropicChatCompletion from .llms.azure.audio_transcriptions import AzureAudioTranscription from .llms.azure.azure import AzureChatCompletion, _check_dynamic_azure_params @@ -1108,11 +1110,11 @@ def completion( # type: ignore # noqa: PLR0915 api_key=api_key, ) - if ( - provider_specific_header is not None - and provider_specific_header["custom_llm_provider"] == custom_llm_provider - ): - headers.update(provider_specific_header["extra_headers"]) + if provider_specific_header is not None: + headers.update(ProviderSpecificHeaderUtils.get_provider_specific_headers( + provider_specific_header=provider_specific_header, + custom_llm_provider=custom_llm_provider, + )) if model_response is not None and hasattr(model_response, "_hidden_params"): model_response._hidden_params["custom_llm_provider"] = custom_llm_provider @@ -1254,6 +1256,7 @@ def completion( # type: ignore # noqa: PLR0915 additional_drop_params=kwargs.get("additional_drop_params"), remove_sensitive_keys=True, add_provider_specific_params=True, + provider_config=provider_config, ) if litellm.add_function_to_prompt and optional_params.get( @@ -1562,6 +1565,7 @@ def completion( # type: ignore # noqa: PLR0915 ) elif custom_llm_provider == "deepseek": ## COMPLETION CALL + try: response = base_llm_http_handler.completion( model=model, @@ -1592,18 +1596,11 @@ def completion( # type: ignore # noqa: PLR0915 raise e elif custom_llm_provider == "azure_ai": - api_base = ( - api_base # for deepinfra/perplexity/anyscale/groq/friendliai we check in get_llm_provider and pass in the api base from there - or litellm.api_base - or get_secret("AZURE_AI_API_BASE") - ) + from litellm.llms.azure_ai.common_utils import AzureFoundryModelInfo + + api_base = AzureFoundryModelInfo.get_api_base(api_base) # set API KEY - api_key = ( - api_key - or litellm.api_key # for deepinfra/perplexity/anyscale/friendliai we check in get_llm_provider and pass in the api key from there - or litellm.openai_key - or get_secret("AZURE_AI_API_KEY") - ) + api_key = AzureFoundryModelInfo.get_api_key(api_key) headers = headers or litellm.headers @@ -1929,6 +1926,7 @@ def completion( # type: ignore # noqa: PLR0915 or custom_llm_provider == "perplexity" or custom_llm_provider == "nvidia_nim" or custom_llm_provider == "cerebras" + or custom_llm_provider == "baseten" or custom_llm_provider == "sambanova" or custom_llm_provider == "volcengine" or custom_llm_provider == "anyscale" @@ -1981,26 +1979,51 @@ def completion( # type: ignore # noqa: PLR0915 optional_params[k] = v ## COMPLETION CALL + use_base_llm_http_handler = get_secret_bool( + "EXPERIMENTAL_OPENAI_BASE_LLM_HTTP_HANDLER" + ) + try: - response = openai_chat_completions.completion( - model=model, - messages=messages, - headers=headers, - model_response=model_response, - print_verbose=print_verbose, - api_key=api_key, - api_base=api_base, - acompletion=acompletion, - logging_obj=logging, - optional_params=optional_params, - litellm_params=litellm_params, - logger_fn=logger_fn, - timeout=timeout, # type: ignore - custom_prompt_dict=custom_prompt_dict, - client=client, # pass AsyncOpenAI, OpenAI client - organization=organization, - custom_llm_provider=custom_llm_provider, - ) + if use_base_llm_http_handler: + + response = base_llm_http_handler.completion( + model=model, + messages=messages, + api_base=api_base, + custom_llm_provider=custom_llm_provider, + model_response=model_response, + encoding=encoding, + logging_obj=logging, + optional_params=optional_params, + timeout=timeout, + litellm_params=litellm_params, + acompletion=acompletion, + stream=stream, + api_key=api_key, + headers=headers, + client=client, + provider_config=provider_config, + ) + else: + response = openai_chat_completions.completion( + model=model, + messages=messages, + headers=headers, + model_response=model_response, + print_verbose=print_verbose, + api_key=api_key, + api_base=api_base, + acompletion=acompletion, + logging_obj=logging, + optional_params=optional_params, + litellm_params=litellm_params, + logger_fn=logger_fn, + timeout=timeout, # type: ignore + custom_prompt_dict=custom_prompt_dict, + client=client, # pass AsyncOpenAI, OpenAI client + organization=organization, + custom_llm_provider=custom_llm_provider, + ) except Exception as e: ## LOGGING - log the original exception returned logging.post_call( @@ -2981,7 +3004,7 @@ def completion( # type: ignore # noqa: PLR0915 logger_fn=logger_fn, encoding=encoding, logging_obj=logging, - extra_headers=extra_headers, + extra_headers=headers, # Use merged headers instead of original extra_headers timeout=timeout, acompletion=acompletion, client=client, @@ -3245,42 +3268,7 @@ def completion( # type: ignore # noqa: PLR0915 api_key=api_key, logging_obj=logging, # model call logging done inside the class as we make need to modify I/O to fit aleph alpha's requirements ) - elif ( - custom_llm_provider == "baseten" - or litellm.api_base == "https://app.baseten.co" - ): - custom_llm_provider = "baseten" - baseten_key = ( - api_key - or litellm.baseten_key - or os.environ.get("BASETEN_API_KEY") - or litellm.api_key - ) - model_response = baseten.completion( - model=model, - messages=messages, - model_response=model_response, - print_verbose=print_verbose, - optional_params=optional_params, - litellm_params=litellm_params, - logger_fn=logger_fn, - encoding=encoding, - api_key=baseten_key, - logging_obj=logging, - ) - if inspect.isgenerator(model_response) or ( - "stream" in optional_params and optional_params["stream"] is True - ): - # don't try to access stream object, - response = CustomStreamWrapper( - model_response, - model, - custom_llm_provider="baseten", - logging_obj=logging, - ) - return response - response = model_response elif custom_llm_provider == "petals" or model in litellm.petals_models: api_base = api_base or litellm.api_base diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 1001aca9c09..b7297f07199 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -722,7 +722,7 @@ "/v1/batch", "/v1/responses" ], - "supported_modalities": [ + "supported_modalities": [ "text", "image" ], @@ -730,13 +730,13 @@ "text" ], "supports_pdf_input": true, - "supports_function_calling": true, - "supports_parallel_function_calling": true, + "supports_function_calling": false, + "supports_parallel_function_calling": false, "supports_response_schema": true, "supports_vision": true, "supports_prompt_caching": true, "supports_system_messages": true, - "supports_tool_choice": true, + "supports_tool_choice": false, "supports_native_streaming": true, "supports_reasoning": true }, @@ -762,13 +762,13 @@ "text" ], "supports_pdf_input": true, - "supports_function_calling": true, - "supports_parallel_function_calling": true, + "supports_function_calling": false, + "supports_parallel_function_calling": false, "supports_response_schema": true, "supports_vision": true, "supports_prompt_caching": true, "supports_system_messages": true, - "supports_tool_choice": true, + "supports_tool_choice": false, "supports_native_streaming": true, "supports_reasoning": true }, @@ -2457,7 +2457,7 @@ }, "azure/gpt-5-chat": { "max_tokens": 128000, - "max_input_tokens": 400000, + "max_input_tokens": 272000, "max_output_tokens": 128000, "input_cost_per_token": 1.25e-06, "output_cost_per_token": 1e-05, @@ -2483,14 +2483,14 @@ "supports_vision": true, "supports_prompt_caching": true, "supports_system_messages": true, - "supports_tool_choice": true, + "supports_tool_choice": false, "supports_native_streaming": true, "supports_reasoning": true, "source": "https://azure.microsoft.com/en-us/blog/gpt-5-in-azure-ai-foundry-the-future-of-ai-apps-and-agents-starts-here/" }, "azure/gpt-5-chat-latest": { "max_tokens": 128000, - "max_input_tokens": 400000, + "max_input_tokens": 272000, "max_output_tokens": 128000, "input_cost_per_token": 1.25e-06, "output_cost_per_token": 1e-05, @@ -2516,7 +2516,7 @@ "supports_vision": true, "supports_prompt_caching": true, "supports_system_messages": true, - "supports_tool_choice": true, + "supports_tool_choice": false, "supports_native_streaming": true, "supports_reasoning": true }, @@ -2658,12 +2658,7 @@ "supports_system_messages": true, "supports_tool_choice": true, "supports_native_streaming": true, - "supports_web_search": true, - "search_context_cost_per_query": { - "search_context_size_low": 0.03, - "search_context_size_medium": 0.035, - "search_context_size_high": 0.05 - } + "supports_web_search": false }, "azure/gpt-4.1-2025-04-14": { "max_tokens": 32768, @@ -2696,12 +2691,7 @@ "supports_system_messages": true, "supports_tool_choice": true, "supports_native_streaming": true, - "supports_web_search": true, - "search_context_cost_per_query": { - "search_context_size_low": 0.03, - "search_context_size_medium": 0.035, - "search_context_size_high": 0.05 - } + "supports_web_search": false }, "azure/gpt-4.1-mini": { "max_tokens": 32768, @@ -2734,12 +2724,7 @@ "supports_system_messages": true, "supports_tool_choice": true, "supports_native_streaming": true, - "supports_web_search": true, - "search_context_cost_per_query": { - "search_context_size_low": 0.025, - "search_context_size_medium": 0.0275, - "search_context_size_high": 0.03 - } + "supports_web_search": false }, "azure/gpt-4.1-mini-2025-04-14": { "max_tokens": 32768, @@ -2772,12 +2757,7 @@ "supports_system_messages": true, "supports_tool_choice": true, "supports_native_streaming": true, - "supports_web_search": true, - "search_context_cost_per_query": { - "search_context_size_low": 0.025, - "search_context_size_medium": 0.0275, - "search_context_size_high": 0.03 - } + "supports_web_search": false }, "azure/gpt-4.1-nano": { "max_tokens": 32768, @@ -4790,6 +4770,24 @@ ], "source": "https://azuremarketplace.microsoft.com/pt-br/marketplace/apps/cohere.cohere-embed-4-offer?tab=PlansAndPrice" }, + "azure_ai/FLUX-1.1-pro": { + "output_cost_per_image": 0.04, + "litellm_provider": "azure_ai", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/black-forest-labs-flux-1-kontext-pro-and-flux1-1-pro-now-available-in-azure-ai-f/4434659" + }, + "azure_ai/FLUX.1-Kontext-pro": { + "output_cost_per_image": 0.04, + "litellm_provider": "azure_ai", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://azuremarketplace.microsoft.com/pt-br/marketplace/apps/cohere.cohere-embed-4-offer?tab=PlansAndPrice" + }, "babbage-002": { "max_tokens": 16384, "max_input_tokens": 16384, @@ -6419,11 +6417,13 @@ "supports_computer_use": true }, "claude-4-sonnet-20250514": { - "max_tokens": 64000, - "max_input_tokens": 200000, - "max_output_tokens": 64000, + "max_tokens": 1000000, + "max_input_tokens": 1000000, + "max_output_tokens": 1000000, "input_cost_per_token": 3e-06, "output_cost_per_token": 1.5e-05, + "input_cost_per_token_above_200k_tokens": 6e-06, + "output_cost_per_token_above_200k_tokens": 2.25e-05, "search_context_cost_per_query": { "search_context_size_low": 0.01, "search_context_size_medium": 0.01, @@ -6431,6 +6431,8 @@ }, "cache_creation_input_token_cost": 3.75e-06, "cache_read_input_token_cost": 3e-07, + "cache_creation_input_token_cost_above_200k_tokens": 7.5e-06, + "cache_read_input_token_cost_above_200k_tokens": 6e-07, "litellm_provider": "anthropic", "mode": "chat", "supports_function_calling": true, @@ -7907,6 +7909,55 @@ "cache_read_input_token_cost": 7.5e-08, "supports_prompt_caching": true }, + "gemini/gemini-2.5-flash-image-preview": { + "max_tokens": 65535, + "max_input_tokens": 1048576, + "max_output_tokens": 65535, + "max_images_per_prompt": 3000, + "max_videos_per_prompt": 10, + "max_video_length": 1, + "max_audio_length_hours": 8.4, + "max_audio_per_prompt": 1, + "max_pdf_size_mb": 30, + "input_cost_per_audio_token": 1e-06, + "input_cost_per_token": 3e-07, + "output_cost_per_token": 2.5e-06, + "output_cost_per_reasoning_token": 2.5e-06, + "output_cost_per_image": 0.039, + "litellm_provider": "gemini", + "mode": "chat", + "supports_reasoning": true, + "supports_system_messages": true, + "supports_function_calling": true, + "supports_vision": true, + "supports_response_schema": true, + "supports_audio_output": false, + "supports_tool_choice": true, + "supported_endpoints": [ + "/v1/chat/completions", + "/v1/completions", + "/v1/batch" + ], + "supported_modalities": [ + "text", + "image", + "audio", + "video" + ], + "supported_output_modalities": [ + "text", + "image" + ], + "source": "https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview", + "supports_parallel_function_calling": true, + "supports_web_search": true, + "supports_url_context": true, + "tpm": 8000000, + "rpm": 100000, + "supports_pdf_input": true, + "cache_read_input_token_cost": 7.5e-08, + "supports_prompt_caching": true + }, "gemini-2.5-flash": { "max_tokens": 65535, "max_input_tokens": 1048576, @@ -8223,6 +8274,55 @@ "cache_read_input_token_cost": 2.5e-08, "supports_prompt_caching": true }, + "gemini-2.5-flash-image-preview": { + "max_tokens": 65535, + "max_input_tokens": 1048576, + "max_output_tokens": 65535, + "max_images_per_prompt": 3000, + "max_videos_per_prompt": 10, + "max_video_length": 1, + "max_audio_length_hours": 8.4, + "max_audio_per_prompt": 1, + "max_pdf_size_mb": 30, + "input_cost_per_audio_token": 1e-06, + "input_cost_per_token": 3e-07, + "output_cost_per_token": 2.5e-06, + "output_cost_per_reasoning_token": 2.5e-06, + "output_cost_per_image": 0.039, + "litellm_provider": "vertex_ai-language-models", + "mode": "chat", + "supports_reasoning": true, + "supports_system_messages": true, + "supports_function_calling": true, + "supports_vision": true, + "supports_response_schema": true, + "supports_audio_output": false, + "supports_tool_choice": true, + "supported_endpoints": [ + "/v1/chat/completions", + "/v1/completions", + "/v1/batch" + ], + "supported_modalities": [ + "text", + "image", + "audio", + "video" + ], + "supported_output_modalities": [ + "text", + "image" + ], + "source": "https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview", + "supports_parallel_function_calling": true, + "supports_web_search": true, + "supports_url_context": true, + "tpm": 8000000, + "rpm": 100000, + "supports_pdf_input": true, + "cache_read_input_token_cost": 7.5e-08, + "supports_prompt_caching": true + }, "gemini-2.5-flash-preview-05-20": { "max_tokens": 65535, "max_input_tokens": 1048576, @@ -9686,6 +9786,45 @@ "supports_assistant_prefill": true, "supports_tool_choice": true }, + "vertex_ai/deepseek-ai/deepseek-r1-0528-maas": { + "max_tokens": 8192, + "max_input_tokens": 65336, + "max_output_tokens": 8192, + "input_cost_per_token": 1.35e-06, + "output_cost_per_token": 5.4e-06, + "litellm_provider": "vertex_ai-deepseek_models", + "mode": "chat", + "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models", + "supports_function_calling": true, + "supports_assistant_prefill": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "supports_prompt_caching": true + }, + "vertex_ai/qwen/qwen3-coder-480b-a35b-instruct-maas": { + "max_tokens": 32768, + "max_input_tokens": 262144, + "max_output_tokens": 32768, + "input_cost_per_token": 1e-06, + "output_cost_per_token": 4e-06, + "litellm_provider": "vertex_ai-qwen_models", + "mode": "chat", + "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing", + "supports_function_calling": true, + "supports_tool_choice": true + }, + "vertex_ai/qwen/qwen3-235b-a22b-instruct-2507-maas": { + "max_tokens": 16384, + "max_input_tokens": 262144, + "max_output_tokens": 16384, + "input_cost_per_token": 0.25e-06, + "output_cost_per_token": 1e-06, + "litellm_provider": "vertex_ai-qwen_models", + "mode": "chat", + "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing", + "supports_function_calling": true, + "supports_tool_choice": true + }, "vertex_ai/meta/llama3-405b-instruct-maas": { "max_tokens": 32000, "max_input_tokens": 32000, @@ -10035,19 +10174,19 @@ "mode": "image_generation", "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing" }, - "vertex_ai/imagen-4.0-generate-preview-06-06": { + "vertex_ai/imagen-4.0-generate-001": { "output_cost_per_image": 0.04, "litellm_provider": "vertex_ai-image-models", "mode": "image_generation", "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing" }, - "vertex_ai/imagen-4.0-ultra-generate-preview-06-06": { + "vertex_ai/imagen-4.0-ultra-generate-001": { "output_cost_per_image": 0.06, "litellm_provider": "vertex_ai-image-models", "mode": "image_generation", "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing" }, - "vertex_ai/imagen-4.0-fast-generate-preview-06-06": { + "vertex_ai/imagen-4.0-fast-generate-001": { "output_cost_per_image": 0.02, "litellm_provider": "vertex_ai-image-models", "mode": "image_generation", @@ -10753,19 +10892,19 @@ "source": "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#foundation_models", "supports_tool_choice": true }, - "gemini/imagen-4.0-generate-preview-06-06": { + "gemini/imagen-4.0-generate-001": { "output_cost_per_image": 0.04, "litellm_provider": "gemini", "mode": "image_generation", "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing" }, - "gemini/imagen-4.0-ultra-generate-preview-06-06": { + "gemini/imagen-4.0-ultra-generate-001": { "output_cost_per_image": 0.06, "litellm_provider": "gemini", "mode": "image_generation", "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing" }, - "gemini/imagen-4.0-fast-generate-preview-06-06": { + "gemini/imagen-4.0-fast-generate-001": { "output_cost_per_image": 0.02, "litellm_provider": "gemini", "mode": "image_generation", @@ -11139,6 +11278,21 @@ "supports_tool_choice": true, "supports_prompt_caching": true }, + "openrouter/deepseek/deepseek-chat-v3.1": { + "max_tokens": 8192, + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "input_cost_per_token": 2e-07, + "input_cost_per_token_cache_hit": 2e-08, + "output_cost_per_token": 8e-07, + "litellm_provider": "openrouter", + "mode": "chat", + "supports_function_calling": true, + "supports_assistant_prefill": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "supports_prompt_caching": true + }, "openrouter/x-ai/grok-4": { "max_tokens": 256000, "max_input_tokens": 256000, @@ -11190,6 +11344,17 @@ "mode": "chat", "supports_tool_choice": true }, + "openrouter/deepseek/deepseek-chat-v3-0324": { + "max_tokens": 8192, + "max_input_tokens": 65536, + "max_output_tokens": 8192, + "input_cost_per_token": 1.4e-07, + "output_cost_per_token": 2.8e-07, + "litellm_provider": "openrouter", + "supports_prompt_caching": true, + "mode": "chat", + "supports_tool_choice": true + }, "openrouter/deepseek/deepseek-coder": { "max_tokens": 8192, "max_input_tokens": 66000, @@ -11388,9 +11553,9 @@ }, "openrouter/anthropic/claude-3.7-sonnet": { "supports_computer_use": true, - "max_tokens": 8192, + "max_tokens": 128000, "max_input_tokens": 200000, - "max_output_tokens": 8192, + "max_output_tokens": 128000, "input_cost_per_token": 3e-06, "output_cost_per_token": 1.5e-05, "input_cost_per_image": 0.0048, @@ -11405,9 +11570,9 @@ }, "openrouter/anthropic/claude-3.7-sonnet:beta": { "supports_computer_use": true, - "max_tokens": 8192, + "max_tokens": 128000, "max_input_tokens": 200000, - "max_output_tokens": 8192, + "max_output_tokens": 128000, "input_cost_per_token": 3e-06, "output_cost_per_token": 1.5e-05, "input_cost_per_image": 0.0048, @@ -11432,9 +11597,9 @@ }, "openrouter/anthropic/claude-sonnet-4": { "supports_computer_use": true, - "max_tokens": 8192, + "max_tokens": 64000, "max_input_tokens": 200000, - "max_output_tokens": 8192, + "max_output_tokens": 64000, "input_cost_per_token": 3e-06, "output_cost_per_token": 1.5e-05, "input_cost_per_image": 0.0048, @@ -11447,6 +11612,40 @@ "supports_assistant_prefill": true, "supports_tool_choice": true }, + "openrouter/anthropic/claude-opus-4": { + "max_tokens": 32000, + "max_input_tokens": 200000, + "max_output_tokens": 32000, + "input_cost_per_token": 1.5e-05, + "output_cost_per_token": 7.5e-05, + "input_cost_per_image": 0.0048, + "litellm_provider": "openrouter", + "mode": "chat", + "supports_function_calling": true, + "supports_vision": true, + "tool_use_system_prompt_tokens": 159, + "supports_assistant_prefill": true, + "supports_tool_choice": true, + "supports_reasoning": true, + "supports_computer_use": true + }, + "openrouter/anthropic/claude-opus-4.1": { + "max_tokens": 32000, + "max_input_tokens": 200000, + "max_output_tokens": 32000, + "input_cost_per_token": 1.5e-05, + "output_cost_per_token": 7.5e-05, + "input_cost_per_image": 0.0048, + "litellm_provider": "openrouter", + "mode": "chat", + "supports_function_calling": true, + "supports_vision": true, + "tool_use_system_prompt_tokens": 159, + "supports_assistant_prefill": true, + "supports_tool_choice": true, + "supports_reasoning": true, + "supports_computer_use": true + }, "openrouter/mistralai/mistral-large": { "max_tokens": 32000, "input_cost_per_token": 8e-06, @@ -11688,6 +11887,63 @@ "mode": "chat", "supports_tool_choice": true }, + "openrouter/openai/gpt-5-mini": { + "max_tokens": 128000, + "max_input_tokens": 400000, + "max_output_tokens": 128000, + "input_cost_per_token": 2.5e-07, + "output_cost_per_token": 2e-06, + "cache_read_input_token_cost": 2.5e-08, + "litellm_provider": "openrouter", + "mode": "chat", + "supported_modalities": [ + "text", + "image" + ], + "supported_output_modalities": [ + "text" + ], + "supports_tool_choice": true, + "supports_reasoning": true + }, + "openrouter/openai/gpt-5-nano": { + "max_tokens": 128000, + "max_input_tokens": 400000, + "max_output_tokens": 128000, + "input_cost_per_token": 5e-08, + "output_cost_per_token": 4e-07, + "cache_read_input_token_cost": 5e-09, + "litellm_provider": "openrouter", + "mode": "chat", + "supported_modalities": [ + "text", + "image" + ], + "supported_output_modalities": [ + "text" + ], + "supports_tool_choice": true, + "supports_reasoning": true + }, + "openrouter/openai/gpt-5-chat": { + "max_tokens": 128000, + "max_input_tokens": 400000, + "max_output_tokens": 128000, + "input_cost_per_token": 1.25e-06, + "output_cost_per_token": 1e-05, + "cache_read_input_token_cost": 1.25e-07, + "litellm_provider": "openrouter", + "mode": "chat", + "supported_modalities": [ + "text", + "image" + ], + "supported_output_modalities": [ + "text" + ], + "supports_tool_choice": false, + "supports_reasoning": true + }, "openrouter/openai/gpt-oss-20b": { "max_tokens": 32768, "max_input_tokens": 131072, @@ -14605,6 +14861,50 @@ "mode": "chat", "supports_tool_choice": true }, + "together_ai/Qwen/Qwen3-235B-A22B-Instruct-2507-tput": { + "input_cost_per_token": 2e-07, + "output_cost_per_token": 6e-06, + "max_input_tokens": 262000, + "litellm_provider": "together_ai", + "supports_function_calling": false, + "supports_parallel_function_calling": false, + "mode": "chat", + "supports_tool_choice": false, + "source": "https://www.together.ai/models/qwen3-235b-a22b-instruct-2507-fp8" + }, + "together_ai/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8": { + "input_cost_per_token": 2e-06, + "output_cost_per_token": 2e-06, + "max_input_tokens": 256000, + "litellm_provider": "together_ai", + "supports_function_calling": false, + "supports_parallel_function_calling": false, + "mode": "chat", + "supports_tool_choice": false, + "source": "https://www.together.ai/models/qwen3-coder-480b-a35b-instruct" + }, + "together_ai/Qwen/Qwen3-235B-A22B-Thinking-2507": { + "input_cost_per_token": 6.5e-07, + "output_cost_per_token": 3e-06, + "max_input_tokens": 256000, + "litellm_provider": "together_ai", + "supports_function_calling": false, + "supports_parallel_function_calling": false, + "mode": "chat", + "supports_tool_choice": false, + "source": "https://www.together.ai/models/qwen3-235b-a22b-thinking-2507" + }, + "together_ai/Qwen/Qwen3-235B-A22B-fp8-tput": { + "input_cost_per_token": 2e-07, + "output_cost_per_token": 6e-07, + "max_input_tokens": 40000, + "litellm_provider": "together_ai", + "supports_function_calling": false, + "supports_parallel_function_calling": false, + "mode": "chat", + "supports_tool_choice": false, + "source": "https://www.together.ai/models/qwen3-235b-a22b-fp8-tput" + }, "together_ai/deepseek-ai/DeepSeek-V3": { "input_cost_per_token": 1.25e-06, "output_cost_per_token": 1.25e-06, @@ -14629,6 +14929,17 @@ "mode": "chat", "supports_tool_choice": true }, + "together_ai/deepseek-ai/DeepSeek-R1-0528-tput": { + "input_cost_per_token": 5.5e-07, + "output_cost_per_token": 2.19e-06, + "max_input_tokens": 128000, + "litellm_provider": "together_ai", + "supports_function_calling": false, + "supports_parallel_function_calling": false, + "mode": "chat", + "supports_tool_choice": false, + "source": "https://www.together.ai/models/deepseek-r1-0528-throughput" + }, "together_ai/mistralai/Mistral-Small-24B-Instruct-2501": { "litellm_provider": "together_ai", "supports_function_calling": true, @@ -14646,6 +14957,39 @@ "mode": "chat", "source": "https://www.together.ai/models/kimi-k2-instruct" }, + "together_ai/openai/gpt-oss-120b": { + "input_cost_per_token": 1.5e-07, + "output_cost_per_token": 6e-07, + "max_input_tokens": 128000, + "litellm_provider": "together_ai", + "supports_function_calling": false, + "supports_tool_choice": false, + "supports_parallel_function_calling": false, + "mode": "chat", + "source": "https://www.together.ai/models/gpt-oss-120b" + }, + "together_ai/OpenAI/gpt-oss-20B": { + "input_cost_per_token": 5e-08, + "output_cost_per_token": 2e-07, + "max_input_tokens": 128000, + "litellm_provider": "together_ai", + "supports_function_calling": false, + "supports_tool_choice": false, + "supports_parallel_function_calling": false, + "mode": "chat", + "source": "https://www.together.ai/models/gpt-oss-20b" + }, + "together_ai/zai-org/GLM-4.5-Air-FP8": { + "input_cost_per_token": 2e-07, + "output_cost_per_token": 1.1e-06, + "max_input_tokens": 128000, + "litellm_provider": "together_ai", + "supports_function_calling": false, + "supports_tool_choice": false, + "supports_parallel_function_calling": false, + "mode": "chat", + "source": "https://www.together.ai/models/glm-4-5-air" + }, "ollama/codegemma": { "max_tokens": 8192, "max_input_tokens": 8192, @@ -14884,12 +15228,12 @@ "litellm_provider": "ollama", "mode": "completion" }, - "deepinfra/lizpreciatior/lzlv_70b_fp16_hf": { + "deepinfra/Austism/chronos-hermes-13b-v2": { "max_tokens": 4096, "max_input_tokens": 4096, "max_output_tokens": 4096, - "input_cost_per_token": 7e-07, - "output_cost_per_token": 9e-07, + "input_cost_per_token": 1.3e-07, + "output_cost_per_token": 1.3e-07, "litellm_provider": "deepinfra", "mode": "chat", "supports_tool_choice": true @@ -14898,64 +15242,65 @@ "max_tokens": 4096, "max_input_tokens": 4096, "max_output_tokens": 4096, - "input_cost_per_token": 2.2e-07, - "output_cost_per_token": 2.2e-07, + "input_cost_per_token": 7.2e-08, + "output_cost_per_token": 7.2e-08, "litellm_provider": "deepinfra", "mode": "chat", "supports_tool_choice": true }, - "deepinfra/mistralai/Mistral-7B-Instruct-v0.1": { - "max_tokens": 8191, - "max_input_tokens": 32768, - "max_output_tokens": 8191, + "deepinfra/Gryphe/MythoMax-L2-13b-turbo": { + "max_tokens": 4096, + "max_input_tokens": 4096, + "max_output_tokens": 4096, "input_cost_per_token": 1.3e-07, "output_cost_per_token": 1.3e-07, "litellm_provider": "deepinfra", "mode": "chat", - "supports_tool_choice": true + "supports_tool_choice": false }, - "deepinfra/meta-llama/Llama-2-70b-chat-hf": { + "deepinfra/KoboldAI/LLaMA2-13B-Tiefighter": { "max_tokens": 4096, "max_input_tokens": 4096, "max_output_tokens": 4096, + "input_cost_per_token": 1e-07, + "output_cost_per_token": 1e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/NousResearch/Hermes-3-Llama-3.1-405B": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, "input_cost_per_token": 7e-07, - "output_cost_per_token": 9e-07, + "output_cost_per_token": 8e-07, "litellm_provider": "deepinfra", "mode": "chat", "supports_tool_choice": true }, - "deepinfra/cognitivecomputations/dolphin-2.6-mixtral-8x7b": { - "max_tokens": 8191, + "deepinfra/NousResearch/Hermes-3-Llama-3.1-70B": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 1e-07, + "output_cost_per_token": 2.8e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/NovaSky-AI/Sky-T1-32B-Preview": { + "max_tokens": 32768, "max_input_tokens": 32768, - "max_output_tokens": 8191, - "input_cost_per_token": 2.7e-07, - "output_cost_per_token": 2.7e-07, + "max_output_tokens": 32768, + "input_cost_per_token": 1.2e-07, + "output_cost_per_token": 1.8e-07, "litellm_provider": "deepinfra", "mode": "chat", - "supports_tool_choice": true - }, - "deepinfra/codellama/CodeLlama-34b-Instruct-hf": { - "max_tokens": 4096, - "max_input_tokens": 4096, - "max_output_tokens": 4096, - "input_cost_per_token": 6e-07, - "output_cost_per_token": 6e-07, - "litellm_provider": "deepinfra", - "mode": "chat", - "supports_tool_choice": true - }, - "deepinfra/deepinfra/mixtral": { - "max_tokens": 4096, - "max_input_tokens": 32000, - "max_output_tokens": 4096, - "input_cost_per_token": 2.7e-07, - "output_cost_per_token": 2.7e-07, - "litellm_provider": "deepinfra", - "mode": "completion" + "supports_tool_choice": false }, "deepinfra/Phind/Phind-CodeLlama-34B-v2": { "max_tokens": 4096, - "max_input_tokens": 16384, + "max_input_tokens": 4096, "max_output_tokens": 4096, "input_cost_per_token": 6e-07, "output_cost_per_token": 6e-07, @@ -14963,16 +15308,306 @@ "mode": "chat", "supports_tool_choice": true }, - "deepinfra/mistralai/Mixtral-8x7B-Instruct-v0.1": { - "max_tokens": 8191, - "max_input_tokens": 32768, - "max_output_tokens": 8191, - "input_cost_per_token": 2.7e-07, - "output_cost_per_token": 2.7e-07, + "deepinfra/Qwen/QVQ-72B-Preview": { + "max_tokens": 32000, + "max_input_tokens": 32000, + "max_output_tokens": 32000, + "input_cost_per_token": 2.5e-07, + "output_cost_per_token": 5e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/Qwen/QwQ-32B": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 7.5e-08, + "output_cost_per_token": 1.5e-07, "litellm_provider": "deepinfra", "mode": "chat", "supports_tool_choice": true }, + "deepinfra/Qwen/QwQ-32B-Preview": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 1.2e-07, + "output_cost_per_token": 1.8e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/Qwen/Qwen2-72B-Instruct": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 3.5e-07, + "output_cost_per_token": 4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Qwen/Qwen2-7B-Instruct": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 5.5e-08, + "output_cost_per_token": 5.5e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Qwen/Qwen2.5-72B-Instruct": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 1.2e-07, + "output_cost_per_token": 3.9e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Qwen/Qwen2.5-7B-Instruct": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 4e-08, + "output_cost_per_token": 1e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/Qwen/Qwen2.5-Coder-32B-Instruct": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 6e-08, + "output_cost_per_token": 1.5e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/Qwen/Qwen2.5-Coder-7B": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 2.5e-08, + "output_cost_per_token": 5e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/Qwen/Qwen2.5-VL-32B-Instruct": { + "max_tokens": 128000, + "max_input_tokens": 128000, + "max_output_tokens": 128000, + "input_cost_per_token": 2e-07, + "output_cost_per_token": 6e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Qwen/Qwen3-14B": { + "max_tokens": 40960, + "max_input_tokens": 40960, + "max_output_tokens": 40960, + "input_cost_per_token": 6e-08, + "output_cost_per_token": 2.4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Qwen/Qwen3-235B-A22B": { + "max_tokens": 40960, + "max_input_tokens": 40960, + "max_output_tokens": 40960, + "input_cost_per_token": 1.3e-07, + "output_cost_per_token": 6e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Qwen/Qwen3-235B-A22B-Instruct-2507": { + "max_tokens": 262144, + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "input_cost_per_token": 1.3e-07, + "output_cost_per_token": 6e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Qwen/Qwen3-235B-A22B-Thinking-2507": { + "max_tokens": 262144, + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "input_cost_per_token": 1.3e-07, + "output_cost_per_token": 6e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Qwen/Qwen3-30B-A3B": { + "max_tokens": 40960, + "max_input_tokens": 40960, + "max_output_tokens": 40960, + "input_cost_per_token": 8e-08, + "output_cost_per_token": 2.9e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Qwen/Qwen3-32B": { + "max_tokens": 40960, + "max_input_tokens": 40960, + "max_output_tokens": 40960, + "input_cost_per_token": 1e-07, + "output_cost_per_token": 3e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Qwen/Qwen3-Coder-480B-A35B-Instruct": { + "max_tokens": 262144, + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "input_cost_per_token": 4e-07, + "output_cost_per_token": 1.6e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Qwen/Qwen3-Coder-480B-A35B-Instruct-Turbo": { + "max_tokens": 262144, + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "input_cost_per_token": 3e-07, + "output_cost_per_token": 1.2e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/Sao10K/L3-70B-Euryale-v2.1": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 7e-07, + "output_cost_per_token": 8e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/Sao10K/L3-8B-Lunaris-v1": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 3e-08, + "output_cost_per_token": 6e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/Sao10K/L3-8B-Lunaris-v1-Turbo": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 2e-08, + "output_cost_per_token": 5e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/Sao10K/L3.1-70B-Euryale-v2.2": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 6.5e-07, + "output_cost_per_token": 7.5e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/Sao10K/L3.3-70B-Euryale-v2.3": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 6.5e-07, + "output_cost_per_token": 7.5e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/allenai/olmOCR-7B-0725-FP8": { + "max_tokens": 16384, + "max_input_tokens": 16384, + "max_output_tokens": 16384, + "input_cost_per_token": 2.7e-07, + "output_cost_per_token": 1.5e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/anthropic/claude-3-7-sonnet-latest": { + "max_tokens": 200000, + "max_input_tokens": 200000, + "max_output_tokens": 200000, + "input_cost_per_token": 3.3e-06, + "output_cost_per_token": 1.65e-05, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/anthropic/claude-4-opus": { + "max_tokens": 200000, + "max_input_tokens": 200000, + "max_output_tokens": 200000, + "input_cost_per_token": 1.65e-05, + "output_cost_per_token": 8.25e-05, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/anthropic/claude-4-sonnet": { + "max_tokens": 200000, + "max_input_tokens": 200000, + "max_output_tokens": 200000, + "input_cost_per_token": 3.3e-06, + "output_cost_per_token": 1.65e-05, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/bigcode/starcoder2-15b-instruct-v0.1": { + "max_tokens": 4096, + "max_input_tokens": 4096, + "max_output_tokens": 4096, + "input_cost_per_token": 1.5e-07, + "output_cost_per_token": 1.5e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/cognitivecomputations/dolphin-2.6-mixtral-8x7b": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 2.4e-07, + "output_cost_per_token": 2.4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/cognitivecomputations/dolphin-2.9.1-llama-3-70b": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 3.5e-07, + "output_cost_per_token": 4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, "deepinfra/deepinfra/airoboros-70b": { "max_tokens": 4096, "max_input_tokens": 4096, @@ -14983,56 +15618,257 @@ "mode": "chat", "supports_tool_choice": true }, - "deepinfra/01-ai/Yi-34B-Chat": { - "max_tokens": 4096, - "max_input_tokens": 4096, - "max_output_tokens": 4096, - "input_cost_per_token": 6e-07, - "output_cost_per_token": 6e-07, + "deepinfra/deepseek-ai/DeepSeek-Prover-V2-671B": { + "max_tokens": 163840, + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "input_cost_per_token": 5e-07, + "output_cost_per_token": 2.18e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/deepseek-ai/DeepSeek-R1": { + "max_tokens": 163840, + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "input_cost_per_token": 4.5e-07, + "output_cost_per_token": 2.15e-06, "litellm_provider": "deepinfra", "mode": "chat", "supports_tool_choice": true }, - "deepinfra/01-ai/Yi-6B-200K": { - "max_tokens": 4096, - "max_input_tokens": 200000, - "max_output_tokens": 4096, - "input_cost_per_token": 1.3e-07, - "output_cost_per_token": 1.3e-07, - "litellm_provider": "deepinfra", - "mode": "completion" - }, - "deepinfra/jondurbin/airoboros-l2-70b-gpt4-1.4.1": { - "max_tokens": 4096, - "max_input_tokens": 4096, - "max_output_tokens": 4096, - "input_cost_per_token": 7e-07, - "output_cost_per_token": 9e-07, + "deepinfra/deepseek-ai/DeepSeek-R1-0528": { + "max_tokens": 163840, + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "input_cost_per_token": 5e-07, + "output_cost_per_token": 2.15e-06, "litellm_provider": "deepinfra", "mode": "chat", "supports_tool_choice": true }, + "deepinfra/deepseek-ai/DeepSeek-R1-0528-Turbo": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 1e-06, + "output_cost_per_token": 3e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/deepseek-ai/DeepSeek-R1-Distill-Llama-70B": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 1e-07, + "output_cost_per_token": 4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 7.5e-08, + "output_cost_per_token": 1.5e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/deepseek-ai/DeepSeek-R1-Turbo": { + "max_tokens": 163840, + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "input_cost_per_token": 1e-06, + "output_cost_per_token": 3e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/deepseek-ai/DeepSeek-V3": { + "max_tokens": 163840, + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "input_cost_per_token": 3.8e-07, + "output_cost_per_token": 8.9e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/deepseek-ai/DeepSeek-V3-0324": { + "max_tokens": 163840, + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "input_cost_per_token": 2.8e-07, + "output_cost_per_token": 8.8e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/deepseek-ai/DeepSeek-V3-0324-Turbo": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 1e-06, + "output_cost_per_token": 3e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/deepseek-ai/DeepSeek-V3.1": { + "max_tokens": 163840, + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "input_cost_per_token": 3e-07, + "output_cost_per_token": 1e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/google/codegemma-7b-it": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 7e-08, + "output_cost_per_token": 7e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/google/gemini-1.5-flash": { + "max_tokens": 1000000, + "max_input_tokens": 1000000, + "max_output_tokens": 1000000, + "input_cost_per_token": 7.5e-08, + "output_cost_per_token": 3e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/google/gemini-1.5-flash-8b": { + "max_tokens": 1000000, + "max_input_tokens": 1000000, + "max_output_tokens": 1000000, + "input_cost_per_token": 3.75e-08, + "output_cost_per_token": 1.5e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/google/gemini-2.0-flash-001": { + "max_tokens": 1000000, + "max_input_tokens": 1000000, + "max_output_tokens": 1000000, + "input_cost_per_token": 1e-07, + "output_cost_per_token": 4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/google/gemini-2.5-flash": { + "max_tokens": 1000000, + "max_input_tokens": 1000000, + "max_output_tokens": 1000000, + "input_cost_per_token": 2.1e-07, + "output_cost_per_token": 1.75e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/google/gemini-2.5-pro": { + "max_tokens": 1000000, + "max_input_tokens": 1000000, + "max_output_tokens": 1000000, + "input_cost_per_token": 8.75e-07, + "output_cost_per_token": 7e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/google/gemma-1.1-7b-it": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 7e-08, + "output_cost_per_token": 7e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/google/gemma-2-27b-it": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 2.7e-07, + "output_cost_per_token": 2.7e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/google/gemma-2-9b-it": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 3e-08, + "output_cost_per_token": 6e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/google/gemma-3-12b-it": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 5e-08, + "output_cost_per_token": 1e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/google/gemma-3-27b-it": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 9e-08, + "output_cost_per_token": 1.7e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/google/gemma-3-4b-it": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 2e-08, + "output_cost_per_token": 4e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/lizpreciatior/lzlv_70b_fp16_hf": { + "max_tokens": 4096, + "max_input_tokens": 4096, + "max_output_tokens": 4096, + "input_cost_per_token": 3.5e-07, + "output_cost_per_token": 4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/mattshumer/Reflection-Llama-3.1-70B": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 3.5e-07, + "output_cost_per_token": 4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, "deepinfra/meta-llama/Llama-2-13b-chat-hf": { - "max_tokens": 4096, - "max_input_tokens": 4096, - "max_output_tokens": 4096, - "input_cost_per_token": 2.2e-07, - "output_cost_per_token": 2.2e-07, - "litellm_provider": "deepinfra", - "mode": "chat", - "supports_tool_choice": true - }, - "deepinfra/amazon/MistralLite": { - "max_tokens": 8191, - "max_input_tokens": 32768, - "max_output_tokens": 8191, - "input_cost_per_token": 2e-07, - "output_cost_per_token": 2e-07, - "litellm_provider": "deepinfra", - "mode": "chat", - "supports_tool_choice": true - }, - "deepinfra/meta-llama/Llama-2-7b-chat-hf": { "max_tokens": 4096, "max_input_tokens": 4096, "max_output_tokens": 4096, @@ -15042,22 +15878,142 @@ "mode": "chat", "supports_tool_choice": true }, - "deepinfra/meta-llama/Meta-Llama-3-8B-Instruct": { - "max_tokens": 8191, - "max_input_tokens": 8191, + "deepinfra/meta-llama/Llama-2-70b-chat-hf": { + "max_tokens": 4096, + "max_input_tokens": 4096, "max_output_tokens": 4096, - "input_cost_per_token": 8e-08, - "output_cost_per_token": 8e-08, + "input_cost_per_token": 6.4e-07, + "output_cost_per_token": 8e-07, "litellm_provider": "deepinfra", "mode": "chat", "supports_tool_choice": true }, + "deepinfra/meta-llama/Llama-3.2-11B-Vision-Instruct": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 4.9e-08, + "output_cost_per_token": 4.9e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/meta-llama/Llama-3.2-1B-Instruct": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 5e-09, + "output_cost_per_token": 1e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/meta-llama/Llama-3.2-3B-Instruct": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 1.2e-08, + "output_cost_per_token": 2.4e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/meta-llama/Llama-3.2-90B-Vision-Instruct": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 3.5e-07, + "output_cost_per_token": 4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/meta-llama/Llama-3.3-70B-Instruct": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 2.3e-07, + "output_cost_per_token": 4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/meta-llama/Llama-3.3-70B-Instruct-Turbo": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 3.8e-08, + "output_cost_per_token": 1.2e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8": { + "max_tokens": 1048576, + "max_input_tokens": 1048576, + "max_output_tokens": 1048576, + "input_cost_per_token": 1.5e-07, + "output_cost_per_token": 6e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/meta-llama/Llama-4-Maverick-17B-128E-Instruct-Turbo": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 5e-07, + "output_cost_per_token": 5e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/meta-llama/Llama-4-Scout-17B-16E-Instruct": { + "max_tokens": 327680, + "max_input_tokens": 327680, + "max_output_tokens": 327680, + "input_cost_per_token": 8e-08, + "output_cost_per_token": 3e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/meta-llama/Llama-Guard-3-8B": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 5.5e-08, + "output_cost_per_token": 5.5e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/meta-llama/Llama-Guard-4-12B": { + "max_tokens": 163840, + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "input_cost_per_token": 1.8e-07, + "output_cost_per_token": 1.8e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, "deepinfra/meta-llama/Meta-Llama-3-70B-Instruct": { - "max_tokens": 8191, - "max_input_tokens": 8191, - "max_output_tokens": 4096, - "input_cost_per_token": 5.9e-07, - "output_cost_per_token": 7.9e-07, + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 3e-07, + "output_cost_per_token": 4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/meta-llama/Meta-Llama-3-8B-Instruct": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 3e-08, + "output_cost_per_token": 6e-08, "litellm_provider": "deepinfra", "mode": "chat", "supports_tool_choice": true @@ -15066,29 +16022,318 @@ "max_tokens": 32768, "max_input_tokens": 32768, "max_output_tokens": 32768, - "input_cost_per_token": 9e-07, - "output_cost_per_token": 9e-07, + "input_cost_per_token": 8e-07, + "output_cost_per_token": 8e-07, "litellm_provider": "deepinfra", "mode": "chat", - "supports_function_calling": true, - "supports_parallel_function_calling": true, "supports_tool_choice": true }, - "deepinfra/01-ai/Yi-34B-200K": { - "max_tokens": 4096, - "max_input_tokens": 200000, - "max_output_tokens": 4096, - "input_cost_per_token": 6e-07, - "output_cost_per_token": 6e-07, + "deepinfra/meta-llama/Meta-Llama-3.1-70B-Instruct": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 2.3e-07, + "output_cost_per_token": 4e-07, "litellm_provider": "deepinfra", - "mode": "completion" + "mode": "chat", + "supports_tool_choice": true }, - "deepinfra/openchat/openchat_3.5": { + "deepinfra/meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 1e-07, + "output_cost_per_token": 2.8e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/meta-llama/Meta-Llama-3.1-8B-Instruct": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 3e-08, + "output_cost_per_token": 5e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 1.5e-08, + "output_cost_per_token": 2e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/microsoft/Phi-3-medium-4k-instruct": { "max_tokens": 4096, "max_input_tokens": 4096, "max_output_tokens": 4096, - "input_cost_per_token": 1.3e-07, - "output_cost_per_token": 1.3e-07, + "input_cost_per_token": 1.4e-07, + "output_cost_per_token": 1.4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/microsoft/Phi-4-multimodal-instruct": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 5e-08, + "output_cost_per_token": 1e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/microsoft/WizardLM-2-7B": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 5.5e-08, + "output_cost_per_token": 5.5e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/microsoft/WizardLM-2-8x22B": { + "max_tokens": 65536, + "max_input_tokens": 65536, + "max_output_tokens": 65536, + "input_cost_per_token": 4.8e-07, + "output_cost_per_token": 4.8e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/microsoft/phi-4": { + "max_tokens": 16384, + "max_input_tokens": 16384, + "max_output_tokens": 16384, + "input_cost_per_token": 7e-08, + "output_cost_per_token": 1.4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/microsoft/phi-4-reasoning-plus": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 7e-08, + "output_cost_per_token": 3.5e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/mistralai/Devstral-Small-2505": { + "max_tokens": 128000, + "max_input_tokens": 128000, + "max_output_tokens": 128000, + "input_cost_per_token": 6e-08, + "output_cost_per_token": 1.2e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/mistralai/Devstral-Small-2507": { + "max_tokens": 128000, + "max_input_tokens": 128000, + "max_output_tokens": 128000, + "input_cost_per_token": 7e-08, + "output_cost_per_token": 2.8e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/mistralai/Mistral-7B-Instruct-v0.1": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 5.5e-08, + "output_cost_per_token": 5.5e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/mistralai/Mistral-7B-Instruct-v0.2": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 5.5e-08, + "output_cost_per_token": 5.5e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/mistralai/Mistral-7B-Instruct-v0.3": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 2.8e-08, + "output_cost_per_token": 5.4e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/mistralai/Mistral-Nemo-Instruct-2407": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 2e-08, + "output_cost_per_token": 4e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/mistralai/Mistral-Small-24B-Instruct-2501": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 5e-08, + "output_cost_per_token": 8e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/mistralai/Mistral-Small-3.1-24B-Instruct-2503": { + "max_tokens": 128000, + "max_input_tokens": 128000, + "max_output_tokens": 128000, + "input_cost_per_token": 5e-08, + "output_cost_per_token": 1e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/mistralai/Mistral-Small-3.2-24B-Instruct-2506": { + "max_tokens": 128000, + "max_input_tokens": 128000, + "max_output_tokens": 128000, + "input_cost_per_token": 5e-08, + "output_cost_per_token": 1e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/mistralai/Mixtral-8x22B-Instruct-v0.1": { + "max_tokens": 65536, + "max_input_tokens": 65536, + "max_output_tokens": 65536, + "input_cost_per_token": 6.5e-07, + "output_cost_per_token": 6.5e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/mistralai/Mixtral-8x7B-Instruct-v0.1": { + "max_tokens": 32768, + "max_input_tokens": 32768, + "max_output_tokens": 32768, + "input_cost_per_token": 8e-08, + "output_cost_per_token": 2.4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/moonshotai/Kimi-K2-Instruct": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 5e-07, + "output_cost_per_token": 2e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/nvidia/Llama-3.1-Nemotron-70B-Instruct": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 1.2e-07, + "output_cost_per_token": 3e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/nvidia/Nemotron-4-340B-Instruct": { + "max_tokens": 4096, + "max_input_tokens": 4096, + "max_output_tokens": 4096, + "input_cost_per_token": 4.2e-06, + "output_cost_per_token": 4.2e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/openai/gpt-oss-120b": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 9e-08, + "output_cost_per_token": 4.5e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/openai/gpt-oss-20b": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 4e-08, + "output_cost_per_token": 1.6e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/openbmb/MiniCPM-Llama3-V-2_5": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 3.4e-07, + "output_cost_per_token": 3.4e-07, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/openchat/openchat-3.6-8b": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 5.5e-08, + "output_cost_per_token": 5.5e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": false + }, + "deepinfra/openchat/openchat_3.5": { + "max_tokens": 8192, + "max_input_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 5.5e-08, + "output_cost_per_token": 5.5e-08, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/zai-org/GLM-4.5": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 5.5e-07, + "output_cost_per_token": 2e-06, + "litellm_provider": "deepinfra", + "mode": "chat", + "supports_tool_choice": true + }, + "deepinfra/zai-org/GLM-4.5-Air": { + "max_tokens": 131072, + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "input_cost_per_token": 2e-07, + "output_cost_per_token": 1.1e-06, "litellm_provider": "deepinfra", "mode": "chat", "supports_tool_choice": true @@ -15514,6 +16759,18 @@ "source": "https://fireworks.ai/pricing", "supports_tool_choice": false }, + "fireworks_ai/accounts/fireworks/models/deepseek-v3-0324": { + "max_tokens": 163840, + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "input_cost_per_token": 9e-07, + "output_cost_per_token": 9e-07, + "litellm_provider": "fireworks_ai", + "mode": "chat", + "supports_response_schema": true, + "source": "https://fireworks.ai/models/fireworks/deepseek-v3-0324", + "supports_tool_choice": false + }, "fireworks_ai/accounts/fireworks/models/deepseek-r1": { "max_tokens": 20480, "max_input_tokens": 128000, @@ -15550,6 +16807,18 @@ "supports_tool_choice": false, "supports_response_schema": true }, + "fireworks_ai/accounts/fireworks/models/deepseek-v3p1": { + "max_tokens": 8192, + "max_input_tokens": 128000, + "max_output_tokens": 8192, + "input_cost_per_token": 5.6e-07, + "output_cost_per_token": 1.68e-06, + "litellm_provider": "fireworks_ai", + "mode": "chat", + "supports_response_schema": true, + "source": "https://fireworks.ai/pricing", + "supports_tool_choice": true + }, "fireworks_ai/accounts/fireworks/models/kimi-k2-instruct": { "max_tokens": 131072, "max_input_tokens": 131072, @@ -16502,6 +17771,14 @@ "litellm_provider": "voyage", "mode": "embedding" }, + "voyage/voyage-context-3": { + "max_tokens": 120000, + "max_input_tokens": 120000, + "input_cost_per_token": 1.8e-07, + "output_cost_per_token": 0.0, + "litellm_provider": "voyage", + "mode": "embedding" + }, "voyage/rerank-2": { "max_tokens": 16000, "max_input_tokens": 16000, @@ -16559,22 +17836,6 @@ }, "supports_tool_choice": true }, - "databricks/databricks-meta-llama-3-1-70b-instruct": { - "max_tokens": 128000, - "max_input_tokens": 128000, - "max_output_tokens": 128000, - "input_cost_per_token": 1.00002e-06, - "input_dbu_cost_per_token": 1.4286e-05, - "output_cost_per_token": 2.99999e-06, - "output_dbu_cost_per_token": 4.2857e-05, - "litellm_provider": "databricks", - "mode": "chat", - "source": "https://www.databricks.com/product/pricing/foundation-model-serving", - "metadata": { - "notes": "Input/output cost per token is dbu cost * $0.070, based on databricks Llama 3.1 70B conversion. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation." - }, - "supports_tool_choice": true - }, "databricks/databricks-meta-llama-3-3-70b-instruct": { "max_tokens": 128000, "max_input_tokens": 128000, @@ -16607,22 +17868,6 @@ }, "supports_tool_choice": true }, - "databricks/databricks-dbrx-instruct": { - "max_tokens": 32768, - "max_input_tokens": 32768, - "max_output_tokens": 32768, - "input_cost_per_token": 7.4998e-07, - "input_dbu_cost_per_token": 1.0714e-05, - "output_cost_per_token": 2.24901e-06, - "output_dbu_cost_per_token": 3.2143e-05, - "litellm_provider": "databricks", - "mode": "chat", - "source": "https://www.databricks.com/product/pricing/foundation-model-serving", - "metadata": { - "notes": "Input/output cost per token is dbu cost * $0.070, based on databricks Llama 3.1 70B conversion. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation." - }, - "supports_tool_choice": true - }, "databricks/databricks-meta-llama-3-70b-instruct": { "max_tokens": 128000, "max_input_tokens": 128000, @@ -18533,5 +19778,118 @@ "supports_function_calling": true, "supports_response_schema": false, "source": "https://www.oracle.com/artificial-intelligence/generative-ai/generative-ai-service/pricing" + }, + "aiml/flux/kontext-pro/text-to-image":{ + "output_cost_per_image": 0.042, + "litellm_provider": "aiml", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://docs.aimlapi.com/", + "metadata": { + "notes": "Flux Pro v1.1 - Enhanced version with improved capabilities and 6x faster inference speed" + } + + }, + "aiml/flux/kontext-max/text-to-image": { + "output_cost_per_image": 0.084, + "litellm_provider": "aiml", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://docs.aimlapi.com/", + "metadata": { + "notes": "Flux Pro v1.1 - Enhanced version with improved capabilities and 6x faster inference speed" + } + }, + "aiml/flux-pro/v1.1-ultra": { + "output_cost_per_image": 0.063, + "litellm_provider": "aiml", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ] + }, + "aiml/flux-pro/v1.1": { + "output_cost_per_image": 0.042, + "litellm_provider": "aiml", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ] + }, + "aiml/flux-realism": { + "output_cost_per_image": 0.037, + "litellm_provider": "aiml", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://docs.aimlapi.com/", + "metadata": { + "notes": "Flux Pro - Professional-grade image generation model" + } + }, + "aiml/flux/schnell": { + "output_cost_per_image": 0.003, + "litellm_provider": "aiml", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://docs.aimlapi.com/", + "metadata": { + "notes": "Flux Schnell - Fast generation model optimized for speed" + } + }, + "aiml/flux/dev": { + "output_cost_per_image": 0.026, + "litellm_provider": "aiml", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://docs.aimlapi.com/", + "metadata": { + "notes": "Flux Dev - Development version optimized for experimentation" + } + }, + "aiml/flux-pro": { + "output_cost_per_image": 0.053, + "litellm_provider": "aiml", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://docs.aimlapi.com/", + "metadata": { + "notes": "Flux Dev - Development version optimized for experimentation" + } + }, + "aiml/dall-e-3": { + "output_cost_per_image": 0.042, + "litellm_provider": "aiml", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://docs.aimlapi.com/", + "metadata": { + "notes": "DALL-E 3 via AI/ML API - High-quality text-to-image generation" + } + }, + "aiml/dall-e-2": { + "output_cost_per_image": 0.021, + "litellm_provider": "aiml", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://docs.aimlapi.com/", + "metadata": { + "notes": "DALL-E 2 via AI/ML API - Reliable text-to-image generation" + } } } diff --git a/litellm/passthrough/main.py b/litellm/passthrough/main.py index 59fab1b3369..f4dc1ef6c84 100644 --- a/litellm/passthrough/main.py +++ b/litellm/passthrough/main.py @@ -24,6 +24,7 @@ import litellm from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler from litellm.llms.custom_httpx.llm_http_handler import BaseLLMHTTPHandler +from litellm.passthrough.utils import CommonUtils from litellm.utils import client base_llm_http_handler = BaseLLMHTTPHandler() @@ -241,6 +242,12 @@ def llm_passthrough_route( request_query_params=request_query_params, litellm_params=litellm_params_dict, ) + + # need to encode the id of application-inference-profile for bedrock + if custom_llm_provider == "bedrock" and "application-inference-profile" in endpoint: + encoded_url_str = CommonUtils.encode_bedrock_runtime_modelid_arn(str(updated_url)) + updated_url = httpx.URL(encoded_url_str) + # Add or update query parameters provider_api_key = provider_config.get_api_key(api_key) diff --git a/litellm/passthrough/utils.py b/litellm/passthrough/utils.py index c52d0e3688d..4bf66d49881 100644 --- a/litellm/passthrough/utils.py +++ b/litellm/passthrough/utils.py @@ -37,3 +37,56 @@ class BasePassthroughUtils: # Combine request headers with custom headers headers = {**request_headers, **headers} return headers + +class CommonUtils: + @staticmethod + def encode_bedrock_runtime_modelid_arn(endpoint: str) -> str: + """ + Encodes any "/" found in the modelId of an AWS Bedrock Runtime Endpoint when arns are passed in. + - modelID value can be an ARN which contains slashes that SHOULD NOT be treated as path separators. + e.g endpoint: /model//invoke + containing arns with slashes need to be encoded from + arn:aws:bedrock:ap-southeast-1:123456789012:application-inference-profile/abdefg12334 => + arn:aws:bedrock:ap-southeast-1:123456789012:application-inference-profile%2Fabdefg12334 + so that it is treated as one part of the path. + Otherwise, the encoded endpoint will return 500 error when passed to Bedrock endpoint. + + See the apis in https://docs.aws.amazon.com/bedrock/latest/APIReference/API_Operations_Amazon_Bedrock_Runtime.html + for more details on the regex patterns of modelId which we use in the regex logic below. + + Args: + endpoint (str): The original endpoint string which may contain ARNs that contain slashes. + + Returns: + str: The endpoint with properly encoded ARN slashes + """ + import re + + # Early exit: if no ARN detected, return unchanged + if 'arn:aws:' not in endpoint: + return endpoint + + # Handle all patterns in one go - more efficient and cleaner + patterns = [ + # Custom model with 2 slashes (order matters - do this first) + (r'(custom-model)/([a-z0-9.-]+)/([a-z0-9]+)', r'\1%2F\2%2F\3'), + + # All other resource types with 1 slash + (r'(:application-inference-profile)/', r'\1%2F'), + (r'(:inference-profile)/', r'\1%2F'), + (r'(:foundation-model)/', r'\1%2F'), + (r'(:imported-model)/', r'\1%2F'), + (r'(:provisioned-model)/', r'\1%2F'), + (r'(:prompt)/', r'\1%2F'), + (r'(:endpoint)/', r'\1%2F'), + (r'(:prompt-router)/', r'\1%2F'), + (r'(:default-prompt-router)/', r'\1%2F'), + ] + + for pattern, replacement in patterns: + # Check if pattern exists before applying regex (early exit optimization) + if re.search(pattern, endpoint): + endpoint = re.sub(pattern, replacement, endpoint) + break # Exit after first match since each ARN has only one resource type + + return endpoint \ No newline at end of file diff --git a/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py b/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py index 7469848e2f2..a075de13fb1 100644 --- a/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py +++ b/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py @@ -236,12 +236,17 @@ class MCPRequestHandler: ) ######################################################### - # If team has mcp_servers, then key must have a subset of the team's mcp_servers + # If team has mcp_servers, handle inheritance and intersection logic ######################################################### if len(allowed_mcp_servers_for_team) > 0: - for _mcp_server in allowed_mcp_servers_for_key: - if _mcp_server in allowed_mcp_servers_for_team: - allowed_mcp_servers.append(_mcp_server) + if len(allowed_mcp_servers_for_key) > 0: + # Key has its own MCP permissions - use intersection with team permissions + for _mcp_server in allowed_mcp_servers_for_key: + if _mcp_server in allowed_mcp_servers_for_team: + allowed_mcp_servers.append(_mcp_server) + else: + # Key has no MCP permissions - inherit from team + allowed_mcp_servers = allowed_mcp_servers_for_team else: allowed_mcp_servers = allowed_mcp_servers_for_key diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py index 15891b53f4e..34a0d604f39 100644 --- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py +++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py @@ -295,6 +295,7 @@ class MCPServerManager: command=getattr(mcp_server, "command", None), args=getattr(mcp_server, "args", None) or [], env=env_dict, + access_groups=getattr(mcp_server, "mcp_access_groups", None), ) self.registry[mcp_server.server_id] = new_server verbose_logger.debug(f"Added MCP Server: {name_for_prefix}") @@ -1050,7 +1051,9 @@ class MCPServerManager: auth_type=_server_config.auth_type, created_at=datetime.datetime.now(), updated_at=datetime.datetime.now(), + description=_server_config.mcp_info.get("description") if _server_config.mcp_info else None, mcp_info=_server_config.mcp_info, + mcp_access_groups=_server_config.access_groups or [], # Stdio-specific fields command=getattr(_server_config, "command", None), args=getattr(_server_config, "args", None) or [], diff --git a/litellm/proxy/_experimental/mcp_server/server.py b/litellm/proxy/_experimental/mcp_server/server.py index aa2a6ee1a75..38619112ccc 100644 --- a/litellm/proxy/_experimental/mcp_server/server.py +++ b/litellm/proxy/_experimental/mcp_server/server.py @@ -40,6 +40,7 @@ except ImportError as e: # Global variables to track initialization _SESSION_MANAGERS_INITIALIZED = False +_INITIALIZATION_LOCK = asyncio.Lock() if MCP_AVAILABLE: from mcp.server import Server @@ -113,21 +114,23 @@ if MCP_AVAILABLE: """Initialize the session managers. Can be called from main app lifespan.""" global _SESSION_MANAGERS_INITIALIZED, _session_manager_cm, _sse_session_manager_cm - if _SESSION_MANAGERS_INITIALIZED: - return + # Use async lock to prevent concurrent initialization + async with _INITIALIZATION_LOCK: + if _SESSION_MANAGERS_INITIALIZED: + return - verbose_logger.info("Initializing MCP session managers...") + verbose_logger.info("Initializing MCP session managers...") - # Start the session managers with context managers - _session_manager_cm = session_manager.run() - _sse_session_manager_cm = sse_session_manager.run() + # Start the session managers with context managers + _session_manager_cm = session_manager.run() + _sse_session_manager_cm = sse_session_manager.run() - # Enter the context managers - await _session_manager_cm.__aenter__() - await _sse_session_manager_cm.__aenter__() + # Enter the context managers + await _session_manager_cm.__aenter__() + await _sse_session_manager_cm.__aenter__() - _SESSION_MANAGERS_INITIALIZED = True - verbose_logger.info("MCP Server started with StreamableHTTP and SSE session managers!") + _SESSION_MANAGERS_INITIALIZED = True + verbose_logger.info("MCP Server started with StreamableHTTP and SSE session managers!") async def shutdown_session_managers(): """Shutdown the session managers.""" diff --git a/litellm/proxy/_experimental/out/_next/static/ILJ2l6ZzNB2f7RRsIZVJI/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/0rzQKhrKTur56aOgaxVrq/_buildManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/ILJ2l6ZzNB2f7RRsIZVJI/_buildManifest.js rename to litellm/proxy/_experimental/out/_next/static/0rzQKhrKTur56aOgaxVrq/_buildManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/ILJ2l6ZzNB2f7RRsIZVJI/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/0rzQKhrKTur56aOgaxVrq/_ssgManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/ILJ2l6ZzNB2f7RRsIZVJI/_ssgManifest.js rename to litellm/proxy/_experimental/out/_next/static/0rzQKhrKTur56aOgaxVrq/_ssgManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/154-7bf3bbb913e68f71.js b/litellm/proxy/_experimental/out/_next/static/chunks/154-7bf3bbb913e68f71.js deleted file mode 100644 index da2cab320b8..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/154-7bf3bbb913e68f71.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[154],{31283:function(e,t,o){o.d(t,{o:function(){return a.Z}});var a=o(49566)},63610:function(e,t,o){o.d(t,{d:function(){return u}});var a=o(57437),r=o(2265),n=o(64482),c=o(52787),s=o(20577),l=o(13634),i=o(31283),d=o(15424),p=o(89970),h=o(19250);let u=["metadata","config","enforced_params","aliases"],w=(e,t)=>u.includes(e)||"json"===t.format,g=e=>{if(!e)return!0;try{return JSON.parse(e),!0}catch(e){return!1}},f=(e,t,o)=>{let a={max_budget:"Enter maximum budget in USD (e.g., 100.50)",budget_duration:"Select a time period for budget reset",tpm_limit:"Enter maximum tokens per minute (whole number)",rpm_limit:"Enter maximum requests per minute (whole number)",duration:"Enter duration (e.g., 30s, 24h, 7d)",metadata:'Enter JSON object with key-value pairs\nExample: {"team": "research", "project": "nlp"}',config:'Enter configuration as JSON object\nExample: {"setting": "value"}',permissions:"Enter comma-separated permission strings",enforced_params:'Enter parameters as JSON object\nExample: {"param": "value"}',blocked:"Enter true/false or specific block conditions",aliases:'Enter aliases as JSON object\nExample: {"alias1": "value1", "alias2": "value2"}',models:"Select one or more model names",key_alias:"Enter a unique identifier for this key",tags:"Enter comma-separated tag strings"}[e]||({string:"Text input",number:"Numeric input",integer:"Whole number input",boolean:"True/False value"})[o]||"Text input";return w(e,t)?"".concat(a,"\nMust be valid JSON format"):t.enum?"Select from available options\nAllowed values: ".concat(t.enum.join(", ")):a};t.Z=e=>{let{schemaComponent:t,excludedFields:o=[],form:u,overrideLabels:m={},overrideTooltips:y={},customValidation:k={},defaultValues:C={}}=e,[_,T]=(0,r.useState)(null),[E,j]=(0,r.useState)(null);(0,r.useEffect)(()=>{(async()=>{try{let e=(await (0,h.getOpenAPISchema)()).components.schemas[t];if(!e)throw Error('Schema component "'.concat(t,'" not found'));T(e);let a={};Object.keys(e.properties).filter(e=>!o.includes(e)&&void 0!==C[e]).forEach(e=>{a[e]=C[e]}),u.setFieldsValue(a)}catch(e){console.error("Schema fetch error:",e),j(e instanceof Error?e.message:"Failed to fetch schema")}})()},[t,u,o]);let S=e=>{if(e.type)return e.type;if(e.anyOf){let t=e.anyOf.map(e=>e.type);if(t.includes("number")||t.includes("integer"))return"number";t.includes("string")}return"string"},v=(e,t)=>{var o;let r;let h=S(t),u=null==_?void 0:null===(o=_.required)||void 0===o?void 0:o.includes(e),T=m[e]||t.title||e,E=y[e]||t.description,j=[];u&&j.push({required:!0,message:"".concat(T," is required")}),k[e]&&j.push({validator:k[e]}),w(e,t)&&j.push({validator:async(e,t)=>{if(t&&!g(t))throw Error("Please enter valid JSON")}});let v=E?(0,a.jsxs)("span",{children:[T," ",(0,a.jsx)(p.Z,{title:E,children:(0,a.jsx)(d.Z,{style:{marginLeft:"4px"}})})]}):T;return r=w(e,t)?(0,a.jsx)(n.default.TextArea,{rows:4,placeholder:"Enter as JSON",className:"font-mono"}):t.enum?(0,a.jsx)(c.default,{children:t.enum.map(e=>(0,a.jsx)(c.default.Option,{value:e,children:e},e))}):"number"===h||"integer"===h?(0,a.jsx)(s.Z,{style:{width:"100%"},precision:"integer"===h?0:void 0}):"duration"===e?(0,a.jsx)(i.o,{placeholder:"eg: 30s, 30h, 30d"}):(0,a.jsx)(i.o,{placeholder:E||""}),(0,a.jsx)(l.Z.Item,{label:v,name:e,className:"mt-8",rules:j,initialValue:C[e],help:(0,a.jsx)("div",{className:"text-xs text-gray-500",children:f(e,t,h)}),children:r},e)};return E?(0,a.jsxs)("div",{className:"text-red-500",children:["Error: ",E]}):(null==_?void 0:_.properties)?(0,a.jsx)("div",{children:Object.entries(_.properties).filter(e=>{let[t]=e;return!o.includes(t)}).map(e=>{let[t,o]=e;return v(t,o)})}):null}},19250:function(e,t,o){o.r(t),o.d(t,{DEFAULT_ORGANIZATION:function(){return h},PredictedSpendLogsCall:function(){return tn},addAllowedIP:function(){return ew},adminGlobalActivity:function(){return eG},adminGlobalActivityExceptions:function(){return eA},adminGlobalActivityExceptionsPerDeployment:function(){return eR},adminGlobalActivityPerModel:function(){return eU},adminGlobalCacheActivity:function(){return eJ},adminSpendLogsCall:function(){return ex},adminTopEndUsersCall:function(){return eO},adminTopKeysCall:function(){return eP},adminTopModelsCall:function(){return eI},adminspendByProvider:function(){return eB},alertingSettingsCall:function(){return J},allEndUsersCall:function(){return ev},allTagNamesCall:function(){return eS},availableTeamListCall:function(){return Z},budgetCreateCall:function(){return P},budgetDeleteCall:function(){return x},budgetUpdateCall:function(){return O},cachingHealthCheckCall:function(){return tT},callMCPTool:function(){return tV},cancelModelCostMapReload:function(){return S},claimOnboardingToken:function(){return en},convertPromptFileToJson:function(){return tO},createGuardrailCall:function(){return tG},createMCPServer:function(){return tM},createPassThroughEndpoint:function(){return tg},createPromptCall:function(){return tF},credentialCreateCall:function(){return eQ},credentialDeleteCall:function(){return e0},credentialGetCall:function(){return e$},credentialListCall:function(){return eX},credentialUpdateCall:function(){return e1},defaultProxyBaseUrl:function(){return c},deleteAllowedIP:function(){return eg},deleteCallback:function(){return od},deleteConfigFieldSetting:function(){return tm},deleteGuardrailCall:function(){return t8},deleteMCPServer:function(){return tz},deletePassThroughEndpointsCall:function(){return ty},deletePromptCall:function(){return tP},fetchMCPAccessGroups:function(){return tI},fetchMCPServers:function(){return tR},formatDate:function(){return n},getAllowedIPs:function(){return eu},getBudgetList:function(){return tl},getBudgetSettings:function(){return ti},getCallbacksCall:function(){return td},getConfigFieldSetting:function(){return tu},getDefaultTeamSettings:function(){return tK},getEmailEventSettings:function(){return t6},getGeneralSettingsCall:function(){return tp},getGuardrailInfo:function(){return oo},getGuardrailProviderSpecificParams:function(){return ot},getGuardrailUISettings:function(){return oe},getGuardrailsList:function(){return tv},getInternalUserSettings:function(){return tU},getModelCostMapReloadStatus:function(){return v},getOnboardingCredentials:function(){return er},getOpenAPISchema:function(){return _},getPassThroughEndpointInfo:function(){return oi},getPassThroughEndpointsCall:function(){return th},getPossibleUserRoles:function(){return eW},getPromptInfo:function(){return tN},getPromptsList:function(){return tb},getProxyBaseUrl:function(){return d},getProxyUISettings:function(){return tS},getPublicModelHubInfo:function(){return C},getRemainingUsers:function(){return os},getSSOSettings:function(){return or},getTeamPermissionsCall:function(){return tX},getTotalSpendCall:function(){return ea},getUiConfig:function(){return k},healthCheckCall:function(){return tC},healthCheckHistoryCall:function(){return tE},individualModelHealthCheckCall:function(){return t_},invitationClaimCall:function(){return G},invitationCreateCall:function(){return B},keyCreateCall:function(){return A},keyCreateServiceAccountCall:function(){return U},keyDeleteCall:function(){return I},keyInfoCall:function(){return eM},keyInfoV1Call:function(){return ez},keyListCall:function(){return eD},keySpendLogsCall:function(){return eT},keyUpdateCall:function(){return e2},latestHealthChecksCall:function(){return tj},listMCPTools:function(){return tD},makeModelGroupPublic:function(){return y},mcpToolsCall:function(){return op},modelAvailableCall:function(){return e_},modelCostMap:function(){return T},modelCreateCall:function(){return b},modelDeleteCall:function(){return F},modelExceptionsCall:function(){return ek},modelHubCall:function(){return eh},modelHubPublicModelsCall:function(){return ep},modelInfoCall:function(){return ei},modelInfoV1Call:function(){return ed},modelMetricsCall:function(){return ef},modelMetricsSlowResponsesCall:function(){return ey},modelPatchUpdateCall:function(){return e4},modelSettingsCall:function(){return N},modelUpdateCall:function(){return e5},organizationCreateCall:function(){return K},organizationDeleteCall:function(){return X},organizationInfoCall:function(){return W},organizationListCall:function(){return Y},organizationMemberAddCall:function(){return te},organizationMemberDeleteCall:function(){return tt},organizationMemberUpdateCall:function(){return to},organizationUpdateCall:function(){return Q},patchPromptCall:function(){return tB},perUserAnalyticsCall:function(){return o_},proxyBaseUrl:function(){return l},regenerateKeyCall:function(){return ec},reloadModelCostMap:function(){return E},resetEmailEventSettings:function(){return t9},scheduleModelCostMapReload:function(){return j},serverRootPath:function(){return s},serviceHealthCheck:function(){return ts},sessionSpendLogsCall:function(){return t0},setCallbacksCall:function(){return tk},setGlobalLitellmHeaderName:function(){return m},slackBudgetAlertsHealthCheck:function(){return tc},spendUsersCall:function(){return eV},streamingModelMetricsCall:function(){return em},tagCreateCall:function(){return tq},tagDailyActivityCall:function(){return et},tagDauCall:function(){return of},tagDeleteCall:function(){return tW},tagDistinctCall:function(){return ok},tagInfoCall:function(){return tZ},tagListCall:function(){return tY},tagMauCall:function(){return oy},tagUpdateCall:function(){return tH},tagWauCall:function(){return om},tagsSpendLogsCall:function(){return ej},teamBulkMemberAddCall:function(){return e7},teamCreateCall:function(){return eK},teamDailyActivityCall:function(){return eo},teamDeleteCall:function(){return L},teamInfoCall:function(){return V},teamListCall:function(){return H},teamMemberAddCall:function(){return e6},teamMemberDeleteCall:function(){return e8},teamMemberUpdateCall:function(){return e9},teamPermissionsUpdateCall:function(){return t$},teamSpendLogsCall:function(){return eE},teamUpdateCall:function(){return e3},testConnectionRequest:function(){return eL},testMCPConnectionRequest:function(){return oh},testMCPToolsListRequest:function(){return ou},transformRequestCall:function(){return $},uiAuditLogsCall:function(){return oc},uiSpendLogDetailsCall:function(){return tJ},uiSpendLogsCall:function(){return eF},updateConfigFieldSetting:function(){return tf},updateDefaultTeamSettings:function(){return tQ},updateEmailEventSettings:function(){return t7},updateGuardrailCall:function(){return oa},updateInternalUserSettings:function(){return tA},updateMCPServer:function(){return tL},updatePassThroughEndpoint:function(){return ol},updatePassThroughFieldSetting:function(){return tw},updatePromptCall:function(){return tx},updateSSOSettings:function(){return on},updateUsefulLinksCall:function(){return eC},userAgentAnalyticsCall:function(){return og},userAgentSummaryCall:function(){return oC},userBulkUpdateUserCall:function(){return tr},userCreateCall:function(){return R},userDailyActivityAggregatedCall:function(){return eZ},userDailyActivityCall:function(){return ee},userDeleteCall:function(){return M},userFilterUICall:function(){return eb},userGetAllUsersCall:function(){return eY},userGetRequesedtModelsCall:function(){return eH},userInfoCall:function(){return D},userListCall:function(){return z},userRequestModelCall:function(){return eq},userSpendLogsCall:function(){return eN},userUpdateUserCall:function(){return ta},v2TeamListCall:function(){return q},vectorStoreCreateCall:function(){return t1},vectorStoreDeleteCall:function(){return t3},vectorStoreInfoCall:function(){return t4},vectorStoreListCall:function(){return t2},vectorStoreSearchCall:function(){return ow},vectorStoreUpdateCall:function(){return t5}});var a=o(42264),r=o(63610);let n=e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)},c=null,s="/",l=null;console.log=function(){};let i=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=window.location.origin,a=t||o;console.log("proxyBaseUrl:",l),console.log("serverRootPath:",e),e.length>0&&!a.endsWith(e)&&"/"!=e&&(a+=e,l=a),console.log("Updated proxyBaseUrl:",l)},d=()=>l||window.location.origin,p={GET:"GET",DELETE:"DELETE"},h="default_organization",u=0,w=async e=>{let t=Date.now();t-u>6e4?(e.includes("Authentication Error - Expired Key")&&(a.ZP.info("UI Session Expired. Logging out."),u=t,document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=window.location.pathname),u=t):console.log("Error suppressed to prevent spam:",e)},g="Authorization",f="x-mcp-auth";function m(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Authorization";console.log("setGlobalLitellmHeaderName: ".concat(e)),g=e}let y=async(e,t)=>{let o=l?"".concat(l,"/model_group/make_public"):"/model_group/make_public";return(await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({model_groups:t})})).json()},k=async()=>{console.log("Getting UI config");let e=await fetch(c?"".concat(c,"/litellm/.well-known/litellm-ui-config"):"/litellm/.well-known/litellm-ui-config"),t=await e.json();return console.log("jsonData in getUiConfig:",t),i(t.server_root_path,t.proxy_base_url),t},C=async()=>{let e=await fetch(c?"".concat(c,"/public/model_hub/info"):"/public/model_hub/info");return await e.json()},_=async()=>{let e=l?"".concat(l,"/openapi.json"):"/openapi.json",t=await fetch(e);return await t.json()},T=async e=>{try{let t=l?"".concat(l,"/get/litellm_model_cost_map"):"/get/litellm_model_cost_map",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}}),a=await o.json();return console.log("received litellm model cost data: ".concat(a)),a}catch(e){throw console.error("Failed to get model cost map:",e),e}},E=async e=>{try{let t=l?"".concat(l,"/reload/model_cost_map"):"/reload/model_cost_map",o=await fetch(t,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}}),a=await o.json();return console.log("Model cost map reload response: ".concat(a)),a}catch(e){throw console.error("Failed to reload model cost map:",e),e}},j=async(e,t)=>{try{let o=l?"".concat(l,"/schedule/model_cost_map_reload?hours=").concat(t):"/schedule/model_cost_map_reload?hours=".concat(t),a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}}),r=await a.json();return console.log("Schedule model cost map reload response: ".concat(r)),r}catch(e){throw console.error("Failed to schedule model cost map reload:",e),e}},S=async e=>{try{let t=l?"".concat(l,"/schedule/model_cost_map_reload"):"/schedule/model_cost_map_reload",o=await fetch(t,{method:"DELETE",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}}),a=await o.json();return console.log("Cancel model cost map reload response: ".concat(a)),a}catch(e){throw console.error("Failed to cancel model cost map reload:",e),e}},v=async e=>{try{let t=l?"".concat(l,"/schedule/model_cost_map_reload/status"):"/schedule/model_cost_map_reload/status";console.log("Fetching status from URL:",t);let o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){console.error("Status request failed with status: ".concat(o.status));let e=await o.text();throw console.error("Error response:",e),Error("HTTP ".concat(o.status,": ").concat(e))}let a=await o.json();return console.log("Model cost map reload status:",a),a}catch(e){throw console.error("Failed to get model cost map reload status:",e),e}},b=async(e,t)=>{try{let o=l?"".concat(l,"/model/new"):"/model/new",r=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!r.ok){let e=await r.text()||"Network response was not ok";throw a.ZP.error(e),Error(e)}let n=await r.json();return console.log("API Response:",n),a.ZP.destroy(),a.ZP.success("Model ".concat(t.model_name," created successfully"),2),n}catch(e){throw console.error("Failed to create key:",e),e}},N=async e=>{try{let t=l?"".concat(l,"/model/settings"):"/model/settings",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){console.error("Failed to get model settings:",e)}},F=async(e,t)=>{console.log("model_id in model delete call: ".concat(t));try{let o=l?"".concat(l,"/model/delete"):"/model/delete",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},x=async(e,t)=>{if(console.log("budget_id in budget delete call: ".concat(t)),null!=e)try{let o=l?"".concat(l,"/budget/delete"):"/budget/delete",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},P=async(e,t)=>{try{console.log("Form Values in budgetCreateCall:",t),console.log("Form Values after check:",t);let o=l?"".concat(l,"/budget/new"):"/budget/new",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},O=async(e,t)=>{try{console.log("Form Values in budgetUpdateCall:",t),console.log("Form Values after check:",t);let o=l?"".concat(l,"/budget/update"):"/budget/update",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},B=async(e,t)=>{try{let o=l?"".concat(l,"/invitation/new"):"/invitation/new",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},G=async(e,t)=>{try{console.log("Form Values in invitationCreateCall:",t),console.log("Form Values after check:",t);let o=l?"".concat(l,"/invitation/claim"):"/invitation/claim",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},J=async e=>{try{let t=l?"".concat(l,"/alerting/settings"):"/alerting/settings",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},U=async(e,t)=>{try{for(let e of(console.log("Form Values in keyCreateServiceAccountCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),r.d))if(t[e]){console.log("formValues.".concat(e,":"),t[e]);try{t[e]=JSON.parse(t[e])}catch(t){throw Error("Failed to parse ".concat(e,": ")+t)}}console.log("Form Values after check:",t);let o=l?"".concat(l,"/key/service-account/generate"):"/key/service-account/generate",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error(e)}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},A=async(e,t,o)=>{try{for(let e of(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)),r.d))if(o[e]){console.log("formValues.".concat(e,":"),o[e]);try{o[e]=JSON.parse(o[e])}catch(t){throw Error("Failed to parse ".concat(e,": ")+t)}}console.log("Form Values after check:",o);let a=l?"".concat(l,"/key/generate"):"/key/generate",n=await fetch(a,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!n.ok){let e=await n.text();throw w(e),console.error("Error response from the server:",e),Error(e)}let c=await n.json();return console.log("API Response:",c),c}catch(e){throw console.error("Failed to create key:",e),e}},R=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.auto_create_key=!1,o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",o);let a=l?"".concat(l,"/user/new"):"/user/new",r=await fetch(a,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!r.ok){let e=await r.text();throw w(e),console.error("Error response from the server:",e),Error(e)}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},I=async(e,t)=>{try{let o=l?"".concat(l,"/key/delete"):"/key/delete";console.log("in keyDeleteCall:",t);let a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[t]})});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},M=async(e,t)=>{try{let o=l?"".concat(l,"/user/delete"):"/user/delete";console.log("in userDeleteCall:",t);let a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_ids:t})});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to delete user(s):",e),e}},L=async(e,t)=>{try{let o=l?"".concat(l,"/team/delete"):"/team/delete";console.log("in teamDeleteCall:",t);let a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[t]})});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to delete key:",e),e}},z=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,i=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,d=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null;try{let p=l?"".concat(l,"/user/list"):"/user/list";console.log("in userListCall");let h=new URLSearchParams;if(t&&t.length>0){let e=t.join(",");h.append("user_ids",e)}o&&h.append("page",o.toString()),a&&h.append("page_size",a.toString()),r&&h.append("user_email",r),n&&h.append("role",n),c&&h.append("team",c),s&&h.append("sso_user_ids",s),i&&h.append("sort_by",i),d&&h.append("sort_order",d);let u=h.toString();u&&(p+="?".concat(u));let f=await fetch(p,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!f.ok){let e=await f.text();throw w(e),Error("Network response was not ok")}let m=await f.json();return console.log("/user/list API Response:",m),m}catch(e){throw console.error("Failed to create key:",e),e}},D=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0,n=arguments.length>5?arguments[5]:void 0,c=arguments.length>6&&void 0!==arguments[6]&&arguments[6];console.log("userInfoCall: ".concat(t,", ").concat(o,", ").concat(a,", ").concat(r,", ").concat(n,", ").concat(c));try{let s;if(a){s=l?"".concat(l,"/user/list"):"/user/list";let e=new URLSearchParams;null!=r&&e.append("page",r.toString()),null!=n&&e.append("page_size",n.toString()),s+="?".concat(e.toString())}else s=l?"".concat(l,"/user/info"):"/user/info",("Admin"!==o&&"Admin Viewer"!==o||c)&&t&&(s+="?user_id=".concat(t));console.log("Requesting user data from:",s);let i=await fetch(s,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.text();throw w(e),Error("Network response was not ok")}let d=await i.json();return console.log("API Response:",d),d}catch(e){throw console.error("Failed to fetch user data:",e),e}},V=async(e,t)=>{try{let o=l?"".concat(l,"/team/info"):"/team/info";t&&(o="".concat(o,"?team_id=").concat(t)),console.log("in teamInfoCall");let a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},q=async function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;arguments.length>5&&void 0!==arguments[5]&&arguments[5],arguments.length>6&&void 0!==arguments[6]&&arguments[6],arguments.length>7&&void 0!==arguments[7]&&arguments[7],arguments.length>8&&void 0!==arguments[8]&&arguments[8];try{let n=l?"".concat(l,"/v2/team/list"):"/v2/team/list";console.log("in teamInfoCall");let c=new URLSearchParams;o&&c.append("user_id",o.toString()),t&&c.append("organization_id",t.toString()),a&&c.append("team_id",a.toString()),r&&c.append("team_alias",r.toString());let s=c.toString();s&&(n+="?".concat(s));let i=await fetch(n,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.text();throw w(e),Error("Network response was not ok")}let d=await i.json();return console.log("/v2/team/list API Response:",d),d}catch(e){throw console.error("Failed to create key:",e),e}},H=async function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;try{let n=l?"".concat(l,"/team/list"):"/team/list";console.log("in teamInfoCall");let c=new URLSearchParams;o&&c.append("user_id",o.toString()),t&&c.append("organization_id",t.toString()),a&&c.append("team_id",a.toString()),r&&c.append("team_alias",r.toString());let s=c.toString();s&&(n+="?".concat(s));let i=await fetch(n,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.text();throw w(e),Error("Network response was not ok")}let d=await i.json();return console.log("/team/list API Response:",d),d}catch(e){throw console.error("Failed to create key:",e),e}},Z=async e=>{try{let t=l?"".concat(l,"/team/available"):"/team/available";console.log("in availableTeamListCall");let o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}let a=await o.json();return console.log("/team/available_teams API Response:",a),a}catch(e){throw e}},Y=async e=>{try{let t=l?"".concat(l,"/organization/list"):"/organization/list",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},W=async(e,t)=>{try{let o=l?"".concat(l,"/organization/info"):"/organization/info";t&&(o="".concat(o,"?organization_id=").concat(t)),console.log("in teamInfoCall");let a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},K=async(e,t)=>{try{if(console.log("Form Values in organizationCreateCall:",t),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw console.error("Failed to parse metadata:",e),Error("Failed to parse metadata: "+e)}}let o=l?"".concat(l,"/organization/new"):"/organization/new",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},Q=async(e,t)=>{try{console.log("Form Values in organizationUpdateCall:",t);let o=l?"".concat(l,"/organization/update"):"/organization/update",a=await fetch(o,{method:"PATCH",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("Update Team Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,t)=>{try{let o=l?"".concat(l,"/organization/delete"):"/organization/delete",a=await fetch(o,{method:"DELETE",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({organization_ids:[t]})});if(!a.ok){let e=await a.text();throw w(e),Error("Error deleting organization: ".concat(e))}return await a.json()}catch(e){throw console.error("Failed to delete organization:",e),e}},$=async(e,t)=>{try{let o=l?"".concat(l,"/utils/transform_request"):"/utils/transform_request",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},ee=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;try{let r=l?"".concat(l,"/user/daily/activity"):"/user/daily/activity",c=new URLSearchParams;c.append("start_date",n(t)),c.append("end_date",n(o)),c.append("page_size","1000"),c.append("page",a.toString());let s=c.toString();s&&(r+="?".concat(s));let i=await fetch(r,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.text();throw w(e),Error("Network response was not ok")}return await i.json()}catch(e){throw console.error("Failed to create key:",e),e}},et=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;try{let c=l?"".concat(l,"/tag/daily/activity"):"/tag/daily/activity",s=new URLSearchParams;s.append("start_date",n(t)),s.append("end_date",n(o)),s.append("page_size","1000"),s.append("page",a.toString()),r&&s.append("tags",r.join(","));let i=s.toString();i&&(c+="?".concat(i));let d=await fetch(c,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!d.ok){let e=await d.text();throw w(e),Error("Network response was not ok")}return await d.json()}catch(e){throw console.error("Failed to create key:",e),e}},eo=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;try{let c=l?"".concat(l,"/team/daily/activity"):"/team/daily/activity",s=new URLSearchParams;s.append("start_date",n(t)),s.append("end_date",n(o)),s.append("page_size","1000"),s.append("page",a.toString()),r&&s.append("team_ids",r.join(",")),s.append("exclude_team_ids","litellm-dashboard");let i=s.toString();i&&(c+="?".concat(i));let d=await fetch(c,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!d.ok){let e=await d.text();throw w(e),Error("Network response was not ok")}return await d.json()}catch(e){throw console.error("Failed to create key:",e),e}},ea=async e=>{try{let t=l?"".concat(l,"/global/spend"):"/global/spend",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},er=async e=>{try{let t=l?"".concat(l,"/onboarding/get_token"):"/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 w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},en=async(e,t,o,a)=>{let r=l?"".concat(l,"/onboarding/claim_token"):"/onboarding/claim_token";try{let n=await fetch(r,{method:"POST",headers:{[g]:"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 w(e),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}},ec=async(e,t,o)=>{try{let a=l?"".concat(l,"/key/").concat(t,"/regenerate"):"/key/".concat(t,"/regenerate"),r=await fetch(a,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){let e=await r.text();throw w(e),Error("Network response was not ok")}let n=await r.json();return console.log("Regenerate key Response:",n),n}catch(e){throw console.error("Failed to regenerate key:",e),e}},es=!1,el=null,ei=async(e,t,o)=>{try{console.log("modelInfoCall:",e,t,o);let r=l?"".concat(l,"/v2/model/info"):"/v2/model/info",n=new URLSearchParams;n.append("include_team_models","true"),n.toString()&&(r+="?".concat(n.toString()));let c=await fetch(r,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.text();throw e+="error shown=".concat(es),es||(e.includes("No model list passed")&&(e="No Models Exist. Click Add Model to get started."),a.ZP.info(e,10),es=!0,el&&clearTimeout(el),el=setTimeout(()=>{es=!1},1e4)),Error("Network response was not ok")}let s=await c.json();return console.log("modelInfoCall:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},ed=async(e,t)=>{try{let o=l?"".concat(l,"/v1/model/info"):"/v1/model/info";o+="?litellm_model_id=".concat(t);let a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok)throw await a.text(),Error("Network response was not ok");let r=await a.json();return console.log("modelInfoV1Call:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},ep=async()=>{let e=l?"".concat(l,"/public/model_hub"):"/public/model_hub";return(await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}})).json()},eh=async e=>{try{let t=l?"".concat(l,"/model_group/info"):"/model_group/info",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");let a=await o.json();return console.log("modelHubCall:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},eu=async e=>{try{let t=l?"".concat(l,"/get/allowed_ips"):"/get/allowed_ips",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw Error("Network response was not ok: ".concat(e))}let a=await o.json();return console.log("getAllowedIPs:",a),a.data}catch(e){throw console.error("Failed to get allowed IPs:",e),e}},ew=async(e,t)=>{try{let o=l?"".concat(l,"/add/allowed_ip"):"/add/allowed_ip",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({ip:t})});if(!a.ok){let e=await a.text();throw Error("Network response was not ok: ".concat(e))}let r=await a.json();return console.log("addAllowedIP:",r),r}catch(e){throw console.error("Failed to add allowed IP:",e),e}},eg=async(e,t)=>{try{let o=l?"".concat(l,"/delete/allowed_ip"):"/delete/allowed_ip",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({ip:t})});if(!a.ok){let e=await a.text();throw Error("Network response was not ok: ".concat(e))}let r=await a.json();return console.log("deleteAllowedIP:",r),r}catch(e){throw console.error("Failed to delete allowed IP:",e),e}},ef=async(e,t,o,a,r,n,c,s)=>{try{let t=l?"".concat(l,"/model/metrics"):"/model/metrics";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(r,"&endTime=").concat(n,"&api_key=").concat(c,"&customer=").concat(s));let o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},em=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/model/streaming_metrics"):"/model/streaming_metrics";t&&(r="".concat(r,"?_selected_model_group=").concat(t,"&startTime=").concat(o,"&endTime=").concat(a));let n=await fetch(r,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.text();throw w(e),Error("Network response was not ok")}return await n.json()}catch(e){throw console.error("Failed to create key:",e),e}},ey=async(e,t,o,a,r,n,c,s)=>{try{let t=l?"".concat(l,"/model/metrics/slow_responses"):"/model/metrics/slow_responses";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(r,"&endTime=").concat(n,"&api_key=").concat(c,"&customer=").concat(s));let o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},ek=async(e,t,o,a,r,n,c,s)=>{try{let t=l?"".concat(l,"/model/metrics/exceptions"):"/model/metrics/exceptions";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(r,"&endTime=").concat(n,"&api_key=").concat(c,"&customer=").concat(s));let o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},eC=async(e,t)=>{try{let o=l?"".concat(l,"/model_hub/update_useful_links"):"/model_hub/update_useful_links",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({useful_links:t})});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},e_=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,n=(arguments.length>5&&void 0!==arguments[5]&&arguments[5],arguments.length>6&&void 0!==arguments[6]&&arguments[6]);console.log("in /models calls, globalLitellmHeaderName",g);try{let t=l?"".concat(l,"/models"):"/models",o=new URLSearchParams;o.append("include_model_access_groups","True"),!0===a&&o.append("return_wildcard_routes","True"),!0===n&&o.append("only_model_access_groups","True"),r&&o.append("team_id",r.toString()),o.toString()&&(t+="?".concat(o.toString()));let c=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.text();throw w(e),Error("Network response was not ok")}return await c.json()}catch(e){throw console.error("Failed to create key:",e),e}},eT=async(e,t)=>{try{let o=l?"".concat(l,"/global/spend/logs"):"/global/spend/logs";console.log("in keySpendLogsCall:",o);let a=await fetch("".concat(o,"?api_key=").concat(t),{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},eE=async e=>{try{let t=l?"".concat(l,"/global/spend/teams"):"/global/spend/teams";console.log("in teamSpendLogsCall:",t);let o=await fetch("".concat(t),{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),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}},ej=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/global/spend/tags"):"/global/spend/tags";t&&o&&(r="".concat(r,"?start_date=").concat(t,"&end_date=").concat(o)),a&&(r+="".concat(r,"&tags=").concat(a.join(","))),console.log("in tagsSpendLogsCall:",r);let n=await fetch("".concat(r),{method:"GET",headers:{[g]:"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}},eS=async e=>{try{let t=l?"".concat(l,"/global/spend/all_tag_names"):"/global/spend/all_tag_names";console.log("in global/spend/all_tag_names call",t);let o=await fetch("".concat(t),{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),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}},ev=async e=>{try{let t=l?"".concat(l,"/global/all_end_users"):"/global/all_end_users";console.log("in global/all_end_users call",t);let o=await fetch("".concat(t),{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),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}},eb=async(e,t)=>{try{let o=l?"".concat(l,"/user/filter/ui"):"/user/filter/ui";t.get("user_email")&&(o+="?user_email=".concat(t.get("user_email"))),t.get("user_id")&&(o+="?user_id=".concat(t.get("user_id")));let a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},eN=async(e,t,o,a,r,n)=>{try{console.log("user role in spend logs call: ".concat(o));let t=l?"".concat(l,"/spend/logs"):"/spend/logs";t="App Owner"==o?"".concat(t,"?user_id=").concat(a,"&start_date=").concat(r,"&end_date=").concat(n):"".concat(t,"?start_date=").concat(r,"&end_date=").concat(n);let c=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.text();throw w(e),Error("Network response was not ok")}let s=await c.json();return console.log(s),s}catch(e){throw console.error("Failed to create key:",e),e}},eF=async(e,t,o,a,r,n,c,s,i,d,p,h)=>{try{let u=l?"".concat(l,"/spend/logs/ui"):"/spend/logs/ui",f=new URLSearchParams;t&&f.append("api_key",t),o&&f.append("team_id",o),a&&f.append("request_id",a),r&&f.append("start_date",r),n&&f.append("end_date",n),c&&f.append("page",c.toString()),s&&f.append("page_size",s.toString()),i&&f.append("user_id",i),d&&f.append("end_user",d),p&&f.append("status_filter",p),h&&f.append("model",h);let m=f.toString();m&&(u+="?".concat(m));let y=await fetch(u,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!y.ok){let e=await y.text();throw w(e),Error("Network response was not ok")}let k=await y.json();return console.log("Spend Logs Response:",k),k}catch(e){throw console.error("Failed to fetch spend logs:",e),e}},ex=async e=>{try{let t=l?"".concat(l,"/global/spend/logs"):"/global/spend/logs",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),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}},eP=async e=>{try{let t=l?"".concat(l,"/global/spend/keys?limit=5"):"/global/spend/keys?limit=5",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),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}},eO=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/global/spend/end_users"):"/global/spend/end_users",n="";n=t?JSON.stringify({api_key:t,startTime:o,endTime:a}):JSON.stringify({startTime:o,endTime:a});let c={method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:n},s=await fetch(r,c);if(!s.ok){let e=await s.text();throw w(e),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}},eB=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/global/spend/provider"):"/global/spend/provider";o&&a&&(r+="?start_date=".concat(o,"&end_date=").concat(a)),t&&(r+="&api_key=".concat(t));let n={method:"GET",headers:{[g]:"Bearer ".concat(e)}},c=await fetch(r,n);if(!c.ok){let e=await c.text();throw w(e),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}},eG=async(e,t,o)=>{try{let a=l?"".concat(l,"/global/activity"):"/global/activity";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o));let r={method:"GET",headers:{[g]:"Bearer ".concat(e)}},n=await fetch(a,r);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}},eJ=async(e,t,o)=>{try{let a=l?"".concat(l,"/global/activity/cache_hits"):"/global/activity/cache_hits";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o));let r={method:"GET",headers:{[g]:"Bearer ".concat(e)}},n=await fetch(a,r);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}},eU=async(e,t,o)=>{try{let a=l?"".concat(l,"/global/activity/model"):"/global/activity/model";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o));let r={method:"GET",headers:{[g]:"Bearer ".concat(e)}},n=await fetch(a,r);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}},eA=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/global/activity/exceptions"):"/global/activity/exceptions";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o)),a&&(r+="&model_group=".concat(a));let n={method:"GET",headers:{[g]:"Bearer ".concat(e)}},c=await fetch(r,n);if(!c.ok)throw await c.text(),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}},eR=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/global/activity/exceptions/deployment"):"/global/activity/exceptions/deployment";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o)),a&&(r+="&model_group=".concat(a));let n={method:"GET",headers:{[g]:"Bearer ".concat(e)}},c=await fetch(r,n);if(!c.ok)throw await c.text(),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}},eI=async e=>{try{let t=l?"".concat(l,"/global/spend/models?limit=5"):"/global/spend/models?limit=5",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),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}},eM=async(e,t)=>{try{let o=l?"".concat(l,"/v2/key/info"):"/v2/key/info",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:t})});if(!a.ok){let e=await a.text();if(e.includes("Invalid proxy server token passed"))throw Error("Invalid proxy server token passed");throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},eL=async(e,t,o)=>{try{console.log("Sending model connection test request:",JSON.stringify(t));let r=l?"".concat(l,"/health/test_connection"):"/health/test_connection",n=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",[g]:"Bearer ".concat(e)},body:JSON.stringify({litellm_params:t,mode:o})}),c=n.headers.get("content-type");if(!c||!c.includes("application/json")){let e=await n.text();throw console.error("Received non-JSON response:",e),Error("Received non-JSON response (".concat(n.status,": ").concat(n.statusText,"). Check network tab for details."))}let s=await n.json();if(!n.ok||"error"===s.status){if("error"===s.status);else{var a;return{status:"error",message:(null===(a=s.error)||void 0===a?void 0:a.message)||"Connection test failed: ".concat(n.status," ").concat(n.statusText)}}}return s}catch(e){throw console.error("Model connection test error:",e),e}},ez=async(e,t)=>{try{console.log("entering keyInfoV1Call");let o=l?"".concat(l,"/key/info"):"/key/info";o="".concat(o,"?key=").concat(t);let r=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(console.log("response",r),!r.ok){let e=await r.text();w(e),a.ZP.error("Failed to fetch key info - "+e)}let n=await r.json();return console.log("data",n),n}catch(e){throw console.error("Failed to fetch key info:",e),e}},eD=async function(e,t,o,a,r,n,c,s){let i=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,d=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null;try{let p=l?"".concat(l,"/key/list"):"/key/list";console.log("in keyListCall");let h=new URLSearchParams;o&&h.append("team_id",o.toString()),t&&h.append("organization_id",t.toString()),a&&h.append("key_alias",a),n&&h.append("key_hash",n),r&&h.append("user_id",r.toString()),c&&h.append("page",c.toString()),s&&h.append("size",s.toString()),i&&h.append("sort_by",i),d&&h.append("sort_order",d),h.append("return_full_object","true"),h.append("include_team_keys","true");let u=h.toString();u&&(p+="?".concat(u));let f=await fetch(p,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!f.ok){let e=await f.text();throw w(e),Error("Network response was not ok")}let m=await f.json();return console.log("/team/list API Response:",m),m}catch(e){throw console.error("Failed to create key:",e),e}},eV=async(e,t)=>{try{let o=l?"".concat(l,"/spend/users"):"/spend/users";console.log("in spendUsersCall:",o);let a=await fetch("".concat(o,"?user_id=").concat(t),{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to get spend for user",e),e}},eq=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/user/request_model"):"/user/request_model",n=await fetch(r,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({models:[t],user_id:o,justification:a})});if(!n.ok){let e=await n.text();throw w(e),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}},eH=async e=>{try{let t=l?"".concat(l,"/user/get_requests"):"/user/get_requests";console.log("in userGetRequesedtModelsCall:",t);let o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to get requested models:",e),e}},eZ=async(e,t,o)=>{try{let a=l?"".concat(l,"/user/daily/activity/aggregated"):"/user/daily/activity/aggregated",r=new URLSearchParams,n=e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)};r.append("start_date",n(t)),r.append("end_date",n(o));let c=r.toString();c&&(a+="?".concat(c));let s=await fetch(a,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw w(e),Error("Network response was not ok")}return await s.json()}catch(e){throw console.error("Failed to fetch aggregated user daily activity:",e),e}},eY=async(e,t)=>{try{let o=l?"".concat(l,"/user/get_users?role=").concat(t):"/user/get_users?role=".concat(t);console.log("in userGetAllUsersCall:",o);let a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},eW=async e=>{try{let t=l?"".concat(l,"/user/available_roles"):"/user/available_roles",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw await o.text(),Error("Network response was not ok");let a=await o.json();return console.log("response from user/available_role",a),a}catch(e){throw e}},eK=async(e,t)=>{try{if(console.log("Form Values in teamCreateCall:",t),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw Error("Failed to parse metadata: "+e)}}let o=l?"".concat(l,"/team/new"):"/team/new",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},eQ=async(e,t)=>{try{if(console.log("Form Values in credentialCreateCall:",t),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw Error("Failed to parse metadata: "+e)}}let o=l?"".concat(l,"/credentials"):"/credentials",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},eX=async e=>{try{let t=l?"".concat(l,"/credentials"):"/credentials";console.log("in credentialListCall");let o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}let a=await o.json();return console.log("/credentials API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},e$=async(e,t,o)=>{try{let a=l?"".concat(l,"/credentials"):"/credentials";t?a+="/by_name/".concat(t):o&&(a+="/by_model/".concat(o)),console.log("in credentialListCall");let r=await fetch(a,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok){let e=await r.text();throw w(e),Error("Network response was not ok")}let n=await r.json();return console.log("/credentials API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},e0=async(e,t)=>{try{let o=l?"".concat(l,"/credentials/").concat(t):"/credentials/".concat(t);console.log("in credentialDeleteCall:",t);let a=await fetch(o,{method:"DELETE",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to delete key:",e),e}},e1=async(e,t,o)=>{try{if(console.log("Form Values in credentialUpdateCall:",o),o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw Error("Failed to parse metadata: "+e)}}let a=l?"".concat(l,"/credentials/").concat(t):"/credentials/".concat(t),r=await fetch(a,{method:"PATCH",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...o})});if(!r.ok){let e=await r.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},e2=async(e,t)=>{try{if(console.log("Form Values in keyUpdateCall:",t),t.model_tpm_limit){console.log("formValues.model_tpm_limit:",t.model_tpm_limit);try{t.model_tpm_limit=JSON.parse(t.model_tpm_limit)}catch(e){throw Error("Failed to parse model_tpm_limit: "+e)}}if(t.model_rpm_limit){console.log("formValues.model_rpm_limit:",t.model_rpm_limit);try{t.model_rpm_limit=JSON.parse(t.model_rpm_limit)}catch(e){throw Error("Failed to parse model_rpm_limit: "+e)}}let o=l?"".concat(l,"/key/update"):"/key/update",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("Update key Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},e3=async(e,t)=>{try{console.log("Form Values in teamUpateCall:",t);let o=l?"".concat(l,"/team/update"):"/team/update",r=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!r.ok){let e=await r.text();throw w(e),console.error("Error response from the server:",e),a.ZP.error("Failed to update team settings: "+e),Error(e)}let n=await r.json();return console.log("Update Team Response:",n),n}catch(e){throw console.error("Failed to update team:",e),e}},e4=async(e,t,o)=>{try{console.log("Form Values in modelUpateCall:",t);let a=l?"".concat(l,"/model/").concat(o,"/update"):"/model/".concat(o,"/update"),r=await fetch(a,{method:"PATCH",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!r.ok){let e=await r.text();throw w(e),console.error("Error update from the server:",e),Error("Network response was not ok")}let n=await r.json();return console.log("Update model Response:",n),n}catch(e){throw console.error("Failed to update model:",e),e}},e5=async(e,t)=>{try{console.log("Form Values in modelUpateCall:",t);let o=l?"".concat(l,"/model/update"):"/model/update",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error update from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("Update model Response:",r),r}catch(e){throw console.error("Failed to update model:",e),e}},e6=async(e,t,o)=>{try{console.log("Form Values in teamMemberAddCall:",o);let r=l?"".concat(l,"/team/member_add"):"/team/member_add",n=await fetch(r,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,member:o})});if(!n.ok){var a;let e=await n.text(),t={};try{t=JSON.parse(e)}catch(t){console.warn("Failed to parse error body as JSON:",e)}let o=(null==t?void 0:null===(a=t.detail)||void 0===a?void 0:a.error)||"Failed to add team member",r=Error(o);throw r.raw=t,r}let c=await n.json();return console.log("API Response:",c),c}catch(e){throw console.error("Failed to create key:",e),e}},e7=async(e,t,o,a,r)=>{try{console.log("Bulk add team members:",{teamId:t,members:o,maxBudgetInTeam:a});let c=l?"".concat(l,"/team/bulk_member_add"):"/team/bulk_member_add",s={team_id:t};r?s.all_users=!0:s.members=o,null!=a&&(s.max_budget_in_team=a);let i=await fetch(c,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok){var n;let e=await i.text(),t={};try{t=JSON.parse(e)}catch(t){console.warn("Failed to parse error body as JSON:",e)}let o=(null==t?void 0:null===(n=t.detail)||void 0===n?void 0:n.error)||"Failed to bulk add team members",a=Error(o);throw a.raw=t,a}let d=await i.json();return console.log("Bulk team member add API Response:",d),d}catch(e){throw console.error("Failed to bulk add team members:",e),e}},e9=async(e,t,o)=>{try{console.log("Form Values in teamMemberUpdateCall:",o);let r=l?"".concat(l,"/team/member_update"):"/team/member_update",n=await fetch(r,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,role:o.role,user_id:o.user_id})});if(!n.ok){var a;let e=await n.text(),t={};try{t=JSON.parse(e)}catch(t){console.warn("Failed to parse error body as JSON:",e)}let o=(null==t?void 0:null===(a=t.detail)||void 0===a?void 0:a.error)||"Failed to add team member",r=Error(o);throw r.raw=t,r}let c=await n.json();return console.log("API Response:",c),c}catch(e){throw console.error("Failed to update team member:",e),e}},e8=async(e,t,o)=>{try{console.log("Form Values in teamMemberAddCall:",o);let a=l?"".concat(l,"/team/member_delete"):"/team/member_delete",r=await fetch(a,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,...void 0!==o.user_email&&{user_email:o.user_email},...void 0!==o.user_id&&{user_id:o.user_id}})});if(!r.ok){let e=await r.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},te=async(e,t,o)=>{try{console.log("Form Values in teamMemberAddCall:",o);let a=l?"".concat(l,"/organization/member_add"):"/organization/member_add",r=await fetch(a,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({organization_id:t,member:o})});if(!r.ok){let e=await r.text();throw w(e),console.error("Error response from the server:",e),Error(e)}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create organization member:",e),e}},tt=async(e,t,o)=>{try{console.log("Form Values in organizationMemberDeleteCall:",o);let a=l?"".concat(l,"/organization/member_delete"):"/organization/member_delete",r=await fetch(a,{method:"DELETE",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({organization_id:t,user_id:o})});if(!r.ok){let e=await r.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to delete organization member:",e),e}},to=async(e,t,o)=>{try{console.log("Form Values in organizationMemberUpdateCall:",o);let a=l?"".concat(l,"/organization/member_update"):"/organization/member_update",r=await fetch(a,{method:"PATCH",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({organization_id:t,...o})});if(!r.ok){let e=await r.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to update organization member:",e),e}},ta=async(e,t,o)=>{try{console.log("Form Values in userUpdateUserCall:",t);let a=l?"".concat(l,"/user/update"):"/user/update",r={...t};null!==o&&(r.user_role=o),r=JSON.stringify(r);let n=await fetch(a,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:r});if(!n.ok){let e=await n.text();throw w(e),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}},tr=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{let r;console.log("Form Values in userUpdateUserCall:",t);let n=l?"".concat(l,"/user/bulk_update"):"/user/bulk_update";if(a)r=JSON.stringify({all_users:!0,user_updates:t});else if(o&&o.length>0){let e=[];for(let a of o)e.push({user_id:a,...t});r=JSON.stringify({users:e})}else throw Error("Must provide either userIds or set allUsers=true");let c=await fetch(n,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:r});if(!c.ok){let e=await c.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let s=await c.json();return console.log("API Response:",s),s}catch(e){throw console.error("Failed to create key:",e),e}},tn=async(e,t)=>{try{let o=l?"".concat(l,"/global/predict/spend/logs"):"/global/predict/spend/logs",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({data:t})});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},tc=async e=>{try{let t=l?"".concat(l,"/health/services?service=slack_budget_alerts"):"/health/services?service=slack_budget_alerts";console.log("Checking Slack Budget Alerts service health");let o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error(e)}let r=await o.json();return a.ZP.success("Test Slack Alert worked - check your Slack!"),console.log("Service Health Response:",r),r}catch(e){throw console.error("Failed to perform health check:",e),e}},ts=async(e,t)=>{try{let o=l?"".concat(l,"/health/services?service=").concat(t):"/health/services?service=".concat(t);console.log("Checking Slack Budget Alerts service health");let a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error(e)}return await a.json()}catch(e){throw console.error("Failed to perform health check:",e),e}},tl=async e=>{try{let t=l?"".concat(l,"/budget/list"):"/budget/list",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},ti=async e=>{try{let t=l?"".concat(l,"/budget/settings"):"/budget/settings",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},td=async(e,t,o)=>{try{let t=l?"".concat(l,"/get/config/callbacks"):"/get/config/callbacks",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},tp=async e=>{try{let t=l?"".concat(l,"/config/list?config_type=general_settings"):"/config/list?config_type=general_settings",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},th=async e=>{try{let t=l?"".concat(l,"/config/pass_through_endpoint"):"/config/pass_through_endpoint",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},tu=async(e,t)=>{try{let o=l?"".concat(l,"/config/field/info?field_name=").concat(t):"/config/field/info?field_name=".concat(t),a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok)throw await a.text(),Error("Network response was not ok");return await a.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},tw=async(e,t,o)=>{try{let r=l?"".concat(l,"/config/pass_through_endpoint"):"/config/pass_through_endpoint",n=await fetch(r,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,field_value:o})});if(!n.ok){let e=await n.text();throw w(e),Error("Network response was not ok")}let c=await n.json();return a.ZP.success("Successfully updated value!"),c}catch(e){throw console.error("Failed to set callbacks:",e),e}},tg=async(e,t)=>{try{let o=l?"".concat(l,"/config/pass_through_endpoint"):"/config/pass_through_endpoint",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},tf=async(e,t,o)=>{try{let r=l?"".concat(l,"/config/field/update"):"/config/field/update",n=await fetch(r,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,field_value:o,config_type:"general_settings"})});if(!n.ok){let e=await n.text();throw w(e),Error("Network response was not ok")}let c=await n.json();return a.ZP.success("Successfully updated value!"),c}catch(e){throw console.error("Failed to set callbacks:",e),e}},tm=async(e,t)=>{try{let o=l?"".concat(l,"/config/field/delete"):"/config/field/delete",r=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,config_type:"general_settings"})});if(!r.ok){let e=await r.text();throw w(e),Error("Network response was not ok")}let n=await r.json();return a.ZP.success("Field reset on proxy"),n}catch(e){throw console.error("Failed to get callbacks:",e),e}},ty=async(e,t)=>{try{let o=l?"".concat(l,"/config/pass_through_endpoint?endpoint_id=").concat(t):"/config/pass_through_endpoint".concat(t),a=await fetch(o,{method:"DELETE",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},tk=async(e,t)=>{try{let o=l?"".concat(l,"/config/update"):"/config/update",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},tC=async e=>{try{let t=l?"".concat(l,"/health"):"/health",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to call /health:",e),e}},t_=async(e,t)=>{try{let o=l?"".concat(l,"/health?model=").concat(encodeURIComponent(t)):"/health?model=".concat(encodeURIComponent(t)),a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw Error(e||"Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to call /health for model ".concat(t,":"),e),e}},tT=async e=>{try{let t=l?"".concat(l,"/cache/ping"):"/cache/ping",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error(e)}return await o.json()}catch(e){throw console.error("Failed to call /cache/ping:",e),e}},tE=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;try{let n=l?"".concat(l,"/health/history"):"/health/history",c=new URLSearchParams;t&&c.append("model",t),o&&c.append("status_filter",o),c.append("limit",a.toString()),c.append("offset",r.toString()),c.toString()&&(n+="?".concat(c.toString()));let s=await fetch(n,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw w(e),Error(e)}return await s.json()}catch(e){throw console.error("Failed to call /health/history:",e),e}},tj=async e=>{try{let t=l?"".concat(l,"/health/latest"):"/health/latest",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error(e)}return await o.json()}catch(e){throw console.error("Failed to call /health/latest:",e),e}},tS=async e=>{try{console.log("Getting proxy UI settings"),console.log("proxyBaseUrl in getProxyUISettings:",l);let t=l?"".concat(l,"/sso/get/ui_settings"):"/sso/get/ui_settings",o=await fetch(t,{method:"GET",headers:{[g]:"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 get callbacks:",e),e}},tv=async e=>{try{let t=l?"".concat(l,"/v2/guardrails/list"):"/v2/guardrails/list",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to get guardrails list:",e),e}},tb=async e=>{try{let t=l?"".concat(l,"/prompts/list"):"/prompts/list",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to get prompts list:",e),e}},tN=async(e,t)=>{try{let o=l?"".concat(l,"/prompts/").concat(t,"/info"):"/prompts/".concat(t,"/info"),a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to get prompt info:",e),e}},tF=async(e,t)=>{try{let o=l?"".concat(l,"/prompts"):"/prompts",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to create prompt:",e),e}},tx=async(e,t,o)=>{try{let a=l?"".concat(l,"/prompts/").concat(t):"/prompts/".concat(t),r=await fetch(a,{method:"PUT",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){let e=await r.text();throw w(e),Error("Network response was not ok")}return await r.json()}catch(e){throw console.error("Failed to update prompt:",e),e}},tP=async(e,t)=>{try{let o=l?"".concat(l,"/prompts/").concat(t):"/prompts/".concat(t),a=await fetch(o,{method:"DELETE",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to delete prompt:",e),e}},tO=async(e,t)=>{try{let o=new FormData;o.append("file",t);let a=l?"".concat(l,"/utils/dotprompt_json_converter"):"/utils/dotprompt_json_converter",r=await fetch(a,{method:"POST",headers:{[g]:"Bearer ".concat(e)},body:o});if(!r.ok){let e=await r.text();throw w(e),Error("Network response was not ok")}return await r.json()}catch(e){throw console.error("Failed to convert prompt file:",e),e}},tB=async(e,t,o)=>{try{let a=l?"".concat(l,"/prompts/").concat(t):"/prompts/".concat(t),r=await fetch(a,{method:"PATCH",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){let e=await r.text();throw w(e),Error("Network response was not ok")}return await r.json()}catch(e){throw console.error("Failed to patch prompt:",e),e}},tG=async(e,t)=>{try{let o=l?"".concat(l,"/guardrails"):"/guardrails",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({guardrail:t})});if(!a.ok){let e=await a.text();throw w(e),Error(e)}let r=await a.json();return console.log("Create guardrail response:",r),r}catch(e){throw console.error("Failed to create guardrail:",e),e}},tJ=async(e,t,o)=>{try{let a=l?"".concat(l,"/spend/logs/ui/").concat(t,"?start_date=").concat(encodeURIComponent(o)):"/spend/logs/ui/".concat(t,"?start_date=").concat(encodeURIComponent(o));console.log("Fetching log details from:",a);let r=await fetch(a,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok){let e=await r.text();throw w(e),Error("Network response was not ok")}let n=await r.json();return console.log("Fetched log details:",n),n}catch(e){throw console.error("Failed to fetch log details:",e),e}},tU=async e=>{try{let t=l?"".concat(l,"/get/internal_user_settings"):"/get/internal_user_settings";console.log("Fetching SSO settings from:",t);let o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}let a=await o.json();return console.log("Fetched SSO settings:",a),a}catch(e){throw console.error("Failed to fetch SSO settings:",e),e}},tA=async(e,t)=>{try{let o=l?"".concat(l,"/update/internal_user_settings"):"/update/internal_user_settings";console.log("Updating internal user settings:",t);let r=await fetch(o,{method:"PATCH",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){let e=await r.text();throw w(e),Error(e)}let n=await r.json();return console.log("Updated internal user settings:",n),a.ZP.success("Internal user settings updated successfully"),n}catch(e){throw console.error("Failed to update internal user settings:",e),e}},tR=async e=>{try{let t=l?"".concat(l,"/v1/mcp/server"):"/v1/mcp/server";console.log("Fetching MCP servers from:",t);let o=await fetch(t,{method:p.GET,headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}let a=await o.json();return console.log("Fetched MCP servers:",a),a}catch(e){throw console.error("Failed to fetch MCP servers:",e),e}},tI=async e=>{try{let t=l?"".concat(l,"/v1/mcp/access_groups"):"/v1/mcp/access_groups";console.log("Fetching MCP access groups from:",t);let o=await fetch(t,{method:p.GET,headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}let a=await o.json();return console.log("Fetched MCP access groups:",a),a.access_groups||[]}catch(e){throw console.error("Failed to fetch MCP access groups:",e),e}},tM=async(e,t)=>{try{console.log("Form Values in createMCPServer:",t);let o=l?"".concat(l,"/v1/mcp/server"):"/v1/mcp/server",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw w(e),console.error("Error response from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},tL=async(e,t)=>{try{let o=l?"".concat(l,"/v1/mcp/server"):"/v1/mcp/server",a=await fetch(o,{method:"PUT",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to update MCP server:",e),e}},tz=async(e,t)=>{try{let o=(l?"".concat(l):"")+"/v1/mcp/server/".concat(t);console.log("in deleteMCPServer:",t);let a=await fetch(o,{method:p.DELETE,headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}}catch(e){throw console.error("Failed to delete key:",e),e}},tD=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/mcp-rest/tools/list?server_id=").concat(t):"/mcp-rest/tools/list?server_id=".concat(t);console.log("Fetching MCP tools from:",r);let n={[g]:"Bearer ".concat(e),"Content-Type":"application/json"};a&&o?n["x-mcp-".concat(a,"-authorization")]=o:o&&(n[f]=o);let c=await fetch(r,{method:"GET",headers:n}),s=await c.json();if(console.log("Fetched MCP tools response:",s),!c.ok){if(s.error&&s.message)throw Error(s.message);throw Error("Failed to fetch MCP tools")}return s}catch(e){return console.error("Failed to fetch MCP tools:",e),{tools:[],error:"network_error",message:e instanceof Error?e.message:"Failed to fetch MCP tools"}}},tV=async(e,t,o,a,r)=>{try{let n=l?"".concat(l,"/mcp-rest/tools/call"):"/mcp-rest/tools/call";console.log("Calling MCP tool:",t,"with arguments:",o);let c={[g]:"Bearer ".concat(e),"Content-Type":"application/json"};r?c["x-mcp-".concat(r,"-authorization")]=a:c[f]=a;let s=await fetch(n,{method:"POST",headers:c,body:JSON.stringify({name:t,arguments:o})});if(!s.ok){let e="Network response was not ok",t=null,o=await s.text();try{let a=JSON.parse(o);a.detail?"string"==typeof a.detail?e=a.detail:"object"==typeof a.detail&&(e=a.detail.message||a.detail.error||"An error occurred",t=a.detail):e=a.message||a.error||e}catch(t){console.error("Failed to parse JSON error response:",t),o&&(e=o)}let a=Error(e);throw a.status=s.status,a.statusText=s.statusText,a.details=t,w(e),a}let i=await s.json();return console.log("MCP tool call response:",i),i}catch(e){throw console.error("Failed to call MCP tool:",e),console.error("Error type:",typeof e),e instanceof Error&&(console.error("Error message:",e.message),console.error("Error stack:",e.stack)),e}},tq=async(e,t)=>{try{let o=l?"".concat(l,"/tag/new"):"/tag/new",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify(t)});if(!a.ok){let e=await a.text();await w(e);return}return await a.json()}catch(e){throw console.error("Error creating tag:",e),e}},tH=async(e,t)=>{try{let o=l?"".concat(l,"/tag/update"):"/tag/update",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify(t)});if(!a.ok){let e=await a.text();await w(e);return}return await a.json()}catch(e){throw console.error("Error updating tag:",e),e}},tZ=async(e,t)=>{try{let o=l?"".concat(l,"/tag/info"):"/tag/info",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({names:t})});if(!a.ok){let e=await a.text();return await w(e),{}}return await a.json()}catch(e){throw console.error("Error getting tag info:",e),e}},tY=async e=>{try{let t=l?"".concat(l,"/tag/list"):"/tag/list",o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!o.ok){let e=await o.text();return await w(e),{}}return await o.json()}catch(e){throw console.error("Error listing tags:",e),e}},tW=async(e,t)=>{try{let o=l?"".concat(l,"/tag/delete"):"/tag/delete",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({name:t})});if(!a.ok){let e=await a.text();await w(e);return}return await a.json()}catch(e){throw console.error("Error deleting tag:",e),e}},tK=async e=>{try{let t=l?"".concat(l,"/get/default_team_settings"):"/get/default_team_settings";console.log("Fetching default team settings from:",t);let o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}let a=await o.json();return console.log("Fetched default team settings:",a),a}catch(e){throw console.error("Failed to fetch default team settings:",e),e}},tQ=async(e,t)=>{try{let o=l?"".concat(l,"/update/default_team_settings"):"/update/default_team_settings";console.log("Updating default team settings:",t);let r=await fetch(o,{method:"PATCH",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){let e=await r.text();throw w(e),Error("Network response was not ok")}let n=await r.json();return console.log("Updated default team settings:",n),a.ZP.success("Default team settings updated successfully"),n}catch(e){throw console.error("Failed to update default team settings:",e),e}},tX=async(e,t)=>{try{let o=l?"".concat(l,"/team/permissions_list?team_id=").concat(t):"/team/permissions_list?team_id=".concat(t),a=await fetch(o,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log("Team permissions response:",r),r}catch(e){throw console.error("Failed to get team permissions:",e),e}},t$=async(e,t,o)=>{try{let a=l?"".concat(l,"/team/permissions_update"):"/team/permissions_update",r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({team_id:t,team_member_permissions:o})});if(!r.ok){let e=await r.text();throw w(e),Error("Network response was not ok")}let n=await r.json();return console.log("Team permissions response:",n),n}catch(e){throw console.error("Failed to update team permissions:",e),e}},t0=async(e,t)=>{try{let o=l?"".concat(l,"/spend/logs/session/ui?session_id=").concat(encodeURIComponent(t)):"/spend/logs/session/ui?session_id=".concat(encodeURIComponent(t)),a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to fetch session logs:",e),e}},t1=async(e,t)=>{try{let o=l?"".concat(l,"/vector_store/new"):"/vector_store/new",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify(t)});if(!a.ok){let e=await a.json();throw Error(e.detail||"Failed to create vector store")}return await a.json()}catch(e){throw console.error("Error creating vector store:",e),e}},t2=async function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{let t=l?"".concat(l,"/vector_store/list"):"/vector_store/list",o=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)}});if(!o.ok){let e=await o.json();throw Error(e.detail||"Failed to list vector stores")}return await o.json()}catch(e){throw console.error("Error listing vector stores:",e),e}},t3=async(e,t)=>{try{let o=l?"".concat(l,"/vector_store/delete"):"/vector_store/delete",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({vector_store_id:t})});if(!a.ok){let e=await a.json();throw Error(e.detail||"Failed to delete vector store")}return await a.json()}catch(e){throw console.error("Error deleting vector store:",e),e}},t4=async(e,t)=>{try{let o=l?"".concat(l,"/vector_store/info"):"/vector_store/info",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({vector_store_id:t})});if(!a.ok){let e=await a.json();throw Error(e.detail||"Failed to get vector store info")}return await a.json()}catch(e){throw console.error("Error getting vector store info:",e),e}},t5=async(e,t)=>{try{let o=l?"".concat(l,"/vector_store/update"):"/vector_store/update",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify(t)});if(!a.ok){let e=await a.json();throw Error(e.detail||"Failed to update vector store")}return await a.json()}catch(e){throw console.error("Error updating vector store:",e),e}},t6=async e=>{try{let t=l?"".concat(l,"/email/event_settings"):"/email/event_settings",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Failed to get email event settings")}let a=await o.json();return console.log("Email event settings response:",a),a}catch(e){throw console.error("Failed to get email event settings:",e),e}},t7=async(e,t)=>{try{let o=l?"".concat(l,"/email/event_settings"):"/email/event_settings",a=await fetch(o,{method:"PATCH",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.text();throw w(e),Error("Failed to update email event settings")}let r=await a.json();return console.log("Update email event settings response:",r),r}catch(e){throw console.error("Failed to update email event settings:",e),e}},t9=async e=>{try{let t=l?"".concat(l,"/email/event_settings/reset"):"/email/event_settings/reset",o=await fetch(t,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Failed to reset email event settings")}let a=await o.json();return console.log("Reset email event settings response:",a),a}catch(e){throw console.error("Failed to reset email event settings:",e),e}},t8=async(e,t)=>{try{let o=l?"".concat(l,"/guardrails/").concat(t):"/guardrails/".concat(t),a=await fetch(o,{method:"DELETE",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error(e)}let r=await a.json();return console.log("Delete guardrail response:",r),r}catch(e){throw console.error("Failed to delete guardrail:",e),e}},oe=async e=>{try{let t=l?"".concat(l,"/guardrails/ui/add_guardrail_settings"):"/guardrails/ui/add_guardrail_settings",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Failed to get guardrail UI settings")}let a=await o.json();return console.log("Guardrail UI settings response:",a),a}catch(e){throw console.error("Failed to get guardrail UI settings:",e),e}},ot=async e=>{try{let t=l?"".concat(l,"/guardrails/ui/provider_specific_params"):"/guardrails/ui/provider_specific_params",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Failed to get guardrail provider specific parameters")}let a=await o.json();return console.log("Guardrail provider specific params response:",a),a}catch(e){throw console.error("Failed to get guardrail provider specific parameters:",e),e}},oo=async(e,t)=>{try{let o=l?"".concat(l,"/guardrails/").concat(t,"/info"):"/guardrails/".concat(t,"/info"),a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Failed to get guardrail info")}let r=await a.json();return console.log("Guardrail info response:",r),r}catch(e){throw console.error("Failed to get guardrail info:",e),e}},oa=async(e,t,o)=>{try{let a=l?"".concat(l,"/guardrails/").concat(t):"/guardrails/".concat(t),r=await fetch(a,{method:"PATCH",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){let e=await r.text();throw w(e),Error("Failed to update guardrail")}let n=await r.json();return console.log("Update guardrail response:",n),n}catch(e){throw console.error("Failed to update guardrail:",e),e}},or=async e=>{try{let t=l?"".concat(l,"/get/sso_settings"):"/get/sso_settings";console.log("Fetching SSO configuration from:",t);let o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}let a=await o.json();return console.log("Fetched SSO configuration:",a),a}catch(e){throw console.error("Failed to fetch SSO configuration:",e),e}},on=async(e,t)=>{try{let o=l?"".concat(l,"/update/sso_settings"):"/update/sso_settings";console.log("Updating SSO configuration:",t);let a=await fetch(o,{method:"PATCH",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=await a.json();return console.log("Updated SSO configuration:",r),r}catch(e){throw console.error("Failed to update SSO configuration:",e),e}},oc=async(e,t,o,a,r)=>{try{let t=l?"".concat(l,"/audit"):"/audit",o=new URLSearchParams;a&&o.append("page",a.toString()),r&&o.append("page_size",r.toString());let n=o.toString();n&&(t+="?".concat(n));let c=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.text();throw w(e),Error("Network response was not ok")}return await c.json()}catch(e){throw console.error("Failed to fetch audit logs:",e),e}},os=async e=>{try{let t=l?"".concat(l,"/user/available_users"):"/user/available_users",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e)}});if(!o.ok){if(404===o.status)return null;let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to fetch remaining users:",e),e}},ol=async(e,t,o)=>{try{let r=l?"".concat(l,"/config/pass_through_endpoint/").concat(encodeURIComponent(t)):"/config/pass_through_endpoint/".concat(encodeURIComponent(t)),n=await fetch(r,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!n.ok){let e=await n.text();throw w(e),Error("Network response was not ok")}let c=await n.json();return a.ZP.success("Pass through endpoint updated successfully"),c}catch(e){throw console.error("Failed to update pass through endpoint:",e),e}},oi=async(e,t)=>{try{let o=l?"".concat(l,"/config/pass_through_endpoint?endpoint_id=").concat(encodeURIComponent(t)):"/config/pass_through_endpoint?endpoint_id=".concat(encodeURIComponent(t)),a=await fetch(o,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}let r=(await a.json()).endpoints;if(!r||0===r.length)throw Error("Pass through endpoint not found");return r[0]}catch(e){throw console.error("Failed to get pass through endpoint info:",e),e}},od=async(e,t)=>{try{let o=l?"".concat(l,"/config/callback/delete"):"/config/callback/delete",a=await fetch(o,{method:"POST",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({callback_name:t})});if(!a.ok){let e=await a.text();throw w(e),Error("Network response was not ok")}return await a.json()}catch(e){throw console.error("Failed to delete specific callback:",e),e}},op=async e=>{let t=d(),o=await fetch("".concat(t,"/v1/mcp/tools"),{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw Error("HTTP error! status: ".concat(o.status));return await o.json()},oh=async(e,t)=>{try{console.log("Testing MCP connection with config:",JSON.stringify(t));let a=l?"".concat(l,"/mcp-rest/test/connection"):"/mcp-rest/test/connection",r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",[g]:"Bearer ".concat(e)},body:JSON.stringify(t)}),n=r.headers.get("content-type");if(!n||!n.includes("application/json")){let e=await r.text();throw console.error("Received non-JSON response:",e),Error("Received non-JSON response (".concat(r.status,": ").concat(r.statusText,"). Check network tab for details."))}let c=await r.json();if(!r.ok||"error"===c.status){if("error"===c.status);else{var o;return{status:"error",message:(null===(o=c.error)||void 0===o?void 0:o.message)||"MCP connection test failed: ".concat(r.status," ").concat(r.statusText)}}}return c}catch(e){throw console.error("MCP connection test error:",e),e}},ou=async(e,t)=>{try{console.log("Testing MCP tools list with config:",JSON.stringify(t));let o=l?"".concat(l,"/mcp-rest/test/tools/list"):"/mcp-rest/test/tools/list",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",[g]:"Bearer ".concat(e)},body:JSON.stringify(t)}),r=a.headers.get("content-type");if(!r||!r.includes("application/json")){let e=await a.text();throw console.error("Received non-JSON response:",e),Error("Received non-JSON response (".concat(a.status,": ").concat(a.statusText,"). Check network tab for details."))}let n=await a.json();if((!a.ok||n.error)&&!n.error)return{tools:[],error:"request_failed",message:n.message||"MCP tools list failed: ".concat(a.status," ").concat(a.statusText)};return n}catch(e){throw console.error("MCP tools list test error:",e),e}},ow=async(e,t,o)=>{try{let a="".concat(d(),"/v1/vector_stores/").concat(t,"/search"),r=await fetch(a,{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({query:o})});if(!r.ok){let e=await r.text();return await w(e),null}return await r.json()}catch(e){throw console.error("Error testing vector store search:",e),e}},og=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:50,n=arguments.length>5?arguments[5]:void 0;try{let c=l?"".concat(l,"/tag/user-agent/analytics"):"/tag/user-agent/analytics",s=new URLSearchParams,i=e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)};s.append("start_date",i(t)),s.append("end_date",i(o)),s.append("page",a.toString()),s.append("page_size",r.toString()),n&&s.append("user_agent_filter",n);let d=s.toString();d&&(c+="?".concat(d));let p=await fetch(c,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!p.ok){let e=await p.text();throw w(e),Error("Network response was not ok")}return await p.json()}catch(e){throw console.error("Failed to fetch user agent analytics:",e),e}},of=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/tag/dau"):"/tag/dau",n=new URLSearchParams;n.append("end_date",(e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)})(t)),a&&a.length>0?a.forEach(e=>{n.append("tag_filters",e)}):o&&n.append("tag_filter",o);let c=n.toString();c&&(r+="?".concat(c));let s=await fetch(r,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw w(e),Error("Network response was not ok")}return await s.json()}catch(e){throw console.error("Failed to fetch DAU:",e),e}},om=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/tag/wau"):"/tag/wau",n=new URLSearchParams;n.append("end_date",(e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)})(t)),a&&a.length>0?a.forEach(e=>{n.append("tag_filters",e)}):o&&n.append("tag_filter",o);let c=n.toString();c&&(r+="?".concat(c));let s=await fetch(r,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw w(e),Error("Network response was not ok")}return await s.json()}catch(e){throw console.error("Failed to fetch WAU:",e),e}},oy=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/tag/mau"):"/tag/mau",n=new URLSearchParams;n.append("end_date",(e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)})(t)),a&&a.length>0?a.forEach(e=>{n.append("tag_filters",e)}):o&&n.append("tag_filter",o);let c=n.toString();c&&(r+="?".concat(c));let s=await fetch(r,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw w(e),Error("Network response was not ok")}return await s.json()}catch(e){throw console.error("Failed to fetch MAU:",e),e}},ok=async e=>{try{let t=l?"".concat(l,"/tag/distinct"):"/tag/distinct",o=await fetch(t,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw w(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to fetch distinct tags:",e),e}},oC=async(e,t,o,a)=>{try{let r=l?"".concat(l,"/tag/summary"):"/tag/summary",n=new URLSearchParams,c=e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)};n.append("start_date",c(t)),n.append("end_date",c(o)),a&&a.length>0&&a.forEach(e=>{n.append("tag_filters",e)});let s=n.toString();s&&(r+="?".concat(s));let i=await fetch(r,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.text();throw w(e),Error("Network response was not ok")}return await i.json()}catch(e){throw console.error("Failed to fetch user agent summary:",e),e}},o_=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:50,a=arguments.length>3?arguments[3]:void 0;try{let r=l?"".concat(l,"/tag/user-agent/per-user-analytics"):"/tag/user-agent/per-user-analytics",n=new URLSearchParams;n.append("page",t.toString()),n.append("page_size",o.toString()),a&&a.length>0&&a.forEach(e=>{n.append("tag_filters",e)});let c=n.toString();c&&(r+="?".concat(c));let s=await fetch(r,{method:"GET",headers:{[g]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!s.ok){let e=await s.text();throw w(e),Error("Network response was not ok")}return await s.json()}catch(e){throw console.error("Failed to fetch per-user analytics:",e),e}}},3914:function(e,t,o){function a(){let e=window.location.hostname,t=["Lax","Strict","None"];["/","/ui"].forEach(o=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=".concat(o,";"),document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=".concat(o,"; domain=").concat(e,";"),t.forEach(t=>{let a="None"===t?" Secure;":"";document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=".concat(o,"; SameSite=").concat(t,";").concat(a),document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=".concat(o,"; domain=").concat(e,"; SameSite=").concat(t,";").concat(a)})}),console.log("After clearing cookies:",document.cookie)}function r(e){let t=document.cookie.split("; ").find(t=>t.startsWith(e+"="));return t?t.split("=")[1]:null}o.d(t,{b:function(){return a},e:function(){return r}})}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/154-fff436ed72b19a24.js b/litellm/proxy/_experimental/out/_next/static/chunks/154-fff436ed72b19a24.js new file mode 100644 index 00000000000..feea71c5b79 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/154-fff436ed72b19a24.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[154],{31283:function(e,t,o){o.d(t,{o:function(){return a.Z}});var a=o(49566)},63610:function(e,t,o){o.d(t,{d:function(){return p}});var a=o(57437),r=o(2265),n=o(64482),l=o(52787),c=o(20577),i=o(13634),s=o(31283),d=o(15424),u=o(89970),h=o(19250);let p=["metadata","config","enforced_params","aliases"],g=(e,t)=>p.includes(e)||"json"===t.format,m=e=>{if(!e)return!0;try{return JSON.parse(e),!0}catch(e){return!1}},f=(e,t,o)=>{let a={max_budget:"Enter maximum budget in USD (e.g., 100.50)",budget_duration:"Select a time period for budget reset",tpm_limit:"Enter maximum tokens per minute (whole number)",rpm_limit:"Enter maximum requests per minute (whole number)",duration:"Enter duration (e.g., 30s, 24h, 7d)",metadata:'Enter JSON object with key-value pairs\nExample: {"team": "research", "project": "nlp"}',config:'Enter configuration as JSON object\nExample: {"setting": "value"}',permissions:"Enter comma-separated permission strings",enforced_params:'Enter parameters as JSON object\nExample: {"param": "value"}',blocked:"Enter true/false or specific block conditions",aliases:'Enter aliases as JSON object\nExample: {"alias1": "value1", "alias2": "value2"}',models:"Select one or more model names",key_alias:"Enter a unique identifier for this key",tags:"Enter comma-separated tag strings"}[e]||({string:"Text input",number:"Numeric input",integer:"Whole number input",boolean:"True/False value"})[o]||"Text input";return g(e,t)?"".concat(a,"\nMust be valid JSON format"):t.enum?"Select from available options\nAllowed values: ".concat(t.enum.join(", ")):a};t.Z=e=>{let{schemaComponent:t,excludedFields:o=[],form:p,overrideLabels:w={},overrideTooltips:y={},customValidation:j={},defaultValues:_={}}=e,[C,k]=(0,r.useState)(null),[v,T]=(0,r.useState)(null);(0,r.useEffect)(()=>{(async()=>{try{let e=(await (0,h.getOpenAPISchema)()).components.schemas[t];if(!e)throw Error('Schema component "'.concat(t,'" not found'));k(e);let a={};Object.keys(e.properties).filter(e=>!o.includes(e)&&void 0!==_[e]).forEach(e=>{a[e]=_[e]}),p.setFieldsValue(a)}catch(e){console.error("Schema fetch error:",e),T(e instanceof Error?e.message:"Failed to fetch schema")}})()},[t,p,o]);let E=e=>{if(e.type)return e.type;if(e.anyOf){let t=e.anyOf.map(e=>e.type);if(t.includes("number")||t.includes("integer"))return"number";t.includes("string")}return"string"},S=(e,t)=>{var o;let r;let h=E(t),p=null==C?void 0:null===(o=C.required)||void 0===o?void 0:o.includes(e),k=w[e]||t.title||e,v=y[e]||t.description,T=[];p&&T.push({required:!0,message:"".concat(k," is required")}),j[e]&&T.push({validator:j[e]}),g(e,t)&&T.push({validator:async(e,t)=>{if(t&&!m(t))throw Error("Please enter valid JSON")}});let S=v?(0,a.jsxs)("span",{children:[k," ",(0,a.jsx)(u.Z,{title:v,children:(0,a.jsx)(d.Z,{style:{marginLeft:"4px"}})})]}):k;return r=g(e,t)?(0,a.jsx)(n.default.TextArea,{rows:4,placeholder:"Enter as JSON",className:"font-mono"}):t.enum?(0,a.jsx)(l.default,{children:t.enum.map(e=>(0,a.jsx)(l.default.Option,{value:e,children:e},e))}):"number"===h||"integer"===h?(0,a.jsx)(c.Z,{style:{width:"100%"},precision:"integer"===h?0:void 0}):"duration"===e?(0,a.jsx)(s.o,{placeholder:"eg: 30s, 30h, 30d"}):(0,a.jsx)(s.o,{placeholder:v||""}),(0,a.jsx)(i.Z.Item,{label:S,name:e,className:"mt-8",rules:T,initialValue:_[e],help:(0,a.jsx)("div",{className:"text-xs text-gray-500",children:f(e,t,h)}),children:r},e)};return v?(0,a.jsxs)("div",{className:"text-red-500",children:["Error: ",v]}):(null==C?void 0:C.properties)?(0,a.jsx)("div",{children:Object.entries(C.properties).filter(e=>{let[t]=e;return!o.includes(t)}).map(e=>{let[t,o]=e;return S(t,o)})}):null}},9114:function(e,t,o){var a=o(2265),r=o(57271),n=o(85968);function l(){return"topRight"}function c(e,t){var o;return"string"==typeof e?{message:t,description:e}:{message:null!==(o=e.message)&&void 0!==o?o:t,...e}}function i(e){return"number"==typeof e?e:"string"==typeof e&&/^\d+$/.test(e)?parseInt(e,10):void 0}let s=["invalid api key","invalid authorization header format","authentication error","invalid proxy server token","invalid jwt token","invalid jwt submitted","unauthorized access to metrics endpoint"],d=["admin-only endpoint","not allowed to access model","user does not have permission","access forbidden","invalid credentials used to access ui","user not allowed to access proxy"],u=["db not connected","database not initialized","no db connected","prisma client not initialized","service unhealthy"],h=["no models configured on proxy","llm router not initialized","no deployments available","no healthy deployment available","not allowed to access model due to tags configuration","invalid model name passed in"],p=["deployment over user-defined ratelimit","crossed tpm / rpm / max parallel request limit","max parallel request limit"],g=["budget exceeded","crossed budget","provider budget"],m=["must be a litellm enterprise user","only be available for liteLLM enterprise users","missing litellm-enterprise package","only available on the docker image","enterprise feature","premium user"],f=["invalid json payload","invalid request type","invalid key format","invalid hash key","invalid sort column","invalid sort order","invalid limit","invalid file type","invalid field","invalid date format"],w=["model not found","model with id","credential not found","user not found","team not found","organization not found","mcp server with id","tool '"],y=["already exists","team member is already in team","user already exists"],j=["violated openai moderation policy","violated jailbreak threshold","violated prompt_injection threshold","violated content safety policy","violated lasso guardrail policy","blocked by pillar security guardrail","violated azure prompt shield guardrail policy","content blocked by model armor","response blocked by model armor","streaming response blocked by model armor","guardrail","moderation"],_=["invalid purpose","service must be specified","invalid response - response.response is none"],C=["cloudzero settings not configured","failed to decrypt cloudzero api key","cloudzero settings not found"],k=["created successfully","updated successfully","deleted successfully","credential created successfully","model added successfully","team created successfully","user created successfully","organization created successfully","cloudzero settings initialized successfully","cloudzero settings updated successfully","cloudzero export completed successfully","mock llm request made","mock slack alert sent","mock email alert sent","spend for all api keys and teams reset successfully","monthlyglobalspend view refreshed","cache cleared successfully","cache set successfully","ip ","deleted successfully"],v=["rate limit reached for deployment","deployment cooldown period active"],T=["this feature is only available for litellm enterprise users","enterprise features are not available","regenerating virtual keys is an enterprise feature","trying to set allowed_routes. this is an enterprise feature"],E=["invalid maximum_spend_logs_retention_interval value","error has invalid or non-convertible code","failed to save health check to database"];t.Z={error(e){var t,o;let a=c(e,"Error");r.ZP.error({...a,placement:null!==(t=a.placement)&&void 0!==t?t:l(),duration:null!==(o=a.duration)&&void 0!==o?o:6})},warning(e){var t,o;let a=c(e,"Warning");r.ZP.warning({...a,placement:null!==(t=a.placement)&&void 0!==t?t:l(),duration:null!==(o=a.duration)&&void 0!==o?o:5})},info(e){var t,o;let a=c(e,"Info");r.ZP.info({...a,placement:null!==(t=a.placement)&&void 0!==t?t:l(),duration:null!==(o=a.duration)&&void 0!==o?o:4})},success(e){var t,o;if(a.isValidElement(e)){r.ZP.success({message:"Success",description:e,placement:l(),duration:3.5});return}let n=c(e,"Success");r.ZP.success({...n,placement:null!==(t=n.placement)&&void 0!==t?t:l(),duration:null!==(o=n.duration)&&void 0!==o?o:3.5})},fromBackend(e,t){var o,a,c,S,b,F,P,O,B,N,x,G;let J=null!==(G=null!==(x=i(null==e?void 0:null===(N=e.response)||void 0===N?void 0:N.status))&&void 0!==x?x:i(null==e?void 0:e.status_code))&&void 0!==G?G:i(null==e?void 0:e.code),A=function(e){var t,o,a,r,l,c,i,s,d,u,h,p;if("string"==typeof e)return e;let g=null!==(p=null!==(h=null!==(u=null!==(d=null!==(s=null==e?void 0:null===(a=e.response)||void 0===a?void 0:null===(o=a.data)||void 0===o?void 0:null===(t=o.error)||void 0===t?void 0:t.message)&&void 0!==s?s:null==e?void 0:null===(l=e.response)||void 0===l?void 0:null===(r=l.data)||void 0===r?void 0:r.message)&&void 0!==d?d:null==e?void 0:null===(i=e.response)||void 0===i?void 0:null===(c=i.data)||void 0===c?void 0:c.error)&&void 0!==u?u:null==e?void 0:e.detail)&&void 0!==h?h:null==e?void 0:e.message)&&void 0!==p?p:e;return(0,n.O)(g)}(e),U={...null!=t?t:{},description:A,placement:null!==(o=null==t?void 0:t.placement)&&void 0!==o?o:l()};if(void 0!==J||e instanceof Error||"string"==typeof e||e&&"object"==typeof e&&("error"in e||"detail"in e)){let e=function(e,t){var o,a,r,n,l;let c=(t||"").toLowerCase();return s.some(e=>c.includes(e))?"Authentication Error":d.some(e=>c.includes(e))?"Access Denied":(null==u?void 0:null===(o=u.some)||void 0===o?void 0:o.call(u,e=>c.includes(e)))||503===e?"Service Unavailable":(null==g?void 0:null===(a=g.some)||void 0===a?void 0:a.call(g,e=>c.includes(e)))?"Budget Exceeded":(null==m?void 0:null===(r=m.some)||void 0===r?void 0:r.call(m,e=>c.includes(e)))?"Feature Unavailable":(null==h?void 0:null===(n=h.some)||void 0===n?void 0:n.call(h,e=>c.includes(e)))?"Routing Error":y.some(e=>c.includes(e))?"Already Exists":j.some(e=>c.includes(e))?"Content Blocked":_.some(e=>c.includes(e))?"Validation Error":C.some(e=>c.includes(e))?"Integration Error":f.some(e=>c.includes(e))?"Validation Error":404===e||c.includes("not found")||w.some(e=>c.includes(e))?"Not Found":429===e||c.includes("rate limit")||c.includes("tpm")||c.includes("rpm")||(null==p?void 0:null===(l=p.some)||void 0===l?void 0:l.call(p,e=>c.includes(e)))?"Rate Limit Exceeded":e&&e>=500?"Server Error":401===e?"Authentication Error":403===e?"Access Denied":c.includes("enterprise")||c.includes("premium")?"Info":e&&e>=400?"Request Error":"Error"}(J,A),o={...U,message:e};if("Rate Limit Exceeded"===e||"Info"===e||"Budget Exceeded"===e||"Feature Unavailable"===e||"Content Blocked"===e||"Integration Error"===e){r.ZP.warning({...o,duration:null!==(a=null==t?void 0:t.duration)&&void 0!==a?a:7});return}if("Server Error"===e){r.ZP.error({...o,duration:null!==(c=null==t?void 0:t.duration)&&void 0!==c?c:8});return}if("Request Error"===e||"Authentication Error"===e||"Access Denied"===e||"Not Found"===e||"Error"===e){r.ZP.error({...o,duration:null!==(S=null==t?void 0:t.duration)&&void 0!==S?S:6});return}r.ZP.info({...o,duration:null!==(b=null==t?void 0:t.duration)&&void 0!==b?b:4});return}let R=function(e){let t=(e||"").toLowerCase();return k.some(e=>t.includes(e))?{kind:"success",title:"Success"}:T.some(e=>t.includes(e))?{kind:"warning",title:"Feature Notice"}:E.some(e=>t.includes(e))?{kind:"warning",title:"Configuration Warning"}:v.some(e=>t.includes(e))?{kind:"warning",title:"Rate Limit"}:null}(A),I={...U,message:null!==(F=null==R?void 0:R.title)&&void 0!==F?F:"Info"};if((null==R?void 0:R.kind)==="success"){r.ZP.success({...I,duration:null!==(P=null==t?void 0:t.duration)&&void 0!==P?P:3.5});return}if((null==R?void 0:R.kind)==="warning"){r.ZP.warning({...I,duration:null!==(O=null==t?void 0:t.duration)&&void 0!==O?O:6});return}r.ZP.info({...I,duration:null!==(B=null==t?void 0:t.duration)&&void 0!==B?B:4})},clear(){r.ZP.destroy()}}},19250:function(e,t,o){o.r(t),o.d(t,{DEFAULT_ORGANIZATION:function(){return p},PredictedSpendLogsCall:function(){return tl},addAllowedIP:function(){return em},adminGlobalActivity:function(){return eJ},adminGlobalActivityExceptions:function(){return eR},adminGlobalActivityExceptionsPerDeployment:function(){return eI},adminGlobalActivityPerModel:function(){return eU},adminGlobalCacheActivity:function(){return eA},adminSpendLogsCall:function(){return eB},adminTopEndUsersCall:function(){return ex},adminTopKeysCall:function(){return eN},adminTopModelsCall:function(){return eM},adminspendByProvider:function(){return eG},alertingSettingsCall:function(){return A},allEndUsersCall:function(){return eb},allTagNamesCall:function(){return eS},availableTeamListCall:function(){return W},budgetCreateCall:function(){return N},budgetDeleteCall:function(){return B},budgetUpdateCall:function(){return x},cachingHealthCheckCall:function(){return tv},callMCPTool:function(){return tZ},cancelModelCostMapReload:function(){return S},claimOnboardingToken:function(){return el},convertPromptFileToJson:function(){return tx},createGuardrailCall:function(){return tJ},createMCPServer:function(){return tz},createPassThroughEndpoint:function(){return tf},createPromptCall:function(){return tO},credentialCreateCall:function(){return eQ},credentialDeleteCall:function(){return e1},credentialGetCall:function(){return e0},credentialListCall:function(){return eX},credentialUpdateCall:function(){return e2},defaultProxyBaseUrl:function(){return c},deleteAllowedIP:function(){return ef},deleteCallback:function(){return ou},deleteConfigFieldSetting:function(){return ty},deleteGuardrailCall:function(){return oe},deleteMCPServer:function(){return tD},deletePassThroughEndpointsCall:function(){return tj},deletePromptCall:function(){return tN},fetchMCPAccessGroups:function(){return tM},fetchMCPServers:function(){return tI},formatDate:function(){return l},getAllowedIPs:function(){return eg},getBudgetList:function(){return ts},getBudgetSettings:function(){return td},getCallbacksCall:function(){return tu},getConfigFieldSetting:function(){return tg},getDefaultTeamSettings:function(){return t$},getEmailEventSettings:function(){return t7},getGeneralSettingsCall:function(){return th},getGuardrailInfo:function(){return oa},getGuardrailProviderSpecificParams:function(){return oo},getGuardrailUISettings:function(){return ot},getGuardrailsList:function(){return tb},getInternalUserSettings:function(){return tU},getModelCostMapReloadStatus:function(){return b},getOnboardingCredentials:function(){return en},getOpenAPISchema:function(){return k},getPassThroughEndpointInfo:function(){return od},getPassThroughEndpointsCall:function(){return tp},getPossibleUserRoles:function(){return eK},getPromptInfo:function(){return tP},getPromptsList:function(){return tF},getProxyBaseUrl:function(){return u},getProxyUISettings:function(){return tS},getPublicModelHubInfo:function(){return C},getRemainingUsers:function(){return oi},getSSOSettings:function(){return on},getTeamPermissionsCall:function(){return tX},getTotalSpendCall:function(){return er},getUiConfig:function(){return _},healthCheckCall:function(){return tC},healthCheckHistoryCall:function(){return tT},individualModelHealthCheckCall:function(){return tk},invitationClaimCall:function(){return J},invitationCreateCall:function(){return G},keyCreateCall:function(){return R},keyCreateServiceAccountCall:function(){return U},keyDeleteCall:function(){return M},keyInfoCall:function(){return ez},keyInfoV1Call:function(){return eD},keyListCall:function(){return eV},keySpendLogsCall:function(){return ev},keyUpdateCall:function(){return e4},latestHealthChecksCall:function(){return tE},listMCPTools:function(){return tV},makeModelGroupPublic:function(){return j},mcpToolsCall:function(){return oh},modelAvailableCall:function(){return ek},modelCostMap:function(){return v},modelCreateCall:function(){return F},modelDeleteCall:function(){return O},modelExceptionsCall:function(){return e_},modelHubCall:function(){return ep},modelHubPublicModelsCall:function(){return eh},modelInfoCall:function(){return ed},modelInfoV1Call:function(){return eu},modelMetricsCall:function(){return ew},modelMetricsSlowResponsesCall:function(){return ej},modelPatchUpdateCall:function(){return e5},modelSettingsCall:function(){return P},modelUpdateCall:function(){return e6},organizationCreateCall:function(){return $},organizationDeleteCall:function(){return X},organizationInfoCall:function(){return K},organizationListCall:function(){return Y},organizationMemberAddCall:function(){return tt},organizationMemberDeleteCall:function(){return to},organizationMemberUpdateCall:function(){return ta},organizationUpdateCall:function(){return Q},patchPromptCall:function(){return tG},perUserAnalyticsCall:function(){return ok},proxyBaseUrl:function(){return s},regenerateKeyCall:function(){return ec},reloadModelCostMap:function(){return T},resetEmailEventSettings:function(){return t8},scheduleModelCostMapReload:function(){return E},serverRootPath:function(){return i},serviceHealthCheck:function(){return ti},sessionSpendLogsCall:function(){return t1},setCallbacksCall:function(){return t_},setGlobalLitellmHeaderName:function(){return y},slackBudgetAlertsHealthCheck:function(){return tc},spendUsersCall:function(){return eZ},streamingModelMetricsCall:function(){return ey},tagCreateCall:function(){return tq},tagDailyActivityCall:function(){return eo},tagDauCall:function(){return ow},tagDeleteCall:function(){return tK},tagDistinctCall:function(){return o_},tagInfoCall:function(){return tW},tagListCall:function(){return tY},tagMauCall:function(){return oj},tagUpdateCall:function(){return tH},tagWauCall:function(){return oy},tagsSpendLogsCall:function(){return eE},teamBulkMemberAddCall:function(){return e9},teamCreateCall:function(){return e$},teamDailyActivityCall:function(){return ea},teamDeleteCall:function(){return L},teamInfoCall:function(){return Z},teamListCall:function(){return H},teamMemberAddCall:function(){return e7},teamMemberDeleteCall:function(){return te},teamMemberUpdateCall:function(){return e8},teamPermissionsUpdateCall:function(){return t0},teamSpendLogsCall:function(){return eT},teamUpdateCall:function(){return e3},testConnectionRequest:function(){return eL},testMCPConnectionRequest:function(){return op},testMCPToolsListRequest:function(){return og},transformRequestCall:function(){return ee},uiAuditLogsCall:function(){return oc},uiSpendLogDetailsCall:function(){return tA},uiSpendLogsCall:function(){return eO},updateConfigFieldSetting:function(){return tw},updateDefaultTeamSettings:function(){return tQ},updateEmailEventSettings:function(){return t9},updateGuardrailCall:function(){return or},updateInternalUserSettings:function(){return tR},updateMCPServer:function(){return tL},updatePassThroughEndpoint:function(){return os},updatePassThroughFieldSetting:function(){return tm},updatePromptCall:function(){return tB},updateSSOSettings:function(){return ol},updateUsefulLinksCall:function(){return eC},userAgentAnalyticsCall:function(){return of},userAgentSummaryCall:function(){return oC},userBulkUpdateUserCall:function(){return tn},userCreateCall:function(){return I},userDailyActivityAggregatedCall:function(){return eW},userDailyActivityCall:function(){return et},userDeleteCall:function(){return z},userFilterUICall:function(){return eF},userGetAllUsersCall:function(){return eY},userGetRequesedtModelsCall:function(){return eH},userInfoCall:function(){return V},userListCall:function(){return D},userRequestModelCall:function(){return eq},userSpendLogsCall:function(){return eP},userUpdateUserCall:function(){return tr},v2TeamListCall:function(){return q},vectorStoreCreateCall:function(){return t2},vectorStoreDeleteCall:function(){return t3},vectorStoreInfoCall:function(){return t5},vectorStoreListCall:function(){return t4},vectorStoreSearchCall:function(){return om},vectorStoreUpdateCall:function(){return t6}});var a=o(42264),r=o(63610),n=o(9114);let l=e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)},c=null,i="/",s=null;console.log=function(){};let d=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=window.location.origin,a=t||o;console.log("proxyBaseUrl:",s),console.log("serverRootPath:",e),e.length>0&&!a.endsWith(e)&&"/"!=e&&(a+=e,s=a),console.log("Updated proxyBaseUrl:",s)},u=()=>s||window.location.origin,h={GET:"GET",DELETE:"DELETE"},p="default_organization",g=0,m=async e=>{let t=Date.now();t-g>6e4?(e.includes("Authentication Error - Expired Key")&&(n.Z.info("UI Session Expired. Logging out."),g=t,document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",window.location.href=window.location.pathname),g=t):console.log("Error suppressed to prevent spam:",e)},f="Authorization",w="x-mcp-auth";function y(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Authorization";console.log("setGlobalLitellmHeaderName: ".concat(e)),f=e}let j=async(e,t)=>{let o=s?"".concat(s,"/model_group/make_public"):"/model_group/make_public";return(await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({model_groups:t})})).json()},_=async()=>{console.log("Getting UI config");let e=await fetch(c?"".concat(c,"/litellm/.well-known/litellm-ui-config"):"/litellm/.well-known/litellm-ui-config"),t=await e.json();return console.log("jsonData in getUiConfig:",t),d(t.server_root_path,t.proxy_base_url),t},C=async()=>{let e=await fetch(c?"".concat(c,"/public/model_hub/info"):"/public/model_hub/info");return await e.json()},k=async()=>{let e=s?"".concat(s,"/openapi.json"):"/openapi.json",t=await fetch(e);return await t.json()},v=async e=>{try{let t=s?"".concat(s,"/get/litellm_model_cost_map"):"/get/litellm_model_cost_map",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}}),a=await o.json();return console.log("received litellm model cost data: ".concat(a)),a}catch(e){throw console.error("Failed to get model cost map:",e),e}},T=async e=>{try{let t=s?"".concat(s,"/reload/model_cost_map"):"/reload/model_cost_map",o=await fetch(t,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}}),a=await o.json();return console.log("Model cost map reload response: ".concat(a)),a}catch(e){throw console.error("Failed to reload model cost map:",e),e}},E=async(e,t)=>{try{let o=s?"".concat(s,"/schedule/model_cost_map_reload?hours=").concat(t):"/schedule/model_cost_map_reload?hours=".concat(t),a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}}),r=await a.json();return console.log("Schedule model cost map reload response: ".concat(r)),r}catch(e){throw console.error("Failed to schedule model cost map reload:",e),e}},S=async e=>{try{let t=s?"".concat(s,"/schedule/model_cost_map_reload"):"/schedule/model_cost_map_reload",o=await fetch(t,{method:"DELETE",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}}),a=await o.json();return console.log("Cancel model cost map reload response: ".concat(a)),a}catch(e){throw console.error("Failed to cancel model cost map reload:",e),e}},b=async e=>{try{let t=s?"".concat(s,"/schedule/model_cost_map_reload/status"):"/schedule/model_cost_map_reload/status";console.log("Fetching status from URL:",t);let o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){console.error("Status request failed with status: ".concat(o.status));let e=await o.text();throw console.error("Error response:",e),Error("HTTP ".concat(o.status,": ").concat(e))}let a=await o.json();return console.log("Model cost map reload status:",a),a}catch(e){throw console.error("Failed to get model cost map reload status:",e),e}},F=async(e,t)=>{try{let o=s?"".concat(s,"/model/new"):"/model/new",r=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let l=await r.json();return console.log("API Response:",l),a.ZP.destroy(),n.Z.success("Model ".concat(t.model_name," created successfully")),l}catch(e){throw console.error("Failed to create key:",e),e}},P=async e=>{try{let t=s?"".concat(s,"/model/settings"):"/model/settings",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){console.error("Failed to get model settings:",e)}},O=async(e,t)=>{console.log("model_id in model delete call: ".concat(t));try{let o=s?"".concat(s,"/model/delete"):"/model/delete",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},B=async(e,t)=>{if(console.log("budget_id in budget delete call: ".concat(t)),null!=e)try{let o=s?"".concat(s,"/budget/delete"):"/budget/delete",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},N=async(e,t)=>{try{console.log("Form Values in budgetCreateCall:",t),console.log("Form Values after check:",t);let o=s?"".concat(s,"/budget/new"):"/budget/new",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},x=async(e,t)=>{try{console.log("Form Values in budgetUpdateCall:",t),console.log("Form Values after check:",t);let o=s?"".concat(s,"/budget/update"):"/budget/update",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},G=async(e,t)=>{try{let o=s?"".concat(s,"/invitation/new"):"/invitation/new",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},J=async(e,t)=>{try{console.log("Form Values in invitationCreateCall:",t),console.log("Form Values after check:",t);let o=s?"".concat(s,"/invitation/claim"):"/invitation/claim",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},A=async e=>{try{let t=s?"".concat(s,"/alerting/settings"):"/alerting/settings",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},U=async(e,t)=>{try{for(let e of(console.log("Form Values in keyCreateServiceAccountCall:",t),t.description&&(t.metadata||(t.metadata={}),t.metadata.description=t.description,delete t.description,t.metadata=JSON.stringify(t.metadata)),r.d))if(t[e]){console.log("formValues.".concat(e,":"),t[e]);try{t[e]=JSON.parse(t[e])}catch(t){throw Error("Failed to parse ".concat(e,": ")+t)}}console.log("Form Values after check:",t);let o=s?"".concat(s,"/key/service-account/generate"):"/key/service-account/generate",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw m(e),console.error("Error response from the server:",e),Error(e)}let n=await a.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},R=async(e,t,o)=>{try{for(let e of(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)),r.d))if(o[e]){console.log("formValues.".concat(e,":"),o[e]);try{o[e]=JSON.parse(o[e])}catch(t){throw Error("Failed to parse ".concat(e,": ")+t)}}console.log("Form Values after check:",o);let a=s?"".concat(s,"/key/generate"):"/key/generate",n=await fetch(a,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!n.ok){let e=await n.text();throw m(e),console.error("Error response from the server:",e),Error(e)}let l=await n.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},I=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.auto_create_key=!1,o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw Error("Failed to parse metadata: "+e)}}console.log("Form Values after check:",o);let a=s?"".concat(s,"/user/new"):"/user/new",r=await fetch(a,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_id:t,...o})});if(!r.ok){let e=await r.text();throw m(e),console.error("Error response from the server:",e),Error(e)}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},M=async(e,t)=>{try{let o=s?"".concat(s,"/key/delete"):"/key/delete";console.log("in keyDeleteCall:",t);let a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:[t]})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},z=async(e,t)=>{try{let o=s?"".concat(s,"/user/delete"):"/user/delete";console.log("in userDeleteCall:",t);let a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({user_ids:t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to delete user(s):",e),e}},L=async(e,t)=>{try{let o=s?"".concat(s,"/team/delete"):"/team/delete";console.log("in teamDeleteCall:",t);let a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_ids:[t]})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to delete key:",e),e}},D=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,l=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,i=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,d=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null;try{let u=s?"".concat(s,"/user/list"):"/user/list";console.log("in userListCall");let h=new URLSearchParams;if(t&&t.length>0){let e=t.join(",");h.append("user_ids",e)}o&&h.append("page",o.toString()),a&&h.append("page_size",a.toString()),r&&h.append("user_email",r),n&&h.append("role",n),l&&h.append("team",l),c&&h.append("sso_user_ids",c),i&&h.append("sort_by",i),d&&h.append("sort_order",d);let p=h.toString();p&&(u+="?".concat(p));let g=await fetch(u,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!g.ok){let e=await g.json(),t=ov(e);throw m(t),Error(t)}let w=await g.json();return console.log("/user/list API Response:",w),w}catch(e){throw console.error("Failed to create key:",e),e}},V=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4?arguments[4]:void 0,n=arguments.length>5?arguments[5]:void 0,l=arguments.length>6&&void 0!==arguments[6]&&arguments[6];console.log("userInfoCall: ".concat(t,", ").concat(o,", ").concat(a,", ").concat(r,", ").concat(n,", ").concat(l));try{let c;if(a){c=s?"".concat(s,"/user/list"):"/user/list";let e=new URLSearchParams;null!=r&&e.append("page",r.toString()),null!=n&&e.append("page_size",n.toString()),c+="?".concat(e.toString())}else c=s?"".concat(s,"/user/info"):"/user/info",("Admin"!==o&&"Admin Viewer"!==o||l)&&t&&(c+="?user_id=".concat(t));console.log("Requesting user data from:",c);let i=await fetch(c,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.json(),t=ov(e);throw m(t),Error(t)}let d=await i.json();return console.log("API Response:",d),d}catch(e){throw console.error("Failed to fetch user data:",e),e}},Z=async(e,t)=>{try{let o=s?"".concat(s,"/team/info"):"/team/info";t&&(o="".concat(o,"?team_id=").concat(t)),console.log("in teamInfoCall");let a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},q=async function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;arguments.length>5&&void 0!==arguments[5]&&arguments[5],arguments.length>6&&void 0!==arguments[6]&&arguments[6],arguments.length>7&&void 0!==arguments[7]&&arguments[7],arguments.length>8&&void 0!==arguments[8]&&arguments[8];try{let n=s?"".concat(s,"/v2/team/list"):"/v2/team/list";console.log("in teamInfoCall");let l=new URLSearchParams;o&&l.append("user_id",o.toString()),t&&l.append("organization_id",t.toString()),a&&l.append("team_id",a.toString()),r&&l.append("team_alias",r.toString());let c=l.toString();c&&(n+="?".concat(c));let i=await fetch(n,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.json(),t=ov(e);throw m(t),Error(t)}let d=await i.json();return console.log("/v2/team/list API Response:",d),d}catch(e){throw console.error("Failed to create key:",e),e}},H=async function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;try{let n=s?"".concat(s,"/team/list"):"/team/list";console.log("in teamInfoCall");let l=new URLSearchParams;o&&l.append("user_id",o.toString()),t&&l.append("organization_id",t.toString()),a&&l.append("team_id",a.toString()),r&&l.append("team_alias",r.toString());let c=l.toString();c&&(n+="?".concat(c));let i=await fetch(n,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.json(),t=ov(e);throw m(t),Error(t)}let d=await i.json();return console.log("/team/list API Response:",d),d}catch(e){throw console.error("Failed to create key:",e),e}},W=async e=>{try{let t=s?"".concat(s,"/team/available"):"/team/available";console.log("in availableTeamListCall");let o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log("/team/available_teams API Response:",a),a}catch(e){throw e}},Y=async e=>{try{let t=s?"".concat(s,"/organization/list"):"/organization/list",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},K=async(e,t)=>{try{let o=s?"".concat(s,"/organization/info"):"/organization/info";t&&(o="".concat(o,"?organization_id=").concat(t)),console.log("in teamInfoCall");let a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},$=async(e,t)=>{try{if(console.log("Form Values in organizationCreateCall:",t),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw console.error("Failed to parse metadata:",e),Error("Failed to parse metadata: "+e)}}let o=s?"".concat(s,"/organization/new"):"/organization/new",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},Q=async(e,t)=>{try{console.log("Form Values in organizationUpdateCall:",t);let o=s?"".concat(s,"/organization/update"):"/organization/update",a=await fetch(o,{method:"PATCH",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("Update Team Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},X=async(e,t)=>{try{let o=s?"".concat(s,"/organization/delete"):"/organization/delete",a=await fetch(o,{method:"DELETE",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({organization_ids:[t]})});if(!a.ok){let e=await a.text();throw m(e),Error("Error deleting organization: ".concat(e))}return await a.json()}catch(e){throw console.error("Failed to delete organization:",e),e}},ee=async(e,t)=>{try{let o=s?"".concat(s,"/utils/transform_request"):"/utils/transform_request",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},et=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;try{let r=s?"".concat(s,"/user/daily/activity"):"/user/daily/activity",n=new URLSearchParams;n.append("start_date",l(t)),n.append("end_date",l(o)),n.append("page_size","1000"),n.append("page",a.toString());let c=n.toString();c&&(r+="?".concat(c));let i=await fetch(r,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.json(),t=ov(e);throw m(t),Error(t)}return await i.json()}catch(e){throw console.error("Failed to create key:",e),e}},eo=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;try{let n=s?"".concat(s,"/tag/daily/activity"):"/tag/daily/activity",c=new URLSearchParams;c.append("start_date",l(t)),c.append("end_date",l(o)),c.append("page_size","1000"),c.append("page",a.toString()),r&&c.append("tags",r.join(","));let i=c.toString();i&&(n+="?".concat(i));let d=await fetch(n,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!d.ok){let e=await d.json(),t=ov(e);throw m(t),Error(t)}return await d.json()}catch(e){throw console.error("Failed to create key:",e),e}},ea=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;try{let n=s?"".concat(s,"/team/daily/activity"):"/team/daily/activity",c=new URLSearchParams;c.append("start_date",l(t)),c.append("end_date",l(o)),c.append("page_size","1000"),c.append("page",a.toString()),r&&c.append("team_ids",r.join(",")),c.append("exclude_team_ids","litellm-dashboard");let i=c.toString();i&&(n+="?".concat(i));let d=await fetch(n,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!d.ok){let e=await d.json(),t=ov(e);throw m(t),Error(t)}return await d.json()}catch(e){throw console.error("Failed to create key:",e),e}},er=async e=>{try{let t=s?"".concat(s,"/global/spend"):"/global/spend",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},en=async e=>{try{let t=s?"".concat(s,"/onboarding/get_token"):"/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.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},el=async(e,t,o,a)=>{let r=s?"".concat(s,"/onboarding/claim_token"):"/onboarding/claim_token";try{let n=await fetch(r,{method:"POST",headers:{[f]:"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.json(),t=ov(e);throw m(t),Error(t)}let l=await n.json();return console.log(l),l}catch(e){throw console.error("Failed to delete key:",e),e}},ec=async(e,t,o)=>{try{let a=s?"".concat(s,"/key/").concat(t,"/regenerate"):"/key/".concat(t,"/regenerate"),r=await fetch(a,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let n=await r.json();return console.log("Regenerate key Response:",n),n}catch(e){throw console.error("Failed to regenerate key:",e),e}},ei=!1,es=null,ed=async(e,t,o)=>{try{console.log("modelInfoCall:",e,t,o);let a=s?"".concat(s,"/v2/model/info"):"/v2/model/info",r=new URLSearchParams;r.append("include_team_models","true"),r.toString()&&(a+="?".concat(r.toString()));let l=await fetch(a,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.text();throw e+="error shown=".concat(ei),ei||(e.includes("No model list passed")&&(e="No Models Exist. Click Add Model to get started."),n.Z.info(e),ei=!0,es&&clearTimeout(es),es=setTimeout(()=>{ei=!1},1e4)),Error("Network response was not ok")}let c=await l.json();return console.log("modelInfoCall:",c),c}catch(e){throw console.error("Failed to create key:",e),e}},eu=async(e,t)=>{try{let o=s?"".concat(s,"/v1/model/info"):"/v1/model/info";o+="?litellm_model_id=".concat(t);let a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("modelInfoV1Call:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},eh=async()=>{let e=s?"".concat(s,"/public/model_hub"):"/public/model_hub";return(await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}})).json()},ep=async e=>{try{let t=s?"".concat(s,"/model_group/info"):"/model_group/info",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log("modelHubCall:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},eg=async e=>{try{let t=s?"".concat(s,"/get/allowed_ips"):"/get/allowed_ips",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log("getAllowedIPs:",a),a.data}catch(e){throw console.error("Failed to get allowed IPs:",e),e}},em=async(e,t)=>{try{let o=s?"".concat(s,"/add/allowed_ip"):"/add/allowed_ip",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({ip:t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("addAllowedIP:",r),r}catch(e){throw console.error("Failed to add allowed IP:",e),e}},ef=async(e,t)=>{try{let o=s?"".concat(s,"/delete/allowed_ip"):"/delete/allowed_ip",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({ip:t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("deleteAllowedIP:",r),r}catch(e){throw console.error("Failed to delete allowed IP:",e),e}},ew=async(e,t,o,a,r,n,l,c)=>{try{let t=s?"".concat(s,"/model/metrics"):"/model/metrics";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(r,"&endTime=").concat(n,"&api_key=").concat(l,"&customer=").concat(c));let o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},ey=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/model/streaming_metrics"):"/model/streaming_metrics";t&&(r="".concat(r,"?_selected_model_group=").concat(t,"&startTime=").concat(o,"&endTime=").concat(a));let n=await fetch(r,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.json(),t=ov(e);throw m(t),Error(t)}return await n.json()}catch(e){throw console.error("Failed to create key:",e),e}},ej=async(e,t,o,a,r,n,l,c)=>{try{let t=s?"".concat(s,"/model/metrics/slow_responses"):"/model/metrics/slow_responses";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(r,"&endTime=").concat(n,"&api_key=").concat(l,"&customer=").concat(c));let o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},e_=async(e,t,o,a,r,n,l,c)=>{try{let t=s?"".concat(s,"/model/metrics/exceptions"):"/model/metrics/exceptions";a&&(t="".concat(t,"?_selected_model_group=").concat(a,"&startTime=").concat(r,"&endTime=").concat(n,"&api_key=").concat(l,"&customer=").concat(c));let o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to create key:",e),e}},eC=async(e,t)=>{try{let o=s?"".concat(s,"/model_hub/update_useful_links"):"/model_hub/update_useful_links",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({useful_links:t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},ek=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,n=(arguments.length>5&&void 0!==arguments[5]&&arguments[5],arguments.length>6&&void 0!==arguments[6]&&arguments[6]);console.log("in /models calls, globalLitellmHeaderName",f);try{let t=s?"".concat(s,"/models"):"/models",o=new URLSearchParams;o.append("include_model_access_groups","True"),!0===a&&o.append("return_wildcard_routes","True"),!0===n&&o.append("only_model_access_groups","True"),r&&o.append("team_id",r.toString()),o.toString()&&(t+="?".concat(o.toString()));let l=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.json(),t=ov(e);throw m(t),Error(t)}return await l.json()}catch(e){throw console.error("Failed to create key:",e),e}},ev=async(e,t)=>{try{let o=s?"".concat(s,"/global/spend/logs"):"/global/spend/logs";console.log("in keySpendLogsCall:",o);let a=await fetch("".concat(o,"?api_key=").concat(t),{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},eT=async e=>{try{let t=s?"".concat(s,"/global/spend/teams"):"/global/spend/teams";console.log("in teamSpendLogsCall:",t);let o=await fetch("".concat(t),{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},eE=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/global/spend/tags"):"/global/spend/tags";t&&o&&(r="".concat(r,"?start_date=").concat(t,"&end_date=").concat(o)),a&&(r+="".concat(r,"&tags=").concat(a.join(","))),console.log("in tagsSpendLogsCall:",r);let n=await fetch("".concat(r),{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!n.ok){let e=await n.json(),t=ov(e);throw m(t),Error(t)}let l=await n.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},eS=async e=>{try{let t=s?"".concat(s,"/global/spend/all_tag_names"):"/global/spend/all_tag_names";console.log("in global/spend/all_tag_names call",t);let o=await fetch("".concat(t),{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},eb=async e=>{try{let t=s?"".concat(s,"/global/all_end_users"):"/global/all_end_users";console.log("in global/all_end_users call",t);let o=await fetch("".concat(t),{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},eF=async(e,t)=>{try{let o=s?"".concat(s,"/user/filter/ui"):"/user/filter/ui";t.get("user_email")&&(o+="?user_email=".concat(t.get("user_email"))),t.get("user_id")&&(o+="?user_id=".concat(t.get("user_id")));let a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to create key:",e),e}},eP=async(e,t,o,a,r,n)=>{try{console.log("user role in spend logs call: ".concat(o));let t=s?"".concat(s,"/spend/logs"):"/spend/logs";t="App Owner"==o?"".concat(t,"?user_id=").concat(a,"&start_date=").concat(r,"&end_date=").concat(n):"".concat(t,"?start_date=").concat(r,"&end_date=").concat(n);let l=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.json(),t=ov(e);throw m(t),Error(t)}let c=await l.json();return console.log(c),c}catch(e){throw console.error("Failed to create key:",e),e}},eO=async(e,t,o,a,r,n,l,c,i,d,u,h)=>{try{let p=s?"".concat(s,"/spend/logs/ui"):"/spend/logs/ui",g=new URLSearchParams;t&&g.append("api_key",t),o&&g.append("team_id",o),a&&g.append("request_id",a),r&&g.append("start_date",r),n&&g.append("end_date",n),l&&g.append("page",l.toString()),c&&g.append("page_size",c.toString()),i&&g.append("user_id",i),d&&g.append("end_user",d),u&&g.append("status_filter",u),h&&g.append("model",h);let w=g.toString();w&&(p+="?".concat(w));let y=await fetch(p,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!y.ok){let e=await y.json(),t=ov(e);throw m(t),Error(t)}let j=await y.json();return console.log("Spend Logs Response:",j),j}catch(e){throw console.error("Failed to fetch spend logs:",e),e}},eB=async e=>{try{let t=s?"".concat(s,"/global/spend/logs"):"/global/spend/logs",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},eN=async e=>{try{let t=s?"".concat(s,"/global/spend/keys?limit=5"):"/global/spend/keys?limit=5",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},ex=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/global/spend/end_users"):"/global/spend/end_users",n="";n=t?JSON.stringify({api_key:t,startTime:o,endTime:a}):JSON.stringify({startTime:o,endTime:a});let l={method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:n},c=await fetch(r,l);if(!c.ok){let e=await c.json(),t=ov(e);throw m(t),Error(t)}let i=await c.json();return console.log(i),i}catch(e){throw console.error("Failed to create key:",e),e}},eG=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/global/spend/provider"):"/global/spend/provider";o&&a&&(r+="?start_date=".concat(o,"&end_date=").concat(a)),t&&(r+="&api_key=".concat(t));let n={method:"GET",headers:{[f]:"Bearer ".concat(e)}},l=await fetch(r,n);if(!l.ok){let e=await l.json(),t=ov(e);throw m(t),Error(t)}let c=await l.json();return console.log(c),c}catch(e){throw console.error("Failed to fetch spend data:",e),e}},eJ=async(e,t,o)=>{try{let a=s?"".concat(s,"/global/activity"):"/global/activity";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o));let r={method:"GET",headers:{[f]:"Bearer ".concat(e)}},n=await fetch(a,r);if(!n.ok){let e=await n.json(),t=ov(e);throw m(t),Error(t)}let l=await n.json();return console.log(l),l}catch(e){throw console.error("Failed to fetch spend data:",e),e}},eA=async(e,t,o)=>{try{let a=s?"".concat(s,"/global/activity/cache_hits"):"/global/activity/cache_hits";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o));let r={method:"GET",headers:{[f]:"Bearer ".concat(e)}},n=await fetch(a,r);if(!n.ok){let e=await n.json(),t=ov(e);throw m(t),Error(t)}let l=await n.json();return console.log(l),l}catch(e){throw console.error("Failed to fetch spend data:",e),e}},eU=async(e,t,o)=>{try{let a=s?"".concat(s,"/global/activity/model"):"/global/activity/model";t&&o&&(a+="?start_date=".concat(t,"&end_date=").concat(o));let r={method:"GET",headers:{[f]:"Bearer ".concat(e)}},n=await fetch(a,r);if(!n.ok){let e=await n.json(),t=ov(e);throw m(t),Error(t)}let l=await n.json();return console.log(l),l}catch(e){throw console.error("Failed to fetch spend data:",e),e}},eR=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/global/activity/exceptions"):"/global/activity/exceptions";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o)),a&&(r+="&model_group=".concat(a));let n={method:"GET",headers:{[f]:"Bearer ".concat(e)}},l=await fetch(r,n);if(!l.ok){let e=await l.json(),t=ov(e);throw m(t),Error(t)}let c=await l.json();return console.log(c),c}catch(e){throw console.error("Failed to fetch spend data:",e),e}},eI=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/global/activity/exceptions/deployment"):"/global/activity/exceptions/deployment";t&&o&&(r+="?start_date=".concat(t,"&end_date=").concat(o)),a&&(r+="&model_group=".concat(a));let n={method:"GET",headers:{[f]:"Bearer ".concat(e)}},l=await fetch(r,n);if(!l.ok){let e=await l.json(),t=ov(e);throw m(t),Error(t)}let c=await l.json();return console.log(c),c}catch(e){throw console.error("Failed to fetch spend data:",e),e}},eM=async e=>{try{let t=s?"".concat(s,"/global/spend/models?limit=5"):"/global/spend/models?limit=5",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to create key:",e),e}},ez=async(e,t)=>{try{let o=s?"".concat(s,"/v2/key/info"):"/v2/key/info",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({keys:t})});if(!a.ok){let e=await a.text();if(e.includes("Invalid proxy server token passed"))throw Error("Invalid proxy server token passed");throw m(e),Error("Network response was not ok")}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},eL=async(e,t,o)=>{try{console.log("Sending model connection test request:",JSON.stringify(t));let r=s?"".concat(s,"/health/test_connection"):"/health/test_connection",n=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",[f]:"Bearer ".concat(e)},body:JSON.stringify({litellm_params:t,mode:o})}),l=n.headers.get("content-type");if(!l||!l.includes("application/json")){let e=await n.text();throw console.error("Received non-JSON response:",e),Error("Received non-JSON response (".concat(n.status,": ").concat(n.statusText,"). Check network tab for details."))}let c=await n.json();if(!n.ok||"error"===c.status){if("error"===c.status);else{var a;return{status:"error",message:(null===(a=c.error)||void 0===a?void 0:a.message)||"Connection test failed: ".concat(n.status," ").concat(n.statusText)}}}return c}catch(e){throw console.error("Model connection test error:",e),e}},eD=async(e,t)=>{try{console.log("entering keyInfoV1Call");let o=s?"".concat(s,"/key/info"):"/key/info";o="".concat(o,"?key=").concat(t);let a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(console.log("response",a),!a.ok){let e=await a.text();m(e),n.Z.fromBackend("Failed to fetch key info - "+e)}let r=await a.json();return console.log("data",r),r}catch(e){throw console.error("Failed to fetch key info:",e),e}},eV=async function(e,t,o,a,r,n,l,c){let i=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,d=arguments.length>9&&void 0!==arguments[9]?arguments[9]:null;try{let u=s?"".concat(s,"/key/list"):"/key/list";console.log("in keyListCall");let h=new URLSearchParams;o&&h.append("team_id",o.toString()),t&&h.append("organization_id",t.toString()),a&&h.append("key_alias",a),n&&h.append("key_hash",n),r&&h.append("user_id",r.toString()),l&&h.append("page",l.toString()),c&&h.append("size",c.toString()),i&&h.append("sort_by",i),d&&h.append("sort_order",d),h.append("return_full_object","true"),h.append("include_team_keys","true");let p=h.toString();p&&(u+="?".concat(p));let g=await fetch(u,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!g.ok){let e=await g.json(),t=ov(e);throw m(t),Error(t)}let w=await g.json();return console.log("/team/list API Response:",w),w}catch(e){throw console.error("Failed to create key:",e),e}},eZ=async(e,t)=>{try{let o=s?"".concat(s,"/spend/users"):"/spend/users";console.log("in spendUsersCall:",o);let a=await fetch("".concat(o,"?user_id=").concat(t),{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to get spend for user",e),e}},eq=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/user/request_model"):"/user/request_model",n=await fetch(r,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({models:[t],user_id:o,justification:a})});if(!n.ok){let e=await n.json(),t=ov(e);throw m(t),Error(t)}let l=await n.json();return console.log(l),l}catch(e){throw console.error("Failed to create key:",e),e}},eH=async e=>{try{let t=s?"".concat(s,"/user/get_requests"):"/user/get_requests";console.log("in userGetRequesedtModelsCall:",t);let o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log(a),a}catch(e){throw console.error("Failed to get requested models:",e),e}},eW=async(e,t,o)=>{try{let a=s?"".concat(s,"/user/daily/activity/aggregated"):"/user/daily/activity/aggregated",r=new URLSearchParams,n=e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)};r.append("start_date",n(t)),r.append("end_date",n(o));let l=r.toString();l&&(a+="?".concat(l));let c=await fetch(a,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.json(),t=ov(e);throw m(t),Error(t)}return await c.json()}catch(e){throw console.error("Failed to fetch aggregated user daily activity:",e),e}},eY=async(e,t)=>{try{let o=s?"".concat(s,"/user/get_users?role=").concat(t):"/user/get_users?role=".concat(t);console.log("in userGetAllUsersCall:",o);let a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to get requested models:",e),e}},eK=async e=>{try{let t=s?"".concat(s,"/user/available_roles"):"/user/available_roles",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log("response from user/available_role",a),a}catch(e){throw e}},e$=async(e,t)=>{try{if(console.log("Form Values in teamCreateCall:",t),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw Error("Failed to parse metadata: "+e)}}let o=s?"".concat(s,"/team/new"):"/team/new",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},eQ=async(e,t)=>{try{if(console.log("Form Values in credentialCreateCall:",t),t.metadata){console.log("formValues.metadata:",t.metadata);try{t.metadata=JSON.parse(t.metadata)}catch(e){throw Error("Failed to parse metadata: "+e)}}let o=s?"".concat(s,"/credentials"):"/credentials",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},eX=async e=>{try{let t=s?"".concat(s,"/credentials"):"/credentials";console.log("in credentialListCall");let o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log("/credentials API Response:",a),a}catch(e){throw console.error("Failed to create key:",e),e}},e0=async(e,t,o)=>{try{let a=s?"".concat(s,"/credentials"):"/credentials";t?a+="/by_name/".concat(t):o&&(a+="/by_model/".concat(o)),console.log("in credentialListCall");let r=await fetch(a,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let n=await r.json();return console.log("/credentials API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},e1=async(e,t)=>{try{let o=s?"".concat(s,"/credentials/").concat(t):"/credentials/".concat(t);console.log("in credentialDeleteCall:",t);let a=await fetch(o,{method:"DELETE",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to delete key:",e),e}},e2=async(e,t,o)=>{try{if(console.log("Form Values in credentialUpdateCall:",o),o.metadata){console.log("formValues.metadata:",o.metadata);try{o.metadata=JSON.parse(o.metadata)}catch(e){throw Error("Failed to parse metadata: "+e)}}let a=s?"".concat(s,"/credentials/").concat(t):"/credentials/".concat(t),r=await fetch(a,{method:"PATCH",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...o})});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},e4=async(e,t)=>{try{if(console.log("Form Values in keyUpdateCall:",t),t.model_tpm_limit){console.log("formValues.model_tpm_limit:",t.model_tpm_limit);try{t.model_tpm_limit=JSON.parse(t.model_tpm_limit)}catch(e){throw Error("Failed to parse model_tpm_limit: "+e)}}if(t.model_rpm_limit){console.log("formValues.model_rpm_limit:",t.model_rpm_limit);try{t.model_rpm_limit=JSON.parse(t.model_rpm_limit)}catch(e){throw Error("Failed to parse model_rpm_limit: "+e)}}let o=s?"".concat(s,"/key/update"):"/key/update",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw m(e),console.error("Error response from the server:",e),Error(e)}let r=await a.json();return console.log("Update key Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},e3=async(e,t)=>{try{console.log("Form Values in teamUpateCall:",t);let o=s?"".concat(s,"/team/update"):"/team/update",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw m(e),console.error("Error response from the server:",e),n.Z.fromBackend("Failed to update team settings: "+e),Error(e)}let r=await a.json();return console.log("Update Team Response:",r),r}catch(e){throw console.error("Failed to update team:",e),e}},e5=async(e,t,o)=>{try{console.log("Form Values in modelUpateCall:",t);let a=s?"".concat(s,"/model/").concat(o,"/update"):"/model/".concat(o,"/update"),r=await fetch(a,{method:"PATCH",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!r.ok){let e=await r.text();throw m(e),console.error("Error update from the server:",e),Error("Network response was not ok")}let n=await r.json();return console.log("Update model Response:",n),n}catch(e){throw console.error("Failed to update model:",e),e}},e6=async(e,t)=>{try{console.log("Form Values in modelUpateCall:",t);let o=s?"".concat(s,"/model/update"):"/model/update",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.text();throw m(e),console.error("Error update from the server:",e),Error("Network response was not ok")}let r=await a.json();return console.log("Update model Response:",r),r}catch(e){throw console.error("Failed to update model:",e),e}},e7=async(e,t,o)=>{try{console.log("Form Values in teamMemberAddCall:",o);let r=s?"".concat(s,"/team/member_add"):"/team/member_add",n=await fetch(r,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,member:o})});if(!n.ok){var a;let e=await n.text(),t={};try{t=JSON.parse(e)}catch(t){console.warn("Failed to parse error body as JSON:",e)}let o=(null==t?void 0:null===(a=t.detail)||void 0===a?void 0:a.error)||"Failed to add team member",r=Error(o);throw r.raw=t,r}let l=await n.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},e9=async(e,t,o,a,r)=>{try{console.log("Bulk add team members:",{teamId:t,members:o,maxBudgetInTeam:a});let l=s?"".concat(s,"/team/bulk_member_add"):"/team/bulk_member_add",c={team_id:t};r?c.all_users=!0:c.members=o,null!=a&&(c.max_budget_in_team=a);let i=await fetch(l,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(c)});if(!i.ok){var n;let e=await i.text(),t={};try{t=JSON.parse(e)}catch(t){console.warn("Failed to parse error body as JSON:",e)}let o=(null==t?void 0:null===(n=t.detail)||void 0===n?void 0:n.error)||"Failed to bulk add team members",a=Error(o);throw a.raw=t,a}let d=await i.json();return console.log("Bulk team member add API Response:",d),d}catch(e){throw console.error("Failed to bulk add team members:",e),e}},e8=async(e,t,o)=>{try{console.log("Form Values in teamMemberUpdateCall:",o),console.log("Budget value:",o.max_budget_in_team),console.log("TPM limit:",o.tpm_limit),console.log("RPM limit:",o.rpm_limit);let r=s?"".concat(s,"/team/member_update"):"/team/member_update",n={team_id:t,role:o.role,user_id:o.user_id};void 0!==o.user_email&&(n.user_email=o.user_email),void 0!==o.max_budget_in_team&&null!==o.max_budget_in_team&&(n.max_budget_in_team=o.max_budget_in_team),void 0!==o.tpm_limit&&null!==o.tpm_limit&&(n.tpm_limit=o.tpm_limit),void 0!==o.rpm_limit&&null!==o.rpm_limit&&(n.rpm_limit=o.rpm_limit),console.log("Final request body:",n);let l=await fetch(r,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok){var a;let e=await l.text(),t={};try{t=JSON.parse(e)}catch(t){console.warn("Failed to parse error body as JSON:",e)}let o=(null==t?void 0:null===(a=t.detail)||void 0===a?void 0:a.error)||"Failed to add team member",r=Error(o);throw r.raw=t,r}let c=await l.json();return console.log("API Response:",c),c}catch(e){throw console.error("Failed to update team member:",e),e}},te=async(e,t,o)=>{try{console.log("Form Values in teamMemberAddCall:",o);let a=s?"".concat(s,"/team/member_delete"):"/team/member_delete",r=await fetch(a,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({team_id:t,...void 0!==o.user_email&&{user_email:o.user_email},...void 0!==o.user_id&&{user_id:o.user_id}})});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create key:",e),e}},tt=async(e,t,o)=>{try{console.log("Form Values in teamMemberAddCall:",o);let a=s?"".concat(s,"/organization/member_add"):"/organization/member_add",r=await fetch(a,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({organization_id:t,member:o})});if(!r.ok){let e=await r.text();throw m(e),console.error("Error response from the server:",e),Error(e)}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to create organization member:",e),e}},to=async(e,t,o)=>{try{console.log("Form Values in organizationMemberDeleteCall:",o);let a=s?"".concat(s,"/organization/member_delete"):"/organization/member_delete",r=await fetch(a,{method:"DELETE",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({organization_id:t,user_id:o})});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to delete organization member:",e),e}},ta=async(e,t,o)=>{try{console.log("Form Values in organizationMemberUpdateCall:",o);let a=s?"".concat(s,"/organization/member_update"):"/organization/member_update",r=await fetch(a,{method:"PATCH",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({organization_id:t,...o})});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let n=await r.json();return console.log("API Response:",n),n}catch(e){throw console.error("Failed to update organization member:",e),e}},tr=async(e,t,o)=>{try{console.log("Form Values in userUpdateUserCall:",t);let a=s?"".concat(s,"/user/update"):"/user/update",r={...t};null!==o&&(r.user_role=o),r=JSON.stringify(r);let n=await fetch(a,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:r});if(!n.ok){let e=await n.json(),t=ov(e);throw m(t),Error(t)}let l=await n.json();return console.log("API Response:",l),l}catch(e){throw console.error("Failed to create key:",e),e}},tn=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{let r;console.log("Form Values in userUpdateUserCall:",t);let n=s?"".concat(s,"/user/bulk_update"):"/user/bulk_update";if(a)r=JSON.stringify({all_users:!0,user_updates:t});else if(o&&o.length>0){let e=[];for(let a of o)e.push({user_id:a,...t});r=JSON.stringify({users:e})}else throw Error("Must provide either userIds or set allUsers=true");let l=await fetch(n,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:r});if(!l.ok){let e=await l.json(),t=ov(e);throw m(t),Error(t)}let c=await l.json();return console.log("API Response:",c),c}catch(e){throw console.error("Failed to create key:",e),e}},tl=async(e,t)=>{try{let o=s?"".concat(s,"/global/predict/spend/logs"):"/global/predict/spend/logs",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({data:t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log(r),r}catch(e){throw console.error("Failed to create key:",e),e}},tc=async e=>{try{let t=s?"".concat(s,"/health/services?service=slack_budget_alerts"):"/health/services?service=slack_budget_alerts";console.log("Checking Slack Budget Alerts service health");let o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw m(e),Error(e)}let a=await o.json();return n.Z.success("Test Slack Alert worked - check your Slack!"),console.log("Service Health Response:",a),a}catch(e){throw console.error("Failed to perform health check:",e),e}},ti=async(e,t)=>{try{let o=s?"".concat(s,"/health/services?service=").concat(t):"/health/services?service=".concat(t);console.log("Checking Slack Budget Alerts service health");let a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw m(e),Error(e)}return await a.json()}catch(e){throw console.error("Failed to perform health check:",e),e}},ts=async e=>{try{let t=s?"".concat(s,"/budget/list"):"/budget/list",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},td=async e=>{try{let t=s?"".concat(s,"/budget/settings"):"/budget/settings",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},tu=async(e,t,o)=>{try{let t=s?"".concat(s,"/get/config/callbacks"):"/get/config/callbacks",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},th=async e=>{try{let t=s?"".concat(s,"/config/list?config_type=general_settings"):"/config/list?config_type=general_settings",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},tp=async e=>{try{let t=s?"".concat(s,"/config/pass_through_endpoint"):"/config/pass_through_endpoint",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},tg=async(e,t)=>{try{let o=s?"".concat(s,"/config/field/info?field_name=").concat(t):"/config/field/info?field_name=".concat(t),a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},tm=async(e,t,o)=>{try{let a=s?"".concat(s,"/config/pass_through_endpoint"):"/config/pass_through_endpoint",r=await fetch(a,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,field_value:o})});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let l=await r.json();return n.Z.success("Successfully updated value!"),l}catch(e){throw console.error("Failed to set callbacks:",e),e}},tf=async(e,t)=>{try{let o=s?"".concat(s,"/config/pass_through_endpoint"):"/config/pass_through_endpoint",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},tw=async(e,t,o)=>{try{let a=s?"".concat(s,"/config/field/update"):"/config/field/update",r=await fetch(a,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,field_value:o,config_type:"general_settings"})});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let l=await r.json();return n.Z.success("Successfully updated value!"),l}catch(e){throw console.error("Failed to set callbacks:",e),e}},ty=async(e,t)=>{try{let o=s?"".concat(s,"/config/field/delete"):"/config/field/delete",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({field_name:t,config_type:"general_settings"})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return n.Z.success("Field reset on proxy"),r}catch(e){throw console.error("Failed to get callbacks:",e),e}},tj=async(e,t)=>{try{let o=s?"".concat(s,"/config/pass_through_endpoint?endpoint_id=").concat(t):"/config/pass_through_endpoint?endpoint_id=".concat(t),a=await fetch(o,{method:"DELETE",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},t_=async(e,t)=>{try{let o=s?"".concat(s,"/config/update"):"/config/update",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to set callbacks:",e),e}},tC=async e=>{try{let t=s?"".concat(s,"/health"):"/health",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to call /health:",e),e}},tk=async(e,t)=>{try{let o=s?"".concat(s,"/health?model=").concat(encodeURIComponent(t)):"/health?model=".concat(encodeURIComponent(t)),a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to call /health for model ".concat(t,":"),e),e}},tv=async e=>{try{let t=s?"".concat(s,"/cache/ping"):"/cache/ping",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw m(e),Error(e)}return await o.json()}catch(e){throw console.error("Failed to call /cache/ping:",e),e}},tT=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;try{let n=s?"".concat(s,"/health/history"):"/health/history",l=new URLSearchParams;t&&l.append("model",t),o&&l.append("status_filter",o),l.append("limit",a.toString()),l.append("offset",r.toString()),l.toString()&&(n+="?".concat(l.toString()));let c=await fetch(n,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.text();throw m(e),Error(e)}return await c.json()}catch(e){throw console.error("Failed to call /health/history:",e),e}},tE=async e=>{try{let t=s?"".concat(s,"/health/latest"):"/health/latest",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw m(e),Error(e)}return await o.json()}catch(e){throw console.error("Failed to call /health/latest:",e),e}},tS=async e=>{try{console.log("Getting proxy UI settings"),console.log("proxyBaseUrl in getProxyUISettings:",s);let t=s?"".concat(s,"/sso/get/ui_settings"):"/sso/get/ui_settings",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to get callbacks:",e),e}},tb=async e=>{try{let t=s?"".concat(s,"/v2/guardrails/list"):"/v2/guardrails/list",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to get guardrails list:",e),e}},tF=async e=>{try{let t=s?"".concat(s,"/prompts/list"):"/prompts/list",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to get prompts list:",e),e}},tP=async(e,t)=>{try{let o=s?"".concat(s,"/prompts/").concat(t,"/info"):"/prompts/".concat(t,"/info"),a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to get prompt info:",e),e}},tO=async(e,t)=>{try{let o=s?"".concat(s,"/prompts"):"/prompts",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to create prompt:",e),e}},tB=async(e,t,o)=>{try{let a=s?"".concat(s,"/prompts/").concat(t):"/prompts/".concat(t),r=await fetch(a,{method:"PUT",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}return await r.json()}catch(e){throw console.error("Failed to update prompt:",e),e}},tN=async(e,t)=>{try{let o=s?"".concat(s,"/prompts/").concat(t):"/prompts/".concat(t),a=await fetch(o,{method:"DELETE",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to delete prompt:",e),e}},tx=async(e,t)=>{try{let o=new FormData;o.append("file",t);let a=s?"".concat(s,"/utils/dotprompt_json_converter"):"/utils/dotprompt_json_converter",r=await fetch(a,{method:"POST",headers:{[f]:"Bearer ".concat(e)},body:o});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}return await r.json()}catch(e){throw console.error("Failed to convert prompt file:",e),e}},tG=async(e,t,o)=>{try{let a=s?"".concat(s,"/prompts/").concat(t):"/prompts/".concat(t),r=await fetch(a,{method:"PATCH",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}return await r.json()}catch(e){throw console.error("Failed to patch prompt:",e),e}},tJ=async(e,t)=>{try{let o=s?"".concat(s,"/guardrails"):"/guardrails",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({guardrail:t})});if(!a.ok){let e=await a.text();throw m(e),Error(e)}let r=await a.json();return console.log("Create guardrail response:",r),r}catch(e){throw console.error("Failed to create guardrail:",e),e}},tA=async(e,t,o)=>{try{let a=s?"".concat(s,"/spend/logs/ui/").concat(t,"?start_date=").concat(encodeURIComponent(o)):"/spend/logs/ui/".concat(t,"?start_date=").concat(encodeURIComponent(o));console.log("Fetching log details from:",a);let r=await fetch(a,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let n=await r.json();return console.log("Fetched log details:",n),n}catch(e){throw console.error("Failed to fetch log details:",e),e}},tU=async e=>{try{let t=s?"".concat(s,"/get/internal_user_settings"):"/get/internal_user_settings";console.log("Fetching SSO settings from:",t);let o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log("Fetched SSO settings:",a),a}catch(e){throw console.error("Failed to fetch SSO settings:",e),e}},tR=async(e,t)=>{try{let o=s?"".concat(s,"/update/internal_user_settings"):"/update/internal_user_settings";console.log("Updating internal user settings:",t);let a=await fetch(o,{method:"PATCH",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.text();throw m(e),Error(e)}let r=await a.json();return console.log("Updated internal user settings:",r),n.Z.success("Internal user settings updated successfully"),r}catch(e){throw console.error("Failed to update internal user settings:",e),e}},tI=async e=>{try{let t=s?"".concat(s,"/v1/mcp/server"):"/v1/mcp/server";console.log("Fetching MCP servers from:",t);let o=await fetch(t,{method:h.GET,headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log("Fetched MCP servers:",a),a}catch(e){throw console.error("Failed to fetch MCP servers:",e),e}},tM=async e=>{try{let t=s?"".concat(s,"/v1/mcp/access_groups"):"/v1/mcp/access_groups";console.log("Fetching MCP access groups from:",t);let o=await fetch(t,{method:h.GET,headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log("Fetched MCP access groups:",a),a.access_groups||[]}catch(e){throw console.error("Failed to fetch MCP access groups:",e),e}},tz=async(e,t)=>{try{console.log("Form Values in createMCPServer:",t);let o=s?"".concat(s,"/v1/mcp/server"):"/v1/mcp/server",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({...t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("API Response:",r),r}catch(e){throw console.error("Failed to create key:",e),e}},tL=async(e,t)=>{try{let o=s?"".concat(s,"/v1/mcp/server"):"/v1/mcp/server",a=await fetch(o,{method:"PUT",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to update MCP server:",e),e}},tD=async(e,t)=>{try{let o=(s?"".concat(s):"")+"/v1/mcp/server/".concat(t);console.log("in deleteMCPServer:",t);let a=await fetch(o,{method:h.DELETE,headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}}catch(e){throw console.error("Failed to delete key:",e),e}},tV=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/mcp-rest/tools/list?server_id=").concat(t):"/mcp-rest/tools/list?server_id=".concat(t);console.log("Fetching MCP tools from:",r);let n={[f]:"Bearer ".concat(e),"Content-Type":"application/json"};a&&o?n["x-mcp-".concat(a,"-authorization")]=o:o&&(n[w]=o);let l=await fetch(r,{method:"GET",headers:n}),c=await l.json();if(console.log("Fetched MCP tools response:",c),!l.ok){if(c.error&&c.message)throw Error(c.message);throw Error("Failed to fetch MCP tools")}return c}catch(e){return console.error("Failed to fetch MCP tools:",e),{tools:[],error:"network_error",message:e instanceof Error?e.message:"Failed to fetch MCP tools"}}},tZ=async(e,t,o,a,r)=>{try{let n=s?"".concat(s,"/mcp-rest/tools/call"):"/mcp-rest/tools/call";console.log("Calling MCP tool:",t,"with arguments:",o);let l={[f]:"Bearer ".concat(e),"Content-Type":"application/json"};r?l["x-mcp-".concat(r,"-authorization")]=a:l[w]=a;let c=await fetch(n,{method:"POST",headers:l,body:JSON.stringify({name:t,arguments:o})});if(!c.ok){let e="Network response was not ok",t=null,o=await c.text();try{let a=JSON.parse(o);a.detail?"string"==typeof a.detail?e=a.detail:"object"==typeof a.detail&&(e=a.detail.message||a.detail.error||"An error occurred",t=a.detail):e=a.message||a.error||e}catch(t){console.error("Failed to parse JSON error response:",t),o&&(e=o)}let a=Error(e);throw a.status=c.status,a.statusText=c.statusText,a.details=t,m(e),a}let i=await c.json();return console.log("MCP tool call response:",i),i}catch(e){throw console.error("Failed to call MCP tool:",e),console.error("Error type:",typeof e),e instanceof Error&&(console.error("Error message:",e.message),console.error("Error stack:",e.stack)),e}},tq=async(e,t)=>{try{let o=s?"".concat(s,"/tag/new"):"/tag/new",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify(t)});if(!a.ok){let e=await a.text();await m(e);return}return await a.json()}catch(e){throw console.error("Error creating tag:",e),e}},tH=async(e,t)=>{try{let o=s?"".concat(s,"/tag/update"):"/tag/update",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify(t)});if(!a.ok){let e=await a.text();await m(e);return}return await a.json()}catch(e){throw console.error("Error updating tag:",e),e}},tW=async(e,t)=>{try{let o=s?"".concat(s,"/tag/info"):"/tag/info",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({names:t})});if(!a.ok){let e=await a.text();return await m(e),{}}return await a.json()}catch(e){throw console.error("Error getting tag info:",e),e}},tY=async e=>{try{let t=s?"".concat(s,"/tag/list"):"/tag/list",o=await fetch(t,{method:"GET",headers:{Authorization:"Bearer ".concat(e)}});if(!o.ok){let e=await o.text();return await m(e),{}}return await o.json()}catch(e){throw console.error("Error listing tags:",e),e}},tK=async(e,t)=>{try{let o=s?"".concat(s,"/tag/delete"):"/tag/delete",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({name:t})});if(!a.ok){let e=await a.text();await m(e);return}return await a.json()}catch(e){throw console.error("Error deleting tag:",e),e}},t$=async e=>{try{let t=s?"".concat(s,"/get/default_team_settings"):"/get/default_team_settings";console.log("Fetching default team settings from:",t);let o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log("Fetched default team settings:",a),a}catch(e){throw console.error("Failed to fetch default team settings:",e),e}},tQ=async(e,t)=>{try{let o=s?"".concat(s,"/update/default_team_settings"):"/update/default_team_settings";console.log("Updating default team settings:",t);let a=await fetch(o,{method:"PATCH",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("Updated default team settings:",r),n.Z.success("Default team settings updated successfully"),r}catch(e){throw console.error("Failed to update default team settings:",e),e}},tX=async(e,t)=>{try{let o=s?"".concat(s,"/team/permissions_list?team_id=").concat(t):"/team/permissions_list?team_id=".concat(t),a=await fetch(o,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("Team permissions response:",r),r}catch(e){throw console.error("Failed to get team permissions:",e),e}},t0=async(e,t,o)=>{try{let a=s?"".concat(s,"/team/permissions_update"):"/team/permissions_update",r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({team_id:t,team_member_permissions:o})});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let n=await r.json();return console.log("Team permissions response:",n),n}catch(e){throw console.error("Failed to update team permissions:",e),e}},t1=async(e,t)=>{try{let o=s?"".concat(s,"/spend/logs/session/ui?session_id=").concat(encodeURIComponent(t)):"/spend/logs/session/ui?session_id=".concat(encodeURIComponent(t)),a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to fetch session logs:",e),e}},t2=async(e,t)=>{try{let o=s?"".concat(s,"/vector_store/new"):"/vector_store/new",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify(t)});if(!a.ok){let e=await a.json();throw Error(e.detail||"Failed to create vector store")}return await a.json()}catch(e){throw console.error("Error creating vector store:",e),e}},t4=async function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{let t=s?"".concat(s,"/vector_store/list"):"/vector_store/list",o=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)}});if(!o.ok){let e=await o.json();throw Error(e.detail||"Failed to list vector stores")}return await o.json()}catch(e){throw console.error("Error listing vector stores:",e),e}},t3=async(e,t)=>{try{let o=s?"".concat(s,"/vector_store/delete"):"/vector_store/delete",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({vector_store_id:t})});if(!a.ok){let e=await a.json();throw Error(e.detail||"Failed to delete vector store")}return await a.json()}catch(e){throw console.error("Error deleting vector store:",e),e}},t5=async(e,t)=>{try{let o=s?"".concat(s,"/vector_store/info"):"/vector_store/info",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({vector_store_id:t})});if(!a.ok){let e=await a.json();throw Error(e.detail||"Failed to get vector store info")}return await a.json()}catch(e){throw console.error("Error getting vector store info:",e),e}},t6=async(e,t)=>{try{let o=s?"".concat(s,"/vector_store/update"):"/vector_store/update",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify(t)});if(!a.ok){let e=await a.json();throw Error(e.detail||"Failed to update vector store")}return await a.json()}catch(e){throw console.error("Error updating vector store:",e),e}},t7=async e=>{try{let t=s?"".concat(s,"/email/event_settings"):"/email/event_settings",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw m(e),Error("Failed to get email event settings")}let a=await o.json();return console.log("Email event settings response:",a),a}catch(e){throw console.error("Failed to get email event settings:",e),e}},t9=async(e,t)=>{try{let o=s?"".concat(s,"/email/event_settings"):"/email/event_settings",a=await fetch(o,{method:"PATCH",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.text();throw m(e),Error("Failed to update email event settings")}let r=await a.json();return console.log("Update email event settings response:",r),r}catch(e){throw console.error("Failed to update email event settings:",e),e}},t8=async e=>{try{let t=s?"".concat(s,"/email/event_settings/reset"):"/email/event_settings/reset",o=await fetch(t,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw m(e),Error("Failed to reset email event settings")}let a=await o.json();return console.log("Reset email event settings response:",a),a}catch(e){throw console.error("Failed to reset email event settings:",e),e}},oe=async(e,t)=>{try{let o=s?"".concat(s,"/guardrails/").concat(t):"/guardrails/".concat(t),a=await fetch(o,{method:"DELETE",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw m(e),Error(e)}let r=await a.json();return console.log("Delete guardrail response:",r),r}catch(e){throw console.error("Failed to delete guardrail:",e),e}},ot=async e=>{try{let t=s?"".concat(s,"/guardrails/ui/add_guardrail_settings"):"/guardrails/ui/add_guardrail_settings",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw m(e),Error("Failed to get guardrail UI settings")}let a=await o.json();return console.log("Guardrail UI settings response:",a),a}catch(e){throw console.error("Failed to get guardrail UI settings:",e),e}},oo=async e=>{try{let t=s?"".concat(s,"/guardrails/ui/provider_specific_params"):"/guardrails/ui/provider_specific_params",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.text();throw m(e),Error("Failed to get guardrail provider specific parameters")}let a=await o.json();return console.log("Guardrail provider specific params response:",a),a}catch(e){throw console.error("Failed to get guardrail provider specific parameters:",e),e}},oa=async(e,t)=>{try{let o=s?"".concat(s,"/guardrails/").concat(t,"/info"):"/guardrails/".concat(t,"/info"),a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.text();throw m(e),Error("Failed to get guardrail info")}let r=await a.json();return console.log("Guardrail info response:",r),r}catch(e){throw console.error("Failed to get guardrail info:",e),e}},or=async(e,t,o)=>{try{let a=s?"".concat(s,"/guardrails/").concat(t):"/guardrails/".concat(t),r=await fetch(a,{method:"PATCH",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){let e=await r.text();throw m(e),Error("Failed to update guardrail")}let n=await r.json();return console.log("Update guardrail response:",n),n}catch(e){throw console.error("Failed to update guardrail:",e),e}},on=async e=>{try{let t=s?"".concat(s,"/get/sso_settings"):"/get/sso_settings";console.log("Fetching SSO configuration from:",t);let o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}let a=await o.json();return console.log("Fetched SSO configuration:",a),a}catch(e){throw console.error("Failed to fetch SSO configuration:",e),e}},ol=async(e,t)=>{try{let o=s?"".concat(s,"/update/sso_settings"):"/update/sso_settings";console.log("Updating SSO configuration:",t);let a=await fetch(o,{method:"PATCH",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=await a.json();return console.log("Updated SSO configuration:",r),r}catch(e){throw console.error("Failed to update SSO configuration:",e),e}},oc=async(e,t,o,a,r)=>{try{let t=s?"".concat(s,"/audit"):"/audit",o=new URLSearchParams;a&&o.append("page",a.toString()),r&&o.append("page_size",r.toString());let n=o.toString();n&&(t+="?".concat(n));let l=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!l.ok){let e=await l.json(),t=ov(e);throw m(t),Error(t)}return await l.json()}catch(e){throw console.error("Failed to fetch audit logs:",e),e}},oi=async e=>{try{let t=s?"".concat(s,"/user/available_users"):"/user/available_users",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e)}});if(!o.ok){if(404===o.status)return null;let e=await o.text();throw m(e),Error("Network response was not ok")}return await o.json()}catch(e){throw console.error("Failed to fetch remaining users:",e),e}},os=async(e,t,o)=>{try{let a=s?"".concat(s,"/config/pass_through_endpoint/").concat(encodeURIComponent(t)):"/config/pass_through_endpoint/".concat(encodeURIComponent(t)),r=await fetch(a,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok){let e=await r.json(),t=ov(e);throw m(t),Error(t)}let l=await r.json();return n.Z.success("Pass through endpoint updated successfully"),l}catch(e){throw console.error("Failed to update pass through endpoint:",e),e}},od=async(e,t)=>{try{let o=s?"".concat(s,"/config/pass_through_endpoint?endpoint_id=").concat(encodeURIComponent(t)):"/config/pass_through_endpoint?endpoint_id=".concat(encodeURIComponent(t)),a=await fetch(o,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}let r=(await a.json()).endpoints;if(!r||0===r.length)throw Error("Pass through endpoint not found");return r[0]}catch(e){throw console.error("Failed to get pass through endpoint info:",e),e}},ou=async(e,t)=>{try{let o=s?"".concat(s,"/config/callback/delete"):"/config/callback/delete",a=await fetch(o,{method:"POST",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({callback_name:t})});if(!a.ok){let e=await a.json(),t=ov(e);throw m(t),Error(t)}return await a.json()}catch(e){throw console.error("Failed to delete specific callback:",e),e}},oh=async e=>{let t=u(),o=await fetch("".concat(t,"/v1/mcp/tools"),{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok)throw Error("HTTP error! status: ".concat(o.status));return await o.json()},op=async(e,t)=>{try{console.log("Testing MCP connection with config:",JSON.stringify(t));let a=s?"".concat(s,"/mcp-rest/test/connection"):"/mcp-rest/test/connection",r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",[f]:"Bearer ".concat(e)},body:JSON.stringify(t)}),n=r.headers.get("content-type");if(!n||!n.includes("application/json")){let e=await r.text();throw console.error("Received non-JSON response:",e),Error("Received non-JSON response (".concat(r.status,": ").concat(r.statusText,"). Check network tab for details."))}let l=await r.json();if(!r.ok||"error"===l.status){if("error"===l.status);else{var o;return{status:"error",message:(null===(o=l.error)||void 0===o?void 0:o.message)||"MCP connection test failed: ".concat(r.status," ").concat(r.statusText)}}}return l}catch(e){throw console.error("MCP connection test error:",e),e}},og=async(e,t)=>{try{console.log("Testing MCP tools list with config:",JSON.stringify(t));let o=s?"".concat(s,"/mcp-rest/test/tools/list"):"/mcp-rest/test/tools/list",a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",[f]:"Bearer ".concat(e)},body:JSON.stringify(t)}),r=a.headers.get("content-type");if(!r||!r.includes("application/json")){let e=await a.text();throw console.error("Received non-JSON response:",e),Error("Received non-JSON response (".concat(a.status,": ").concat(a.statusText,"). Check network tab for details."))}let n=await a.json();if((!a.ok||n.error)&&!n.error)return{tools:[],error:"request_failed",message:n.message||"MCP tools list failed: ".concat(a.status," ").concat(a.statusText)};return n}catch(e){throw console.error("MCP tools list test error:",e),e}},om=async(e,t,o)=>{try{let a="".concat(u(),"/v1/vector_stores/").concat(t,"/search"),r=await fetch(a,{method:"POST",headers:{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"},body:JSON.stringify({query:o})});if(!r.ok){let e=await r.text();return await m(e),null}return await r.json()}catch(e){throw console.error("Error testing vector store search:",e),e}},of=async function(e,t,o){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:50,n=arguments.length>5?arguments[5]:void 0;try{let l=s?"".concat(s,"/tag/user-agent/analytics"):"/tag/user-agent/analytics",c=new URLSearchParams,i=e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)};c.append("start_date",i(t)),c.append("end_date",i(o)),c.append("page",a.toString()),c.append("page_size",r.toString()),n&&c.append("user_agent_filter",n);let d=c.toString();d&&(l+="?".concat(d));let u=await fetch(l,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!u.ok){let e=await u.json(),t=ov(e);throw m(t),Error(t)}return await u.json()}catch(e){throw console.error("Failed to fetch user agent analytics:",e),e}},ow=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/tag/dau"):"/tag/dau",n=new URLSearchParams;n.append("end_date",(e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)})(t)),a&&a.length>0?a.forEach(e=>{n.append("tag_filters",e)}):o&&n.append("tag_filter",o);let l=n.toString();l&&(r+="?".concat(l));let c=await fetch(r,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.json(),t=ov(e);throw m(t),Error(t)}return await c.json()}catch(e){throw console.error("Failed to fetch DAU:",e),e}},oy=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/tag/wau"):"/tag/wau",n=new URLSearchParams;n.append("end_date",(e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)})(t)),a&&a.length>0?a.forEach(e=>{n.append("tag_filters",e)}):o&&n.append("tag_filter",o);let l=n.toString();l&&(r+="?".concat(l));let c=await fetch(r,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.json(),t=ov(e);throw m(t),Error(t)}return await c.json()}catch(e){throw console.error("Failed to fetch WAU:",e),e}},oj=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/tag/mau"):"/tag/mau",n=new URLSearchParams;n.append("end_date",(e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)})(t)),a&&a.length>0?a.forEach(e=>{n.append("tag_filters",e)}):o&&n.append("tag_filter",o);let l=n.toString();l&&(r+="?".concat(l));let c=await fetch(r,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.json(),t=ov(e);throw m(t),Error(t)}return await c.json()}catch(e){throw console.error("Failed to fetch MAU:",e),e}},o_=async e=>{try{let t=s?"".concat(s,"/tag/distinct"):"/tag/distinct",o=await fetch(t,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=ov(e);throw m(t),Error(t)}return await o.json()}catch(e){throw console.error("Failed to fetch distinct tags:",e),e}},oC=async(e,t,o,a)=>{try{let r=s?"".concat(s,"/tag/summary"):"/tag/summary",n=new URLSearchParams,l=e=>{let t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(o,"-").concat(a)};n.append("start_date",l(t)),n.append("end_date",l(o)),a&&a.length>0&&a.forEach(e=>{n.append("tag_filters",e)});let c=n.toString();c&&(r+="?".concat(c));let i=await fetch(r,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!i.ok){let e=await i.json(),t=ov(e);throw m(t),Error(t)}return await i.json()}catch(e){throw console.error("Failed to fetch user agent summary:",e),e}},ok=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:50,a=arguments.length>3?arguments[3]:void 0;try{let r=s?"".concat(s,"/tag/user-agent/per-user-analytics"):"/tag/user-agent/per-user-analytics",n=new URLSearchParams;n.append("page",t.toString()),n.append("page_size",o.toString()),a&&a.length>0&&a.forEach(e=>{n.append("tag_filters",e)});let l=n.toString();l&&(r+="?".concat(l));let c=await fetch(r,{method:"GET",headers:{[f]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!c.ok){let e=await c.json(),t=ov(e);throw m(t),Error(t)}return await c.json()}catch(e){throw console.error("Failed to fetch per-user analytics:",e),e}},ov=e=>(null==e?void 0:e.error)&&(e.error.message||e.error)||(null==e?void 0:e.message)||(null==e?void 0:e.detail)||(null==e?void 0:e.error)||JSON.stringify(e)},85968:function(e,t,o){o.d(t,{O:function(){return a}});let a=e=>{if(!e)return"An unknown error occurred";if("string"==typeof e)return e;if(e.message)try{let t=JSON.parse(e.message);if(t.error&&t.error.message)return t.error.message;return"string"==typeof t?t:JSON.stringify(t,null,2)}catch(t){return e.message}if(e.response&&e.response.data){if("string"==typeof e.response.data)return e.response.data;if(e.response.data.message)return e.response.data.message;if(e.response.data.error)return"string"==typeof e.response.data.error?e.response.data.error:e.response.data.error.message||JSON.stringify(e.response.data.error)}return String(e)}},3914:function(e,t,o){function a(){let e=window.location.hostname,t=["Lax","Strict","None"];["/","/ui"].forEach(o=>{document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=".concat(o,";"),document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=".concat(o,"; domain=").concat(e,";"),t.forEach(t=>{let a="None"===t?" Secure;":"";document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=".concat(o,"; SameSite=").concat(t,";").concat(a),document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=".concat(o,"; domain=").concat(e,"; SameSite=").concat(t,";").concat(a)})}),console.log("After clearing cookies:",document.cookie)}function r(e){let t=document.cookie.split("; ").find(t=>t.startsWith(e+"="));return t?t.split("=")[1]:null}o.d(t,{b:function(){return a},e:function(){return r}})}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/162-76acc071cdf524f9.js b/litellm/proxy/_experimental/out/_next/static/chunks/162-76acc071cdf524f9.js new file mode 100644 index 00000000000..dd149327dfa --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/162-76acc071cdf524f9.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[162],{36724:function(e,t,n){n.d(t,{Dx:function(){return i.Z},Zb:function(){return s.Z},xv:function(){return r.Z},zx:function(){return a.Z}});var a=n(20831),s=n(12514),r=n(84264),i=n(96761)},19130:function(e,t,n){n.d(t,{RM:function(){return s.Z},SC:function(){return l.Z},iA:function(){return a.Z},pj:function(){return r.Z},ss:function(){return i.Z},xs:function(){return o.Z}});var a=n(21626),s=n(97214),r=n(28241),i=n(58834),o=n(69552),l=n(71876)},88658:function(e,t,n){n.d(t,{L:function(){return s}});var a=n(49817);let s=e=>{let t;let{apiKeySource:n,accessToken:s,apiKey:r,inputMessage:i,chatHistory:o,selectedTags:l,selectedVectorStores:c,selectedGuardrails:d,endpointType:m,selectedModel:p,selectedSdk:u}=e,g="session"===n?s:r,x=window.location.origin,h=i||"Your prompt here",f=h.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n"),_=o.filter(e=>!e.isImage).map(e=>{let{role:t,content:n}=e;return{role:t,content:n}}),b={};l.length>0&&(b.tags=l),c.length>0&&(b.vector_stores=c),d.length>0&&(b.guardrails=d);let v=p||"your-model-name",j="azure"===u?'import openai\n\nclient = openai.AzureOpenAI(\n api_key="'.concat(g||"YOUR_LITELLM_API_KEY",'",\n azure_endpoint="').concat(x,'",\n api_version="2024-02-01"\n)'):'import openai\n\nclient = openai.OpenAI(\n api_key="'.concat(g||"YOUR_LITELLM_API_KEY",'",\n base_url="').concat(x,'"\n)');switch(m){case a.KP.CHAT:{let e=Object.keys(b).length>0,n="";if(e){let e=JSON.stringify({metadata:b},null,2).split("\n").map(e=>" ".repeat(4)+e).join("\n").trim();n=",\n extra_body=".concat(e)}let a=_.length>0?_:[{role:"user",content:h}];t='\nimport base64\n\n# Helper function to encode images to base64\ndef encode_image(image_path):\n with open(image_path, "rb") as image_file:\n return base64.b64encode(image_file.read()).decode(\'utf-8\')\n\n# Example with text only\nresponse = client.chat.completions.create(\n model="'.concat(v,'",\n messages=').concat(JSON.stringify(a,null,4)).concat(n,'\n)\n\nprint(response)\n\n# Example with image or PDF (uncomment and provide file path to use)\n# base64_file = encode_image("path/to/your/file.jpg") # or .pdf\n# response_with_file = client.chat.completions.create(\n# model="').concat(v,'",\n# messages=[\n# {\n# "role": "user",\n# "content": [\n# {\n# "type": "text",\n# "text": "').concat(f,'"\n# },\n# {\n# "type": "image_url",\n# "image_url": {\n# "url": f"data:image/jpeg;base64,{base64_file}" # or data:application/pdf;base64,{base64_file}\n# }\n# }\n# ]\n# }\n# ]').concat(n,"\n# )\n# print(response_with_file)\n");break}case a.KP.RESPONSES:{let e=Object.keys(b).length>0,n="";if(e){let e=JSON.stringify({metadata:b},null,2).split("\n").map(e=>" ".repeat(4)+e).join("\n").trim();n=",\n extra_body=".concat(e)}let a=_.length>0?_:[{role:"user",content:h}];t='\nimport base64\n\n# Helper function to encode images to base64\ndef encode_image(image_path):\n with open(image_path, "rb") as image_file:\n return base64.b64encode(image_file.read()).decode(\'utf-8\')\n\n# Example with text only\nresponse = client.responses.create(\n model="'.concat(v,'",\n input=').concat(JSON.stringify(a,null,4)).concat(n,'\n)\n\nprint(response.output_text)\n\n# Example with image or PDF (uncomment and provide file path to use)\n# base64_file = encode_image("path/to/your/file.jpg") # or .pdf\n# response_with_file = client.responses.create(\n# model="').concat(v,'",\n# input=[\n# {\n# "role": "user",\n# "content": [\n# {"type": "input_text", "text": "').concat(f,'"},\n# {\n# "type": "input_image",\n# "image_url": f"data:image/jpeg;base64,{base64_file}", # or data:application/pdf;base64,{base64_file}\n# },\n# ],\n# }\n# ]').concat(n,"\n# )\n# print(response_with_file.output_text)\n");break}case a.KP.IMAGE:t="azure"===u?"\n# NOTE: The Azure SDK does not have a direct equivalent to the multi-modal 'responses.create' method shown for OpenAI.\n# This snippet uses 'client.images.generate' and will create a new image based on your prompt.\n# It does not use the uploaded image, as 'client.images.generate' does not support image inputs in this context.\nimport os\nimport requests\nimport json\nimport time\nfrom PIL import Image\n\nresult = client.images.generate(\n model=\"".concat(v,'",\n prompt="').concat(i,'",\n n=1\n)\n\njson_response = json.loads(result.model_dump_json())\n\n# Set the directory for the stored image\nimage_dir = os.path.join(os.curdir, \'images\')\n\n# If the directory doesn\'t exist, create it\nif not os.path.isdir(image_dir):\n os.mkdir(image_dir)\n\n# Initialize the image path\nimage_filename = f"generated_image_{int(time.time())}.png"\nimage_path = os.path.join(image_dir, image_filename)\n\ntry:\n # Retrieve the generated image\n if json_response.get("data") && len(json_response["data"]) > 0 && json_response["data"][0].get("url"):\n image_url = json_response["data"][0]["url"]\n generated_image = requests.get(image_url).content\n with open(image_path, "wb") as image_file:\n image_file.write(generated_image)\n\n print(f"Image saved to {image_path}")\n # Display the image\n image = Image.open(image_path)\n image.show()\n else:\n print("Could not find image URL in response.")\n print("Full response:", json_response)\nexcept Exception as e:\n print(f"An error occurred: {e}")\n print("Full response:", json_response)\n'):"\nimport base64\nimport os\nimport time\nimport json\nfrom PIL import Image\nimport requests\n\n# Helper function to encode images to base64\ndef encode_image(image_path):\n with open(image_path, \"rb\") as image_file:\n return base64.b64encode(image_file.read()).decode('utf-8')\n\n# Helper function to create a file (simplified for this example)\ndef create_file(image_path):\n # In a real implementation, this would upload the file to OpenAI\n # For this example, we'll just return a placeholder ID\n return f\"file_{os.path.basename(image_path).replace('.', '_')}\"\n\n# The prompt entered by the user\nprompt = \"".concat(f,'"\n\n# Encode images to base64\nbase64_image1 = encode_image("body-lotion.png")\nbase64_image2 = encode_image("soap.png")\n\n# Create file IDs\nfile_id1 = create_file("body-lotion.png")\nfile_id2 = create_file("incense-kit.png")\n\nresponse = client.responses.create(\n model="').concat(v,'",\n input=[\n {\n "role": "user",\n "content": [\n {"type": "input_text", "text": prompt},\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image1}",\n },\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image2}",\n },\n {\n "type": "input_image",\n "file_id": file_id1,\n },\n {\n "type": "input_image",\n "file_id": file_id2,\n }\n ],\n }\n ],\n tools=[{"type": "image_generation"}],\n)\n\n# Process the response\nimage_generation_calls = [\n output\n for output in response.output\n if output.type == "image_generation_call"\n]\n\nimage_data = [output.result for output in image_generation_calls]\n\nif image_data:\n image_base64 = image_data[0]\n image_filename = f"edited_image_{int(time.time())}.png"\n with open(image_filename, "wb") as f:\n f.write(base64.b64decode(image_base64))\n print(f"Image saved to {image_filename}")\nelse:\n # If no image is generated, there might be a text response with an explanation\n text_response = [output.text for output in response.output if hasattr(output, \'text\')]\n if text_response:\n print("No image generated. Model response:")\n print("\\n".join(text_response))\n else:\n print("No image data found in response.")\n print("Full response for debugging:")\n print(response)\n');break;case a.KP.IMAGE_EDITS:t="azure"===u?'\nimport base64\nimport os\nimport time\nimport json\nfrom PIL import Image\nimport requests\n\n# Helper function to encode images to base64\ndef encode_image(image_path):\n with open(image_path, "rb") as image_file:\n return base64.b64encode(image_file.read()).decode(\'utf-8\')\n\n# The prompt entered by the user\nprompt = "'.concat(f,'"\n\n# Encode images to base64\nbase64_image1 = encode_image("body-lotion.png")\nbase64_image2 = encode_image("soap.png")\n\n# Create file IDs\nfile_id1 = create_file("body-lotion.png")\nfile_id2 = create_file("incense-kit.png")\n\nresponse = client.responses.create(\n model="').concat(v,'",\n input=[\n {\n "role": "user",\n "content": [\n {"type": "input_text", "text": prompt},\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image1}",\n },\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image2}",\n },\n {\n "type": "input_image",\n "file_id": file_id1,\n },\n {\n "type": "input_image",\n "file_id": file_id2,\n }\n ],\n }\n ],\n tools=[{"type": "image_generation"}],\n)\n\n# Process the response\nimage_generation_calls = [\n output\n for output in response.output\n if output.type == "image_generation_call"\n]\n\nimage_data = [output.result for output in image_generation_calls]\n\nif image_data:\n image_base64 = image_data[0]\n image_filename = f"edited_image_{int(time.time())}.png"\n with open(image_filename, "wb") as f:\n f.write(base64.b64decode(image_base64))\n print(f"Image saved to {image_filename}")\nelse:\n # If no image is generated, there might be a text response with an explanation\n text_response = [output.text for output in response.output if hasattr(output, \'text\')]\n if text_response:\n print("No image generated. Model response:")\n print("\\n".join(text_response))\n else:\n print("No image data found in response.")\n print("Full response for debugging:")\n print(response)\n'):"\nimport base64\nimport os\nimport time\n\n# Helper function to encode images to base64\ndef encode_image(image_path):\n with open(image_path, \"rb\") as image_file:\n return base64.b64encode(image_file.read()).decode('utf-8')\n\n# Helper function to create a file (simplified for this example)\ndef create_file(image_path):\n # In a real implementation, this would upload the file to OpenAI\n # For this example, we'll just return a placeholder ID\n return f\"file_{os.path.basename(image_path).replace('.', '_')}\"\n\n# The prompt entered by the user\nprompt = \"".concat(f,'"\n\n# Encode images to base64\nbase64_image1 = encode_image("body-lotion.png")\nbase64_image2 = encode_image("soap.png")\n\n# Create file IDs\nfile_id1 = create_file("body-lotion.png")\nfile_id2 = create_file("incense-kit.png")\n\nresponse = client.responses.create(\n model="').concat(v,'",\n input=[\n {\n "role": "user",\n "content": [\n {"type": "input_text", "text": prompt},\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image1}",\n },\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image2}",\n },\n {\n "type": "input_image",\n "file_id": file_id1,\n },\n {\n "type": "input_image",\n "file_id": file_id2,\n }\n ],\n }\n ],\n tools=[{"type": "image_generation"}],\n)\n\n# Process the response\nimage_generation_calls = [\n output\n for output in response.output\n if output.type == "image_generation_call"\n]\n\nimage_data = [output.result for output in image_generation_calls]\n\nif image_data:\n image_base64 = image_data[0]\n image_filename = f"edited_image_{int(time.time())}.png"\n with open(image_filename, "wb") as f:\n f.write(base64.b64decode(image_base64))\n print(f"Image saved to {image_filename}")\nelse:\n # If no image is generated, there might be a text response with an explanation\n text_response = [output.text for output in response.output if hasattr(output, \'text\')]\n if text_response:\n print("No image generated. Model response:")\n print("\\n".join(text_response))\n else:\n print("No image data found in response.")\n print("Full response for debugging:")\n print(response)\n');break;default:t="\n# Code generation for this endpoint is not implemented yet."}return"".concat(j,"\n").concat(t)}},49817:function(e,t,n){var a,s,r,i;n.d(t,{KP:function(){return s},vf:function(){return l}}),(r=a||(a={})).IMAGE_GENERATION="image_generation",r.CHAT="chat",r.RESPONSES="responses",r.IMAGE_EDITS="image_edits",r.ANTHROPIC_MESSAGES="anthropic_messages",(i=s||(s={})).IMAGE="image",i.CHAT="chat",i.RESPONSES="responses",i.IMAGE_EDITS="image_edits",i.ANTHROPIC_MESSAGES="anthropic_messages";let o={image_generation:"image",chat:"chat",responses:"responses",image_edits:"image_edits",anthropic_messages:"anthropic_messages"},l=e=>{if(console.log("getEndpointType:",e),Object.values(a).includes(e)){let t=o[e];return console.log("endpointType:",t),t}return"chat"}},29488:function(e,t,n){n.d(t,{Hc:function(){return i},Ui:function(){return r},e4:function(){return o},xd:function(){return l}});let a="litellm_mcp_auth_tokens",s=()=>{try{let e=localStorage.getItem(a);return e?JSON.parse(e):{}}catch(e){return console.error("Error reading MCP auth tokens from localStorage:",e),{}}},r=(e,t)=>{try{let n=s()[e];if(n&&n.serverAlias===t||n&&!t&&!n.serverAlias)return n.authValue;return null}catch(e){return console.error("Error getting MCP auth token:",e),null}},i=(e,t,n,r)=>{try{let i=s();i[e]={serverId:e,serverAlias:r,authValue:t,authType:n,timestamp:Date.now()},localStorage.setItem(a,JSON.stringify(i))}catch(e){console.error("Error storing MCP auth token:",e)}},o=e=>{try{let t=s();delete t[e],localStorage.setItem(a,JSON.stringify(t))}catch(e){console.error("Error removing MCP auth token:",e)}},l=()=>{try{localStorage.removeItem(a)}catch(e){console.error("Error clearing MCP auth tokens:",e)}}},8048:function(e,t,n){n.d(t,{C:function(){return m}});var a=n(57437),s=n(71594),r=n(24525),i=n(2265),o=n(19130),l=n(44633),c=n(86462),d=n(49084);function m(e){let{data:t=[],columns:n,isLoading:m=!1,table:p,defaultSorting:u=[]}=e,[g,x]=i.useState(u),[h]=i.useState("onChange"),[f,_]=i.useState({}),[b,v]=i.useState({}),j=(0,s.b7)({data:t,columns:n,state:{sorting:g,columnSizing:f,columnVisibility:b},columnResizeMode:h,onSortingChange:x,onColumnSizingChange:_,onColumnVisibilityChange:v,getCoreRowModel:(0,r.sC)(),getSortedRowModel:(0,r.tj)(),enableSorting:!0,enableColumnResizing:!0,defaultColumn:{minSize:40,maxSize:500}});return i.useEffect(()=>{p&&(p.current=j)},[j,p]),(0,a.jsx)("div",{className:"rounded-lg custom-border relative",children:(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsx)("div",{className:"relative min-w-full",children:(0,a.jsxs)(o.iA,{className:"[&_td]:py-2 [&_th]:py-2 w-full",children:[(0,a.jsx)(o.ss,{children:j.getHeaderGroups().map(e=>(0,a.jsx)(o.SC,{children:e.headers.map(e=>{var t;return(0,a.jsxs)(o.xs,{className:"py-1 h-8 relative ".concat("actions"===e.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)] z-20 w-[120px] ml-8":""," ").concat((null===(t=e.column.columnDef.meta)||void 0===t?void 0:t.className)||""),style:{width:"actions"===e.id?120:e.getSize(),position:"actions"===e.id?"sticky":"relative",right:"actions"===e.id?0:"auto"},onClick:e.column.getCanSort()?e.column.getToggleSortingHandler():void 0,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("div",{className:"flex items-center",children:e.isPlaceholder?null:(0,s.ie)(e.column.columnDef.header,e.getContext())}),"actions"!==e.id&&e.column.getCanSort()&&(0,a.jsx)("div",{className:"w-4",children:e.column.getIsSorted()?({asc:(0,a.jsx)(l.Z,{className:"h-4 w-4 text-blue-500"}),desc:(0,a.jsx)(c.Z,{className:"h-4 w-4 text-blue-500"})})[e.column.getIsSorted()]:(0,a.jsx)(d.Z,{className:"h-4 w-4 text-gray-400"})})]}),e.column.getCanResize()&&(0,a.jsx)("div",{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:"absolute right-0 top-0 h-full w-2 cursor-col-resize select-none touch-none ".concat(e.column.getIsResizing()?"bg-blue-500":"hover:bg-blue-200")})]},e.id)})},e.id))}),(0,a.jsx)(o.RM,{children:m?(0,a.jsx)(o.SC,{children:(0,a.jsx)(o.pj,{colSpan:n.length,className:"h-8 text-center",children:(0,a.jsx)("div",{className:"text-center text-gray-500",children:(0,a.jsx)("p",{children:"\uD83D\uDE85 Loading models..."})})})}):j.getRowModel().rows.length>0?j.getRowModel().rows.map(e=>(0,a.jsx)(o.SC,{children:e.getVisibleCells().map(e=>{var t;return(0,a.jsx)(o.pj,{className:"py-0.5 ".concat("actions"===e.column.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)] z-20 w-[120px] ml-8":""," ").concat((null===(t=e.column.columnDef.meta)||void 0===t?void 0:t.className)||""),style:{width:"actions"===e.column.id?120:e.column.getSize(),position:"actions"===e.column.id?"sticky":"relative",right:"actions"===e.column.id?0:"auto"},children:(0,s.ie)(e.column.columnDef.cell,e.getContext())},e.id)})},e.id)):(0,a.jsx)(o.SC,{children:(0,a.jsx)(o.pj,{colSpan:n.length,className:"h-8 text-center",children:(0,a.jsx)("div",{className:"text-center text-gray-500",children:(0,a.jsx)("p",{children:"No models found"})})})})})]})})})})}},65373:function(e,t,n){n.d(t,{Z:function(){return _}});var a=n(57437),s=n(27648),r=n(2265),i=n(89970),o=n(80795),l=n(19250),c=n(15883),d=n(46346),m=n(57400),p=n(91870),u=n(40428),g=n(3914);let x=async e=>{if(!e)return null;try{return await (0,l.getProxyUISettings)(e)}catch(e){return console.error("Error fetching proxy settings:",e),null}};var h=n(69734),f=n(29488),_=e=>{let{userID:t,userEmail:n,userRole:_,premiumUser:b,proxySettings:v,setProxySettings:j,accessToken:y,isPublicPage:N=!1}=e,w=(0,l.getProxyBaseUrl)(),[A,I]=(0,r.useState)(""),{logoUrl:S}=(0,h.F)();(0,r.useEffect)(()=>{(async()=>{if(y){let e=await x(y);console.log("response from fetchProxySettings",e),e&&j(e)}})()},[y]),(0,r.useEffect)(()=>{I((null==v?void 0:v.PROXY_LOGOUT_URL)||"")},[v]);let k=[{key:"user-info",label:(0,a.jsxs)("div",{className:"px-3 py-3 border-b border-gray-100",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(c.Z,{className:"mr-2 text-gray-700"}),(0,a.jsx)("span",{className:"text-sm font-semibold text-gray-900",children:t})]}),b?(0,a.jsx)(i.Z,{title:"Premium User",placement:"left",children:(0,a.jsxs)("div",{className:"flex items-center bg-gradient-to-r from-amber-500 to-yellow-500 text-white px-2 py-0.5 rounded-full cursor-help",children:[(0,a.jsx)(d.Z,{className:"mr-1 text-xs"}),(0,a.jsx)("span",{className:"text-xs font-medium",children:"Premium"})]})}):(0,a.jsx)(i.Z,{title:"Upgrade to Premium for advanced features",placement:"left",children:(0,a.jsxs)("div",{className:"flex items-center bg-gray-100 text-gray-500 px-2 py-0.5 rounded-full cursor-help",children:[(0,a.jsx)(d.Z,{className:"mr-1 text-xs"}),(0,a.jsx)("span",{className:"text-xs font-medium",children:"Standard"})]})})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center text-sm",children:[(0,a.jsx)(m.Z,{className:"mr-2 text-gray-400 text-xs"}),(0,a.jsx)("span",{className:"text-gray-500 text-xs",children:"Role"}),(0,a.jsx)("span",{className:"ml-auto text-gray-700 font-medium",children:_})]}),(0,a.jsxs)("div",{className:"flex items-center text-sm",children:[(0,a.jsx)(p.Z,{className:"mr-2 text-gray-400 text-xs"}),(0,a.jsx)("span",{className:"text-gray-500 text-xs",children:"Email"}),(0,a.jsx)("span",{className:"ml-auto text-gray-700 font-medium truncate max-w-[150px]",title:n||"Unknown",children:n||"Unknown"})]})]})]})},{key:"logout",label:(0,a.jsxs)("div",{className:"flex items-center py-2 px-3 hover:bg-gray-50 rounded-md mx-1 my-1",onClick:()=>{(0,g.b)(),(0,f.xd)(),window.location.href=A},children:[(0,a.jsx)(u.Z,{className:"mr-3 text-gray-600"}),(0,a.jsx)("span",{className:"text-gray-800",children:"Logout"})]})}];return(0,a.jsx)("nav",{className:"bg-white border-b border-gray-200 sticky top-0 z-10",children:(0,a.jsx)("div",{className:"w-full",children:(0,a.jsxs)("div",{className:"flex items-center h-12 px-4",children:[(0,a.jsx)("div",{className:"flex items-center flex-shrink-0",children:(0,a.jsx)(s.default,{href:"/",className:"flex items-center",children:(0,a.jsx)("img",{src:S||"".concat(w,"/get_image"),alt:"LiteLLM Brand",className:"h-8 w-auto"})})}),(0,a.jsxs)("div",{className:"flex items-center space-x-5 ml-auto",children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/",target:"_blank",rel:"noopener noreferrer",className:"text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:"Docs"}),!N&&(0,a.jsx)(o.Z,{menu:{items:k,className:"min-w-[200px]",style:{padding:"8px",marginTop:"8px",borderRadius:"12px",boxShadow:"0 4px 24px rgba(0, 0, 0, 0.08)"}},overlayStyle:{minWidth:"200px"},children:(0,a.jsxs)("button",{className:"inline-flex items-center text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:["User",(0,a.jsx)("svg",{className:"ml-1 w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 9l-7 7-7-7"})})]})})]})]})})})}},42673:function(e,t,n){var a,s;n.d(t,{Cl:function(){return a},bK:function(){return d},cd:function(){return o},dr:function(){return l},fK:function(){return r},ph:function(){return c}}),n(2265),(s=a||(a={})).AIML="AI/ML API",s.Bedrock="Amazon Bedrock",s.Anthropic="Anthropic",s.AssemblyAI="AssemblyAI",s.SageMaker="AWS SageMaker",s.Azure="Azure",s.Azure_AI_Studio="Azure AI Foundry (Studio)",s.Cerebras="Cerebras",s.Cohere="Cohere",s.Databricks="Databricks",s.DeepInfra="DeepInfra",s.Deepgram="Deepgram",s.Deepseek="Deepseek",s.ElevenLabs="ElevenLabs",s.FireworksAI="Fireworks AI",s.Google_AI_Studio="Google AI Studio",s.GradientAI="GradientAI",s.Groq="Groq",s.Hosted_Vllm="vllm",s.JinaAI="Jina AI",s.MistralAI="Mistral AI",s.Ollama="Ollama",s.OpenAI="OpenAI",s.OpenAI_Compatible="OpenAI-Compatible Endpoints (Together AI, etc.)",s.OpenAI_Text="OpenAI Text Completion",s.OpenAI_Text_Compatible="OpenAI-Compatible Text Completion Models (Together AI, etc.)",s.Openrouter="Openrouter",s.Perplexity="Perplexity",s.Sambanova="Sambanova",s.TogetherAI="TogetherAI",s.Triton="Triton",s.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",s.VolcEngine="VolcEngine",s.Voyage="Voyage AI",s.xAI="xAI";let r={AIML:"aiml",OpenAI:"openai",OpenAI_Text:"text-completion-openai",Azure:"azure",Azure_AI_Studio:"azure_ai",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",Groq:"groq",MistralAI:"mistral",Cohere:"cohere",OpenAI_Compatible:"openai",OpenAI_Text_Compatible:"text-completion-openai",Vertex_AI:"vertex_ai",Databricks:"databricks",xAI:"xai",Deepseek:"deepseek",Ollama:"ollama",AssemblyAI:"assemblyai",Cerebras:"cerebras",Sambanova:"sambanova",Perplexity:"perplexity",TogetherAI:"together_ai",Openrouter:"openrouter",FireworksAI:"fireworks_ai",GradientAI:"gradient_ai",Triton:"triton",Deepgram:"deepgram",ElevenLabs:"elevenlabs",SageMaker:"sagemaker_chat",Voyage:"voyage",JinaAI:"jina_ai",VolcEngine:"volcengine",DeepInfra:"deepinfra",Hosted_Vllm:"hosted_vllm"},i="/ui/assets/logos/",o={"AI/ML API":"".concat(i,"aiml_api.svg"),Anthropic:"".concat(i,"anthropic.svg"),AssemblyAI:"".concat(i,"assemblyai_small.png"),Azure:"".concat(i,"microsoft_azure.svg"),"Azure AI Foundry (Studio)":"".concat(i,"microsoft_azure.svg"),"Amazon Bedrock":"".concat(i,"bedrock.svg"),"AWS SageMaker":"".concat(i,"bedrock.svg"),Cerebras:"".concat(i,"cerebras.svg"),Cohere:"".concat(i,"cohere.svg"),Databricks:"".concat(i,"databricks.svg"),Deepseek:"".concat(i,"deepseek.svg"),"Fireworks AI":"".concat(i,"fireworks.svg"),Groq:"".concat(i,"groq.svg"),"Google AI Studio":"".concat(i,"google.svg"),vllm:"".concat(i,"vllm.png"),"Mistral AI":"".concat(i,"mistral.svg"),Ollama:"".concat(i,"ollama.svg"),OpenAI:"".concat(i,"openai_small.svg"),"OpenAI Text Completion":"".concat(i,"openai_small.svg"),"OpenAI-Compatible Text Completion Models (Together AI, etc.)":"".concat(i,"openai_small.svg"),"OpenAI-Compatible Endpoints (Together AI, etc.)":"".concat(i,"openai_small.svg"),Openrouter:"".concat(i,"openrouter.svg"),Perplexity:"".concat(i,"perplexity-ai.svg"),Sambanova:"".concat(i,"sambanova.svg"),TogetherAI:"".concat(i,"togetherai.svg"),"Vertex AI (Anthropic, Gemini, etc.)":"".concat(i,"google.svg"),xAI:"".concat(i,"xai.svg"),GradientAI:"".concat(i,"gradientai.svg"),Triton:"".concat(i,"nvidia_triton.png"),Deepgram:"".concat(i,"deepgram.png"),ElevenLabs:"".concat(i,"elevenlabs.png"),"Voyage AI":"".concat(i,"voyage.webp"),"Jina AI":"".concat(i,"jina.png"),VolcEngine:"".concat(i,"volcengine.png"),DeepInfra:"".concat(i,"deepinfra.png")},l=e=>{if(!e)return{logo:"",displayName:"-"};if("gemini"===e.toLowerCase()){let e="Google AI Studio";return{logo:o[e],displayName:e}}let t=Object.keys(r).find(t=>r[t].toLowerCase()===e.toLowerCase());if(!t)return{logo:"",displayName:e};let n=a[t];return{logo:o[n],displayName:n}},c=e=>{if("AI/ML API"===e)return"aiml/flux-pro/v1.1";if("Vertex AI (Anthropic, Gemini, etc.)"===e)return"gemini-pro";if("Anthropic"==e||"Amazon Bedrock"==e)return"claude-3-opus";if("AWS SageMaker"==e)return"sagemaker/jumpstart-dft-meta-textgeneration-llama-2-7b";if("Google AI Studio"==e)return"gemini-pro";if("Azure AI Foundry (Studio)"==e)return"azure_ai/command-r-plus";else if("Azure"==e)return"azure/my-deployment";else if("Voyage AI"==e)return"voyage/";else if("Jina AI"==e)return"jina_ai/";else if("VolcEngine"==e)return"volcengine/";else if("DeepInfra"==e)return"deepinfra/";else return"gpt-3.5-turbo"},d=(e,t)=>{console.log("Provider key: ".concat(e));let n=r[e];console.log("Provider mapped to: ".concat(n));let a=[];return e&&"object"==typeof t&&(Object.entries(t).forEach(e=>{let[t,s]=e;null!==s&&"object"==typeof s&&"litellm_provider"in s&&(s.litellm_provider===n||s.litellm_provider.includes(n))&&a.push(t)}),"Cohere"==e&&(console.log("Adding cohere chat models"),Object.entries(t).forEach(e=>{let[t,n]=e;null!==n&&"object"==typeof n&&"litellm_provider"in n&&"cohere_chat"===n.litellm_provider&&a.push(t)})),"AWS SageMaker"==e&&(console.log("Adding sagemaker chat models"),Object.entries(t).forEach(e=>{let[t,n]=e;null!==n&&"object"==typeof n&&"litellm_provider"in n&&"sagemaker_chat"===n.litellm_provider&&a.push(t)}))),a}},72162:function(e,t,n){var a=n(57437),s=n(2265),r=n(19250),i=n(8048),o=n(36724),l=n(89970),c=n(3810),d=n(52787),m=n(82680),p=n(3477),u=n(17732),g=n(33245),x=n(78867),h=n(88658),f=n(49817),_=n(42673),b=n(65373),v=n(69734),j=n(9114);t.Z=e=>{var t,n;let{accessToken:y}=e,[N,w]=(0,s.useState)(null),[A,I]=(0,s.useState)("LiteLLM Gateway"),[S,k]=(0,s.useState)(null),[C,E]=(0,s.useState)(""),[M,O]=(0,s.useState)({}),[T,D]=(0,s.useState)(!0),[z,P]=(0,s.useState)(""),[L,Z]=(0,s.useState)([]),[G,R]=(0,s.useState)([]),[H,F]=(0,s.useState)([]),[K,V]=(0,s.useState)("I'm alive! ✓"),[U,W]=(0,s.useState)(!1),[q,J]=(0,s.useState)(null),[B,Y]=(0,s.useState)({}),$=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=async()=>{try{D(!0);let e=await (0,r.modelHubPublicModelsCall)();console.log("ModelHubData:",e),w(e)}catch(e){console.error("There was an error fetching the public model data",e),V("Service unavailable")}finally{D(!1)}};(async()=>{let e=await (0,r.getPublicModelHubInfo)();console.log("Public Model Hub Info:",e),I(e.docs_title),k(e.custom_docs_description),E(e.litellm_version),O(e.useful_links||{})})(),e()},[]),(0,s.useEffect)(()=>{},[z,L,G,H]);let X=(0,s.useMemo)(()=>{if(!N)return[];let e=N;if(z.trim()){let t=z.toLowerCase(),n=t.split(/\s+/),a=N.filter(e=>{let a=e.model_group.toLowerCase();return!!a.includes(t)||n.every(e=>a.includes(e))});a.length>0&&(e=a.sort((e,n)=>{let a=e.model_group.toLowerCase(),s=n.model_group.toLowerCase(),r=a===t?1e3:0,i=s===t?1e3:0,o=a.startsWith(t)?100:0,l=s.startsWith(t)?100:0,c=t.split(/\s+/).every(e=>a.includes(e))?50:0,d=t.split(/\s+/).every(e=>s.includes(e))?50:0,m=a.length;return i+l+d+(1e3-s.length)-(r+o+c+(1e3-m))}))}return e.filter(e=>{let t=0===L.length||L.some(t=>e.providers.includes(t)),n=0===G.length||G.includes(e.mode||""),a=0===H.length||Object.entries(e).filter(e=>{let[t,n]=e;return t.startsWith("supports_")&&!0===n}).some(e=>{let[t]=e,n=t.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");return H.includes(n)});return t&&n&&a})},[N,z,L,G,H]),Q=e=>{J(e),W(!0)},ee=e=>{navigator.clipboard.writeText(e),j.Z.success("Copied to clipboard!")},et=e=>e.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),en=e=>Object.entries(e).filter(e=>{let[t,n]=e;return t.startsWith("supports_")&&!0===n}).map(e=>{let[t]=e;return t}),ea=e=>"$".concat((1e6*e).toFixed(4)),es=e=>e?e>=1e3?"".concat((e/1e3).toFixed(0),"K"):e.toString():"N/A",er=(e,t)=>{let n=[];return e&&n.push("RPM: ".concat(e.toLocaleString())),t&&n.push("TPM: ".concat(t.toLocaleString())),n.length>0?n.join(", "):"N/A"};return(0,a.jsx)(v.f,{accessToken:y,children:(0,a.jsxs)("div",{className:"min-h-screen bg-white",children:[(0,a.jsx)(b.Z,{userID:null,userEmail:null,userRole:null,premiumUser:!1,setProxySettings:Y,proxySettings:B,accessToken:y||null,isPublicPage:!0}),(0,a.jsxs)("div",{className:"w-full px-8 py-12",children:[(0,a.jsxs)(o.Zb,{className:"mb-10 p-8 bg-white border border-gray-200 rounded-lg shadow-sm",children:[(0,a.jsx)(o.Dx,{className:"text-2xl font-semibold mb-6 text-gray-900",children:"About"}),(0,a.jsx)("p",{className:"text-gray-700 mb-6 text-base leading-relaxed",children:S||"Proxy Server to call 100+ LLMs in the OpenAI format."}),(0,a.jsx)("div",{className:"flex items-center space-x-3 text-sm text-gray-600",children:(0,a.jsxs)("span",{className:"flex items-center",children:[(0,a.jsx)("span",{className:"w-4 h-4 mr-2",children:"\uD83D\uDD27"}),"Built with litellm: v",C]})})]}),M&&Object.keys(M).length>0&&(0,a.jsxs)(o.Zb,{className:"mb-10 p-8 bg-white border border-gray-200 rounded-lg shadow-sm",children:[(0,a.jsx)(o.Dx,{className:"text-2xl font-semibold mb-6 text-gray-900",children:"Useful Links"}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Object.entries(M||{}).map(e=>{let[t,n]=e;return(0,a.jsxs)("button",{onClick:()=>window.open(n,"_blank"),className:"flex items-center space-x-3 text-blue-600 hover:text-blue-800 transition-colors p-3 rounded-lg hover:bg-blue-50 border border-gray-200",children:[(0,a.jsx)(p.Z,{className:"w-4 h-4"}),(0,a.jsx)(o.xv,{className:"text-sm font-medium",children:t})]},t)})})]}),(0,a.jsxs)(o.Zb,{className:"mb-10 p-8 bg-white border border-gray-200 rounded-lg shadow-sm",children:[(0,a.jsx)(o.Dx,{className:"text-2xl font-semibold mb-6 text-gray-900",children:"Health and Endpoint Status"}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:(0,a.jsxs)(o.xv,{className:"text-green-600 font-medium text-sm",children:["Service status: ",K]})})]}),(0,a.jsxs)(o.Zb,{className:"p-8 bg-white border border-gray-200 rounded-lg shadow-sm",children:[(0,a.jsx)("div",{className:"flex justify-between items-center mb-8",children:(0,a.jsx)(o.Dx,{className:"text-2xl font-semibold text-gray-900",children:"Available Models"})}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8 p-6 bg-gray-50 rounded-lg border border-gray-200",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2 mb-3",children:[(0,a.jsx)(o.xv,{className:"text-sm font-medium text-gray-700",children:"Search Models:"}),(0,a.jsx)(l.Z,{title:"Smart search with relevance ranking - finds models containing your search terms, ranked by relevance. Try searching 'xai grok-4', 'claude-4', 'gpt-4', or 'sonnet'",placement:"top",children:(0,a.jsx)(g.Z,{className:"w-4 h-4 text-gray-400 cursor-help"})})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(u.Z,{className:"w-4 h-4 text-gray-400 absolute left-3 top-1/2 transform -translate-y-1/2"}),(0,a.jsx)("input",{type:"text",placeholder:"Search model names... (smart search enabled)",value:z,onChange:e=>P(e.target.value),className:"border border-gray-300 rounded-lg pl-10 pr-4 py-2 w-full text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-sm font-medium mb-3 text-gray-700",children:"Provider:"}),(0,a.jsx)(d.default,{mode:"multiple",value:L,onChange:e=>Z(e),placeholder:"Select providers",className:"w-full",size:"large",allowClear:!0,optionRender:e=>{let{logo:t}=(0,_.dr)(e.value);return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[t&&(0,a.jsx)("img",{src:t,alt:e.label,className:"w-5 h-5 flex-shrink-0 object-contain",onError:e=>{e.target.style.display="none"}}),(0,a.jsx)("span",{className:"capitalize",children:e.label})]})},children:N&&(e=>{let t=new Set;return e.forEach(e=>{e.providers.forEach(e=>t.add(e))}),Array.from(t)})(N).map(e=>(0,a.jsx)(d.default.Option,{value:e,children:e},e))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-sm font-medium mb-3 text-gray-700",children:"Mode:"}),(0,a.jsx)(d.default,{mode:"multiple",value:G,onChange:e=>R(e),placeholder:"Select modes",className:"w-full",size:"large",allowClear:!0,children:N&&(e=>{let t=new Set;return e.forEach(e=>{e.mode&&t.add(e.mode)}),Array.from(t)})(N).map(e=>(0,a.jsx)(d.default.Option,{value:e,children:e},e))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-sm font-medium mb-3 text-gray-700",children:"Features:"}),(0,a.jsx)(d.default,{mode:"multiple",value:H,onChange:e=>F(e),placeholder:"Select features",className:"w-full",size:"large",allowClear:!0,children:N&&(e=>{let t=new Set;return e.forEach(e=>{Object.entries(e).filter(e=>{let[t,n]=e;return t.startsWith("supports_")&&!0===n}).forEach(e=>{let[n]=e,a=n.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.add(a)})}),Array.from(t).sort()})(N).map(e=>(0,a.jsx)(d.default.Option,{value:e,children:e},e))})]})]}),(0,a.jsx)(i.C,{columns:[{header:"Model Name",accessorKey:"model_group",enableSorting:!0,cell:e=>{let{row:t}=e;return(0,a.jsx)("div",{className:"overflow-hidden",children:(0,a.jsx)(l.Z,{title:t.original.model_group,children:(0,a.jsx)(o.zx,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left",onClick:()=>Q(t.original),children:t.original.model_group})})})},size:150},{header:"Providers",accessorKey:"providers",enableSorting:!0,cell:e=>{let{row:t}=e,n=t.original.providers;return(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:n.map(e=>{let{logo:t}=(0,_.dr)(e);return(0,a.jsxs)("div",{className:"flex items-center space-x-1 px-2 py-1 bg-gray-100 rounded text-xs",children:[t&&(0,a.jsx)("img",{src:t,alt:e,className:"w-3 h-3 flex-shrink-0 object-contain",onError:e=>{e.target.style.display="none"}}),(0,a.jsx)("span",{className:"capitalize",children:e})]},e)})})},size:120},{header:"Mode",accessorKey:"mode",enableSorting:!0,cell:e=>{let{row:t}=e,n=t.original.mode;return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{children:(e=>{switch(null==e?void 0:e.toLowerCase()){case"chat":return"\uD83D\uDCAC";case"rerank":return"\uD83D\uDD04";case"embedding":return"\uD83D\uDCC4";default:return"\uD83E\uDD16"}})(n||"")}),(0,a.jsx)(o.xv,{children:n||"Chat"})]})},size:100},{header:"Max Input",accessorKey:"max_input_tokens",enableSorting:!0,cell:e=>{let{row:t}=e;return(0,a.jsx)(o.xv,{className:"text-center",children:es(t.original.max_input_tokens)})},size:100,meta:{className:"text-center"}},{header:"Max Output",accessorKey:"max_output_tokens",enableSorting:!0,cell:e=>{let{row:t}=e;return(0,a.jsx)(o.xv,{className:"text-center",children:es(t.original.max_output_tokens)})},size:100,meta:{className:"text-center"}},{header:"Input $/1M",accessorKey:"input_cost_per_token",enableSorting:!0,cell:e=>{let{row:t}=e,n=t.original.input_cost_per_token;return(0,a.jsx)(o.xv,{className:"text-center",children:n?ea(n):"Free"})},size:100,meta:{className:"text-center"}},{header:"Output $/1M",accessorKey:"output_cost_per_token",enableSorting:!0,cell:e=>{let{row:t}=e,n=t.original.output_cost_per_token;return(0,a.jsx)(o.xv,{className:"text-center",children:n?ea(n):"Free"})},size:100,meta:{className:"text-center"}},{header:"Features",accessorKey:"supports_vision",enableSorting:!1,cell:e=>{let{row:t}=e,n=Object.entries(t.original).filter(e=>{let[t,n]=e;return t.startsWith("supports_")&&!0===n}).map(e=>{let[t]=e;return et(t)});return 0===n.length?(0,a.jsx)(o.xv,{className:"text-gray-400",children:"-"}):1===n.length?(0,a.jsx)("div",{className:"h-6 flex items-center",children:(0,a.jsx)(c.Z,{color:"blue",className:"text-xs",children:n[0]})}):(0,a.jsxs)("div",{className:"h-6 flex items-center space-x-1",children:[(0,a.jsx)(c.Z,{color:"blue",className:"text-xs",children:n[0]}),(0,a.jsx)(l.Z,{title:(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"font-medium",children:"All Features:"}),n.map((e,t)=>(0,a.jsxs)("div",{className:"text-xs",children:["• ",e]},t))]}),trigger:"click",placement:"topLeft",children:(0,a.jsxs)("span",{className:"text-xs text-blue-600 cursor-pointer hover:text-blue-800 hover:underline",onClick:e=>e.stopPropagation(),children:["+",n.length-1]})})]})},size:120},{header:"Limits",accessorKey:"rpm",enableSorting:!0,cell:e=>{let{row:t}=e,n=t.original;return(0,a.jsx)(o.xv,{className:"text-xs text-gray-600",children:er(n.rpm,n.tpm)})},size:150}],data:X,isLoading:T,table:$,defaultSorting:[{id:"model_group",desc:!1}]}),(0,a.jsx)("div",{className:"mt-8 text-center",children:(0,a.jsxs)(o.xv,{className:"text-sm text-gray-600",children:["Showing ",X.length," of ",(null==N?void 0:N.length)||0," models"]})})]})]}),(0,a.jsx)(m.Z,{title:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{children:(null==q?void 0:q.model_group)||"Model Details"}),q&&(0,a.jsx)(l.Z,{title:"Copy model name",children:(0,a.jsx)(x.Z,{onClick:()=>ee(q.model_group),className:"cursor-pointer text-gray-500 hover:text-blue-500 w-4 h-4"})})]}),width:1e3,open:U,footer:null,onOk:()=>{W(!1),J(null)},onCancel:()=>{W(!1),J(null)},children:q&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Model Overview"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Model Name:"}),(0,a.jsx)(o.xv,{children:q.model_group})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Mode:"}),(0,a.jsx)(o.xv,{children:q.mode||"Not specified"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Providers:"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:q.providers.map(e=>{let{logo:t}=(0,_.dr)(e);return(0,a.jsx)(c.Z,{color:"blue",children:(0,a.jsxs)("div",{className:"flex items-center space-x-1",children:[t&&(0,a.jsx)("img",{src:t,alt:e,className:"w-3 h-3 flex-shrink-0 object-contain",onError:e=>{e.target.style.display="none"}}),(0,a.jsx)("span",{className:"capitalize",children:e})]})},e)})})]})]}),q.model_group.includes("*")&&(0,a.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 mb-4",children:(0,a.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,a.jsx)(g.Z,{className:"w-4 h-4 text-blue-600 mt-0.5 flex-shrink-0"}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium text-blue-900 mb-2",children:"Wildcard Routing"}),(0,a.jsxs)(o.xv,{className:"text-sm text-blue-800 mb-2",children:["This model uses wildcard routing. You can pass any value where you see the ",(0,a.jsx)("code",{className:"bg-blue-100 px-1 py-0.5 rounded text-xs",children:"*"})," symbol."]}),(0,a.jsxs)(o.xv,{className:"text-sm text-blue-800",children:["For example, with ",(0,a.jsx)("code",{className:"bg-blue-100 px-1 py-0.5 rounded text-xs",children:q.model_group}),", you can use any string (",(0,a.jsx)("code",{className:"bg-blue-100 px-1 py-0.5 rounded text-xs",children:q.model_group.replace("*","my-custom-value")}),") that matches this pattern."]})]})]})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Token & Cost Information"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Max Input Tokens:"}),(0,a.jsx)(o.xv,{children:(null===(t=q.max_input_tokens)||void 0===t?void 0:t.toLocaleString())||"Not specified"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Max Output Tokens:"}),(0,a.jsx)(o.xv,{children:(null===(n=q.max_output_tokens)||void 0===n?void 0:n.toLocaleString())||"Not specified"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Input Cost per 1M Tokens:"}),(0,a.jsx)(o.xv,{children:q.input_cost_per_token?ea(q.input_cost_per_token):"Not specified"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Output Cost per 1M Tokens:"}),(0,a.jsx)(o.xv,{children:q.output_cost_per_token?ea(q.output_cost_per_token):"Not specified"})]})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Capabilities"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:(()=>{let e=en(q),t=["green","blue","purple","orange","red","yellow"];return 0===e.length?(0,a.jsx)(o.xv,{className:"text-gray-500",children:"No special capabilities listed"}):e.map((e,n)=>(0,a.jsx)(c.Z,{color:t[n%t.length],children:et(e)},e))})()})]}),(q.tpm||q.rpm)&&(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Rate Limits"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[q.tpm&&(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Tokens per Minute:"}),(0,a.jsx)(o.xv,{children:q.tpm.toLocaleString()})]}),q.rpm&&(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Requests per Minute:"}),(0,a.jsx)(o.xv,{children:q.rpm.toLocaleString()})]})]})]}),q.supported_openai_params&&(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Supported OpenAI Parameters"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:q.supported_openai_params.map(e=>(0,a.jsx)(c.Z,{color:"green",children:e},e))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Usage Example"}),(0,a.jsx)("div",{className:"bg-gray-900 text-gray-100 p-4 rounded-lg overflow-x-auto",children:(0,a.jsx)("pre",{className:"text-sm",children:(0,h.L)({apiKeySource:"custom",accessToken:null,apiKey:"your_api_key",inputMessage:"Hello, how are you?",chatHistory:[{role:"user",content:"Hello, how are you?",isImage:!1}],selectedTags:[],selectedVectorStores:[],selectedGuardrails:[],endpointType:(0,f.vf)(q.mode||"chat"),selectedModel:q.model_group,selectedSdk:"openai"})})}),(0,a.jsx)("div",{className:"mt-2 text-right",children:(0,a.jsx)("button",{onClick:()=>{ee((0,h.L)({apiKeySource:"custom",accessToken:null,apiKey:"your_api_key",inputMessage:"Hello, how are you?",chatHistory:[{role:"user",content:"Hello, how are you?",isImage:!1}],selectedTags:[],selectedVectorStores:[],selectedGuardrails:[],endpointType:(0,f.vf)(q.mode||"chat"),selectedModel:q.model_group,selectedSdk:"openai"}))},className:"text-sm text-blue-600 hover:text-blue-800 cursor-pointer",children:"Copy to clipboard"})})]})]})})]})})}},69734:function(e,t,n){n.d(t,{F:function(){return o},f:function(){return l}});var a=n(57437),s=n(2265),r=n(19250);let i=(0,s.createContext)(void 0),o=()=>{let e=(0,s.useContext)(i);if(!e)throw Error("useTheme must be used within a ThemeProvider");return e},l=e=>{let{children:t,accessToken:n}=e,[o,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(async()=>{if(n)try{let t=(0,r.getProxyBaseUrl)(),a=await fetch(t?"".concat(t,"/get/ui_theme_settings"):"/get/ui_theme_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(a.ok){var e;let t=await a.json();(null===(e=t.values)||void 0===e?void 0:e.logo_url)&&l(t.values.logo_url)}}catch(e){console.warn("Failed to load logo settings from backend:",e)}})()},[n]),(0,a.jsx)(i.Provider,{value:{logoUrl:o,setLogoUrl:l},children:t})}}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/162-f2925685093720a4.js b/litellm/proxy/_experimental/out/_next/static/chunks/162-f2925685093720a4.js deleted file mode 100644 index 61e8b1eebad..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/162-f2925685093720a4.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[162],{36724:function(e,t,n){n.d(t,{Dx:function(){return i.Z},Zb:function(){return s.Z},xv:function(){return r.Z},zx:function(){return a.Z}});var a=n(20831),s=n(12514),r=n(84264),i=n(96761)},19130:function(e,t,n){n.d(t,{RM:function(){return s.Z},SC:function(){return l.Z},iA:function(){return a.Z},pj:function(){return r.Z},ss:function(){return i.Z},xs:function(){return o.Z}});var a=n(21626),s=n(97214),r=n(28241),i=n(58834),o=n(69552),l=n(71876)},88658:function(e,t,n){n.d(t,{L:function(){return s}});var a=n(49817);let s=e=>{let t;let{apiKeySource:n,accessToken:s,apiKey:r,inputMessage:i,chatHistory:o,selectedTags:l,selectedVectorStores:c,selectedGuardrails:d,endpointType:m,selectedModel:p,selectedSdk:u}=e,g="session"===n?s:r,x=window.location.origin,h=i||"Your prompt here",f=h.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n"),_=o.filter(e=>!e.isImage).map(e=>{let{role:t,content:n}=e;return{role:t,content:n}}),b={};l.length>0&&(b.tags=l),c.length>0&&(b.vector_stores=c),d.length>0&&(b.guardrails=d);let v=p||"your-model-name",j="azure"===u?'import openai\n\nclient = openai.AzureOpenAI(\n api_key="'.concat(g||"YOUR_LITELLM_API_KEY",'",\n azure_endpoint="').concat(x,'",\n api_version="2024-02-01"\n)'):'import openai\n\nclient = openai.OpenAI(\n api_key="'.concat(g||"YOUR_LITELLM_API_KEY",'",\n base_url="').concat(x,'"\n)');switch(m){case a.KP.CHAT:{let e=Object.keys(b).length>0,n="";if(e){let e=JSON.stringify({metadata:b},null,2).split("\n").map(e=>" ".repeat(4)+e).join("\n").trim();n=",\n extra_body=".concat(e)}let a=_.length>0?_:[{role:"user",content:h}];t='\nimport base64\n\n# Helper function to encode images to base64\ndef encode_image(image_path):\n with open(image_path, "rb") as image_file:\n return base64.b64encode(image_file.read()).decode(\'utf-8\')\n\n# Example with text only\nresponse = client.chat.completions.create(\n model="'.concat(v,'",\n messages=').concat(JSON.stringify(a,null,4)).concat(n,'\n)\n\nprint(response)\n\n# Example with image or PDF (uncomment and provide file path to use)\n# base64_file = encode_image("path/to/your/file.jpg") # or .pdf\n# response_with_file = client.chat.completions.create(\n# model="').concat(v,'",\n# messages=[\n# {\n# "role": "user",\n# "content": [\n# {\n# "type": "text",\n# "text": "').concat(f,'"\n# },\n# {\n# "type": "image_url",\n# "image_url": {\n# "url": f"data:image/jpeg;base64,{base64_file}" # or data:application/pdf;base64,{base64_file}\n# }\n# }\n# ]\n# }\n# ]').concat(n,"\n# )\n# print(response_with_file)\n");break}case a.KP.RESPONSES:{let e=Object.keys(b).length>0,n="";if(e){let e=JSON.stringify({metadata:b},null,2).split("\n").map(e=>" ".repeat(4)+e).join("\n").trim();n=",\n extra_body=".concat(e)}let a=_.length>0?_:[{role:"user",content:h}];t='\nimport base64\n\n# Helper function to encode images to base64\ndef encode_image(image_path):\n with open(image_path, "rb") as image_file:\n return base64.b64encode(image_file.read()).decode(\'utf-8\')\n\n# Example with text only\nresponse = client.responses.create(\n model="'.concat(v,'",\n input=').concat(JSON.stringify(a,null,4)).concat(n,'\n)\n\nprint(response.output_text)\n\n# Example with image or PDF (uncomment and provide file path to use)\n# base64_file = encode_image("path/to/your/file.jpg") # or .pdf\n# response_with_file = client.responses.create(\n# model="').concat(v,'",\n# input=[\n# {\n# "role": "user",\n# "content": [\n# {"type": "input_text", "text": "').concat(f,'"},\n# {\n# "type": "input_image",\n# "image_url": f"data:image/jpeg;base64,{base64_file}", # or data:application/pdf;base64,{base64_file}\n# },\n# ],\n# }\n# ]').concat(n,"\n# )\n# print(response_with_file.output_text)\n");break}case a.KP.IMAGE:t="azure"===u?"\n# NOTE: The Azure SDK does not have a direct equivalent to the multi-modal 'responses.create' method shown for OpenAI.\n# This snippet uses 'client.images.generate' and will create a new image based on your prompt.\n# It does not use the uploaded image, as 'client.images.generate' does not support image inputs in this context.\nimport os\nimport requests\nimport json\nimport time\nfrom PIL import Image\n\nresult = client.images.generate(\n model=\"".concat(v,'",\n prompt="').concat(i,'",\n n=1\n)\n\njson_response = json.loads(result.model_dump_json())\n\n# Set the directory for the stored image\nimage_dir = os.path.join(os.curdir, \'images\')\n\n# If the directory doesn\'t exist, create it\nif not os.path.isdir(image_dir):\n os.mkdir(image_dir)\n\n# Initialize the image path\nimage_filename = f"generated_image_{int(time.time())}.png"\nimage_path = os.path.join(image_dir, image_filename)\n\ntry:\n # Retrieve the generated image\n if json_response.get("data") && len(json_response["data"]) > 0 && json_response["data"][0].get("url"):\n image_url = json_response["data"][0]["url"]\n generated_image = requests.get(image_url).content\n with open(image_path, "wb") as image_file:\n image_file.write(generated_image)\n\n print(f"Image saved to {image_path}")\n # Display the image\n image = Image.open(image_path)\n image.show()\n else:\n print("Could not find image URL in response.")\n print("Full response:", json_response)\nexcept Exception as e:\n print(f"An error occurred: {e}")\n print("Full response:", json_response)\n'):"\nimport base64\nimport os\nimport time\nimport json\nfrom PIL import Image\nimport requests\n\n# Helper function to encode images to base64\ndef encode_image(image_path):\n with open(image_path, \"rb\") as image_file:\n return base64.b64encode(image_file.read()).decode('utf-8')\n\n# Helper function to create a file (simplified for this example)\ndef create_file(image_path):\n # In a real implementation, this would upload the file to OpenAI\n # For this example, we'll just return a placeholder ID\n return f\"file_{os.path.basename(image_path).replace('.', '_')}\"\n\n# The prompt entered by the user\nprompt = \"".concat(f,'"\n\n# Encode images to base64\nbase64_image1 = encode_image("body-lotion.png")\nbase64_image2 = encode_image("soap.png")\n\n# Create file IDs\nfile_id1 = create_file("body-lotion.png")\nfile_id2 = create_file("incense-kit.png")\n\nresponse = client.responses.create(\n model="').concat(v,'",\n input=[\n {\n "role": "user",\n "content": [\n {"type": "input_text", "text": prompt},\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image1}",\n },\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image2}",\n },\n {\n "type": "input_image",\n "file_id": file_id1,\n },\n {\n "type": "input_image",\n "file_id": file_id2,\n }\n ],\n }\n ],\n tools=[{"type": "image_generation"}],\n)\n\n# Process the response\nimage_generation_calls = [\n output\n for output in response.output\n if output.type == "image_generation_call"\n]\n\nimage_data = [output.result for output in image_generation_calls]\n\nif image_data:\n image_base64 = image_data[0]\n image_filename = f"edited_image_{int(time.time())}.png"\n with open(image_filename, "wb") as f:\n f.write(base64.b64decode(image_base64))\n print(f"Image saved to {image_filename}")\nelse:\n # If no image is generated, there might be a text response with an explanation\n text_response = [output.text for output in response.output if hasattr(output, \'text\')]\n if text_response:\n print("No image generated. Model response:")\n print("\\n".join(text_response))\n else:\n print("No image data found in response.")\n print("Full response for debugging:")\n print(response)\n');break;case a.KP.IMAGE_EDITS:t="azure"===u?'\nimport base64\nimport os\nimport time\nimport json\nfrom PIL import Image\nimport requests\n\n# Helper function to encode images to base64\ndef encode_image(image_path):\n with open(image_path, "rb") as image_file:\n return base64.b64encode(image_file.read()).decode(\'utf-8\')\n\n# The prompt entered by the user\nprompt = "'.concat(f,'"\n\n# Encode images to base64\nbase64_image1 = encode_image("body-lotion.png")\nbase64_image2 = encode_image("soap.png")\n\n# Create file IDs\nfile_id1 = create_file("body-lotion.png")\nfile_id2 = create_file("incense-kit.png")\n\nresponse = client.responses.create(\n model="').concat(v,'",\n input=[\n {\n "role": "user",\n "content": [\n {"type": "input_text", "text": prompt},\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image1}",\n },\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image2}",\n },\n {\n "type": "input_image",\n "file_id": file_id1,\n },\n {\n "type": "input_image",\n "file_id": file_id2,\n }\n ],\n }\n ],\n tools=[{"type": "image_generation"}],\n)\n\n# Process the response\nimage_generation_calls = [\n output\n for output in response.output\n if output.type == "image_generation_call"\n]\n\nimage_data = [output.result for output in image_generation_calls]\n\nif image_data:\n image_base64 = image_data[0]\n image_filename = f"edited_image_{int(time.time())}.png"\n with open(image_filename, "wb") as f:\n f.write(base64.b64decode(image_base64))\n print(f"Image saved to {image_filename}")\nelse:\n # If no image is generated, there might be a text response with an explanation\n text_response = [output.text for output in response.output if hasattr(output, \'text\')]\n if text_response:\n print("No image generated. Model response:")\n print("\\n".join(text_response))\n else:\n print("No image data found in response.")\n print("Full response for debugging:")\n print(response)\n'):"\nimport base64\nimport os\nimport time\n\n# Helper function to encode images to base64\ndef encode_image(image_path):\n with open(image_path, \"rb\") as image_file:\n return base64.b64encode(image_file.read()).decode('utf-8')\n\n# Helper function to create a file (simplified for this example)\ndef create_file(image_path):\n # In a real implementation, this would upload the file to OpenAI\n # For this example, we'll just return a placeholder ID\n return f\"file_{os.path.basename(image_path).replace('.', '_')}\"\n\n# The prompt entered by the user\nprompt = \"".concat(f,'"\n\n# Encode images to base64\nbase64_image1 = encode_image("body-lotion.png")\nbase64_image2 = encode_image("soap.png")\n\n# Create file IDs\nfile_id1 = create_file("body-lotion.png")\nfile_id2 = create_file("incense-kit.png")\n\nresponse = client.responses.create(\n model="').concat(v,'",\n input=[\n {\n "role": "user",\n "content": [\n {"type": "input_text", "text": prompt},\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image1}",\n },\n {\n "type": "input_image",\n "image_url": f"data:image/jpeg;base64,{base64_image2}",\n },\n {\n "type": "input_image",\n "file_id": file_id1,\n },\n {\n "type": "input_image",\n "file_id": file_id2,\n }\n ],\n }\n ],\n tools=[{"type": "image_generation"}],\n)\n\n# Process the response\nimage_generation_calls = [\n output\n for output in response.output\n if output.type == "image_generation_call"\n]\n\nimage_data = [output.result for output in image_generation_calls]\n\nif image_data:\n image_base64 = image_data[0]\n image_filename = f"edited_image_{int(time.time())}.png"\n with open(image_filename, "wb") as f:\n f.write(base64.b64decode(image_base64))\n print(f"Image saved to {image_filename}")\nelse:\n # If no image is generated, there might be a text response with an explanation\n text_response = [output.text for output in response.output if hasattr(output, \'text\')]\n if text_response:\n print("No image generated. Model response:")\n print("\\n".join(text_response))\n else:\n print("No image data found in response.")\n print("Full response for debugging:")\n print(response)\n');break;default:t="\n# Code generation for this endpoint is not implemented yet."}return"".concat(j,"\n").concat(t)}},49817:function(e,t,n){var a,s,r,i;n.d(t,{KP:function(){return s},vf:function(){return l}}),(r=a||(a={})).IMAGE_GENERATION="image_generation",r.CHAT="chat",r.RESPONSES="responses",r.IMAGE_EDITS="image_edits",r.ANTHROPIC_MESSAGES="anthropic_messages",(i=s||(s={})).IMAGE="image",i.CHAT="chat",i.RESPONSES="responses",i.IMAGE_EDITS="image_edits",i.ANTHROPIC_MESSAGES="anthropic_messages";let o={image_generation:"image",chat:"chat",responses:"responses",image_edits:"image_edits",anthropic_messages:"anthropic_messages"},l=e=>{if(console.log("getEndpointType:",e),Object.values(a).includes(e)){let t=o[e];return console.log("endpointType:",t),t}return"chat"}},29488:function(e,t,n){n.d(t,{Hc:function(){return i},Ui:function(){return r},e4:function(){return o},xd:function(){return l}});let a="litellm_mcp_auth_tokens",s=()=>{try{let e=localStorage.getItem(a);return e?JSON.parse(e):{}}catch(e){return console.error("Error reading MCP auth tokens from localStorage:",e),{}}},r=(e,t)=>{try{let n=s()[e];if(n&&n.serverAlias===t||n&&!t&&!n.serverAlias)return n.authValue;return null}catch(e){return console.error("Error getting MCP auth token:",e),null}},i=(e,t,n,r)=>{try{let i=s();i[e]={serverId:e,serverAlias:r,authValue:t,authType:n,timestamp:Date.now()},localStorage.setItem(a,JSON.stringify(i))}catch(e){console.error("Error storing MCP auth token:",e)}},o=e=>{try{let t=s();delete t[e],localStorage.setItem(a,JSON.stringify(t))}catch(e){console.error("Error removing MCP auth token:",e)}},l=()=>{try{localStorage.removeItem(a)}catch(e){console.error("Error clearing MCP auth tokens:",e)}}},8048:function(e,t,n){n.d(t,{C:function(){return m}});var a=n(57437),s=n(71594),r=n(24525),i=n(2265),o=n(19130),l=n(44633),c=n(86462),d=n(49084);function m(e){let{data:t=[],columns:n,isLoading:m=!1,table:p,defaultSorting:u=[]}=e,[g,x]=i.useState(u),[h]=i.useState("onChange"),[f,_]=i.useState({}),[b,v]=i.useState({}),j=(0,s.b7)({data:t,columns:n,state:{sorting:g,columnSizing:f,columnVisibility:b},columnResizeMode:h,onSortingChange:x,onColumnSizingChange:_,onColumnVisibilityChange:v,getCoreRowModel:(0,r.sC)(),getSortedRowModel:(0,r.tj)(),enableSorting:!0,enableColumnResizing:!0,defaultColumn:{minSize:40,maxSize:500}});return i.useEffect(()=>{p&&(p.current=j)},[j,p]),(0,a.jsx)("div",{className:"rounded-lg custom-border relative",children:(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsx)("div",{className:"relative min-w-full",children:(0,a.jsxs)(o.iA,{className:"[&_td]:py-2 [&_th]:py-2 w-full",children:[(0,a.jsx)(o.ss,{children:j.getHeaderGroups().map(e=>(0,a.jsx)(o.SC,{children:e.headers.map(e=>{var t;return(0,a.jsxs)(o.xs,{className:"py-1 h-8 relative ".concat("actions"===e.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)] z-20 w-[120px] ml-8":""," ").concat((null===(t=e.column.columnDef.meta)||void 0===t?void 0:t.className)||""),style:{width:"actions"===e.id?120:e.getSize(),position:"actions"===e.id?"sticky":"relative",right:"actions"===e.id?0:"auto"},onClick:e.column.getCanSort()?e.column.getToggleSortingHandler():void 0,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("div",{className:"flex items-center",children:e.isPlaceholder?null:(0,s.ie)(e.column.columnDef.header,e.getContext())}),"actions"!==e.id&&e.column.getCanSort()&&(0,a.jsx)("div",{className:"w-4",children:e.column.getIsSorted()?({asc:(0,a.jsx)(l.Z,{className:"h-4 w-4 text-blue-500"}),desc:(0,a.jsx)(c.Z,{className:"h-4 w-4 text-blue-500"})})[e.column.getIsSorted()]:(0,a.jsx)(d.Z,{className:"h-4 w-4 text-gray-400"})})]}),e.column.getCanResize()&&(0,a.jsx)("div",{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:"absolute right-0 top-0 h-full w-2 cursor-col-resize select-none touch-none ".concat(e.column.getIsResizing()?"bg-blue-500":"hover:bg-blue-200")})]},e.id)})},e.id))}),(0,a.jsx)(o.RM,{children:m?(0,a.jsx)(o.SC,{children:(0,a.jsx)(o.pj,{colSpan:n.length,className:"h-8 text-center",children:(0,a.jsx)("div",{className:"text-center text-gray-500",children:(0,a.jsx)("p",{children:"\uD83D\uDE85 Loading models..."})})})}):j.getRowModel().rows.length>0?j.getRowModel().rows.map(e=>(0,a.jsx)(o.SC,{children:e.getVisibleCells().map(e=>{var t;return(0,a.jsx)(o.pj,{className:"py-0.5 ".concat("actions"===e.column.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)] z-20 w-[120px] ml-8":""," ").concat((null===(t=e.column.columnDef.meta)||void 0===t?void 0:t.className)||""),style:{width:"actions"===e.column.id?120:e.column.getSize(),position:"actions"===e.column.id?"sticky":"relative",right:"actions"===e.column.id?0:"auto"},children:(0,s.ie)(e.column.columnDef.cell,e.getContext())},e.id)})},e.id)):(0,a.jsx)(o.SC,{children:(0,a.jsx)(o.pj,{colSpan:n.length,className:"h-8 text-center",children:(0,a.jsx)("div",{className:"text-center text-gray-500",children:(0,a.jsx)("p",{children:"No models found"})})})})})]})})})})}},65373:function(e,t,n){n.d(t,{Z:function(){return _}});var a=n(57437),s=n(27648),r=n(2265),i=n(89970),o=n(80795),l=n(19250),c=n(15883),d=n(46346),m=n(57400),p=n(91870),u=n(40428),g=n(3914);let x=async e=>{if(!e)return null;try{return await (0,l.getProxyUISettings)(e)}catch(e){return console.error("Error fetching proxy settings:",e),null}};var h=n(69734),f=n(29488),_=e=>{let{userID:t,userEmail:n,userRole:_,premiumUser:b,proxySettings:v,setProxySettings:j,accessToken:y,isPublicPage:N=!1}=e,w=(0,l.getProxyBaseUrl)(),[S,A]=(0,r.useState)(""),{logoUrl:I}=(0,h.F)();(0,r.useEffect)(()=>{(async()=>{if(y){let e=await x(y);console.log("response from fetchProxySettings",e),e&&j(e)}})()},[y]),(0,r.useEffect)(()=>{A((null==v?void 0:v.PROXY_LOGOUT_URL)||"")},[v]);let k=[{key:"user-info",label:(0,a.jsxs)("div",{className:"px-3 py-3 border-b border-gray-100",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(c.Z,{className:"mr-2 text-gray-700"}),(0,a.jsx)("span",{className:"text-sm font-semibold text-gray-900",children:t})]}),b?(0,a.jsx)(i.Z,{title:"Premium User",placement:"left",children:(0,a.jsxs)("div",{className:"flex items-center bg-gradient-to-r from-amber-500 to-yellow-500 text-white px-2 py-0.5 rounded-full cursor-help",children:[(0,a.jsx)(d.Z,{className:"mr-1 text-xs"}),(0,a.jsx)("span",{className:"text-xs font-medium",children:"Premium"})]})}):(0,a.jsx)(i.Z,{title:"Upgrade to Premium for advanced features",placement:"left",children:(0,a.jsxs)("div",{className:"flex items-center bg-gray-100 text-gray-500 px-2 py-0.5 rounded-full cursor-help",children:[(0,a.jsx)(d.Z,{className:"mr-1 text-xs"}),(0,a.jsx)("span",{className:"text-xs font-medium",children:"Standard"})]})})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center text-sm",children:[(0,a.jsx)(m.Z,{className:"mr-2 text-gray-400 text-xs"}),(0,a.jsx)("span",{className:"text-gray-500 text-xs",children:"Role"}),(0,a.jsx)("span",{className:"ml-auto text-gray-700 font-medium",children:_})]}),(0,a.jsxs)("div",{className:"flex items-center text-sm",children:[(0,a.jsx)(p.Z,{className:"mr-2 text-gray-400 text-xs"}),(0,a.jsx)("span",{className:"text-gray-500 text-xs",children:"Email"}),(0,a.jsx)("span",{className:"ml-auto text-gray-700 font-medium truncate max-w-[150px]",title:n||"Unknown",children:n||"Unknown"})]})]})]})},{key:"logout",label:(0,a.jsxs)("div",{className:"flex items-center py-2 px-3 hover:bg-gray-50 rounded-md mx-1 my-1",onClick:()=>{(0,g.b)(),(0,f.xd)(),window.location.href=S},children:[(0,a.jsx)(u.Z,{className:"mr-3 text-gray-600"}),(0,a.jsx)("span",{className:"text-gray-800",children:"Logout"})]})}];return(0,a.jsx)("nav",{className:"bg-white border-b border-gray-200 sticky top-0 z-10",children:(0,a.jsx)("div",{className:"w-full",children:(0,a.jsxs)("div",{className:"flex items-center h-12 px-4",children:[(0,a.jsx)("div",{className:"flex items-center flex-shrink-0",children:(0,a.jsx)(s.default,{href:"/",className:"flex items-center",children:(0,a.jsx)("img",{src:I||"".concat(w,"/get_image"),alt:"LiteLLM Brand",className:"h-8 w-auto"})})}),(0,a.jsxs)("div",{className:"flex items-center space-x-5 ml-auto",children:[(0,a.jsx)("a",{href:"https://docs.litellm.ai/docs/",target:"_blank",rel:"noopener noreferrer",className:"text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:"Docs"}),!N&&(0,a.jsx)(o.Z,{menu:{items:k,className:"min-w-[200px]",style:{padding:"8px",marginTop:"8px",borderRadius:"12px",boxShadow:"0 4px 24px rgba(0, 0, 0, 0.08)"}},overlayStyle:{minWidth:"200px"},children:(0,a.jsxs)("button",{className:"inline-flex items-center text-[13px] text-gray-600 hover:text-gray-900 transition-colors",children:["User",(0,a.jsx)("svg",{className:"ml-1 w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 9l-7 7-7-7"})})]})})]})]})})})}},42673:function(e,t,n){var a,s;n.d(t,{Cl:function(){return a},bK:function(){return d},cd:function(){return o},dr:function(){return l},fK:function(){return r},ph:function(){return c}}),n(2265),(s=a||(a={})).Bedrock="Amazon Bedrock",s.Anthropic="Anthropic",s.AssemblyAI="AssemblyAI",s.SageMaker="AWS SageMaker",s.Azure="Azure",s.Azure_AI_Studio="Azure AI Foundry (Studio)",s.Cerebras="Cerebras",s.Cohere="Cohere",s.Databricks="Databricks",s.DeepInfra="DeepInfra",s.Deepgram="Deepgram",s.Deepseek="Deepseek",s.ElevenLabs="ElevenLabs",s.FireworksAI="Fireworks AI",s.Google_AI_Studio="Google AI Studio",s.GradientAI="GradientAI",s.Groq="Groq",s.JinaAI="Jina AI",s.MistralAI="Mistral AI",s.Ollama="Ollama",s.OpenAI="OpenAI",s.OpenAI_Compatible="OpenAI-Compatible Endpoints (Together AI, etc.)",s.OpenAI_Text="OpenAI Text Completion",s.OpenAI_Text_Compatible="OpenAI-Compatible Text Completion Models (Together AI, etc.)",s.Openrouter="Openrouter",s.Perplexity="Perplexity",s.Sambanova="Sambanova",s.TogetherAI="TogetherAI",s.Triton="Triton",s.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",s.VolcEngine="VolcEngine",s.Voyage="Voyage AI",s.xAI="xAI";let r={OpenAI:"openai",OpenAI_Text:"text-completion-openai",Azure:"azure",Azure_AI_Studio:"azure_ai",Anthropic:"anthropic",Google_AI_Studio:"gemini",Bedrock:"bedrock",Groq:"groq",MistralAI:"mistral",Cohere:"cohere",OpenAI_Compatible:"openai",OpenAI_Text_Compatible:"text-completion-openai",Vertex_AI:"vertex_ai",Databricks:"databricks",xAI:"xai",Deepseek:"deepseek",Ollama:"ollama",AssemblyAI:"assemblyai",Cerebras:"cerebras",Sambanova:"sambanova",Perplexity:"perplexity",TogetherAI:"together_ai",Openrouter:"openrouter",FireworksAI:"fireworks_ai",GradientAI:"gradient_ai",Triton:"triton",Deepgram:"deepgram",ElevenLabs:"elevenlabs",SageMaker:"sagemaker_chat",Voyage:"voyage",JinaAI:"jina_ai",VolcEngine:"volcengine",DeepInfra:"deepinfra"},i="/ui/assets/logos/",o={Anthropic:"".concat(i,"anthropic.svg"),AssemblyAI:"".concat(i,"assemblyai_small.png"),Azure:"".concat(i,"microsoft_azure.svg"),"Azure AI Foundry (Studio)":"".concat(i,"microsoft_azure.svg"),"Amazon Bedrock":"".concat(i,"bedrock.svg"),"AWS SageMaker":"".concat(i,"bedrock.svg"),Cerebras:"".concat(i,"cerebras.svg"),Cohere:"".concat(i,"cohere.svg"),Databricks:"".concat(i,"databricks.svg"),Deepseek:"".concat(i,"deepseek.svg"),"Fireworks AI":"".concat(i,"fireworks.svg"),Groq:"".concat(i,"groq.svg"),"Google AI Studio":"".concat(i,"google.svg"),"Mistral AI":"".concat(i,"mistral.svg"),Ollama:"".concat(i,"ollama.svg"),OpenAI:"".concat(i,"openai_small.svg"),"OpenAI Text Completion":"".concat(i,"openai_small.svg"),"OpenAI-Compatible Text Completion Models (Together AI, etc.)":"".concat(i,"openai_small.svg"),"OpenAI-Compatible Endpoints (Together AI, etc.)":"".concat(i,"openai_small.svg"),Openrouter:"".concat(i,"openrouter.svg"),Perplexity:"".concat(i,"perplexity-ai.svg"),Sambanova:"".concat(i,"sambanova.svg"),TogetherAI:"".concat(i,"togetherai.svg"),"Vertex AI (Anthropic, Gemini, etc.)":"".concat(i,"google.svg"),xAI:"".concat(i,"xai.svg"),GradientAI:"".concat(i,"gradientai.svg"),Triton:"".concat(i,"nvidia_triton.png"),Deepgram:"".concat(i,"deepgram.png"),ElevenLabs:"".concat(i,"elevenlabs.png"),"Voyage AI":"".concat(i,"voyage.webp"),"Jina AI":"".concat(i,"jina.png"),VolcEngine:"".concat(i,"volcengine.png"),DeepInfra:"".concat(i,"deepinfra.png")},l=e=>{if(!e)return{logo:"",displayName:"-"};if("gemini"===e.toLowerCase()){let e="Google AI Studio";return{logo:o[e],displayName:e}}let t=Object.keys(r).find(t=>r[t].toLowerCase()===e.toLowerCase());if(!t)return{logo:"",displayName:e};let n=a[t];return{logo:o[n],displayName:n}},c=e=>{if("Vertex AI (Anthropic, Gemini, etc.)"===e)return"gemini-pro";if("Anthropic"==e||"Amazon Bedrock"==e)return"claude-3-opus";if("AWS SageMaker"==e)return"sagemaker/jumpstart-dft-meta-textgeneration-llama-2-7b";if("Google AI Studio"==e)return"gemini-pro";if("Azure AI Foundry (Studio)"==e)return"azure_ai/command-r-plus";if("Azure"==e)return"azure/my-deployment";else if("Voyage AI"==e)return"voyage/";else if("Jina AI"==e)return"jina_ai/";else if("VolcEngine"==e)return"volcengine/";else if("DeepInfra"==e)return"deepinfra/";else return"gpt-3.5-turbo"},d=(e,t)=>{console.log("Provider key: ".concat(e));let n=r[e];console.log("Provider mapped to: ".concat(n));let a=[];return e&&"object"==typeof t&&(Object.entries(t).forEach(e=>{let[t,s]=e;null!==s&&"object"==typeof s&&"litellm_provider"in s&&(s.litellm_provider===n||s.litellm_provider.includes(n))&&a.push(t)}),"Cohere"==e&&(console.log("Adding cohere chat models"),Object.entries(t).forEach(e=>{let[t,n]=e;null!==n&&"object"==typeof n&&"litellm_provider"in n&&"cohere_chat"===n.litellm_provider&&a.push(t)})),"AWS SageMaker"==e&&(console.log("Adding sagemaker chat models"),Object.entries(t).forEach(e=>{let[t,n]=e;null!==n&&"object"==typeof n&&"litellm_provider"in n&&"sagemaker_chat"===n.litellm_provider&&a.push(t)}))),a}},72162:function(e,t,n){var a=n(57437),s=n(2265),r=n(19250),i=n(8048),o=n(36724),l=n(42264),c=n(89970),d=n(3810),m=n(52787),p=n(82680),u=n(3477),g=n(17732),x=n(33245),h=n(78867),f=n(88658),_=n(49817),b=n(42673),v=n(65373);t.Z=e=>{var t,n;let{accessToken:j}=e,[y,N]=(0,s.useState)(null),[w,S]=(0,s.useState)("LiteLLM Gateway"),[A,I]=(0,s.useState)(null),[k,C]=(0,s.useState)(""),[E,O]=(0,s.useState)({}),[M,T]=(0,s.useState)(!0),[D,z]=(0,s.useState)(""),[P,L]=(0,s.useState)([]),[Z,G]=(0,s.useState)([]),[R,H]=(0,s.useState)([]),[F,K]=(0,s.useState)("I'm alive! ✓"),[U,V]=(0,s.useState)(!1),[W,q]=(0,s.useState)(null),[J,B]=(0,s.useState)({}),Y=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=async()=>{try{T(!0);let e=await (0,r.modelHubPublicModelsCall)();console.log("ModelHubData:",e),N(e)}catch(e){console.error("There was an error fetching the public model data",e),K("Service unavailable")}finally{T(!1)}};(async()=>{let e=await (0,r.getPublicModelHubInfo)();console.log("Public Model Hub Info:",e),S(e.docs_title),I(e.custom_docs_description),C(e.litellm_version),O(e.useful_links||{})})(),e()},[]),(0,s.useEffect)(()=>{},[D,P,Z,R]);let $=(0,s.useMemo)(()=>{if(!y)return[];let e=y;if(D.trim()){let t=D.toLowerCase(),n=t.split(/\s+/),a=y.filter(e=>{let a=e.model_group.toLowerCase();return!!a.includes(t)||n.every(e=>a.includes(e))});a.length>0&&(e=a.sort((e,n)=>{let a=e.model_group.toLowerCase(),s=n.model_group.toLowerCase(),r=a===t?1e3:0,i=s===t?1e3:0,o=a.startsWith(t)?100:0,l=s.startsWith(t)?100:0,c=t.split(/\s+/).every(e=>a.includes(e))?50:0,d=t.split(/\s+/).every(e=>s.includes(e))?50:0,m=a.length;return i+l+d+(1e3-s.length)-(r+o+c+(1e3-m))}))}return e.filter(e=>{let t=0===P.length||P.some(t=>e.providers.includes(t)),n=0===Z.length||Z.includes(e.mode||""),a=0===R.length||Object.entries(e).filter(e=>{let[t,n]=e;return t.startsWith("supports_")&&!0===n}).some(e=>{let[t]=e,n=t.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");return R.includes(n)});return t&&n&&a})},[y,D,P,Z,R]),X=e=>{q(e),V(!0)},Q=e=>{navigator.clipboard.writeText(e),l.ZP.success("Copied to clipboard!")},ee=e=>e.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),et=e=>Object.entries(e).filter(e=>{let[t,n]=e;return t.startsWith("supports_")&&!0===n}).map(e=>{let[t]=e;return t}),en=e=>"$".concat((1e6*e).toFixed(4)),ea=e=>e?e>=1e3?"".concat((e/1e3).toFixed(0),"K"):e.toString():"N/A",es=(e,t)=>{let n=[];return e&&n.push("RPM: ".concat(e.toLocaleString())),t&&n.push("TPM: ".concat(t.toLocaleString())),n.length>0?n.join(", "):"N/A"};return(0,a.jsxs)("div",{className:"min-h-screen bg-white",children:[(0,a.jsx)(v.Z,{userID:null,userEmail:null,userRole:null,premiumUser:!1,setProxySettings:B,proxySettings:J,accessToken:j||null,isPublicPage:!0}),(0,a.jsxs)("div",{className:"w-full px-8 py-12",children:[(0,a.jsxs)(o.Zb,{className:"mb-10 p-8 bg-white border border-gray-200 rounded-lg shadow-sm",children:[(0,a.jsx)(o.Dx,{className:"text-2xl font-semibold mb-6 text-gray-900",children:"About"}),(0,a.jsx)("p",{className:"text-gray-700 mb-6 text-base leading-relaxed",children:A||"Proxy Server to call 100+ LLMs in the OpenAI format."}),(0,a.jsx)("div",{className:"flex items-center space-x-3 text-sm text-gray-600",children:(0,a.jsxs)("span",{className:"flex items-center",children:[(0,a.jsx)("span",{className:"w-4 h-4 mr-2",children:"\uD83D\uDD27"}),"Built with litellm: v",k]})})]}),E&&Object.keys(E).length>0&&(0,a.jsxs)(o.Zb,{className:"mb-10 p-8 bg-white border border-gray-200 rounded-lg shadow-sm",children:[(0,a.jsx)(o.Dx,{className:"text-2xl font-semibold mb-6 text-gray-900",children:"Useful Links"}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Object.entries(E||{}).map(e=>{let[t,n]=e;return(0,a.jsxs)("button",{onClick:()=>window.open(n,"_blank"),className:"flex items-center space-x-3 text-blue-600 hover:text-blue-800 transition-colors p-3 rounded-lg hover:bg-blue-50 border border-gray-200",children:[(0,a.jsx)(u.Z,{className:"w-4 h-4"}),(0,a.jsx)(o.xv,{className:"text-sm font-medium",children:t})]},t)})})]}),(0,a.jsxs)(o.Zb,{className:"mb-10 p-8 bg-white border border-gray-200 rounded-lg shadow-sm",children:[(0,a.jsx)(o.Dx,{className:"text-2xl font-semibold mb-6 text-gray-900",children:"Health and Endpoint Status"}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:(0,a.jsxs)(o.xv,{className:"text-green-600 font-medium text-sm",children:["Service status: ",F]})})]}),(0,a.jsxs)(o.Zb,{className:"p-8 bg-white border border-gray-200 rounded-lg shadow-sm",children:[(0,a.jsx)("div",{className:"flex justify-between items-center mb-8",children:(0,a.jsx)(o.Dx,{className:"text-2xl font-semibold text-gray-900",children:"Available Models"})}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8 p-6 bg-gray-50 rounded-lg border border-gray-200",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2 mb-3",children:[(0,a.jsx)(o.xv,{className:"text-sm font-medium text-gray-700",children:"Search Models:"}),(0,a.jsx)(c.Z,{title:"Smart search with relevance ranking - finds models containing your search terms, ranked by relevance. Try searching 'xai grok-4', 'claude-4', 'gpt-4', or 'sonnet'",placement:"top",children:(0,a.jsx)(x.Z,{className:"w-4 h-4 text-gray-400 cursor-help"})})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(g.Z,{className:"w-4 h-4 text-gray-400 absolute left-3 top-1/2 transform -translate-y-1/2"}),(0,a.jsx)("input",{type:"text",placeholder:"Search model names... (smart search enabled)",value:D,onChange:e=>z(e.target.value),className:"border border-gray-300 rounded-lg pl-10 pr-4 py-2 w-full text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-sm font-medium mb-3 text-gray-700",children:"Provider:"}),(0,a.jsx)(m.default,{mode:"multiple",value:P,onChange:e=>L(e),placeholder:"Select providers",className:"w-full",size:"large",allowClear:!0,optionRender:e=>{let{logo:t}=(0,b.dr)(e.value);return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[t&&(0,a.jsx)("img",{src:t,alt:e.label,className:"w-5 h-5 flex-shrink-0 object-contain",onError:e=>{e.target.style.display="none"}}),(0,a.jsx)("span",{className:"capitalize",children:e.label})]})},children:y&&(e=>{let t=new Set;return e.forEach(e=>{e.providers.forEach(e=>t.add(e))}),Array.from(t)})(y).map(e=>(0,a.jsx)(m.default.Option,{value:e,children:e},e))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-sm font-medium mb-3 text-gray-700",children:"Mode:"}),(0,a.jsx)(m.default,{mode:"multiple",value:Z,onChange:e=>G(e),placeholder:"Select modes",className:"w-full",size:"large",allowClear:!0,children:y&&(e=>{let t=new Set;return e.forEach(e=>{e.mode&&t.add(e.mode)}),Array.from(t)})(y).map(e=>(0,a.jsx)(m.default.Option,{value:e,children:e},e))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-sm font-medium mb-3 text-gray-700",children:"Features:"}),(0,a.jsx)(m.default,{mode:"multiple",value:R,onChange:e=>H(e),placeholder:"Select features",className:"w-full",size:"large",allowClear:!0,children:y&&(e=>{let t=new Set;return e.forEach(e=>{Object.entries(e).filter(e=>{let[t,n]=e;return t.startsWith("supports_")&&!0===n}).forEach(e=>{let[n]=e,a=n.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.add(a)})}),Array.from(t).sort()})(y).map(e=>(0,a.jsx)(m.default.Option,{value:e,children:e},e))})]})]}),(0,a.jsx)(i.C,{columns:[{header:"Model Name",accessorKey:"model_group",enableSorting:!0,cell:e=>{let{row:t}=e;return(0,a.jsx)("div",{className:"overflow-hidden",children:(0,a.jsx)(c.Z,{title:t.original.model_group,children:(0,a.jsx)(o.zx,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left",onClick:()=>X(t.original),children:t.original.model_group})})})},size:150},{header:"Providers",accessorKey:"providers",enableSorting:!0,cell:e=>{let{row:t}=e,n=t.original.providers;return(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:n.map(e=>{let{logo:t}=(0,b.dr)(e);return(0,a.jsxs)("div",{className:"flex items-center space-x-1 px-2 py-1 bg-gray-100 rounded text-xs",children:[t&&(0,a.jsx)("img",{src:t,alt:e,className:"w-3 h-3 flex-shrink-0 object-contain",onError:e=>{e.target.style.display="none"}}),(0,a.jsx)("span",{className:"capitalize",children:e})]},e)})})},size:120},{header:"Mode",accessorKey:"mode",enableSorting:!0,cell:e=>{let{row:t}=e,n=t.original.mode;return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{children:(e=>{switch(null==e?void 0:e.toLowerCase()){case"chat":return"\uD83D\uDCAC";case"rerank":return"\uD83D\uDD04";case"embedding":return"\uD83D\uDCC4";default:return"\uD83E\uDD16"}})(n||"")}),(0,a.jsx)(o.xv,{children:n||"Chat"})]})},size:100},{header:"Max Input",accessorKey:"max_input_tokens",enableSorting:!0,cell:e=>{let{row:t}=e;return(0,a.jsx)(o.xv,{className:"text-center",children:ea(t.original.max_input_tokens)})},size:100,meta:{className:"text-center"}},{header:"Max Output",accessorKey:"max_output_tokens",enableSorting:!0,cell:e=>{let{row:t}=e;return(0,a.jsx)(o.xv,{className:"text-center",children:ea(t.original.max_output_tokens)})},size:100,meta:{className:"text-center"}},{header:"Input $/1M",accessorKey:"input_cost_per_token",enableSorting:!0,cell:e=>{let{row:t}=e,n=t.original.input_cost_per_token;return(0,a.jsx)(o.xv,{className:"text-center",children:n?en(n):"Free"})},size:100,meta:{className:"text-center"}},{header:"Output $/1M",accessorKey:"output_cost_per_token",enableSorting:!0,cell:e=>{let{row:t}=e,n=t.original.output_cost_per_token;return(0,a.jsx)(o.xv,{className:"text-center",children:n?en(n):"Free"})},size:100,meta:{className:"text-center"}},{header:"Features",accessorKey:"supports_vision",enableSorting:!1,cell:e=>{let{row:t}=e,n=Object.entries(t.original).filter(e=>{let[t,n]=e;return t.startsWith("supports_")&&!0===n}).map(e=>{let[t]=e;return ee(t)});return 0===n.length?(0,a.jsx)(o.xv,{className:"text-gray-400",children:"-"}):1===n.length?(0,a.jsx)("div",{className:"h-6 flex items-center",children:(0,a.jsx)(d.Z,{color:"blue",className:"text-xs",children:n[0]})}):(0,a.jsxs)("div",{className:"h-6 flex items-center space-x-1",children:[(0,a.jsx)(d.Z,{color:"blue",className:"text-xs",children:n[0]}),(0,a.jsx)(c.Z,{title:(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"font-medium",children:"All Features:"}),n.map((e,t)=>(0,a.jsxs)("div",{className:"text-xs",children:["• ",e]},t))]}),trigger:"click",placement:"topLeft",children:(0,a.jsxs)("span",{className:"text-xs text-blue-600 cursor-pointer hover:text-blue-800 hover:underline",onClick:e=>e.stopPropagation(),children:["+",n.length-1]})})]})},size:120},{header:"Limits",accessorKey:"rpm",enableSorting:!0,cell:e=>{let{row:t}=e,n=t.original;return(0,a.jsx)(o.xv,{className:"text-xs text-gray-600",children:es(n.rpm,n.tpm)})},size:150}],data:$,isLoading:M,table:Y,defaultSorting:[{id:"model_group",desc:!1}]}),(0,a.jsx)("div",{className:"mt-8 text-center",children:(0,a.jsxs)(o.xv,{className:"text-sm text-gray-600",children:["Showing ",$.length," of ",(null==y?void 0:y.length)||0," models"]})})]})]}),(0,a.jsx)(p.Z,{title:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{children:(null==W?void 0:W.model_group)||"Model Details"}),W&&(0,a.jsx)(c.Z,{title:"Copy model name",children:(0,a.jsx)(h.Z,{onClick:()=>Q(W.model_group),className:"cursor-pointer text-gray-500 hover:text-blue-500 w-4 h-4"})})]}),width:1e3,open:U,footer:null,onOk:()=>{V(!1),q(null)},onCancel:()=>{V(!1),q(null)},children:W&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Model Overview"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Model Name:"}),(0,a.jsx)(o.xv,{children:W.model_group})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Mode:"}),(0,a.jsx)(o.xv,{children:W.mode||"Not specified"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Providers:"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:W.providers.map(e=>{let{logo:t}=(0,b.dr)(e);return(0,a.jsx)(d.Z,{color:"blue",children:(0,a.jsxs)("div",{className:"flex items-center space-x-1",children:[t&&(0,a.jsx)("img",{src:t,alt:e,className:"w-3 h-3 flex-shrink-0 object-contain",onError:e=>{e.target.style.display="none"}}),(0,a.jsx)("span",{className:"capitalize",children:e})]})},e)})})]})]}),W.model_group.includes("*")&&(0,a.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 mb-4",children:(0,a.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,a.jsx)(x.Z,{className:"w-4 h-4 text-blue-600 mt-0.5 flex-shrink-0"}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium text-blue-900 mb-2",children:"Wildcard Routing"}),(0,a.jsxs)(o.xv,{className:"text-sm text-blue-800 mb-2",children:["This model uses wildcard routing. You can pass any value where you see the ",(0,a.jsx)("code",{className:"bg-blue-100 px-1 py-0.5 rounded text-xs",children:"*"})," symbol."]}),(0,a.jsxs)(o.xv,{className:"text-sm text-blue-800",children:["For example, with ",(0,a.jsx)("code",{className:"bg-blue-100 px-1 py-0.5 rounded text-xs",children:W.model_group}),", you can use any string (",(0,a.jsx)("code",{className:"bg-blue-100 px-1 py-0.5 rounded text-xs",children:W.model_group.replace("*","my-custom-value")}),") that matches this pattern."]})]})]})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Token & Cost Information"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Max Input Tokens:"}),(0,a.jsx)(o.xv,{children:(null===(t=W.max_input_tokens)||void 0===t?void 0:t.toLocaleString())||"Not specified"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Max Output Tokens:"}),(0,a.jsx)(o.xv,{children:(null===(n=W.max_output_tokens)||void 0===n?void 0:n.toLocaleString())||"Not specified"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Input Cost per 1M Tokens:"}),(0,a.jsx)(o.xv,{children:W.input_cost_per_token?en(W.input_cost_per_token):"Not specified"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Output Cost per 1M Tokens:"}),(0,a.jsx)(o.xv,{children:W.output_cost_per_token?en(W.output_cost_per_token):"Not specified"})]})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Capabilities"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:(()=>{let e=et(W),t=["green","blue","purple","orange","red","yellow"];return 0===e.length?(0,a.jsx)(o.xv,{className:"text-gray-500",children:"No special capabilities listed"}):e.map((e,n)=>(0,a.jsx)(d.Z,{color:t[n%t.length],children:ee(e)},e))})()})]}),(W.tpm||W.rpm)&&(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Rate Limits"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[W.tpm&&(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Tokens per Minute:"}),(0,a.jsx)(o.xv,{children:W.tpm.toLocaleString()})]}),W.rpm&&(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"font-medium",children:"Requests per Minute:"}),(0,a.jsx)(o.xv,{children:W.rpm.toLocaleString()})]})]})]}),W.supported_openai_params&&(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Supported OpenAI Parameters"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:W.supported_openai_params.map(e=>(0,a.jsx)(d.Z,{color:"green",children:e},e))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(o.xv,{className:"text-lg font-semibold mb-4",children:"Usage Example"}),(0,a.jsx)("div",{className:"bg-gray-900 text-gray-100 p-4 rounded-lg overflow-x-auto",children:(0,a.jsx)("pre",{className:"text-sm",children:(0,f.L)({apiKeySource:"custom",accessToken:null,apiKey:"your_api_key",inputMessage:"Hello, how are you?",chatHistory:[{role:"user",content:"Hello, how are you?",isImage:!1}],selectedTags:[],selectedVectorStores:[],selectedGuardrails:[],endpointType:(0,_.vf)(W.mode||"chat"),selectedModel:W.model_group,selectedSdk:"openai"})})}),(0,a.jsx)("div",{className:"mt-2 text-right",children:(0,a.jsx)("button",{onClick:()=>{Q((0,f.L)({apiKeySource:"custom",accessToken:null,apiKey:"your_api_key",inputMessage:"Hello, how are you?",chatHistory:[{role:"user",content:"Hello, how are you?",isImage:!1}],selectedTags:[],selectedVectorStores:[],selectedGuardrails:[],endpointType:(0,_.vf)(W.mode||"chat"),selectedModel:W.model_group,selectedSdk:"openai"}))},className:"text-sm text-blue-600 hover:text-blue-800 cursor-pointer",children:"Copy to clipboard"})})]})]})})]})}},69734:function(e,t,n){n.d(t,{F:function(){return o},f:function(){return l}});var a=n(57437),s=n(2265),r=n(19250);let i=(0,s.createContext)(void 0),o=()=>{let e=(0,s.useContext)(i);if(!e)throw Error("useTheme must be used within a ThemeProvider");return e},l=e=>{let{children:t,accessToken:n}=e,[o,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(async()=>{if(n)try{let t=(0,r.getProxyBaseUrl)(),a=await fetch(t?"".concat(t,"/get/ui_theme_settings"):"/get/ui_theme_settings",{method:"GET",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(a.ok){var e;let t=await a.json();(null===(e=t.values)||void 0===e?void 0:e.logo_url)&&l(t.values.logo_url)}}catch(e){console.warn("Failed to load logo settings from backend:",e)}})()},[n]),(0,a.jsx)(i.Provider,{value:{logoUrl:o,setLogoUrl:l},children:t})}}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/172-0f7049c565983c4d.js b/litellm/proxy/_experimental/out/_next/static/chunks/172-0f7049c565983c4d.js new file mode 100644 index 00000000000..65e0c151dc5 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/172-0f7049c565983c4d.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[172],{57018:function(e,s,l){l.d(s,{Ct:function(){return t.Z},Dx:function(){return i.Z},Zb:function(){return r.Z},xv:function(){return n.Z},zx:function(){return a.Z}});var t=l(41649),a=l(20831),r=l(12514),n=l(84264),i=l(96761)},95704:function(e,s,l){l.d(s,{Dx:function(){return x.Z},RM:function(){return r.Z},SC:function(){return o.Z},Zb:function(){return t.Z},iA:function(){return a.Z},pj:function(){return n.Z},ss:function(){return i.Z},xs:function(){return c.Z},xv:function(){return d.Z}});var t=l(12514),a=l(21626),r=l(97214),n=l(28241),i=l(58834),c=l(69552),o=l(71876),d=l(84264),x=l(96761)},36172:function(e,s,l){l.d(s,{Z:function(){return D}});var t=l(57437),a=l(2265),r=l(99376),n=l(19250),i=l(8048),c=l(41649),o=l(20831),d=l(84264),x=l(89970),m=l(3810),u=l(23639),p=l(15424);let h=e=>e.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),g=e=>Object.entries(e).filter(e=>{let[s,l]=e;return s.startsWith("supports_")&&!0===l}).map(e=>{let[s]=e;return s}),j=e=>"$".concat((1e6*e).toFixed(2)),b=e=>e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):e.toString(),v=function(e,s){let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=[{header:"Public Model Name",accessorKey:"model_group",enableSorting:!0,sortingFn:"alphanumeric",cell:e=>{let{row:l}=e,a=l.original;return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(d.Z,{className:"font-medium text-sm",children:a.model_group}),(0,t.jsx)(x.Z,{title:"Copy model name",children:(0,t.jsx)(u.Z,{onClick:()=>s(a.model_group),className:"cursor-pointer text-gray-500 hover:text-blue-500 text-xs"})})]}),(0,t.jsx)("div",{className:"md:hidden",children:(0,t.jsx)(d.Z,{className:"text-xs text-gray-600",children:a.providers.join(", ")})})]})}},{header:"Provider",accessorKey:"providers",enableSorting:!0,sortingFn:(e,s)=>{let l=e.original.providers.join(", "),t=s.original.providers.join(", ");return l.localeCompare(t)},cell:e=>{let{row:s}=e,l=s.original;return(0,t.jsxs)("div",{className:"flex flex-wrap gap-1",children:[l.providers.slice(0,2).map(e=>(0,t.jsx)(m.Z,{color:"blue",className:"text-xs",children:e},e)),l.providers.length>2&&(0,t.jsxs)(d.Z,{className:"text-xs text-gray-500",children:["+",l.providers.length-2]})]})},meta:{className:"hidden md:table-cell"}},{header:"Mode",accessorKey:"mode",enableSorting:!0,sortingFn:"alphanumeric",cell:e=>{let{row:s}=e,l=s.original;return l.mode?(0,t.jsx)(c.Z,{color:"green",size:"sm",children:l.mode}):(0,t.jsx)(d.Z,{className:"text-gray-500",children:"-"})},meta:{className:"hidden lg:table-cell"}},{header:"Tokens",accessorKey:"max_input_tokens",enableSorting:!0,sortingFn:(e,s)=>(e.original.max_input_tokens||0)+(e.original.max_output_tokens||0)-((s.original.max_input_tokens||0)+(s.original.max_output_tokens||0)),cell:e=>{let{row:s}=e,l=s.original;return(0,t.jsx)("div",{className:"space-y-1",children:(0,t.jsxs)(d.Z,{className:"text-xs",children:[l.max_input_tokens?b(l.max_input_tokens):"-"," / ",l.max_output_tokens?b(l.max_output_tokens):"-"]})})},meta:{className:"hidden lg:table-cell"}},{header:"Cost/1M",accessorKey:"input_cost_per_token",enableSorting:!0,sortingFn:(e,s)=>(e.original.input_cost_per_token||0)+(e.original.output_cost_per_token||0)-((s.original.input_cost_per_token||0)+(s.original.output_cost_per_token||0)),cell:e=>{let{row:s}=e,l=s.original;return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(d.Z,{className:"text-xs",children:l.input_cost_per_token?j(l.input_cost_per_token):"-"}),(0,t.jsx)(d.Z,{className:"text-xs text-gray-500",children:l.output_cost_per_token?j(l.output_cost_per_token):"-"})]})}},{header:"Features",accessorKey:"capabilities",enableSorting:!1,cell:e=>{let{row:s}=e,l=g(s.original),a=["green","blue","purple","orange","red","yellow"];return(0,t.jsx)("div",{className:"flex flex-wrap gap-1",children:0===l.length?(0,t.jsx)(d.Z,{className:"text-gray-500 text-xs",children:"-"}):l.map((e,s)=>(0,t.jsx)(c.Z,{color:a[s%a.length],size:"xs",children:h(e)},e))})}},{header:"Public",accessorKey:"is_public_model_group",enableSorting:!0,sortingFn:(e,s)=>(!0===e.original.is_public_model_group?1:0)-(!0===s.original.is_public_model_group?1:0),cell:e=>{let{row:s}=e;return!0===s.original.is_public_model_group?(0,t.jsx)(c.Z,{color:"green",size:"xs",children:"Yes"}):(0,t.jsx)(c.Z,{color:"gray",size:"xs",children:"No"})},meta:{className:"hidden md:table-cell"}},{header:"Details",id:"details",enableSorting:!1,cell:s=>{let{row:l}=s,a=l.original;return(0,t.jsxs)(o.Z,{size:"xs",variant:"secondary",onClick:()=>e(a),icon:p.Z,children:[(0,t.jsx)("span",{className:"hidden lg:inline",children:"Details"}),(0,t.jsx)("span",{className:"lg:hidden",children:"Info"})]})}}];return l?a.filter(e=>!("accessorKey"in e)||"is_public_model_group"!==e.accessorKey):a};var f=l(72162),y=l(91810),N=l(13634),_=l(61994),k=l(73002),w=l(82680),Z=l(96761),C=l(12514),S=e=>{let{modelHubData:s,onFilteredDataChange:l,showFiltersCard:r=!0,className:n=""}=e,[i,c]=(0,a.useState)(""),[o,x]=(0,a.useState)(""),[m,u]=(0,a.useState)(""),[p,h]=(0,a.useState)(""),g=(0,a.useRef)([]),j=(0,a.useMemo)(()=>(null==s?void 0:s.filter(e=>{let s=e.model_group.toLowerCase().includes(i.toLowerCase()),l=""===o||e.providers.includes(o),t=""===m||e.mode===m,a=""===p||Object.entries(e).filter(e=>{let[s,l]=e;return s.startsWith("supports_")&&!0===l}).some(e=>{let[s]=e;return s.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")===p});return s&&l&&t&&a}))||[],[s,i,o,m,p]);(0,a.useEffect)(()=>{(j.length!==g.current.length||j.some((e,s)=>{var l;return e.model_group!==(null===(l=g.current[s])||void 0===l?void 0:l.model_group)}))&&(g.current=j,l(j))},[j,l]);let b=(0,t.jsxs)("div",{className:"flex flex-wrap gap-4 items-center",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(d.Z,{className:"text-sm font-medium mb-2",children:"Search Models:"}),(0,t.jsx)("input",{type:"text",placeholder:"Search model names...",value:i,onChange:e=>c(e.target.value),className:"border rounded px-3 py-2 w-64 h-10 text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(d.Z,{className:"text-sm font-medium mb-2",children:"Provider:"}),(0,t.jsxs)("select",{value:o,onChange:e=>x(e.target.value),className:"border rounded px-3 py-2 text-sm text-gray-600 w-40 h-10",children:[(0,t.jsx)("option",{value:"",className:"text-sm text-gray-600",children:"All Providers"}),s&&(e=>{let s=new Set;return e.forEach(e=>{e.providers.forEach(e=>s.add(e))}),Array.from(s)})(s).map(e=>(0,t.jsx)("option",{value:e,className:"text-sm text-gray-800",children:e},e))]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(d.Z,{className:"text-sm font-medium mb-2",children:"Mode:"}),(0,t.jsxs)("select",{value:m,onChange:e=>u(e.target.value),className:"border rounded px-3 py-2 text-sm text-gray-600 w-32 h-10",children:[(0,t.jsx)("option",{value:"",className:"text-sm text-gray-600",children:"All Modes"}),s&&(e=>{let s=new Set;return e.forEach(e=>{e.mode&&s.add(e.mode)}),Array.from(s)})(s).map(e=>(0,t.jsx)("option",{value:e,className:"text-sm text-gray-800",children:e},e))]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(d.Z,{className:"text-sm font-medium mb-2",children:"Features:"}),(0,t.jsxs)("select",{value:p,onChange:e=>h(e.target.value),className:"border rounded px-3 py-2 text-sm text-gray-600 w-48 h-10",children:[(0,t.jsx)("option",{value:"",className:"text-sm text-gray-600",children:"All Features"}),s&&(e=>{let s=new Set;return e.forEach(e=>{Object.entries(e).filter(e=>{let[s,l]=e;return s.startsWith("supports_")&&!0===l}).forEach(e=>{let[l]=e,t=l.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");s.add(t)})}),Array.from(s).sort()})(s).map(e=>(0,t.jsx)("option",{value:e,className:"text-sm text-gray-800",children:e},e))]})]}),(i||o||m||p)&&(0,t.jsx)("div",{className:"flex items-end",children:(0,t.jsx)("button",{onClick:()=>{c(""),x(""),u(""),h("")},className:"text-blue-600 hover:text-blue-800 text-sm underline h-10 flex items-center",children:"Clear Filters"})})]});return r?(0,t.jsx)(C.Z,{className:"mb-6 ".concat(n),children:b}):(0,t.jsx)("div",{className:n,children:b})},M=l(9114);let{Step:P}=y.default;var L=e=>{let{visible:s,onClose:l,accessToken:r,modelHubData:i,onSuccess:o}=e,[x,m]=(0,a.useState)(0),[u,p]=(0,a.useState)(new Set),[h,g]=(0,a.useState)([]),[j,b]=(0,a.useState)(!1),[v]=N.Z.useForm(),f=()=>{m(0),p(new Set),g([]),v.resetFields(),l()},C=(e,s)=>{let l=new Set(u);s?l.add(e):l.delete(e),p(l)},L=e=>{e?p(new Set(h.map(e=>e.model_group))):p(new Set)},A=(0,a.useCallback)(e=>{g(e)},[]);(0,a.useEffect)(()=>{s&&i.length>0&&(g(i),p(new Set(i.filter(e=>!0===e.is_public_model_group).map(e=>e.model_group))))},[s,i]);let F=async()=>{if(0===u.size){M.Z.fromBackend("Please select at least one model to make public");return}b(!0);try{let e=Array.from(u);await (0,n.makeModelGroupPublic)(r,e),M.Z.success("Successfully made ".concat(e.length," model group(s) public!")),f(),o()}catch(e){console.error("Error making model groups public:",e),M.Z.fromBackend("Failed to make model groups public. Please try again.")}finally{b(!1)}},U=()=>{let e=h.length>0&&h.every(e=>u.has(e.model_group)),s=u.size>0&&!e;return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)(Z.Z,{children:"Select Models to Make Public"}),(0,t.jsx)("div",{className:"flex items-center space-x-2",children:(0,t.jsxs)(_.Z,{checked:e,indeterminate:s,onChange:e=>L(e.target.checked),disabled:0===h.length,children:["Select All ",h.length>0&&"(".concat(h.length,")")]})})]}),(0,t.jsx)(d.Z,{className:"text-sm text-gray-600",children:"Select the models you want to be visible on the public model hub. Users will still require a valid API key to use these models."}),(0,t.jsx)(S,{modelHubData:i,onFilteredDataChange:A,showFiltersCard:!1,className:"border rounded-lg p-4 bg-gray-50"}),(0,t.jsx)("div",{className:"max-h-96 overflow-y-auto border rounded-lg p-4",children:(0,t.jsx)("div",{className:"space-y-3",children:0===h.length?(0,t.jsx)("div",{className:"text-center py-8 text-gray-500",children:(0,t.jsx)(d.Z,{children:"No models match the current filters."})}):h.map(e=>(0,t.jsxs)("div",{className:"flex items-center space-x-3 p-3 border rounded-lg hover:bg-gray-50",children:[(0,t.jsx)(_.Z,{checked:u.has(e.model_group),onChange:s=>C(e.model_group,s.target.checked)}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(d.Z,{className:"font-medium",children:e.model_group}),e.mode&&(0,t.jsx)(c.Z,{color:"green",size:"sm",children:e.mode})]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:e.providers.map(e=>(0,t.jsx)(c.Z,{color:"blue",size:"xs",children:e},e))})]})]},e.model_group))})}),u.size>0&&(0,t.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3",children:(0,t.jsxs)(d.Z,{className:"text-sm text-blue-800",children:[(0,t.jsx)("strong",{children:u.size})," model",1!==u.size?"s":""," selected"]})})]})},z=()=>(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(Z.Z,{children:"Confirm Making Models Public"}),(0,t.jsx)("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4",children:(0,t.jsxs)(d.Z,{className:"text-sm text-yellow-800",children:[(0,t.jsx)("strong",{children:"Warning:"})," Once you make these models public, anyone who can go to the ",(0,t.jsx)("code",{children:"/ui/model_hub_table"})," will be able to know they exist on the proxy."]})}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(d.Z,{className:"font-medium",children:"Models to be made public:"}),(0,t.jsx)("div",{className:"max-h-48 overflow-y-auto border rounded-lg p-3",children:(0,t.jsx)("div",{className:"space-y-2",children:Array.from(u).map(e=>{let s=i.find(s=>s.model_group===e);return(0,t.jsx)("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:(0,t.jsxs)("div",{children:[(0,t.jsx)(d.Z,{className:"font-medium",children:e}),s&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:s.providers.map(e=>(0,t.jsx)(c.Z,{color:"blue",size:"xs",children:e},e))})]})},e)})})})]}),(0,t.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3",children:(0,t.jsxs)(d.Z,{className:"text-sm text-blue-800",children:["Total: ",(0,t.jsx)("strong",{children:u.size})," model",1!==u.size?"s":""," will be made public"]})})]});return(0,t.jsx)(w.Z,{title:"Make Models Public",open:s,onCancel:f,footer:null,width:1200,maskClosable:!1,children:(0,t.jsxs)(N.Z,{form:v,layout:"vertical",children:[(0,t.jsxs)(y.default,{current:x,className:"mb-6",children:[(0,t.jsx)(P,{title:"Select Models"}),(0,t.jsx)(P,{title:"Confirm"})]}),(()=>{switch(x){case 0:return U();case 1:return z();default:return null}})(),(0,t.jsxs)("div",{className:"flex justify-between mt-6",children:[(0,t.jsx)(k.ZP,{onClick:0===x?f:()=>{1===x&&m(0)},children:0===x?"Cancel":"Previous"}),(0,t.jsxs)("div",{className:"flex space-x-2",children:[0===x&&(0,t.jsx)(k.ZP,{onClick:()=>{if(0===x){if(0===u.size){M.Z.fromBackend("Please select at least one model to make public");return}m(1)}},disabled:0===u.size,children:"Next"}),1===x&&(0,t.jsx)(k.ZP,{onClick:F,loading:j,children:"Make Public"})]})]})]})})},A=l(69870),F=l(57018),U=l(17906),z=l(78867),E=l(20347),D=e=>{var s,l;let{accessToken:c,publicPage:o,premiumUser:d,userRole:x}=e,[m,u]=(0,a.useState)(!1),[p,h]=(0,a.useState)(null),[g,j]=(0,a.useState)(!0),[b,y]=(0,a.useState)(!1),[N,_]=(0,a.useState)(!1),[k,Z]=(0,a.useState)(null),[C,P]=(0,a.useState)([]),[D,R]=(0,a.useState)(!1),H=(0,r.useRouter)(),O=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=async e=>{try{j(!0);let s=await (0,n.modelHubCall)(e);console.log("ModelHubData:",s),h(s.data),(0,n.getConfigFieldSetting)(e,"enable_public_model_hub").then(e=>{console.log("data: ".concat(JSON.stringify(e))),!0==e.field_value&&u(!0)}).catch(e=>{})}catch(e){console.error("There was an error fetching the model data",e)}finally{j(!1)}},s=async()=>{try{var e,s;j(!0);let l=await (0,n.modelHubPublicModelsCall)();console.log("ModelHubData:",l),console.log("First model structure:",l[0]),console.log("Model has model_group?",null===(e=l[0])||void 0===e?void 0:e.model_group),console.log("Model has providers?",null===(s=l[0])||void 0===s?void 0:s.providers),h(l),u(!0)}catch(e){console.error("There was an error fetching the public model data",e)}finally{j(!1)}};c?e(c):o&&s()},[c,o]);let T=()=>{c&&R(!0)},B=()=>{y(!1),_(!1),Z(null)},I=()=>{y(!1),_(!1),Z(null)},K=e=>{navigator.clipboard.writeText(e),M.Z.success("Copied to clipboard!")},Y=e=>e.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),W=e=>Object.entries(e).filter(e=>{let[s,l]=e;return s.startsWith("supports_")&&!0===l}).map(e=>{let[s]=e;return s}),V=e=>"$".concat((1e6*e).toFixed(2)),q=(0,a.useCallback)(e=>{P(e)},[]);return(console.log("publicPage: ",o),console.log("publicPageAllowed: ",m),o&&m)?(0,t.jsx)(f.Z,{accessToken:c}):(0,t.jsxs)("div",{className:"w-full mx-4 h-[75vh]",children:[!1==o?(0,t.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,t.jsxs)("div",{className:"flex flex-col items-start",children:[(0,t.jsx)(F.Dx,{className:"text-center",children:"Model Hub"}),(0,E.tY)(x||"")?(0,t.jsx)("p",{className:"text-sm text-gray-600",children:"Make models public for developers to know what models are available on the proxy."}):(0,t.jsx)("p",{className:"text-sm text-gray-600",children:"A list of all public model names personally available to you."})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,t.jsx)(F.xv,{children:"Model Hub URL:"}),(0,t.jsxs)("div",{className:"flex items-center bg-gray-200 px-2 py-1 rounded",children:[(0,t.jsx)(F.xv,{className:"mr-2",children:"".concat((0,n.getProxyBaseUrl)(),"/ui/model_hub_table")}),(0,t.jsx)("button",{onClick:()=>K("".concat((0,n.getProxyBaseUrl)(),"/ui/model_hub_table")),className:"p-1 hover:bg-gray-300 rounded transition-colors",title:"Copy URL",children:(0,t.jsx)(z.Z,{size:16,className:"text-gray-600"})})]}),!1==o&&(0,E.tY)(x||"")&&(0,t.jsx)(F.zx,{className:"ml-4",onClick:()=>T(),children:"Make Public"})]})]}),(0,E.tY)(x||"")&&(0,t.jsx)("div",{className:"mt-8 mb-2",children:(0,t.jsx)(A.Z,{accessToken:c,userRole:x})}),(0,t.jsxs)(F.Zb,{children:[(0,t.jsx)(S,{modelHubData:p||[],onFilteredDataChange:q}),(0,t.jsx)(i.C,{columns:v(e=>{Z(e),y(!0)},K,o),data:C,isLoading:g,table:O,defaultSorting:[{id:"model_group",desc:!1}]})]}),(0,t.jsx)("div",{className:"mt-4 text-center space-y-2",children:(0,t.jsxs)(F.xv,{className:"text-sm text-gray-600",children:["Showing ",C.length," of ",(null==p?void 0:p.length)||0," models"]})})]}):(0,t.jsxs)(F.Zb,{className:"mx-auto max-w-xl mt-10",children:[(0,t.jsx)(F.xv,{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)(w.Z,{title:"Public Model Hub",width:600,visible:N,footer:null,onOk:B,onCancel:I,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)(F.xv,{className:"text-base mr-2",children:"Shareable Link:"}),(0,t.jsx)(F.xv,{className:"max-w-sm ml-2 bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center rounded",children:"".concat((0,n.getProxyBaseUrl)(),"/ui/model_hub_table")})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(F.zx,{onClick:()=>{H.replace("/model_hub_table?key=".concat(c))},children:"See Page"})})]})}),(0,t.jsx)(w.Z,{title:(null==k?void 0:k.model_group)||"Model Details",width:1e3,visible:b,footer:null,onOk:B,onCancel:I,children:k&&(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Model Overview"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Model Group:"}),(0,t.jsx)(F.xv,{children:k.model_group})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Mode:"}),(0,t.jsx)(F.xv,{children:k.mode||"Not specified"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Providers:"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:k.providers.map(e=>(0,t.jsx)(F.Ct,{color:"blue",children:e},e))})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Token & Cost Information"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Max Input Tokens:"}),(0,t.jsx)(F.xv,{children:(null===(s=k.max_input_tokens)||void 0===s?void 0:s.toLocaleString())||"Not specified"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Max Output Tokens:"}),(0,t.jsx)(F.xv,{children:(null===(l=k.max_output_tokens)||void 0===l?void 0:l.toLocaleString())||"Not specified"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Input Cost per 1M Tokens:"}),(0,t.jsx)(F.xv,{children:k.input_cost_per_token?V(k.input_cost_per_token):"Not specified"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Output Cost per 1M Tokens:"}),(0,t.jsx)(F.xv,{children:k.output_cost_per_token?V(k.output_cost_per_token):"Not specified"})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Capabilities"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:(()=>{let e=W(k),s=["green","blue","purple","orange","red","yellow"];return 0===e.length?(0,t.jsx)(F.xv,{className:"text-gray-500",children:"No special capabilities listed"}):e.map((e,l)=>(0,t.jsx)(F.Ct,{color:s[l%s.length],children:Y(e)},e))})()})]}),(k.tpm||k.rpm)&&(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Rate Limits"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[k.tpm&&(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Tokens per Minute:"}),(0,t.jsx)(F.xv,{children:k.tpm.toLocaleString()})]}),k.rpm&&(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Requests per Minute:"}),(0,t.jsx)(F.xv,{children:k.rpm.toLocaleString()})]})]})]}),k.supported_openai_params&&(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Supported OpenAI Parameters"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:k.supported_openai_params.map(e=>(0,t.jsx)(F.Ct,{color:"green",children:e},e))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Usage Example"}),(0,t.jsx)(U.Z,{language:"python",className:"text-sm",children:'import openai\n\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # Your LiteLLM Proxy URL\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(k.model_group,'",\n messages=[\n {\n "role": "user",\n "content": "Hello, how are you?"\n }\n ]\n)\n\nprint(response.choices[0].message.content)')})]})]})}),(0,t.jsx)(L,{visible:D,onClose:()=>R(!1),accessToken:c||"",modelHubData:p||[],onSuccess:()=>{c&&(async()=>{try{let e=await (0,n.modelHubCall)(c);h(e.data)}catch(e){console.error("Error refreshing model data:",e)}})()}})]})}},69870:function(e,s,l){var t=l(57437),a=l(2265),r=l(82680),n=l(86462),i=l(47686),c=l(77355),o=l(93416),d=l(74998),x=l(20347),m=l(19250),u=l(95704),p=l(9114);s.Z=e=>{let{accessToken:s,userRole:l}=e,[h,g]=(0,a.useState)([]),[j,b]=(0,a.useState)({url:"",displayName:""}),[v,f]=(0,a.useState)(null),[y,N]=(0,a.useState)(!1),[_,k]=(0,a.useState)(!0),w=async()=>{if(s)try{N(!0);let e=await (0,m.getPublicModelHubInfo)();if(e&&e.useful_links){let s=e.useful_links||{},l=Object.entries(s).map((e,s)=>{let[l,t]=e;return{id:"".concat(s,"-").concat(l),displayName:l,url:t}});g(l)}else g([])}catch(e){console.error("Error fetching useful links:",e),g([])}finally{N(!1)}};if((0,a.useEffect)(()=>{w()},[s]),!(0,x.tY)(l||""))return null;let Z=async e=>{if(!s)return!1;try{let l={};return e.forEach(e=>{l[e.displayName]=e.url}),await (0,m.updateUsefulLinksCall)(s,l),r.Z.success({title:"Links Saved Successfully",content:(0,t.jsxs)("div",{className:"py-4",children:[(0,t.jsx)("p",{className:"text-gray-600 mb-4",children:"Your useful links have been saved and are now visible on the public model hub."}),(0,t.jsxs)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[(0,t.jsx)("p",{className:"text-sm text-blue-800 mb-2 font-medium",children:"View your updated model hub:"}),(0,t.jsx)("a",{href:"".concat((0,m.getProxyBaseUrl)(),"/ui/model_hub_table"),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-blue-600 hover:text-blue-800 underline text-sm font-medium",children:"Open Public Model Hub →"})]})]}),width:500,okText:"Close",maskClosable:!0,keyboard:!0}),!0}catch(e){return console.error("Error saving links:",e),p.Z.fromBackend("Failed to save links - ".concat(e)),!1}},C=async()=>{if(!j.url||!j.displayName)return;try{new URL(j.url)}catch(e){p.Z.fromBackend("Please enter a valid URL");return}if(h.some(e=>e.displayName===j.displayName)){p.Z.fromBackend("A link with this display name already exists");return}let e=[...h,{id:"".concat(Date.now(),"-").concat(j.displayName),displayName:j.displayName,url:j.url}];await Z(e)&&(g(e),b({url:"",displayName:""}),p.Z.success("Link added successfully"))},S=e=>{f({...e})},M=async()=>{if(!v)return;try{new URL(v.url)}catch(e){p.Z.fromBackend("Please enter a valid URL");return}if(h.some(e=>e.id!==v.id&&e.displayName===v.displayName)){p.Z.fromBackend("A link with this display name already exists");return}let e=h.map(e=>e.id===v.id?v:e);await Z(e)&&(g(e),f(null),p.Z.success("Link updated successfully"))},P=()=>{f(null)},L=async e=>{let s=h.filter(s=>s.id!==e);await Z(s)&&(g(s),p.Z.success("Link deleted successfully"))},A=e=>{window.open(e,"_blank")};return(0,t.jsxs)(u.Zb,{className:"mb-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>k(!_),children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)(u.Dx,{className:"mb-0",children:"Link Management"}),(0,t.jsx)("p",{className:"text-sm text-gray-500",children:"Manage the links that are displayed under 'Useful Links' on the public model hub."})]}),(0,t.jsx)("div",{className:"flex items-center",children:_?(0,t.jsx)(n.Z,{className:"w-5 h-5 text-gray-500"}):(0,t.jsx)(i.Z,{className:"w-5 h-5 text-gray-500"})})]}),_&&(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsx)(u.xv,{className:"text-sm font-medium text-gray-700 mb-2",children:"Add New Link"}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"URL"}),(0,t.jsx)("input",{type:"text",value:j.url,onChange:e=>b({...j,url:e.target.value}),placeholder:"https://example.com",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"Display Name"}),(0,t.jsx)("input",{type:"text",value:j.displayName,onChange:e=>b({...j,displayName:e.target.value}),placeholder:"Friendly name",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),(0,t.jsx)("div",{className:"flex items-end",children:(0,t.jsxs)("button",{onClick:C,disabled:!j.url||!j.displayName,className:"flex items-center px-4 py-2 rounded-md text-sm ".concat(j.url&&j.displayName?"bg-green-600 text-white hover:bg-green-700":"bg-gray-300 text-gray-500 cursor-not-allowed"),children:[(0,t.jsx)(c.Z,{className:"w-4 h-4 mr-1"}),"Add Link"]})})]})]}),(0,t.jsx)(u.xv,{className:"text-sm font-medium text-gray-700 mb-2",children:"Manage Existing Links"}),(0,t.jsx)("div",{className:"rounded-lg custom-border relative",children:(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)(u.iA,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,t.jsx)(u.ss,{children:(0,t.jsxs)(u.SC,{children:[(0,t.jsx)(u.xs,{className:"py-1 h-8",children:"Display Name"}),(0,t.jsx)(u.xs,{className:"py-1 h-8",children:"URL"}),(0,t.jsx)(u.xs,{className:"py-1 h-8",children:"Actions"})]})}),(0,t.jsxs)(u.RM,{children:[h.map(e=>(0,t.jsx)(u.SC,{className:"h-8",children:v&&v.id===e.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.pj,{className:"py-0.5",children:(0,t.jsx)("input",{type:"text",value:v.displayName,onChange:e=>f({...v,displayName:e.target.value}),className:"w-full px-2 py-1 border border-gray-300 rounded-md text-sm"})}),(0,t.jsx)(u.pj,{className:"py-0.5",children:(0,t.jsx)("input",{type:"text",value:v.url,onChange:e=>f({...v,url:e.target.value}),className:"w-full px-2 py-1 border border-gray-300 rounded-md text-sm"})}),(0,t.jsx)(u.pj,{className:"py-0.5 whitespace-nowrap",children:(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)("button",{onClick:M,className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:"Save"}),(0,t.jsx)("button",{onClick:P,className:"text-xs bg-gray-50 text-gray-600 px-2 py-1 rounded hover:bg-gray-100",children:"Cancel"})]})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.pj,{className:"py-0.5 text-sm text-gray-900",children:e.displayName}),(0,t.jsx)(u.pj,{className:"py-0.5 text-sm text-gray-500",children:e.url}),(0,t.jsx)(u.pj,{className:"py-0.5 whitespace-nowrap",children:(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)("button",{onClick:()=>A(e.url),className:"text-xs bg-green-50 text-green-600 px-2 py-1 rounded hover:bg-green-100",children:"Use"}),(0,t.jsx)("button",{onClick:()=>S(e),className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:(0,t.jsx)(o.Z,{className:"w-3 h-3"})}),(0,t.jsx)("button",{onClick:()=>L(e.id),className:"text-xs bg-red-50 text-red-600 px-2 py-1 rounded hover:bg-red-100",children:(0,t.jsx)(d.Z,{className:"w-3 h-3"})})]})})]})},e.id)),0===h.length&&(0,t.jsx)(u.SC,{children:(0,t.jsx)(u.pj,{colSpan:3,className:"py-0.5 text-sm text-gray-500 text-center",children:"No links added yet. Add a new link above."})})]})]})})})]})]})}},20347:function(e,s,l){l.d(s,{LQ:function(){return r},ZL:function(){return t},lo:function(){return a},tY:function(){return n}});let t=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],a=["Internal User","Internal Viewer"],r=["Internal User","Admin"],n=e=>t.includes(e)}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/172-25e8f67ccf021150.js b/litellm/proxy/_experimental/out/_next/static/chunks/172-25e8f67ccf021150.js deleted file mode 100644 index 28e153daca4..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/172-25e8f67ccf021150.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[172],{57018:function(e,s,l){l.d(s,{Ct:function(){return t.Z},Dx:function(){return i.Z},Zb:function(){return a.Z},xv:function(){return n.Z},zx:function(){return r.Z}});var t=l(41649),r=l(20831),a=l(12514),n=l(84264),i=l(96761)},95704:function(e,s,l){l.d(s,{Dx:function(){return x.Z},RM:function(){return a.Z},SC:function(){return o.Z},Zb:function(){return t.Z},iA:function(){return r.Z},pj:function(){return n.Z},ss:function(){return i.Z},xs:function(){return c.Z},xv:function(){return d.Z}});var t=l(12514),r=l(21626),a=l(97214),n=l(28241),i=l(58834),c=l(69552),o=l(71876),d=l(84264),x=l(96761)},36172:function(e,s,l){l.d(s,{Z:function(){return D}});var t=l(57437),r=l(2265),a=l(99376),n=l(19250),i=l(8048),c=l(41649),o=l(20831),d=l(84264),x=l(89970),m=l(3810),u=l(23639),p=l(15424);let h=e=>e.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),g=e=>Object.entries(e).filter(e=>{let[s,l]=e;return s.startsWith("supports_")&&!0===l}).map(e=>{let[s]=e;return s}),j=e=>"$".concat((1e6*e).toFixed(2)),b=e=>e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):e.toString(),v=function(e,s){let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[{header:"Public Model Name",accessorKey:"model_group",enableSorting:!0,sortingFn:"alphanumeric",cell:e=>{let{row:l}=e,r=l.original;return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(d.Z,{className:"font-medium text-sm",children:r.model_group}),(0,t.jsx)(x.Z,{title:"Copy model name",children:(0,t.jsx)(u.Z,{onClick:()=>s(r.model_group),className:"cursor-pointer text-gray-500 hover:text-blue-500 text-xs"})})]}),(0,t.jsx)("div",{className:"md:hidden",children:(0,t.jsx)(d.Z,{className:"text-xs text-gray-600",children:r.providers.join(", ")})})]})}},{header:"Provider",accessorKey:"providers",enableSorting:!0,sortingFn:(e,s)=>{let l=e.original.providers.join(", "),t=s.original.providers.join(", ");return l.localeCompare(t)},cell:e=>{let{row:s}=e,l=s.original;return(0,t.jsxs)("div",{className:"flex flex-wrap gap-1",children:[l.providers.slice(0,2).map(e=>(0,t.jsx)(m.Z,{color:"blue",className:"text-xs",children:e},e)),l.providers.length>2&&(0,t.jsxs)(d.Z,{className:"text-xs text-gray-500",children:["+",l.providers.length-2]})]})},meta:{className:"hidden md:table-cell"}},{header:"Mode",accessorKey:"mode",enableSorting:!0,sortingFn:"alphanumeric",cell:e=>{let{row:s}=e,l=s.original;return l.mode?(0,t.jsx)(c.Z,{color:"green",size:"sm",children:l.mode}):(0,t.jsx)(d.Z,{className:"text-gray-500",children:"-"})},meta:{className:"hidden lg:table-cell"}},{header:"Tokens",accessorKey:"max_input_tokens",enableSorting:!0,sortingFn:(e,s)=>(e.original.max_input_tokens||0)+(e.original.max_output_tokens||0)-((s.original.max_input_tokens||0)+(s.original.max_output_tokens||0)),cell:e=>{let{row:s}=e,l=s.original;return(0,t.jsx)("div",{className:"space-y-1",children:(0,t.jsxs)(d.Z,{className:"text-xs",children:[l.max_input_tokens?b(l.max_input_tokens):"-"," / ",l.max_output_tokens?b(l.max_output_tokens):"-"]})})},meta:{className:"hidden lg:table-cell"}},{header:"Cost/1M",accessorKey:"input_cost_per_token",enableSorting:!0,sortingFn:(e,s)=>(e.original.input_cost_per_token||0)+(e.original.output_cost_per_token||0)-((s.original.input_cost_per_token||0)+(s.original.output_cost_per_token||0)),cell:e=>{let{row:s}=e,l=s.original;return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(d.Z,{className:"text-xs",children:l.input_cost_per_token?j(l.input_cost_per_token):"-"}),(0,t.jsx)(d.Z,{className:"text-xs text-gray-500",children:l.output_cost_per_token?j(l.output_cost_per_token):"-"})]})}},{header:"Features",accessorKey:"capabilities",enableSorting:!1,cell:e=>{let{row:s}=e,l=g(s.original),r=["green","blue","purple","orange","red","yellow"];return(0,t.jsx)("div",{className:"flex flex-wrap gap-1",children:0===l.length?(0,t.jsx)(d.Z,{className:"text-gray-500 text-xs",children:"-"}):l.map((e,s)=>(0,t.jsx)(c.Z,{color:r[s%r.length],size:"xs",children:h(e)},e))})}},{header:"Public",accessorKey:"is_public_model_group",enableSorting:!0,sortingFn:(e,s)=>(!0===e.original.is_public_model_group?1:0)-(!0===s.original.is_public_model_group?1:0),cell:e=>{let{row:s}=e;return!0===s.original.is_public_model_group?(0,t.jsx)(c.Z,{color:"green",size:"xs",children:"Yes"}):(0,t.jsx)(c.Z,{color:"gray",size:"xs",children:"No"})},meta:{className:"hidden md:table-cell"}},{header:"Details",id:"details",enableSorting:!1,cell:s=>{let{row:l}=s,r=l.original;return(0,t.jsxs)(o.Z,{size:"xs",variant:"secondary",onClick:()=>e(r),icon:p.Z,children:[(0,t.jsx)("span",{className:"hidden lg:inline",children:"Details"}),(0,t.jsx)("span",{className:"lg:hidden",children:"Info"})]})}}];return l?r.filter(e=>!("accessorKey"in e)||"is_public_model_group"!==e.accessorKey):r};var y=l(72162),N=l(91810),f=l(13634),_=l(42264),k=l(61994),w=l(73002),Z=l(82680),C=l(96761),S=l(12514),P=e=>{let{modelHubData:s,onFilteredDataChange:l,showFiltersCard:a=!0,className:n=""}=e,[i,c]=(0,r.useState)(""),[o,x]=(0,r.useState)(""),[m,u]=(0,r.useState)(""),[p,h]=(0,r.useState)(""),g=(0,r.useRef)([]),j=(0,r.useMemo)(()=>(null==s?void 0:s.filter(e=>{let s=e.model_group.toLowerCase().includes(i.toLowerCase()),l=""===o||e.providers.includes(o),t=""===m||e.mode===m,r=""===p||Object.entries(e).filter(e=>{let[s,l]=e;return s.startsWith("supports_")&&!0===l}).some(e=>{let[s]=e;return s.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")===p});return s&&l&&t&&r}))||[],[s,i,o,m,p]);(0,r.useEffect)(()=>{(j.length!==g.current.length||j.some((e,s)=>{var l;return e.model_group!==(null===(l=g.current[s])||void 0===l?void 0:l.model_group)}))&&(g.current=j,l(j))},[j,l]);let b=(0,t.jsxs)("div",{className:"flex flex-wrap gap-4 items-center",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(d.Z,{className:"text-sm font-medium mb-2",children:"Search Models:"}),(0,t.jsx)("input",{type:"text",placeholder:"Search model names...",value:i,onChange:e=>c(e.target.value),className:"border rounded px-3 py-2 w-64 h-10 text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(d.Z,{className:"text-sm font-medium mb-2",children:"Provider:"}),(0,t.jsxs)("select",{value:o,onChange:e=>x(e.target.value),className:"border rounded px-3 py-2 text-sm text-gray-600 w-40 h-10",children:[(0,t.jsx)("option",{value:"",className:"text-sm text-gray-600",children:"All Providers"}),s&&(e=>{let s=new Set;return e.forEach(e=>{e.providers.forEach(e=>s.add(e))}),Array.from(s)})(s).map(e=>(0,t.jsx)("option",{value:e,className:"text-sm text-gray-800",children:e},e))]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(d.Z,{className:"text-sm font-medium mb-2",children:"Mode:"}),(0,t.jsxs)("select",{value:m,onChange:e=>u(e.target.value),className:"border rounded px-3 py-2 text-sm text-gray-600 w-32 h-10",children:[(0,t.jsx)("option",{value:"",className:"text-sm text-gray-600",children:"All Modes"}),s&&(e=>{let s=new Set;return e.forEach(e=>{e.mode&&s.add(e.mode)}),Array.from(s)})(s).map(e=>(0,t.jsx)("option",{value:e,className:"text-sm text-gray-800",children:e},e))]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(d.Z,{className:"text-sm font-medium mb-2",children:"Features:"}),(0,t.jsxs)("select",{value:p,onChange:e=>h(e.target.value),className:"border rounded px-3 py-2 text-sm text-gray-600 w-48 h-10",children:[(0,t.jsx)("option",{value:"",className:"text-sm text-gray-600",children:"All Features"}),s&&(e=>{let s=new Set;return e.forEach(e=>{Object.entries(e).filter(e=>{let[s,l]=e;return s.startsWith("supports_")&&!0===l}).forEach(e=>{let[l]=e,t=l.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");s.add(t)})}),Array.from(s).sort()})(s).map(e=>(0,t.jsx)("option",{value:e,className:"text-sm text-gray-800",children:e},e))]})]}),(i||o||m||p)&&(0,t.jsx)("div",{className:"flex items-end",children:(0,t.jsx)("button",{onClick:()=>{c(""),x(""),u(""),h("")},className:"text-blue-600 hover:text-blue-800 text-sm underline h-10 flex items-center",children:"Clear Filters"})})]});return a?(0,t.jsx)(S.Z,{className:"mb-6 ".concat(n),children:b}):(0,t.jsx)("div",{className:n,children:b})};let{Step:M}=N.default;var L=e=>{let{visible:s,onClose:l,accessToken:a,modelHubData:i,onSuccess:o}=e,[x,m]=(0,r.useState)(0),[u,p]=(0,r.useState)(new Set),[h,g]=(0,r.useState)([]),[j,b]=(0,r.useState)(!1),[v]=f.Z.useForm(),y=()=>{m(0),p(new Set),g([]),v.resetFields(),l()},S=(e,s)=>{let l=new Set(u);s?l.add(e):l.delete(e),p(l)},L=e=>{e?p(new Set(h.map(e=>e.model_group))):p(new Set)},A=(0,r.useCallback)(e=>{g(e)},[]);(0,r.useEffect)(()=>{s&&i.length>0&&(g(i),p(new Set(i.filter(e=>!0===e.is_public_model_group).map(e=>e.model_group))))},[s,i]);let F=async()=>{if(0===u.size){_.ZP.error("Please select at least one model to make public");return}b(!0);try{let e=Array.from(u);await (0,n.makeModelGroupPublic)(a,e),_.ZP.success("Successfully made ".concat(e.length," model group(s) public!")),y(),o()}catch(e){console.error("Error making model groups public:",e),_.ZP.error("Failed to make model groups public. Please try again.")}finally{b(!1)}},U=()=>{let e=h.length>0&&h.every(e=>u.has(e.model_group)),s=u.size>0&&!e;return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)(C.Z,{children:"Select Models to Make Public"}),(0,t.jsx)("div",{className:"flex items-center space-x-2",children:(0,t.jsxs)(k.Z,{checked:e,indeterminate:s,onChange:e=>L(e.target.checked),disabled:0===h.length,children:["Select All ",h.length>0&&"(".concat(h.length,")")]})})]}),(0,t.jsx)(d.Z,{className:"text-sm text-gray-600",children:"Select the models you want to be visible on the public model hub. Users will still require a valid API key to use these models."}),(0,t.jsx)(P,{modelHubData:i,onFilteredDataChange:A,showFiltersCard:!1,className:"border rounded-lg p-4 bg-gray-50"}),(0,t.jsx)("div",{className:"max-h-96 overflow-y-auto border rounded-lg p-4",children:(0,t.jsx)("div",{className:"space-y-3",children:0===h.length?(0,t.jsx)("div",{className:"text-center py-8 text-gray-500",children:(0,t.jsx)(d.Z,{children:"No models match the current filters."})}):h.map(e=>(0,t.jsxs)("div",{className:"flex items-center space-x-3 p-3 border rounded-lg hover:bg-gray-50",children:[(0,t.jsx)(k.Z,{checked:u.has(e.model_group),onChange:s=>S(e.model_group,s.target.checked)}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(d.Z,{className:"font-medium",children:e.model_group}),e.mode&&(0,t.jsx)(c.Z,{color:"green",size:"sm",children:e.mode})]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:e.providers.map(e=>(0,t.jsx)(c.Z,{color:"blue",size:"xs",children:e},e))})]})]},e.model_group))})}),u.size>0&&(0,t.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3",children:(0,t.jsxs)(d.Z,{className:"text-sm text-blue-800",children:[(0,t.jsx)("strong",{children:u.size})," model",1!==u.size?"s":""," selected"]})})]})},z=()=>(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(C.Z,{children:"Confirm Making Models Public"}),(0,t.jsx)("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4",children:(0,t.jsxs)(d.Z,{className:"text-sm text-yellow-800",children:[(0,t.jsx)("strong",{children:"Warning:"})," Once you make these models public, anyone who can go to the ",(0,t.jsx)("code",{children:"/ui/model_hub_table"})," will be able to know they exist on the proxy."]})}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(d.Z,{className:"font-medium",children:"Models to be made public:"}),(0,t.jsx)("div",{className:"max-h-48 overflow-y-auto border rounded-lg p-3",children:(0,t.jsx)("div",{className:"space-y-2",children:Array.from(u).map(e=>{let s=i.find(s=>s.model_group===e);return(0,t.jsx)("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:(0,t.jsxs)("div",{children:[(0,t.jsx)(d.Z,{className:"font-medium",children:e}),s&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:s.providers.map(e=>(0,t.jsx)(c.Z,{color:"blue",size:"xs",children:e},e))})]})},e)})})})]}),(0,t.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3",children:(0,t.jsxs)(d.Z,{className:"text-sm text-blue-800",children:["Total: ",(0,t.jsx)("strong",{children:u.size})," model",1!==u.size?"s":""," will be made public"]})})]});return(0,t.jsx)(Z.Z,{title:"Make Models Public",open:s,onCancel:y,footer:null,width:1200,maskClosable:!1,children:(0,t.jsxs)(f.Z,{form:v,layout:"vertical",children:[(0,t.jsxs)(N.default,{current:x,className:"mb-6",children:[(0,t.jsx)(M,{title:"Select Models"}),(0,t.jsx)(M,{title:"Confirm"})]}),(()=>{switch(x){case 0:return U();case 1:return z();default:return null}})(),(0,t.jsxs)("div",{className:"flex justify-between mt-6",children:[(0,t.jsx)(w.ZP,{onClick:0===x?y:()=>{1===x&&m(0)},children:0===x?"Cancel":"Previous"}),(0,t.jsxs)("div",{className:"flex space-x-2",children:[0===x&&(0,t.jsx)(w.ZP,{onClick:()=>{if(0===x){if(0===u.size){_.ZP.error("Please select at least one model to make public");return}m(1)}},disabled:0===u.size,children:"Next"}),1===x&&(0,t.jsx)(w.ZP,{onClick:F,loading:j,children:"Make Public"})]})]})]})})},A=l(69870),F=l(57018),U=l(17906),z=l(78867),E=l(20347),D=e=>{var s,l;let{accessToken:c,publicPage:o,premiumUser:d,userRole:x}=e,[m,u]=(0,r.useState)(!1),[p,h]=(0,r.useState)(null),[g,j]=(0,r.useState)(!0),[b,N]=(0,r.useState)(!1),[f,k]=(0,r.useState)(!1),[w,C]=(0,r.useState)(null),[S,M]=(0,r.useState)([]),[D,R]=(0,r.useState)(!1),H=(0,a.useRouter)(),O=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=async e=>{try{j(!0);let s=await (0,n.modelHubCall)(e);console.log("ModelHubData:",s),h(s.data),(0,n.getConfigFieldSetting)(e,"enable_public_model_hub").then(e=>{console.log("data: ".concat(JSON.stringify(e))),!0==e.field_value&&u(!0)}).catch(e=>{})}catch(e){console.error("There was an error fetching the model data",e)}finally{j(!1)}},s=async()=>{try{var e,s;j(!0);let l=await (0,n.modelHubPublicModelsCall)();console.log("ModelHubData:",l),console.log("First model structure:",l[0]),console.log("Model has model_group?",null===(e=l[0])||void 0===e?void 0:e.model_group),console.log("Model has providers?",null===(s=l[0])||void 0===s?void 0:s.providers),h(l),u(!0)}catch(e){console.error("There was an error fetching the public model data",e)}finally{j(!1)}};c?e(c):o&&s()},[c,o]);let T=()=>{c&&R(!0)},I=()=>{N(!1),k(!1),C(null)},K=()=>{N(!1),k(!1),C(null)},Y=e=>{navigator.clipboard.writeText(e),_.ZP.success("Copied to clipboard!")},W=e=>e.replace(/^supports_/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),B=e=>Object.entries(e).filter(e=>{let[s,l]=e;return s.startsWith("supports_")&&!0===l}).map(e=>{let[s]=e;return s}),V=e=>"$".concat((1e6*e).toFixed(2)),q=(0,r.useCallback)(e=>{M(e)},[]);return(console.log("publicPage: ",o),console.log("publicPageAllowed: ",m),o&&m)?(0,t.jsx)(y.Z,{accessToken:c}):(0,t.jsxs)("div",{className:"w-full mx-4 h-[75vh]",children:[!1==o?(0,t.jsxs)("div",{className:"w-full m-2 mt-2 p-8",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,t.jsxs)("div",{className:"flex flex-col items-start",children:[(0,t.jsx)(F.Dx,{className:"text-center",children:"Model Hub"}),(0,E.tY)(x||"")?(0,t.jsx)("p",{className:"text-sm text-gray-600",children:"Make models public for developers to know what models are available on the proxy."}):(0,t.jsx)("p",{className:"text-sm text-gray-600",children:"A list of all public model names personally available to you."})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,t.jsx)(F.xv,{children:"Model Hub URL:"}),(0,t.jsxs)("div",{className:"flex items-center bg-gray-200 px-2 py-1 rounded",children:[(0,t.jsx)(F.xv,{className:"mr-2",children:"".concat((0,n.getProxyBaseUrl)(),"/ui/model_hub_table")}),(0,t.jsx)("button",{onClick:()=>Y("".concat((0,n.getProxyBaseUrl)(),"/ui/model_hub_table")),className:"p-1 hover:bg-gray-300 rounded transition-colors",title:"Copy URL",children:(0,t.jsx)(z.Z,{size:16,className:"text-gray-600"})})]}),!1==o&&(0,E.tY)(x||"")&&(0,t.jsx)(F.zx,{className:"ml-4",onClick:()=>T(),children:"Make Public"})]})]}),(0,E.tY)(x||"")&&(0,t.jsx)("div",{className:"mt-8 mb-2",children:(0,t.jsx)(A.Z,{accessToken:c,userRole:x})}),(0,t.jsxs)(F.Zb,{children:[(0,t.jsx)(P,{modelHubData:p||[],onFilteredDataChange:q}),(0,t.jsx)(i.C,{columns:v(e=>{C(e),N(!0)},Y,o),data:S,isLoading:g,table:O,defaultSorting:[{id:"model_group",desc:!1}]})]}),(0,t.jsx)("div",{className:"mt-4 text-center space-y-2",children:(0,t.jsxs)(F.xv,{className:"text-sm text-gray-600",children:["Showing ",S.length," of ",(null==p?void 0:p.length)||0," models"]})})]}):(0,t.jsxs)(F.Zb,{className:"mx-auto max-w-xl mt-10",children:[(0,t.jsx)(F.xv,{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)(Z.Z,{title:"Public Model Hub",width:600,visible:f,footer:null,onOk:I,onCancel:K,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)(F.xv,{className:"text-base mr-2",children:"Shareable Link:"}),(0,t.jsx)(F.xv,{className:"max-w-sm ml-2 bg-gray-200 pr-2 pl-2 pt-1 pb-1 text-center rounded",children:"".concat((0,n.getProxyBaseUrl)(),"/ui/model_hub_table")})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(F.zx,{onClick:()=>{H.replace("/model_hub_table?key=".concat(c))},children:"See Page"})})]})}),(0,t.jsx)(Z.Z,{title:(null==w?void 0:w.model_group)||"Model Details",width:1e3,visible:b,footer:null,onOk:I,onCancel:K,children:w&&(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Model Overview"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Model Group:"}),(0,t.jsx)(F.xv,{children:w.model_group})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Mode:"}),(0,t.jsx)(F.xv,{children:w.mode||"Not specified"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Providers:"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:w.providers.map(e=>(0,t.jsx)(F.Ct,{color:"blue",children:e},e))})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Token & Cost Information"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Max Input Tokens:"}),(0,t.jsx)(F.xv,{children:(null===(s=w.max_input_tokens)||void 0===s?void 0:s.toLocaleString())||"Not specified"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Max Output Tokens:"}),(0,t.jsx)(F.xv,{children:(null===(l=w.max_output_tokens)||void 0===l?void 0:l.toLocaleString())||"Not specified"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Input Cost per 1M Tokens:"}),(0,t.jsx)(F.xv,{children:w.input_cost_per_token?V(w.input_cost_per_token):"Not specified"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Output Cost per 1M Tokens:"}),(0,t.jsx)(F.xv,{children:w.output_cost_per_token?V(w.output_cost_per_token):"Not specified"})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Capabilities"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:(()=>{let e=B(w),s=["green","blue","purple","orange","red","yellow"];return 0===e.length?(0,t.jsx)(F.xv,{className:"text-gray-500",children:"No special capabilities listed"}):e.map((e,l)=>(0,t.jsx)(F.Ct,{color:s[l%s.length],children:W(e)},e))})()})]}),(w.tpm||w.rpm)&&(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Rate Limits"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[w.tpm&&(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Tokens per Minute:"}),(0,t.jsx)(F.xv,{children:w.tpm.toLocaleString()})]}),w.rpm&&(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"font-medium",children:"Requests per Minute:"}),(0,t.jsx)(F.xv,{children:w.rpm.toLocaleString()})]})]})]}),w.supported_openai_params&&(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Supported OpenAI Parameters"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:w.supported_openai_params.map(e=>(0,t.jsx)(F.Ct,{color:"green",children:e},e))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(F.xv,{className:"text-lg font-semibold mb-4",children:"Usage Example"}),(0,t.jsx)(U.Z,{language:"python",className:"text-sm",children:'import openai\n\nclient = openai.OpenAI(\n api_key="your_api_key",\n base_url="http://0.0.0.0:4000" # Your LiteLLM Proxy URL\n)\n\nresponse = client.chat.completions.create(\n model="'.concat(w.model_group,'",\n messages=[\n {\n "role": "user",\n "content": "Hello, how are you?"\n }\n ]\n)\n\nprint(response.choices[0].message.content)')})]})]})}),(0,t.jsx)(L,{visible:D,onClose:()=>R(!1),accessToken:c||"",modelHubData:p||[],onSuccess:()=>{c&&(async()=>{try{let e=await (0,n.modelHubCall)(c);h(e.data)}catch(e){console.error("Error refreshing model data:",e)}})()}})]})}},69870:function(e,s,l){var t=l(57437),r=l(2265),a=l(82680),n=l(42264),i=l(86462),c=l(47686),o=l(77355),d=l(93416),x=l(74998),m=l(20347),u=l(19250),p=l(95704);s.Z=e=>{let{accessToken:s,userRole:l}=e,[h,g]=(0,r.useState)([]),[j,b]=(0,r.useState)({url:"",displayName:""}),[v,y]=(0,r.useState)(null),[N,f]=(0,r.useState)(!1),[_,k]=(0,r.useState)(!0),w=async()=>{if(s)try{f(!0);let e=await (0,u.getPublicModelHubInfo)();if(e&&e.useful_links){let s=e.useful_links||{},l=Object.entries(s).map((e,s)=>{let[l,t]=e;return{id:"".concat(s,"-").concat(l),displayName:l,url:t}});g(l)}else g([])}catch(e){console.error("Error fetching useful links:",e),g([])}finally{f(!1)}};if((0,r.useEffect)(()=>{w()},[s]),!(0,m.tY)(l||""))return null;let Z=async e=>{if(!s)return!1;try{let l={};return e.forEach(e=>{l[e.displayName]=e.url}),await (0,u.updateUsefulLinksCall)(s,l),a.Z.success({title:"Links Saved Successfully",content:(0,t.jsxs)("div",{className:"py-4",children:[(0,t.jsx)("p",{className:"text-gray-600 mb-4",children:"Your useful links have been saved and are now visible on the public model hub."}),(0,t.jsxs)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[(0,t.jsx)("p",{className:"text-sm text-blue-800 mb-2 font-medium",children:"View your updated model hub:"}),(0,t.jsx)("a",{href:"".concat((0,u.getProxyBaseUrl)(),"/ui/model_hub_table"),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-blue-600 hover:text-blue-800 underline text-sm font-medium",children:"Open Public Model Hub →"})]})]}),width:500,okText:"Close",maskClosable:!0,keyboard:!0}),!0}catch(e){return console.error("Error saving links:",e),n.ZP.error("Failed to save links - ".concat(e)),!1}},C=async()=>{if(!j.url||!j.displayName)return;try{new URL(j.url)}catch(e){n.ZP.error("Please enter a valid URL");return}if(h.some(e=>e.displayName===j.displayName)){n.ZP.error("A link with this display name already exists");return}let e=[...h,{id:"".concat(Date.now(),"-").concat(j.displayName),displayName:j.displayName,url:j.url}];await Z(e)&&(g(e),b({url:"",displayName:""}),n.ZP.success("Link added successfully"))},S=e=>{y({...e})},P=async()=>{if(!v)return;try{new URL(v.url)}catch(e){n.ZP.error("Please enter a valid URL");return}if(h.some(e=>e.id!==v.id&&e.displayName===v.displayName)){n.ZP.error("A link with this display name already exists");return}let e=h.map(e=>e.id===v.id?v:e);await Z(e)&&(g(e),y(null),n.ZP.success("Link updated successfully"))},M=()=>{y(null)},L=async e=>{let s=h.filter(s=>s.id!==e);await Z(s)&&(g(s),n.ZP.success("Link deleted successfully"))},A=e=>{window.open(e,"_blank")};return(0,t.jsxs)(p.Zb,{className:"mb-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>k(!_),children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)(p.Dx,{className:"mb-0",children:"Link Management"}),(0,t.jsx)("p",{className:"text-sm text-gray-500",children:"Manage the links that are displayed under 'Useful Links' on the public model hub."})]}),(0,t.jsx)("div",{className:"flex items-center",children:_?(0,t.jsx)(i.Z,{className:"w-5 h-5 text-gray-500"}):(0,t.jsx)(c.Z,{className:"w-5 h-5 text-gray-500"})})]}),_&&(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsx)(p.xv,{className:"text-sm font-medium text-gray-700 mb-2",children:"Add New Link"}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"URL"}),(0,t.jsx)("input",{type:"text",value:j.url,onChange:e=>b({...j,url:e.target.value}),placeholder:"https://example.com",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"Display Name"}),(0,t.jsx)("input",{type:"text",value:j.displayName,onChange:e=>b({...j,displayName:e.target.value}),placeholder:"Friendly name",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),(0,t.jsx)("div",{className:"flex items-end",children:(0,t.jsxs)("button",{onClick:C,disabled:!j.url||!j.displayName,className:"flex items-center px-4 py-2 rounded-md text-sm ".concat(j.url&&j.displayName?"bg-green-600 text-white hover:bg-green-700":"bg-gray-300 text-gray-500 cursor-not-allowed"),children:[(0,t.jsx)(o.Z,{className:"w-4 h-4 mr-1"}),"Add Link"]})})]})]}),(0,t.jsx)(p.xv,{className:"text-sm font-medium text-gray-700 mb-2",children:"Manage Existing Links"}),(0,t.jsx)("div",{className:"rounded-lg custom-border relative",children:(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)(p.iA,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,t.jsx)(p.ss,{children:(0,t.jsxs)(p.SC,{children:[(0,t.jsx)(p.xs,{className:"py-1 h-8",children:"Display Name"}),(0,t.jsx)(p.xs,{className:"py-1 h-8",children:"URL"}),(0,t.jsx)(p.xs,{className:"py-1 h-8",children:"Actions"})]})}),(0,t.jsxs)(p.RM,{children:[h.map(e=>(0,t.jsx)(p.SC,{className:"h-8",children:v&&v.id===e.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.pj,{className:"py-0.5",children:(0,t.jsx)("input",{type:"text",value:v.displayName,onChange:e=>y({...v,displayName:e.target.value}),className:"w-full px-2 py-1 border border-gray-300 rounded-md text-sm"})}),(0,t.jsx)(p.pj,{className:"py-0.5",children:(0,t.jsx)("input",{type:"text",value:v.url,onChange:e=>y({...v,url:e.target.value}),className:"w-full px-2 py-1 border border-gray-300 rounded-md text-sm"})}),(0,t.jsx)(p.pj,{className:"py-0.5 whitespace-nowrap",children:(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)("button",{onClick:P,className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:"Save"}),(0,t.jsx)("button",{onClick:M,className:"text-xs bg-gray-50 text-gray-600 px-2 py-1 rounded hover:bg-gray-100",children:"Cancel"})]})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.pj,{className:"py-0.5 text-sm text-gray-900",children:e.displayName}),(0,t.jsx)(p.pj,{className:"py-0.5 text-sm text-gray-500",children:e.url}),(0,t.jsx)(p.pj,{className:"py-0.5 whitespace-nowrap",children:(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)("button",{onClick:()=>A(e.url),className:"text-xs bg-green-50 text-green-600 px-2 py-1 rounded hover:bg-green-100",children:"Use"}),(0,t.jsx)("button",{onClick:()=>S(e),className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:(0,t.jsx)(d.Z,{className:"w-3 h-3"})}),(0,t.jsx)("button",{onClick:()=>L(e.id),className:"text-xs bg-red-50 text-red-600 px-2 py-1 rounded hover:bg-red-100",children:(0,t.jsx)(x.Z,{className:"w-3 h-3"})})]})})]})},e.id)),0===h.length&&(0,t.jsx)(p.SC,{children:(0,t.jsx)(p.pj,{colSpan:3,className:"py-0.5 text-sm text-gray-500 text-center",children:"No links added yet. Add a new link above."})})]})]})})})]})]})}},20347:function(e,s,l){l.d(s,{LQ:function(){return a},ZL:function(){return t},lo:function(){return r},tY:function(){return n}});let t=["Admin","Admin Viewer","proxy_admin","proxy_admin_viewer","org_admin"],r=["Internal User","Internal Viewer"],a=["Internal User","Admin"],n=e=>t.includes(e)}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/247-7557228b7131016b.js b/litellm/proxy/_experimental/out/_next/static/chunks/247-7557228b7131016b.js deleted file mode 100644 index fce6b847721..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/247-7557228b7131016b.js +++ /dev/null @@ -1,12 +0,0 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[247],{12660:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M917.7 148.8l-42.4-42.4c-1.6-1.6-3.6-2.3-5.7-2.3s-4.1.8-5.7 2.3l-76.1 76.1a199.27 199.27 0 00-112.1-34.3c-51.2 0-102.4 19.5-141.5 58.6L432.3 308.7a8.03 8.03 0 000 11.3L704 591.7c1.6 1.6 3.6 2.3 5.7 2.3 2 0 4.1-.8 5.7-2.3l101.9-101.9c68.9-69 77-175.7 24.3-253.5l76.1-76.1c3.1-3.2 3.1-8.3 0-11.4zM769.1 441.7l-59.4 59.4-186.8-186.8 59.4-59.4c24.9-24.9 58.1-38.7 93.4-38.7 35.3 0 68.4 13.7 93.4 38.7 24.9 24.9 38.7 58.1 38.7 93.4 0 35.3-13.8 68.4-38.7 93.4zm-190.2 105a8.03 8.03 0 00-11.3 0L501 613.3 410.7 523l66.7-66.7c3.1-3.1 3.1-8.2 0-11.3L441 408.6a8.03 8.03 0 00-11.3 0L363 475.3l-43-43a7.85 7.85 0 00-5.7-2.3c-2 0-4.1.8-5.7 2.3L206.8 534.2c-68.9 69-77 175.7-24.3 253.5l-76.1 76.1a8.03 8.03 0 000 11.3l42.4 42.4c1.6 1.6 3.6 2.3 5.7 2.3s4.1-.8 5.7-2.3l76.1-76.1c33.7 22.9 72.9 34.3 112.1 34.3 51.2 0 102.4-19.5 141.5-58.6l101.9-101.9c3.1-3.1 3.1-8.2 0-11.3l-43-43 66.7-66.7c3.1-3.1 3.1-8.2 0-11.3l-36.6-36.2zM441.7 769.1a131.32 131.32 0 01-93.4 38.7c-35.3 0-68.4-13.7-93.4-38.7a131.32 131.32 0 01-38.7-93.4c0-35.3 13.7-68.4 38.7-93.4l59.4-59.4 186.8 186.8-59.4 59.4z"}}]},name:"api",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},88009:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M464 144H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H212V212h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H612V212h200v200zM464 544H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H212V612h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H612V612h200v200z"}}]},name:"appstore",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},79276:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M868 545.5L536.1 163a31.96 31.96 0 00-48.3 0L156 545.5a7.97 7.97 0 006 13.2h81c4.6 0 9-2 12.1-5.5L474 300.9V864c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V300.9l218.9 252.3c3 3.5 7.4 5.5 12.1 5.5h81c6.8 0 10.5-8 6-13.2z"}}]},name:"arrow-up",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},37527:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M894 462c30.9 0 43.8-39.7 18.7-58L530.8 126.2a31.81 31.81 0 00-37.6 0L111.3 404c-25.1 18.2-12.2 58 18.8 58H192v374h-72c-4.4 0-8 3.6-8 8v52c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-52c0-4.4-3.6-8-8-8h-72V462h62zM512 196.7l271.1 197.2H240.9L512 196.7zM264 462h117v374H264V462zm189 0h117v374H453V462zm307 374H642V462h118v374z"}}]},name:"bank",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},9775:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm-600-80h56c4.4 0 8-3.6 8-8V560c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v144c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V384c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v320c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V462c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v242c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V304c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v400c0 4.4 3.6 8 8 8z"}}]},name:"bar-chart",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},11429:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M766.4 744.3c43.7 0 79.4-36.2 79.4-80.5 0-53.5-79.4-140.8-79.4-140.8S687 610.3 687 663.8c0 44.3 35.7 80.5 79.4 80.5zm-377.1-44.1c7.1 7.1 18.6 7.1 25.6 0l256.1-256c7.1-7.1 7.1-18.6 0-25.6l-256-256c-.6-.6-1.3-1.2-2-1.7l-78.2-78.2a9.11 9.11 0 00-12.8 0l-48 48a9.11 9.11 0 000 12.8l67.2 67.2-207.8 207.9c-7.1 7.1-7.1 18.6 0 25.6l255.9 256zm12.9-448.6l178.9 178.9H223.4l178.8-178.9zM904 816H120c-4.4 0-8 3.6-8 8v80c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-80c0-4.4-3.6-8-8-8z"}}]},name:"bg-colors",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},68208:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M856 376H648V168c0-8.8-7.2-16-16-16H168c-8.8 0-16 7.2-16 16v464c0 8.8 7.2 16 16 16h208v208c0 8.8 7.2 16 16 16h464c8.8 0 16-7.2 16-16V392c0-8.8-7.2-16-16-16zm-480 16v188H220V220h360v156H392c-8.8 0-16 7.2-16 16zm204 52v136H444V444h136zm224 360H444V648h188c8.8 0 16-7.2 16-16V444h156v360z"}}]},name:"block",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},83322:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M632 888H392c-4.4 0-8 3.6-8 8v32c0 17.7 14.3 32 32 32h192c17.7 0 32-14.3 32-32v-32c0-4.4-3.6-8-8-8zM512 64c-181.1 0-328 146.9-328 328 0 121.4 66 227.4 164 284.1V792c0 17.7 14.3 32 32 32h264c17.7 0 32-14.3 32-32V676.1c98-56.7 164-162.7 164-284.1 0-181.1-146.9-328-328-328zm127.9 549.8L604 634.6V752H420V634.6l-35.9-20.8C305.4 568.3 256 484.5 256 392c0-141.4 114.6-256 256-256s256 114.6 256 256c0 92.5-49.4 176.3-128.1 221.8z"}}]},name:"bulb",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},49634:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zm-40 656H184V460h656v380zM184 392V256h128v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h256v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h128v136H184z"}}]},name:"calendar",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},83669:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M699 353h-46.9c-10.2 0-19.9 4.9-25.9 13.3L469 584.3l-71.2-98.8c-6-8.3-15.6-13.3-25.9-13.3H325c-6.5 0-10.3 7.4-6.5 12.7l124.6 172.8a31.8 31.8 0 0051.7 0l210.6-292c3.9-5.3.1-12.7-6.4-12.7z"}},{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}}]},name:"check-circle",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},26430:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M899.1 869.6l-53-305.6H864c14.4 0 26-11.6 26-26V346c0-14.4-11.6-26-26-26H618V138c0-14.4-11.6-26-26-26H432c-14.4 0-26 11.6-26 26v182H160c-14.4 0-26 11.6-26 26v192c0 14.4 11.6 26 26 26h17.9l-53 305.6a25.95 25.95 0 0025.6 30.4h723c1.5 0 3-.1 4.4-.4a25.88 25.88 0 0021.2-30zM204 390h272V182h72v208h272v104H204V390zm468 440V674c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v156H416V674c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v156H202.8l45.1-260H776l45.1 260H672z"}}]},name:"clear",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},5540:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M686.7 638.6L544.1 535.5V288c0-4.4-3.6-8-8-8H488c-4.4 0-8 3.6-8 8v275.4c0 2.6 1.2 5 3.3 6.5l165.4 120.6c3.6 2.6 8.6 1.8 11.2-1.7l28.6-39c2.6-3.7 1.8-8.7-1.8-11.2z"}}]},name:"clock-circle",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},11894:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M516 673c0 4.4 3.4 8 7.5 8h185c4.1 0 7.5-3.6 7.5-8v-48c0-4.4-3.4-8-7.5-8h-185c-4.1 0-7.5 3.6-7.5 8v48zm-194.9 6.1l192-161c3.8-3.2 3.8-9.1 0-12.3l-192-160.9A7.95 7.95 0 00308 351v62.7c0 2.4 1 4.6 2.9 6.1L420.7 512l-109.8 92.2a8.1 8.1 0 00-2.9 6.1V673c0 6.8 7.9 10.5 13.1 6.1zM880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]},name:"code",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},44625:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-600 72h560v208H232V136zm560 480H232V408h560v208zm0 272H232V680h560v208zM304 240a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0z"}}]},name:"database",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},26349:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"}}]},name:"delete",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},62670:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372zm47.7-395.2l-25.4-5.9V348.6c38 5.2 61.5 29 65.5 58.2.5 4 3.9 6.9 7.9 6.9h44.9c4.7 0 8.4-4.1 8-8.8-6.1-62.3-57.4-102.3-125.9-109.2V263c0-4.4-3.6-8-8-8h-28.1c-4.4 0-8 3.6-8 8v33c-70.8 6.9-126.2 46-126.2 119 0 67.6 49.8 100.2 102.1 112.7l24.7 6.3v142.7c-44.2-5.9-69-29.5-74.1-61.3-.6-3.8-4-6.6-7.9-6.6H363c-4.7 0-8.4 4-8 8.7 4.5 55 46.2 105.6 135.2 112.1V761c0 4.4 3.6 8 8 8h28.4c4.4 0 8-3.6 8-8.1l-.2-31.7c78.3-6.9 134.3-48.8 134.3-124-.1-69.4-44.2-100.4-109-116.4zm-68.6-16.2c-5.6-1.6-10.3-3.1-15-5-33.8-12.2-49.5-31.9-49.5-57.3 0-36.3 27.5-57 64.5-61.7v124zM534.3 677V543.3c3.1.9 5.9 1.6 8.8 2.2 47.3 14.4 63.2 34.4 63.2 65.1 0 39.1-29.4 62.6-72 66.4z"}}]},name:"dollar",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},73879:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"download",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},29271:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M464 688a48 48 0 1096 0 48 48 0 10-96 0zm24-112h48c4.4 0 8-3.6 8-8V296c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8z"}}]},name:"exclamation-circle",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},41169:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 472a40 40 0 1080 0 40 40 0 10-80 0zm367 352.9L696.3 352V178H768v-68H256v68h71.7v174L145 824.9c-2.8 7.4-4.3 15.2-4.3 23.1 0 35.3 28.7 64 64 64h614.6c7.9 0 15.7-1.5 23.1-4.3 33-12.7 49.4-49.8 36.6-82.8zM395.7 364.7V180h232.6v184.7L719.2 600c-20.7-5.3-42.1-8-63.9-8-61.2 0-119.2 21.5-165.3 60a188.78 188.78 0 01-121.3 43.9c-32.7 0-64.1-8.3-91.8-23.7l118.8-307.5zM210.5 844l41.7-107.8c35.7 18.1 75.4 27.8 116.6 27.8 61.2 0 119.2-21.5 165.3-60 33.9-28.2 76.3-43.9 121.3-43.9 35 0 68.4 9.5 97.6 27.1L813.5 844h-603z"}}]},name:"experiment",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},11741:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"}}]},name:"export",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},34310:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494zM472 744a40 40 0 1080 0 40 40 0 10-80 0zm16-104h48c4.4 0 8-3.6 8-8V448c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v184c0 4.4 3.6 8 8 8z"}}]},name:"file-exclamation",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},50010:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M531.3 574.4l.3-1.4c5.8-23.9 13.1-53.7 7.4-80.7-3.8-21.3-19.5-29.6-32.9-30.2-15.8-.7-29.9 8.3-33.4 21.4-6.6 24-.7 56.8 10.1 98.6-13.6 32.4-35.3 79.5-51.2 107.5-29.6 15.3-69.3 38.9-75.2 68.7-1.2 5.5.2 12.5 3.5 18.8 3.7 7 9.6 12.4 16.5 15 3 1.1 6.6 2 10.8 2 17.6 0 46.1-14.2 84.1-79.4 5.8-1.9 11.8-3.9 17.6-5.9 27.2-9.2 55.4-18.8 80.9-23.1 28.2 15.1 60.3 24.8 82.1 24.8 21.6 0 30.1-12.8 33.3-20.5 5.6-13.5 2.9-30.5-6.2-39.6-13.2-13-45.3-16.4-95.3-10.2-24.6-15-40.7-35.4-52.4-65.8zM421.6 726.3c-13.9 20.2-24.4 30.3-30.1 34.7 6.7-12.3 19.8-25.3 30.1-34.7zm87.6-235.5c5.2 8.9 4.5 35.8.5 49.4-4.9-19.9-5.6-48.1-2.7-51.4.8.1 1.5.7 2.2 2zm-1.6 120.5c10.7 18.5 24.2 34.4 39.1 46.2-21.6 4.9-41.3 13-58.9 20.2-4.2 1.7-8.3 3.4-12.3 5 13.3-24.1 24.4-51.4 32.1-71.4zm155.6 65.5c.1.2.2.5-.4.9h-.2l-.2.3c-.8.5-9 5.3-44.3-8.6 40.6-1.9 45 7.3 45.1 7.4zm191.4-388.2L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494z"}}]},name:"file-pdf",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},38434:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494zM504 618H320c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zM312 490v48c0 4.4 3.6 8 8 8h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H320c-4.4 0-8 3.6-8 8z"}}]},name:"file-text",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},10798:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880.1 154H143.9c-24.5 0-39.8 26.7-27.5 48L349 597.4V838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3 31.8-32V597.4L907.7 202c12.2-21.3-3.1-48-27.6-48zM603.4 798H420.6V642h182.9v156zm9.6-236.6l-9.5 16.6h-183l-9.5-16.6L212.7 226h598.6L613 561.4z"}}]},name:"filter",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},71282:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM653.3 424.6l52.2 52.2a8.01 8.01 0 01-4.7 13.6l-179.4 21c-5.1.6-9.5-3.7-8.9-8.9l21-179.4c.8-6.6 8.9-9.4 13.6-4.7l52.4 52.4 256.2-256.2c3.1-3.1 8.2-3.1 11.3 0l42.4 42.4c3.1 3.1 3.1 8.2 0 11.3L653.3 424.6z"}}]},name:"import",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},92403:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M608 112c-167.9 0-304 136.1-304 304 0 70.3 23.9 135 63.9 186.5l-41.1 41.1-62.3-62.3a8.15 8.15 0 00-11.4 0l-39.8 39.8a8.15 8.15 0 000 11.4l62.3 62.3-44.9 44.9-62.3-62.3a8.15 8.15 0 00-11.4 0l-39.8 39.8a8.15 8.15 0 000 11.4l62.3 62.3-65.3 65.3a8.03 8.03 0 000 11.3l42.3 42.3c3.1 3.1 8.2 3.1 11.3 0l253.6-253.6A304.06 304.06 0 00608 720c167.9 0 304-136.1 304-304S775.9 112 608 112zm161.2 465.2C726.2 620.3 668.9 644 608 644c-60.9 0-118.2-23.7-161.2-66.8-43.1-43-66.8-100.3-66.8-161.2 0-60.9 23.7-118.2 66.8-161.2 43-43.1 100.3-66.8 161.2-66.8 60.9 0 118.2 23.7 161.2 66.8 43.1 43 66.8 100.3 66.8 161.2 0 60.9-23.7 118.2-66.8 161.2z"}}]},name:"key",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},48231:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM305.8 637.7c3.1 3.1 8.1 3.1 11.3 0l138.3-137.6L583 628.5c3.1 3.1 8.2 3.1 11.3 0l275.4-275.3c3.1-3.1 3.1-8.2 0-11.3l-39.6-39.6a8.03 8.03 0 00-11.3 0l-230 229.9L461.4 404a8.03 8.03 0 00-11.3 0L266.3 586.7a8.03 8.03 0 000 11.3l39.5 39.7z"}}]},name:"line-chart",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},62272:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M574 665.4a8.03 8.03 0 00-11.3 0L446.5 781.6c-53.8 53.8-144.6 59.5-204 0-59.5-59.5-53.8-150.2 0-204l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3l-39.8-39.8a8.03 8.03 0 00-11.3 0L191.4 526.5c-84.6 84.6-84.6 221.5 0 306s221.5 84.6 306 0l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3L574 665.4zm258.6-474c-84.6-84.6-221.5-84.6-306 0L410.3 307.6a8.03 8.03 0 000 11.3l39.7 39.7c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c53.8-53.8 144.6-59.5 204 0 59.5 59.5 53.8 150.2 0 204L665.3 562.6a8.03 8.03 0 000 11.3l39.8 39.8c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c84.5-84.6 84.5-221.5 0-306.1zM610.1 372.3a8.03 8.03 0 00-11.3 0L372.3 598.7a8.03 8.03 0 000 11.3l39.6 39.6c3.1 3.1 8.2 3.1 11.3 0l226.4-226.4c3.1-3.1 3.1-8.2 0-11.3l-39.5-39.6z"}}]},name:"link",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},45246:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"}},{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}}]},name:"minus-circle",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},16601:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M872 394c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8H708V152c0-4.4-3.6-8-8-8h-64c-4.4 0-8 3.6-8 8v166H400V152c0-4.4-3.6-8-8-8h-64c-4.4 0-8 3.6-8 8v166H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h168v236H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h168v166c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V706h228v166c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V706h164c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8H708V394h164zM628 630H400V394h228v236z"}}]},name:"number",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},53508:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M779.3 196.6c-94.2-94.2-247.6-94.2-341.7 0l-261 260.8c-1.7 1.7-2.6 4-2.6 6.4s.9 4.7 2.6 6.4l36.9 36.9a9 9 0 0012.7 0l261-260.8c32.4-32.4 75.5-50.2 121.3-50.2s88.9 17.8 121.2 50.2c32.4 32.4 50.2 75.5 50.2 121.2 0 45.8-17.8 88.8-50.2 121.2l-266 265.9-43.1 43.1c-40.3 40.3-105.8 40.3-146.1 0-19.5-19.5-30.2-45.4-30.2-73s10.7-53.5 30.2-73l263.9-263.8c6.7-6.6 15.5-10.3 24.9-10.3h.1c9.4 0 18.1 3.7 24.7 10.3 6.7 6.7 10.3 15.5 10.3 24.9 0 9.3-3.7 18.1-10.3 24.7L372.4 653c-1.7 1.7-2.6 4-2.6 6.4s.9 4.7 2.6 6.4l36.9 36.9a9 9 0 0012.7 0l215.6-215.6c19.9-19.9 30.8-46.3 30.8-74.4s-11-54.6-30.8-74.4c-41.1-41.1-107.9-41-149 0L463 364 224.8 602.1A172.22 172.22 0 00174 724.8c0 46.3 18.1 89.8 50.8 122.5 33.9 33.8 78.3 50.7 122.7 50.7 44.4 0 88.8-16.9 122.6-50.7l309.2-309C824.8 492.7 850 432 850 367.5c.1-64.6-25.1-125.3-70.7-170.9z"}}]},name:"paper-clip",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},99890:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-40 632H136v-39.9l138.5-164.3 150.1 178L658.1 489 888 761.6V792zm0-129.8L664.2 396.8c-3.2-3.8-9-3.8-12.2 0L424.6 666.4l-144-170.7c-3.2-3.8-9-3.8-12.2 0L136 652.7V232h752v430.2zM304 456a88 88 0 100-176 88 88 0 000 176zm0-116c15.5 0 28 12.5 28 28s-12.5 28-28 28-28-12.5-28-28 12.5-28 28-28z"}}]},name:"picture",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},28595:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M719.4 499.1l-296.1-215A15.9 15.9 0 00398 297v430c0 13.1 14.8 20.5 25.3 12.9l296.1-215a15.9 15.9 0 000-25.8zm-257.6 134V390.9L628.5 512 461.8 633.1z"}}]},name:"play-circle",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},34419:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"}},{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}}]},name:"plus-circle",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},96473:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z"}},{tag:"path",attrs:{d:"M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8z"}}]},name:"plus",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},89245:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"}}]},name:"reload",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},69993:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M300 328a60 60 0 10120 0 60 60 0 10-120 0zM852 64H172c-17.7 0-32 14.3-32 32v660c0 17.7 14.3 32 32 32h680c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-32 660H204V128h616v596zM604 328a60 60 0 10120 0 60 60 0 10-120 0zm250.2 556H169.8c-16.5 0-29.8 14.3-29.8 32v36c0 4.4 3.3 8 7.4 8h729.1c4.1 0 7.4-3.6 7.4-8v-36c.1-17.7-13.2-32-29.7-32zM664 508H360c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h304c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z"}}]},name:"robot",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},78355:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M893.3 293.3L730.7 130.7c-7.5-7.5-16.7-13-26.7-16V112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V338.5c0-17-6.7-33.2-18.7-45.2zM384 184h256v104H384V184zm456 656H184V184h136v136c0 17.7 14.3 32 32 32h320c17.7 0 32-14.3 32-32V205.8l136 136V840zM512 442c-79.5 0-144 64.5-144 144s64.5 144 144 144 144-64.5 144-144-64.5-144-144-144zm0 224c-44.2 0-80-35.8-80-80s35.8-80 80-80 80 35.8 80 80-35.8 80-80 80z"}}]},name:"save",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},23907:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M931.4 498.9L94.9 79.5c-3.4-1.7-7.3-2.1-11-1.2a15.99 15.99 0 00-11.7 19.3l86.2 352.2c1.3 5.3 5.2 9.6 10.4 11.3l147.7 50.7-147.6 50.7c-5.2 1.8-9.1 6-10.3 11.3L72.2 926.5c-.9 3.7-.5 7.6 1.2 10.9 3.9 7.9 13.5 11.1 21.5 7.2l836.5-417c3.1-1.5 5.6-4.1 7.2-7.1 3.9-8 .7-17.6-7.2-21.6zM170.8 826.3l50.3-205.6 295.2-101.3c2.3-.8 4.2-2.6 5-5 1.4-4.2-.8-8.7-5-10.2L221.1 403 171 198.2l628 314.9-628.2 313.2z"}}]},name:"send",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},55322:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M924.8 625.7l-65.5-56c3.1-19 4.7-38.4 4.7-57.8s-1.6-38.8-4.7-57.8l65.5-56a32.03 32.03 0 009.3-35.2l-.9-2.6a443.74 443.74 0 00-79.7-137.9l-1.8-2.1a32.12 32.12 0 00-35.1-9.5l-81.3 28.9c-30-24.6-63.5-44-99.7-57.6l-15.7-85a32.05 32.05 0 00-25.8-25.7l-2.7-.5c-52.1-9.4-106.9-9.4-159 0l-2.7.5a32.05 32.05 0 00-25.8 25.7l-15.8 85.4a351.86 351.86 0 00-99 57.4l-81.9-29.1a32 32 0 00-35.1 9.5l-1.8 2.1a446.02 446.02 0 00-79.7 137.9l-.9 2.6c-4.5 12.5-.8 26.5 9.3 35.2l66.3 56.6c-3.1 18.8-4.6 38-4.6 57.1 0 19.2 1.5 38.4 4.6 57.1L99 625.5a32.03 32.03 0 00-9.3 35.2l.9 2.6c18.1 50.4 44.9 96.9 79.7 137.9l1.8 2.1a32.12 32.12 0 0035.1 9.5l81.9-29.1c29.8 24.5 63.1 43.9 99 57.4l15.8 85.4a32.05 32.05 0 0025.8 25.7l2.7.5a449.4 449.4 0 00159 0l2.7-.5a32.05 32.05 0 0025.8-25.7l15.7-85a350 350 0 0099.7-57.6l81.3 28.9a32 32 0 0035.1-9.5l1.8-2.1c34.8-41.1 61.6-87.5 79.7-137.9l.9-2.6c4.5-12.3.8-26.3-9.3-35zM788.3 465.9c2.5 15.1 3.8 30.6 3.8 46.1s-1.3 31-3.8 46.1l-6.6 40.1 74.7 63.9a370.03 370.03 0 01-42.6 73.6L721 702.8l-31.4 25.8c-23.9 19.6-50.5 35-79.3 45.8l-38.1 14.3-17.9 97a377.5 377.5 0 01-85 0l-17.9-97.2-37.8-14.5c-28.5-10.8-55-26.2-78.7-45.7l-31.4-25.9-93.4 33.2c-17-22.9-31.2-47.6-42.6-73.6l75.5-64.5-6.5-40c-2.4-14.9-3.7-30.3-3.7-45.5 0-15.3 1.2-30.6 3.7-45.5l6.5-40-75.5-64.5c11.3-26.1 25.6-50.7 42.6-73.6l93.4 33.2 31.4-25.9c23.7-19.5 50.2-34.9 78.7-45.7l37.9-14.3 17.9-97.2c28.1-3.2 56.8-3.2 85 0l17.9 97 38.1 14.3c28.7 10.8 55.4 26.2 79.3 45.8l31.4 25.8 92.8-32.9c17 22.9 31.2 47.6 42.6 73.6L781.8 426l6.5 39.9zM512 326c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm79.2 255.2A111.6 111.6 0 01512 614c-29.9 0-58-11.7-79.2-32.8A111.6 111.6 0 01400 502c0-29.9 11.7-58 32.8-79.2C454 401.6 482.1 390 512 390c29.9 0 58 11.6 79.2 32.8A111.6 111.6 0 01624 502c0 29.9-11.7 58-32.8 79.2z"}}]},name:"setting",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},8881:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372 0-89 31.3-170.8 83.5-234.8l523.3 523.3C682.8 852.7 601 884 512 884zm288.5-137.2L277.2 223.5C341.2 171.3 423 140 512 140c205.4 0 372 166.6 372 372 0 89-31.3 170.8-83.5 234.8z"}}]},name:"stop",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},71891:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M483.2 790.3L861.4 412c1.7-1.7 2.5-4 2.3-6.3l-25.5-301.4c-.7-7.8-6.8-13.9-14.6-14.6L522.2 64.3c-2.3-.2-4.7.6-6.3 2.3L137.7 444.8a8.03 8.03 0 000 11.3l334.2 334.2c3.1 3.2 8.2 3.2 11.3 0zm62.6-651.7l224.6 19 19 224.6L477.5 694 233.9 450.5l311.9-311.9zm60.16 186.23a48 48 0 1067.88-67.89 48 48 0 10-67.88 67.89zM889.7 539.8l-39.6-39.5a8.03 8.03 0 00-11.3 0l-362 361.3-237.6-237a8.03 8.03 0 00-11.3 0l-39.6 39.5a8.03 8.03 0 000 11.3l243.2 242.8 39.6 39.5c3.1 3.1 8.2 3.1 11.3 0l407.3-406.6c3.1-3.1 3.1-8.2 0-11.3z"}}]},name:"tags",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},41361:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M824.2 699.9a301.55 301.55 0 00-86.4-60.4C783.1 602.8 812 546.8 812 484c0-110.8-92.4-201.7-203.2-200-109.1 1.7-197 90.6-197 200 0 62.8 29 118.8 74.2 155.5a300.95 300.95 0 00-86.4 60.4C345 754.6 314 826.8 312 903.8a8 8 0 008 8.2h56c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5A226.62 226.62 0 01612 684c60.9 0 118.2 23.7 161.3 66.8C814.5 792 838 846.3 840 904.3c.1 4.3 3.7 7.7 8 7.7h56a8 8 0 008-8.2c-2-77-33-149.2-87.8-203.9zM612 612c-34.2 0-66.4-13.3-90.5-37.5a126.86 126.86 0 01-37.5-91.8c.3-32.8 13.4-64.5 36.3-88 24-24.6 56.1-38.3 90.4-38.7 33.9-.3 66.8 12.9 91 36.6 24.8 24.3 38.4 56.8 38.4 91.4 0 34.2-13.3 66.3-37.5 90.5A127.3 127.3 0 01612 612zM361.5 510.4c-.9-8.7-1.4-17.5-1.4-26.4 0-15.9 1.5-31.4 4.3-46.5.7-3.6-1.2-7.3-4.5-8.8-13.6-6.1-26.1-14.5-36.9-25.1a127.54 127.54 0 01-38.7-95.4c.9-32.1 13.8-62.6 36.3-85.6 24.7-25.3 57.9-39.1 93.2-38.7 31.9.3 62.7 12.6 86 34.4 7.9 7.4 14.7 15.6 20.4 24.4 2 3.1 5.9 4.4 9.3 3.2 17.6-6.1 36.2-10.4 55.3-12.4 5.6-.6 8.8-6.6 6.3-11.6-32.5-64.3-98.9-108.7-175.7-109.9-110.9-1.7-203.3 89.2-203.3 199.9 0 62.8 28.9 118.8 74.2 155.5-31.8 14.7-61.1 35-86.5 60.4-54.8 54.7-85.8 126.9-87.8 204a8 8 0 008 8.2h56.1c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5 29.4-29.4 65.4-49.8 104.7-59.7 3.9-1 6.5-4.7 6-8.7z"}}]},name:"team",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},58630:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M876.6 239.5c-.5-.9-1.2-1.8-2-2.5-5-5-13.1-5-18.1 0L684.2 409.3l-67.9-67.9L788.7 169c.8-.8 1.4-1.6 2-2.5 3.6-6.1 1.6-13.9-4.5-17.5-98.2-58-226.8-44.7-311.3 39.7-67 67-89.2 162-66.5 247.4l-293 293c-3 3-2.8 7.9.3 11l169.7 169.7c3.1 3.1 8.1 3.3 11 .3l292.9-292.9c85.5 22.8 180.5.7 247.6-66.4 84.4-84.5 97.7-213.1 39.7-311.3zM786 499.8c-58.1 58.1-145.3 69.3-214.6 33.6l-8.8 8.8-.1-.1-274 274.1-79.2-79.2 230.1-230.1s0 .1.1.1l52.8-52.8c-35.7-69.3-24.5-156.5 33.6-214.6a184.2 184.2 0 01144-53.5L537 318.9a32.05 32.05 0 000 45.3l124.5 124.5a32.05 32.05 0 0045.3 0l132.8-132.8c3.7 51.8-14.4 104.8-53.6 143.9z"}}]},name:"tool",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},3632:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M400 317.7h73.9V656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V317.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 163a8 8 0 00-12.6 0l-112 141.7c-4.1 5.3-.4 13 6.3 13zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"upload",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},35291:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1119),o=n(2265),i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8zm475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z"}}]},name:"warning",theme:"outlined"},a=n(55015),l=o.forwardRef(function(e,t){return o.createElement(a.Z,(0,r.Z)({},e,{ref:t,icon:i}))})},58747:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(5853),o=n(2265);let i=e=>{var t=(0,r._T)(e,[]);return o.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),o.createElement("path",{d:"M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z"}))}},4537:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(5853),o=n(2265);let i=e=>{var t=(0,r._T)(e,[]);return o.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),o.createElement("path",{d:"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 10.5858L9.17157 7.75736L7.75736 9.17157L10.5858 12L7.75736 14.8284L9.17157 16.2426L12 13.4142L14.8284 16.2426L16.2426 14.8284L13.4142 12L16.2426 9.17157L14.8284 7.75736L12 10.5858Z"}))}},75105:function(e,t,n){"use strict";n.d(t,{Z:function(){return et}});var r=n(5853),o=n(2265),i=n(47625),a=n(93765),l=n(87602),s=n(59221),c=n(86757),u=n.n(c),d=n(95645),f=n.n(d),p=n(77571),h=n.n(p),m=n(82559),g=n.n(m),v=n(21652),y=n.n(v),b=n(57165),x=n(81889),w=n(9841),k=n(58772),S=n(34067),E=n(16630),O=n(85355),C=n(82944),j=["layout","type","stroke","connectNulls","isRange","ref"];function _(e){return(_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function P(){return(P=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(i,j));return o.createElement(w.m,{clipPath:n?"url(#clipPath-".concat(r,")"):null},o.createElement(b.H,P({},(0,C.L6)(d,!0),{points:e,connectNulls:c,type:l,baseLine:t,layout:a,stroke:"none",className:"recharts-area-area"})),"none"!==s&&o.createElement(b.H,P({},(0,C.L6)(this.props,!1),{className:"recharts-area-curve",layout:a,type:l,connectNulls:c,fill:"none",points:e})),"none"!==s&&u&&o.createElement(b.H,P({},(0,C.L6)(this.props,!1),{className:"recharts-area-curve",layout:a,type:l,connectNulls:c,fill:"none",points:t})))}},{key:"renderAreaWithAnimation",value:function(e,t){var n=this,r=this.props,i=r.points,a=r.baseLine,l=r.isAnimationActive,c=r.animationBegin,u=r.animationDuration,d=r.animationEasing,f=r.animationId,p=this.state,m=p.prevPoints,v=p.prevBaseLine;return o.createElement(s.ZP,{begin:c,duration:u,isActive:l,easing:d,from:{t:0},to:{t:1},key:"area-".concat(f),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(r){var l=r.t;if(m){var s,c=m.length/i.length,u=i.map(function(e,t){var n=Math.floor(t*c);if(m[n]){var r=m[n],o=(0,E.k4)(r.x,e.x),i=(0,E.k4)(r.y,e.y);return T(T({},e),{},{x:o(l),y:i(l)})}return e});return s=(0,E.hj)(a)&&"number"==typeof a?(0,E.k4)(v,a)(l):h()(a)||g()(a)?(0,E.k4)(v,0)(l):a.map(function(e,t){var n=Math.floor(t*c);if(v[n]){var r=v[n],o=(0,E.k4)(r.x,e.x),i=(0,E.k4)(r.y,e.y);return T(T({},e),{},{x:o(l),y:i(l)})}return e}),n.renderAreaStatically(u,s,e,t)}return o.createElement(w.m,null,o.createElement("defs",null,o.createElement("clipPath",{id:"animationClipPath-".concat(t)},n.renderClipRect(l))),o.createElement(w.m,{clipPath:"url(#animationClipPath-".concat(t,")")},n.renderAreaStatically(i,a,e,t)))})}},{key:"renderArea",value:function(e,t){var n=this.props,r=n.points,o=n.baseLine,i=n.isAnimationActive,a=this.state,l=a.prevPoints,s=a.prevBaseLine,c=a.totalLength;return i&&r&&r.length&&(!l&&c>0||!y()(l,r)||!y()(s,o))?this.renderAreaWithAnimation(e,t):this.renderAreaStatically(r,o,e,t)}},{key:"render",value:function(){var e,t=this.props,n=t.hide,r=t.dot,i=t.points,a=t.className,s=t.top,c=t.left,u=t.xAxis,d=t.yAxis,f=t.width,p=t.height,m=t.isAnimationActive,g=t.id;if(n||!i||!i.length)return null;var v=this.state.isAnimationFinished,y=1===i.length,b=(0,l.Z)("recharts-area",a),x=u&&u.allowDataOverflow,S=d&&d.allowDataOverflow,E=x||S,O=h()(g)?this.id:g,j=null!==(e=(0,C.L6)(r,!1))&&void 0!==e?e:{r:3,strokeWidth:2},_=j.r,P=j.strokeWidth,N=((0,C.$k)(r)?r:{}).clipDot,T=void 0===N||N,A=2*(void 0===_?3:_)+(void 0===P?2:P);return o.createElement(w.m,{className:b},x||S?o.createElement("defs",null,o.createElement("clipPath",{id:"clipPath-".concat(O)},o.createElement("rect",{x:x?c:c-f/2,y:S?s:s-p/2,width:x?f:2*f,height:S?p:2*p})),!T&&o.createElement("clipPath",{id:"clipPath-dots-".concat(O)},o.createElement("rect",{x:c-A/2,y:s-A/2,width:f+A,height:p+A}))):null,y?null:this.renderArea(E,O),(r||y)&&this.renderDots(E,T,O),(!m||v)&&k.e.renderCallByParent(this.props,i))}}],r=[{key:"getDerivedStateFromProps",value:function(e,t){return e.animationId!==t.prevAnimationId?{prevAnimationId:e.animationId,curPoints:e.points,curBaseLine:e.baseLine,prevPoints:t.curPoints,prevBaseLine:t.curBaseLine}:e.points!==t.curPoints||e.baseLine!==t.curBaseLine?{curPoints:e.points,curBaseLine:e.baseLine}:null}}],n&&A(a.prototype,n),r&&A(a,r),Object.defineProperty(a,"prototype",{writable:!1}),a}(o.PureComponent);D(Z,"displayName","Area"),D(Z,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!S.x.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"}),D(Z,"getBaseValue",function(e,t,n,r){var o=e.layout,i=e.baseValue,a=t.props.baseValue,l=null!=a?a:i;if((0,E.hj)(l)&&"number"==typeof l)return l;var s="horizontal"===o?r:n,c=s.scale.domain();if("number"===s.type){var u=Math.max(c[0],c[1]),d=Math.min(c[0],c[1]);return"dataMin"===l?d:"dataMax"===l?u:u<0?u:Math.max(Math.min(c[0],c[1]),0)}return"dataMin"===l?c[0]:"dataMax"===l?c[1]:c[0]}),D(Z,"getComposedData",function(e){var t,n=e.props,r=e.item,o=e.xAxis,i=e.yAxis,a=e.xAxisTicks,l=e.yAxisTicks,s=e.bandSize,c=e.dataKey,u=e.stackedData,d=e.dataStartIndex,f=e.displayedData,p=e.offset,h=n.layout,m=u&&u.length,g=Z.getBaseValue(n,r,o,i),v="horizontal"===h,y=!1,b=f.map(function(e,t){m?n=u[d+t]:Array.isArray(n=(0,O.F$)(e,c))?y=!0:n=[g,n];var n,r=null==n[1]||m&&null==(0,O.F$)(e,c);return v?{x:(0,O.Hv)({axis:o,ticks:a,bandSize:s,entry:e,index:t}),y:r?null:i.scale(n[1]),value:n,payload:e}:{x:r?null:o.scale(n[1]),y:(0,O.Hv)({axis:i,ticks:l,bandSize:s,entry:e,index:t}),value:n,payload:e}});return t=m||y?b.map(function(e){var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:null!=t&&null!=e.y?i.scale(t):null}:{x:null!=t?o.scale(t):null,y:e.y}}):v?i.scale(g):o.scale(g),T({points:b,baseLine:t,layout:h,isRange:y},p)}),D(Z,"renderDotItem",function(e,t){return o.isValidElement(e)?o.cloneElement(e,t):u()(e)?e(t):o.createElement(x.o,P({},t,{className:"recharts-area-dot"}))});var z=n(97059),B=n(62994),F=n(25311),H=(0,a.z)({chartName:"AreaChart",GraphicalChild:Z,axisComponents:[{axisType:"xAxis",AxisComp:z.K},{axisType:"yAxis",AxisComp:B.B}],formatAxisMap:F.t9}),q=n(56940),U=n(8147),W=n(22190),K=n(54061),$=n(65278),V=n(98593),X=n(69448),G=n(32644),Y=n(7084),Q=n(26898),J=n(97324),ee=n(1153);let et=o.forwardRef((e,t)=>{let{data:n=[],categories:a=[],index:l,stack:s=!1,colors:c=Q.s,valueFormatter:u=ee.Cj,startEndOnly:d=!1,showXAxis:f=!0,showYAxis:p=!0,yAxisWidth:h=56,intervalType:m="equidistantPreserveStart",showAnimation:g=!1,animationDuration:v=900,showTooltip:y=!0,showLegend:b=!0,showGridLines:w=!0,showGradient:k=!0,autoMinValue:S=!1,curveType:E="linear",minValue:O,maxValue:C,connectNulls:j=!1,allowDecimals:_=!0,noDataText:P,className:N,onValueChange:T,enableLegendSlider:A=!1,customTooltip:M,rotateLabelX:I,tickGap:R=5}=e,D=(0,r._T)(e,["data","categories","index","stack","colors","valueFormatter","startEndOnly","showXAxis","showYAxis","yAxisWidth","intervalType","showAnimation","animationDuration","showTooltip","showLegend","showGridLines","showGradient","autoMinValue","curveType","minValue","maxValue","connectNulls","allowDecimals","noDataText","className","onValueChange","enableLegendSlider","customTooltip","rotateLabelX","tickGap"]),L=(f||p)&&(!d||p)?20:0,[F,et]=(0,o.useState)(60),[en,er]=(0,o.useState)(void 0),[eo,ei]=(0,o.useState)(void 0),ea=(0,G.me)(a,c),el=(0,G.i4)(S,O,C),es=!!T;function ec(e){es&&(e===eo&&!en||(0,G.FB)(n,e)&&en&&en.dataKey===e?(ei(void 0),null==T||T(null)):(ei(e),null==T||T({eventType:"category",categoryClicked:e})),er(void 0))}return o.createElement("div",Object.assign({ref:t,className:(0,J.q)("w-full h-80",N)},D),o.createElement(i.h,{className:"h-full w-full"},(null==n?void 0:n.length)?o.createElement(H,{data:n,onClick:es&&(eo||en)?()=>{er(void 0),ei(void 0),null==T||T(null)}:void 0},w?o.createElement(q.q,{className:(0,J.q)("stroke-1","stroke-tremor-border","dark:stroke-dark-tremor-border"),horizontal:!0,vertical:!1}):null,o.createElement(z.K,{padding:{left:L,right:L},hide:!f,dataKey:l,tick:{transform:"translate(0, 6)"},ticks:d?[n[0][l],n[n.length-1][l]]:void 0,fill:"",stroke:"",className:(0,J.q)("text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content"),interval:d?"preserveStartEnd":m,tickLine:!1,axisLine:!1,minTickGap:R,angle:null==I?void 0:I.angle,dy:null==I?void 0:I.verticalShift,height:null==I?void 0:I.xAxisHeight}),o.createElement(B.B,{width:h,hide:!p,axisLine:!1,tickLine:!1,type:"number",domain:el,tick:{transform:"translate(-3, 0)"},fill:"",stroke:"",className:(0,J.q)("text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content"),tickFormatter:u,allowDecimals:_}),o.createElement(U.u,{wrapperStyle:{outline:"none"},isAnimationActive:!1,cursor:{stroke:"#d1d5db",strokeWidth:1},content:y?e=>{let{active:t,payload:n,label:r}=e;return M?o.createElement(M,{payload:null==n?void 0:n.map(e=>{var t;return Object.assign(Object.assign({},e),{color:null!==(t=ea.get(e.dataKey))&&void 0!==t?t:Y.fr.Gray})}),active:t,label:r}):o.createElement(V.ZP,{active:t,payload:n,label:r,valueFormatter:u,categoryColors:ea})}:o.createElement(o.Fragment,null),position:{y:0}}),b?o.createElement(W.D,{verticalAlign:"top",height:F,content:e=>{let{payload:t}=e;return(0,$.Z)({payload:t},ea,et,eo,es?e=>ec(e):void 0,A)}}):null,a.map(e=>{var t,n;return o.createElement("defs",{key:e},k?o.createElement("linearGradient",{className:(0,ee.bM)(null!==(t=ea.get(e))&&void 0!==t?t:Y.fr.Gray,Q.K.text).textColor,id:ea.get(e),x1:"0",y1:"0",x2:"0",y2:"1"},o.createElement("stop",{offset:"5%",stopColor:"currentColor",stopOpacity:en||eo&&eo!==e?.15:.4}),o.createElement("stop",{offset:"95%",stopColor:"currentColor",stopOpacity:0})):o.createElement("linearGradient",{className:(0,ee.bM)(null!==(n=ea.get(e))&&void 0!==n?n:Y.fr.Gray,Q.K.text).textColor,id:ea.get(e),x1:"0",y1:"0",x2:"0",y2:"1"},o.createElement("stop",{stopColor:"currentColor",stopOpacity:en||eo&&eo!==e?.1:.3})))}),a.map(e=>{var t;return o.createElement(Z,{className:(0,ee.bM)(null!==(t=ea.get(e))&&void 0!==t?t:Y.fr.Gray,Q.K.text).strokeColor,strokeOpacity:en||eo&&eo!==e?.3:1,activeDot:e=>{var t;let{cx:r,cy:i,stroke:a,strokeLinecap:l,strokeLinejoin:s,strokeWidth:c,dataKey:u}=e;return o.createElement(x.o,{className:(0,J.q)("stroke-tremor-background dark:stroke-dark-tremor-background",T?"cursor-pointer":"",(0,ee.bM)(null!==(t=ea.get(u))&&void 0!==t?t:Y.fr.Gray,Q.K.text).fillColor),cx:r,cy:i,r:5,fill:"",stroke:a,strokeLinecap:l,strokeLinejoin:s,strokeWidth:c,onClick:(t,r)=>{r.stopPropagation(),es&&(e.index===(null==en?void 0:en.index)&&e.dataKey===(null==en?void 0:en.dataKey)||(0,G.FB)(n,e.dataKey)&&eo&&eo===e.dataKey?(ei(void 0),er(void 0),null==T||T(null)):(ei(e.dataKey),er({index:e.index,dataKey:e.dataKey}),null==T||T(Object.assign({eventType:"dot",categoryClicked:e.dataKey},e.payload))))}})},dot:t=>{var r;let{stroke:i,strokeLinecap:a,strokeLinejoin:l,strokeWidth:s,cx:c,cy:u,dataKey:d,index:f}=t;return(0,G.FB)(n,e)&&!(en||eo&&eo!==e)||(null==en?void 0:en.index)===f&&(null==en?void 0:en.dataKey)===e?o.createElement(x.o,{key:f,cx:c,cy:u,r:5,stroke:i,fill:"",strokeLinecap:a,strokeLinejoin:l,strokeWidth:s,className:(0,J.q)("stroke-tremor-background dark:stroke-dark-tremor-background",T?"cursor-pointer":"",(0,ee.bM)(null!==(r=ea.get(d))&&void 0!==r?r:Y.fr.Gray,Q.K.text).fillColor)}):o.createElement(o.Fragment,{key:f})},key:e,name:e,type:E,dataKey:e,stroke:"",fill:"url(#".concat(ea.get(e),")"),strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",isAnimationActive:g,animationDuration:v,stackId:s?"a":void 0,connectNulls:j})}),T?a.map(e=>o.createElement(K.x,{className:(0,J.q)("cursor-pointer"),strokeOpacity:0,key:e,name:e,type:E,dataKey:e,stroke:"transparent",fill:"transparent",legendType:"none",tooltipType:"none",strokeWidth:12,connectNulls:j,onClick:(e,t)=>{t.stopPropagation();let{name:n}=e;ec(n)}})):null):o.createElement(X.Z,{noDataText:P})))});et.displayName="AreaChart"},40278:function(e,t,n){"use strict";n.d(t,{Z:function(){return S}});var r=n(5853),o=n(7084),i=n(26898),a=n(97324),l=n(1153),s=n(2265),c=n(47625),u=n(93765),d=n(31699),f=n(97059),p=n(62994),h=n(25311),m=(0,u.z)({chartName:"BarChart",GraphicalChild:d.$,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:f.K},{axisType:"yAxis",AxisComp:p.B}],formatAxisMap:h.t9}),g=n(56940),v=n(8147),y=n(22190),b=n(65278),x=n(98593),w=n(69448),k=n(32644);let S=s.forwardRef((e,t)=>{let{data:n=[],categories:u=[],index:h,colors:S=i.s,valueFormatter:E=l.Cj,layout:O="horizontal",stack:C=!1,relative:j=!1,startEndOnly:_=!1,animationDuration:P=900,showAnimation:N=!1,showXAxis:T=!0,showYAxis:A=!0,yAxisWidth:M=56,intervalType:I="equidistantPreserveStart",showTooltip:R=!0,showLegend:D=!0,showGridLines:L=!0,autoMinValue:Z=!1,minValue:z,maxValue:B,allowDecimals:F=!0,noDataText:H,onValueChange:q,enableLegendSlider:U=!1,customTooltip:W,rotateLabelX:K,tickGap:$=5,className:V}=e,X=(0,r._T)(e,["data","categories","index","colors","valueFormatter","layout","stack","relative","startEndOnly","animationDuration","showAnimation","showXAxis","showYAxis","yAxisWidth","intervalType","showTooltip","showLegend","showGridLines","autoMinValue","minValue","maxValue","allowDecimals","noDataText","onValueChange","enableLegendSlider","customTooltip","rotateLabelX","tickGap","className"]),G=T||A?20:0,[Y,Q]=(0,s.useState)(60),J=(0,k.me)(u,S),[ee,et]=s.useState(void 0),[en,er]=(0,s.useState)(void 0),eo=!!q;function ei(e,t,n){var r,o,i,a;n.stopPropagation(),q&&((0,k.vZ)(ee,Object.assign(Object.assign({},e.payload),{value:e.value}))?(er(void 0),et(void 0),null==q||q(null)):(er(null===(o=null===(r=e.tooltipPayload)||void 0===r?void 0:r[0])||void 0===o?void 0:o.dataKey),et(Object.assign(Object.assign({},e.payload),{value:e.value})),null==q||q(Object.assign({eventType:"bar",categoryClicked:null===(a=null===(i=e.tooltipPayload)||void 0===i?void 0:i[0])||void 0===a?void 0:a.dataKey},e.payload))))}let ea=(0,k.i4)(Z,z,B);return s.createElement("div",Object.assign({ref:t,className:(0,a.q)("w-full h-80",V)},X),s.createElement(c.h,{className:"h-full w-full"},(null==n?void 0:n.length)?s.createElement(m,{data:n,stackOffset:C?"sign":j?"expand":"none",layout:"vertical"===O?"vertical":"horizontal",onClick:eo&&(en||ee)?()=>{et(void 0),er(void 0),null==q||q(null)}:void 0},L?s.createElement(g.q,{className:(0,a.q)("stroke-1","stroke-tremor-border","dark:stroke-dark-tremor-border"),horizontal:"vertical"!==O,vertical:"vertical"===O}):null,"vertical"!==O?s.createElement(f.K,{padding:{left:G,right:G},hide:!T,dataKey:h,interval:_?"preserveStartEnd":I,tick:{transform:"translate(0, 6)"},ticks:_?[n[0][h],n[n.length-1][h]]:void 0,fill:"",stroke:"",className:(0,a.q)("mt-4 text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content"),tickLine:!1,axisLine:!1,angle:null==K?void 0:K.angle,dy:null==K?void 0:K.verticalShift,height:null==K?void 0:K.xAxisHeight,minTickGap:$}):s.createElement(f.K,{hide:!T,type:"number",tick:{transform:"translate(-3, 0)"},domain:ea,fill:"",stroke:"",className:(0,a.q)("text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content"),tickLine:!1,axisLine:!1,tickFormatter:E,minTickGap:$,allowDecimals:F,angle:null==K?void 0:K.angle,dy:null==K?void 0:K.verticalShift,height:null==K?void 0:K.xAxisHeight}),"vertical"!==O?s.createElement(p.B,{width:M,hide:!A,axisLine:!1,tickLine:!1,type:"number",domain:ea,tick:{transform:"translate(-3, 0)"},fill:"",stroke:"",className:(0,a.q)("text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content"),tickFormatter:j?e=>"".concat((100*e).toString()," %"):E,allowDecimals:F}):s.createElement(p.B,{width:M,hide:!A,dataKey:h,axisLine:!1,tickLine:!1,ticks:_?[n[0][h],n[n.length-1][h]]:void 0,type:"category",interval:"preserveStartEnd",tick:{transform:"translate(0, 6)"},fill:"",stroke:"",className:(0,a.q)("text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content")}),s.createElement(v.u,{wrapperStyle:{outline:"none"},isAnimationActive:!1,cursor:{fill:"#d1d5db",opacity:"0.15"},content:R?e=>{let{active:t,payload:n,label:r}=e;return W?s.createElement(W,{payload:null==n?void 0:n.map(e=>{var t;return Object.assign(Object.assign({},e),{color:null!==(t=J.get(e.dataKey))&&void 0!==t?t:o.fr.Gray})}),active:t,label:r}):s.createElement(x.ZP,{active:t,payload:n,label:r,valueFormatter:E,categoryColors:J})}:s.createElement(s.Fragment,null),position:{y:0}}),D?s.createElement(y.D,{verticalAlign:"top",height:Y,content:e=>{let{payload:t}=e;return(0,b.Z)({payload:t},J,Q,en,eo?e=>{eo&&(e!==en||ee?(er(e),null==q||q({eventType:"category",categoryClicked:e})):(er(void 0),null==q||q(null)),et(void 0))}:void 0,U)}}):null,u.map(e=>{var t;return s.createElement(d.$,{className:(0,a.q)((0,l.bM)(null!==(t=J.get(e))&&void 0!==t?t:o.fr.Gray,i.K.background).fillColor,q?"cursor-pointer":""),key:e,name:e,type:"linear",stackId:C||j?"a":void 0,dataKey:e,fill:"",isAnimationActive:N,animationDuration:P,shape:e=>((e,t,n,r)=>{let{fillOpacity:o,name:i,payload:a,value:l}=e,{x:c,width:u,y:d,height:f}=e;return"horizontal"===r&&f<0?(d+=f,f=Math.abs(f)):"vertical"===r&&u<0&&(c+=u,u=Math.abs(u)),s.createElement("rect",{x:c,y:d,width:u,height:f,opacity:t||n&&n!==i?(0,k.vZ)(t,Object.assign(Object.assign({},a),{value:l}))?o:.3:o})})(e,ee,en,O),onClick:ei})})):s.createElement(w.Z,{noDataText:H})))});S.displayName="BarChart"},14042:function(e,t,n){"use strict";n.d(t,{Z:function(){return ez}});var r=n(5853),o=n(7084),i=n(26898),a=n(97324),l=n(1153),s=n(2265),c=n(60474),u=n(47625),d=n(93765),f=n(86757),p=n.n(f),h=n(9841),m=n(81889),g=n(87602),v=n(82944),y=["points","className","baseLinePoints","connectNulls"];function b(){return(b=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n0&&void 0!==arguments[0]?arguments[0]:[],t=[[]];return e.forEach(function(e){k(e)?t[t.length-1].push(e):t[t.length-1].length>0&&t.push([])}),k(e[0])&&t[t.length-1].push(e[0]),t[t.length-1].length<=0&&(t=t.slice(0,-1)),t},E=function(e,t){var n=S(e);t&&(n=[n.reduce(function(e,t){return[].concat(x(e),x(t))},[])]);var r=n.map(function(e){return e.reduce(function(e,t,n){return"".concat(e).concat(0===n?"M":"L").concat(t.x,",").concat(t.y)},"")}).join("");return 1===n.length?"".concat(r,"Z"):r},O=function(e,t,n){var r=E(e,n);return"".concat("Z"===r.slice(-1)?r.slice(0,-1):r,"L").concat(E(t.reverse(),n).slice(1))},C=function(e){var t=e.points,n=e.className,r=e.baseLinePoints,o=e.connectNulls,i=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,y);if(!t||!t.length)return null;var a=(0,g.Z)("recharts-polygon",n);if(r&&r.length){var l=i.stroke&&"none"!==i.stroke,c=O(t,r,o);return s.createElement("g",{className:a},s.createElement("path",b({},(0,v.L6)(i,!0),{fill:"Z"===c.slice(-1)?i.fill:"none",stroke:"none",d:c})),l?s.createElement("path",b({},(0,v.L6)(i,!0),{fill:"none",d:E(t,o)})):null,l?s.createElement("path",b({},(0,v.L6)(i,!0),{fill:"none",d:E(r,o)})):null)}var u=E(t,o);return s.createElement("path",b({},(0,v.L6)(i,!0),{fill:"Z"===u.slice(-1)?i.fill:"none",className:a,d:u}))},j=n(58811),_=n(41637),P=n(39206);function N(e){return(N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function T(){return(T=Object.assign?Object.assign.bind():function(e){for(var t=1;t1e-5?"outer"===t?"start":"end":n<-.00001?"outer"===t?"end":"start":"middle"}},{key:"renderAxisLine",value:function(){var e=this.props,t=e.cx,n=e.cy,r=e.radius,o=e.axisLine,i=e.axisLineType,a=M(M({},(0,v.L6)(this.props,!1)),{},{fill:"none"},(0,v.L6)(o,!1));if("circle"===i)return s.createElement(m.o,T({className:"recharts-polar-angle-axis-line"},a,{cx:t,cy:n,r:r}));var l=this.props.ticks.map(function(e){return(0,P.op)(t,n,r,e.coordinate)});return s.createElement(C,T({className:"recharts-polar-angle-axis-line"},a,{points:l}))}},{key:"renderTicks",value:function(){var e=this,t=this.props,n=t.ticks,r=t.tick,o=t.tickLine,a=t.tickFormatter,l=t.stroke,c=(0,v.L6)(this.props,!1),u=(0,v.L6)(r,!1),d=M(M({},c),{},{fill:"none"},(0,v.L6)(o,!1)),f=n.map(function(t,n){var f=e.getTickLineCoord(t),p=M(M(M({textAnchor:e.getTickTextAnchor(t)},c),{},{stroke:"none",fill:l},u),{},{index:n,payload:t,x:f.x2,y:f.y2});return s.createElement(h.m,T({className:"recharts-polar-angle-axis-tick",key:"tick-".concat(t.coordinate)},(0,_.bw)(e.props,t,n)),o&&s.createElement("line",T({className:"recharts-polar-angle-axis-tick-line"},d,f)),r&&i.renderTickItem(r,p,a?a(t.value,n):t.value))});return s.createElement(h.m,{className:"recharts-polar-angle-axis-ticks"},f)}},{key:"render",value:function(){var e=this.props,t=e.ticks,n=e.radius,r=e.axisLine;return!(n<=0)&&t&&t.length?s.createElement(h.m,{className:"recharts-polar-angle-axis"},r&&this.renderAxisLine(),this.renderTicks()):null}}],r=[{key:"renderTickItem",value:function(e,t,n){return s.isValidElement(e)?s.cloneElement(e,t):p()(e)?e(t):s.createElement(j.x,T({},t,{className:"recharts-polar-angle-axis-tick-value"}),n)}}],n&&I(i.prototype,n),r&&I(i,r),Object.defineProperty(i,"prototype",{writable:!1}),i}(s.PureComponent);L(B,"displayName","PolarAngleAxis"),L(B,"axisType","angleAxis"),L(B,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var F=n(35802),H=n.n(F),q=n(37891),U=n.n(q),W=n(26680),K=["cx","cy","angle","ticks","axisLine"],$=["ticks","tick","angle","tickFormatter","stroke"];function V(e){return(V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function X(){return(X=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function J(e,t){for(var n=0;n0?el()(e,"paddingAngle",0):0;if(n){var l=(0,eg.k4)(n.endAngle-n.startAngle,e.endAngle-e.startAngle),s=eS(eS({},e),{},{startAngle:i+a,endAngle:i+l(r)+a});o.push(s),i=s.endAngle}else{var c=e.endAngle,d=e.startAngle,f=(0,eg.k4)(0,c-d)(r),p=eS(eS({},e),{},{startAngle:i+a,endAngle:i+f+a});o.push(p),i=p.endAngle}}),s.createElement(h.m,null,e.renderSectorsStatically(o))})}},{key:"attachKeyboardHandlers",value:function(e){var t=this;e.onkeydown=function(e){if(!e.altKey)switch(e.key){case"ArrowLeft":var n=++t.state.sectorToFocus%t.sectorRefs.length;t.sectorRefs[n].focus(),t.setState({sectorToFocus:n});break;case"ArrowRight":var r=--t.state.sectorToFocus<0?t.sectorRefs.length-1:t.state.sectorToFocus%t.sectorRefs.length;t.sectorRefs[r].focus(),t.setState({sectorToFocus:r});break;case"Escape":t.sectorRefs[t.state.sectorToFocus].blur(),t.setState({sectorToFocus:0})}}}},{key:"renderSectors",value:function(){var e=this.props,t=e.sectors,n=e.isAnimationActive,r=this.state.prevSectors;return n&&t&&t.length&&(!r||!ec()(r,t))?this.renderSectorsWithAnimation():this.renderSectorsStatically(t)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var e=this,t=this.props,n=t.hide,r=t.sectors,o=t.className,i=t.label,a=t.cx,l=t.cy,c=t.innerRadius,u=t.outerRadius,d=t.isAnimationActive,f=this.state.isAnimationFinished;if(n||!r||!r.length||!(0,eg.hj)(a)||!(0,eg.hj)(l)||!(0,eg.hj)(c)||!(0,eg.hj)(u))return null;var p=(0,g.Z)("recharts-pie",o);return s.createElement(h.m,{tabIndex:this.props.rootTabIndex,className:p,ref:function(t){e.pieRef=t}},this.renderSectors(),i&&this.renderLabels(r),W._.renderCallByParent(this.props,null,!1),(!d||f)&&ep.e.renderCallByParent(this.props,r,!1))}}],r=[{key:"getDerivedStateFromProps",value:function(e,t){return t.prevIsAnimationActive!==e.isAnimationActive?{prevIsAnimationActive:e.isAnimationActive,prevAnimationId:e.animationId,curSectors:e.sectors,prevSectors:[],isAnimationFinished:!0}:e.isAnimationActive&&e.animationId!==t.prevAnimationId?{prevAnimationId:e.animationId,curSectors:e.sectors,prevSectors:t.curSectors,isAnimationFinished:!0}:e.sectors!==t.curSectors?{curSectors:e.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(e,t){return e>t?"start":e=360?x:x-1)*u,k=i.reduce(function(e,t){var n=(0,ev.F$)(t,b,0);return e+((0,eg.hj)(n)?n:0)},0);return k>0&&(t=i.map(function(e,t){var r,o=(0,ev.F$)(e,b,0),i=(0,ev.F$)(e,f,t),a=((0,eg.hj)(o)?o:0)/k,c=(r=t?n.endAngle+(0,eg.uY)(v)*u*(0!==o?1:0):s)+(0,eg.uY)(v)*((0!==o?m:0)+a*w),d=(r+c)/2,p=(g.innerRadius+g.outerRadius)/2,y=[{name:i,value:o,payload:e,dataKey:b,type:h}],x=(0,P.op)(g.cx,g.cy,p,d);return n=eS(eS(eS({percent:a,cornerRadius:l,name:i,tooltipPayload:y,midAngle:d,middleRadius:p,tooltipPosition:x},e),g),{},{value:(0,ev.F$)(e,b),startAngle:r,endAngle:c,payload:e,paddingAngle:(0,eg.uY)(v)*u})})),eS(eS({},g),{},{sectors:t,data:i})});var eT=(0,d.z)({chartName:"PieChart",GraphicalChild:eN,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:B},{axisType:"radiusAxis",AxisComp:eo}],formatAxisMap:P.t9,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}}),eA=n(8147),eM=n(69448),eI=n(98593);let eR=e=>{let{active:t,payload:n,valueFormatter:r}=e;if(t&&(null==n?void 0:n[0])){let e=null==n?void 0:n[0];return s.createElement(eI.$B,null,s.createElement("div",{className:(0,a.q)("px-4 py-2")},s.createElement(eI.zX,{value:r(e.value),name:e.name,color:e.payload.color})))}return null},eD=(e,t)=>e.map((e,n)=>{let r=ne||t((0,l.vP)(n.map(e=>e[r]))),eZ=e=>{let{cx:t,cy:n,innerRadius:r,outerRadius:o,startAngle:i,endAngle:a,className:l}=e;return s.createElement("g",null,s.createElement(c.L,{cx:t,cy:n,innerRadius:r,outerRadius:o,startAngle:i,endAngle:a,className:l,fill:"",opacity:.3,style:{outline:"none"}}))},ez=s.forwardRef((e,t)=>{let{data:n=[],category:c="value",index:d="name",colors:f=i.s,variant:p="donut",valueFormatter:h=l.Cj,label:m,showLabel:g=!0,animationDuration:v=900,showAnimation:y=!1,showTooltip:b=!0,noDataText:x,onValueChange:w,customTooltip:k,className:S}=e,E=(0,r._T)(e,["data","category","index","colors","variant","valueFormatter","label","showLabel","animationDuration","showAnimation","showTooltip","noDataText","onValueChange","customTooltip","className"]),O="donut"==p,C=eL(m,h,n,c),[j,_]=s.useState(void 0),P=!!w;return(0,s.useEffect)(()=>{let e=document.querySelectorAll(".recharts-pie-sector");e&&e.forEach(e=>{e.setAttribute("style","outline: none")})},[j]),s.createElement("div",Object.assign({ref:t,className:(0,a.q)("w-full h-40",S)},E),s.createElement(u.h,{className:"h-full w-full"},(null==n?void 0:n.length)?s.createElement(eT,{onClick:P&&j?()=>{_(void 0),null==w||w(null)}:void 0,margin:{top:0,left:0,right:0,bottom:0}},g&&O?s.createElement("text",{className:(0,a.q)("fill-tremor-content-emphasis","dark:fill-dark-tremor-content-emphasis"),x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle"},C):null,s.createElement(eN,{className:(0,a.q)("stroke-tremor-background dark:stroke-dark-tremor-background",w?"cursor-pointer":"cursor-default"),data:eD(n,f),cx:"50%",cy:"50%",startAngle:90,endAngle:-270,innerRadius:O?"75%":"0%",outerRadius:"100%",stroke:"",strokeLinejoin:"round",dataKey:c,nameKey:d,isAnimationActive:y,animationDuration:v,onClick:function(e,t,n){n.stopPropagation(),P&&(j===t?(_(void 0),null==w||w(null)):(_(t),null==w||w(Object.assign({eventType:"slice"},e.payload.payload))))},activeIndex:j,inactiveShape:eZ,style:{outline:"none"}}),s.createElement(eA.u,{wrapperStyle:{outline:"none"},isAnimationActive:!1,content:b?e=>{var t;let{active:n,payload:r}=e;return k?s.createElement(k,{payload:null==r?void 0:r.map(e=>{var t,n,i;return Object.assign(Object.assign({},e),{color:null!==(i=null===(n=null===(t=null==r?void 0:r[0])||void 0===t?void 0:t.payload)||void 0===n?void 0:n.color)&&void 0!==i?i:o.fr.Gray})}),active:n,label:null===(t=null==r?void 0:r[0])||void 0===t?void 0:t.name}):s.createElement(eR,{active:n,payload:r,valueFormatter:h})}:s.createElement(s.Fragment,null)})):s.createElement(eM.Z,{noDataText:x})))});ez.displayName="DonutChart"},59664:function(e,t,n){"use strict";n.d(t,{Z:function(){return E}});var r=n(5853),o=n(2265),i=n(47625),a=n(93765),l=n(54061),s=n(97059),c=n(62994),u=n(25311),d=(0,a.z)({chartName:"LineChart",GraphicalChild:l.x,axisComponents:[{axisType:"xAxis",AxisComp:s.K},{axisType:"yAxis",AxisComp:c.B}],formatAxisMap:u.t9}),f=n(56940),p=n(8147),h=n(22190),m=n(81889),g=n(65278),v=n(98593),y=n(69448),b=n(32644),x=n(7084),w=n(26898),k=n(97324),S=n(1153);let E=o.forwardRef((e,t)=>{let{data:n=[],categories:a=[],index:u,colors:E=w.s,valueFormatter:O=S.Cj,startEndOnly:C=!1,showXAxis:j=!0,showYAxis:_=!0,yAxisWidth:P=56,intervalType:N="equidistantPreserveStart",animationDuration:T=900,showAnimation:A=!1,showTooltip:M=!0,showLegend:I=!0,showGridLines:R=!0,autoMinValue:D=!1,curveType:L="linear",minValue:Z,maxValue:z,connectNulls:B=!1,allowDecimals:F=!0,noDataText:H,className:q,onValueChange:U,enableLegendSlider:W=!1,customTooltip:K,rotateLabelX:$,tickGap:V=5}=e,X=(0,r._T)(e,["data","categories","index","colors","valueFormatter","startEndOnly","showXAxis","showYAxis","yAxisWidth","intervalType","animationDuration","showAnimation","showTooltip","showLegend","showGridLines","autoMinValue","curveType","minValue","maxValue","connectNulls","allowDecimals","noDataText","className","onValueChange","enableLegendSlider","customTooltip","rotateLabelX","tickGap"]),G=j||_?20:0,[Y,Q]=(0,o.useState)(60),[J,ee]=(0,o.useState)(void 0),[et,en]=(0,o.useState)(void 0),er=(0,b.me)(a,E),eo=(0,b.i4)(D,Z,z),ei=!!U;function ea(e){ei&&(e===et&&!J||(0,b.FB)(n,e)&&J&&J.dataKey===e?(en(void 0),null==U||U(null)):(en(e),null==U||U({eventType:"category",categoryClicked:e})),ee(void 0))}return o.createElement("div",Object.assign({ref:t,className:(0,k.q)("w-full h-80",q)},X),o.createElement(i.h,{className:"h-full w-full"},(null==n?void 0:n.length)?o.createElement(d,{data:n,onClick:ei&&(et||J)?()=>{ee(void 0),en(void 0),null==U||U(null)}:void 0},R?o.createElement(f.q,{className:(0,k.q)("stroke-1","stroke-tremor-border","dark:stroke-dark-tremor-border"),horizontal:!0,vertical:!1}):null,o.createElement(s.K,{padding:{left:G,right:G},hide:!j,dataKey:u,interval:C?"preserveStartEnd":N,tick:{transform:"translate(0, 6)"},ticks:C?[n[0][u],n[n.length-1][u]]:void 0,fill:"",stroke:"",className:(0,k.q)("text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content"),tickLine:!1,axisLine:!1,minTickGap:V,angle:null==$?void 0:$.angle,dy:null==$?void 0:$.verticalShift,height:null==$?void 0:$.xAxisHeight}),o.createElement(c.B,{width:P,hide:!_,axisLine:!1,tickLine:!1,type:"number",domain:eo,tick:{transform:"translate(-3, 0)"},fill:"",stroke:"",className:(0,k.q)("text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content"),tickFormatter:O,allowDecimals:F}),o.createElement(p.u,{wrapperStyle:{outline:"none"},isAnimationActive:!1,cursor:{stroke:"#d1d5db",strokeWidth:1},content:M?e=>{let{active:t,payload:n,label:r}=e;return K?o.createElement(K,{payload:null==n?void 0:n.map(e=>{var t;return Object.assign(Object.assign({},e),{color:null!==(t=er.get(e.dataKey))&&void 0!==t?t:x.fr.Gray})}),active:t,label:r}):o.createElement(v.ZP,{active:t,payload:n,label:r,valueFormatter:O,categoryColors:er})}:o.createElement(o.Fragment,null),position:{y:0}}),I?o.createElement(h.D,{verticalAlign:"top",height:Y,content:e=>{let{payload:t}=e;return(0,g.Z)({payload:t},er,Q,et,ei?e=>ea(e):void 0,W)}}):null,a.map(e=>{var t;return o.createElement(l.x,{className:(0,k.q)((0,S.bM)(null!==(t=er.get(e))&&void 0!==t?t:x.fr.Gray,w.K.text).strokeColor),strokeOpacity:J||et&&et!==e?.3:1,activeDot:e=>{var t;let{cx:r,cy:i,stroke:a,strokeLinecap:l,strokeLinejoin:s,strokeWidth:c,dataKey:u}=e;return o.createElement(m.o,{className:(0,k.q)("stroke-tremor-background dark:stroke-dark-tremor-background",U?"cursor-pointer":"",(0,S.bM)(null!==(t=er.get(u))&&void 0!==t?t:x.fr.Gray,w.K.text).fillColor),cx:r,cy:i,r:5,fill:"",stroke:a,strokeLinecap:l,strokeLinejoin:s,strokeWidth:c,onClick:(t,r)=>{r.stopPropagation(),ei&&(e.index===(null==J?void 0:J.index)&&e.dataKey===(null==J?void 0:J.dataKey)||(0,b.FB)(n,e.dataKey)&&et&&et===e.dataKey?(en(void 0),ee(void 0),null==U||U(null)):(en(e.dataKey),ee({index:e.index,dataKey:e.dataKey}),null==U||U(Object.assign({eventType:"dot",categoryClicked:e.dataKey},e.payload))))}})},dot:t=>{var r;let{stroke:i,strokeLinecap:a,strokeLinejoin:l,strokeWidth:s,cx:c,cy:u,dataKey:d,index:f}=t;return(0,b.FB)(n,e)&&!(J||et&&et!==e)||(null==J?void 0:J.index)===f&&(null==J?void 0:J.dataKey)===e?o.createElement(m.o,{key:f,cx:c,cy:u,r:5,stroke:i,fill:"",strokeLinecap:a,strokeLinejoin:l,strokeWidth:s,className:(0,k.q)("stroke-tremor-background dark:stroke-dark-tremor-background",U?"cursor-pointer":"",(0,S.bM)(null!==(r=er.get(d))&&void 0!==r?r:x.fr.Gray,w.K.text).fillColor)}):o.createElement(o.Fragment,{key:f})},key:e,name:e,type:L,dataKey:e,stroke:"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",isAnimationActive:A,animationDuration:T,connectNulls:B})}),U?a.map(e=>o.createElement(l.x,{className:(0,k.q)("cursor-pointer"),strokeOpacity:0,key:e,name:e,type:L,dataKey:e,stroke:"transparent",fill:"transparent",legendType:"none",tooltipType:"none",strokeWidth:12,connectNulls:B,onClick:(e,t)=>{t.stopPropagation();let{name:n}=e;ea(n)}})):null):o.createElement(y.Z,{noDataText:H})))});E.displayName="LineChart"},65278:function(e,t,n){"use strict";n.d(t,{Z:function(){return m}});var r=n(2265);let o=(e,t)=>{let[n,o]=(0,r.useState)(t);(0,r.useEffect)(()=>{let t=()=>{o(window.innerWidth),e()};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[e,n])};var i=n(5853),a=n(26898),l=n(97324),s=n(1153);let c=e=>{var t=(0,i._T)(e,[]);return r.createElement("svg",Object.assign({},t,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"}),r.createElement("path",{d:"M8 12L14 6V18L8 12Z"}))},u=e=>{var t=(0,i._T)(e,[]);return r.createElement("svg",Object.assign({},t,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"}),r.createElement("path",{d:"M16 12L10 18V6L16 12Z"}))},d=(0,s.fn)("Legend"),f=e=>{let{name:t,color:n,onClick:o,activeLegend:i}=e,c=!!o;return r.createElement("li",{className:(0,l.q)(d("legendItem"),"group inline-flex items-center px-2 py-0.5 rounded-tremor-small transition whitespace-nowrap",c?"cursor-pointer":"cursor-default","text-tremor-content",c?"hover:bg-tremor-background-subtle":"","dark:text-dark-tremor-content",c?"dark:hover:bg-dark-tremor-background-subtle":""),onClick:e=>{e.stopPropagation(),null==o||o(t,n)}},r.createElement("svg",{className:(0,l.q)("flex-none h-2 w-2 mr-1.5",(0,s.bM)(n,a.K.text).textColor,i&&i!==t?"opacity-40":"opacity-100"),fill:"currentColor",viewBox:"0 0 8 8"},r.createElement("circle",{cx:4,cy:4,r:4})),r.createElement("p",{className:(0,l.q)("whitespace-nowrap truncate text-tremor-default","text-tremor-content",c?"group-hover:text-tremor-content-emphasis":"","dark:text-dark-tremor-content",i&&i!==t?"opacity-40":"opacity-100",c?"dark:group-hover:text-dark-tremor-content-emphasis":"")},t))},p=e=>{let{icon:t,onClick:n,disabled:o}=e,[i,a]=r.useState(!1),s=r.useRef(null);return r.useEffect(()=>(i?s.current=setInterval(()=>{null==n||n()},300):clearInterval(s.current),()=>clearInterval(s.current)),[i,n]),(0,r.useEffect)(()=>{o&&(clearInterval(s.current),a(!1))},[o]),r.createElement("button",{type:"button",className:(0,l.q)(d("legendSliderButton"),"w-5 group inline-flex items-center truncate rounded-tremor-small transition",o?"cursor-not-allowed":"cursor-pointer",o?"text-tremor-content-subtle":"text-tremor-content hover:text-tremor-content-emphasis hover:bg-tremor-background-subtle",o?"dark:text-dark-tremor-subtle":"dark:text-dark-tremor dark:hover:text-tremor-content-emphasis dark:hover:bg-dark-tremor-background-subtle"),disabled:o,onClick:e=>{e.stopPropagation(),null==n||n()},onMouseDown:e=>{e.stopPropagation(),a(!0)},onMouseUp:e=>{e.stopPropagation(),a(!1)}},r.createElement(t,{className:"w-full"}))},h=r.forwardRef((e,t)=>{var n,o;let{categories:s,colors:h=a.s,className:m,onClickLegendItem:g,activeLegend:v,enableLegendSlider:y=!1}=e,b=(0,i._T)(e,["categories","colors","className","onClickLegendItem","activeLegend","enableLegendSlider"]),x=r.useRef(null),[w,k]=r.useState(null),[S,E]=r.useState(null),O=r.useRef(null),C=(0,r.useCallback)(()=>{let e=null==x?void 0:x.current;e&&k({left:e.scrollLeft>0,right:e.scrollWidth-e.clientWidth>e.scrollLeft})},[k]),j=(0,r.useCallback)(e=>{var t;let n=null==x?void 0:x.current,r=null!==(t=null==n?void 0:n.clientWidth)&&void 0!==t?t:0;n&&y&&(n.scrollTo({left:"left"===e?n.scrollLeft-r:n.scrollLeft+r,behavior:"smooth"}),setTimeout(()=>{C()},400))},[y,C]);r.useEffect(()=>{let e=e=>{"ArrowLeft"===e?j("left"):"ArrowRight"===e&&j("right")};return S?(e(S),O.current=setInterval(()=>{e(S)},300)):clearInterval(O.current),()=>clearInterval(O.current)},[S,j]);let _=e=>{e.stopPropagation(),"ArrowLeft"!==e.key&&"ArrowRight"!==e.key||(e.preventDefault(),E(e.key))},P=e=>{e.stopPropagation(),E(null)};return r.useEffect(()=>{let e=null==x?void 0:x.current;return y&&(C(),null==e||e.addEventListener("keydown",_),null==e||e.addEventListener("keyup",P)),()=>{null==e||e.removeEventListener("keydown",_),null==e||e.removeEventListener("keyup",P)}},[C,y]),r.createElement("ol",Object.assign({ref:t,className:(0,l.q)(d("root"),"relative overflow-hidden",m)},b),r.createElement("div",{ref:x,tabIndex:0,className:(0,l.q)("h-full flex",y?(null==w?void 0:w.right)||(null==w?void 0:w.left)?"pl-4 pr-12 items-center overflow-auto snap-mandatory [&::-webkit-scrollbar]:hidden [scrollbar-width:none]":"":"flex-wrap")},s.map((e,t)=>r.createElement(f,{key:"item-".concat(t),name:e,color:h[t],onClick:g,activeLegend:v}))),y&&((null==w?void 0:w.right)||(null==w?void 0:w.left))?r.createElement(r.Fragment,null,r.createElement("div",{className:(0,l.q)("from-tremor-background","dark:from-dark-tremor-background","absolute top-0 bottom-0 left-0 w-4 bg-gradient-to-r to-transparent pointer-events-none")}),r.createElement("div",{className:(0,l.q)("to-tremor-background","dark:to-dark-tremor-background","absolute top-0 bottom-0 right-10 w-4 bg-gradient-to-r from-transparent pointer-events-none")}),r.createElement("div",{className:(0,l.q)("bg-tremor-background","dark:bg-dark-tremor-background","absolute flex top-0 pr-1 bottom-0 right-0 items-center justify-center h-full")},r.createElement(p,{icon:c,onClick:()=>{E(null),j("left")},disabled:!(null==w?void 0:w.left)}),r.createElement(p,{icon:u,onClick:()=>{E(null),j("right")},disabled:!(null==w?void 0:w.right)}))):null)});h.displayName="Legend";let m=(e,t,n,i,a,l)=>{let{payload:s}=e,c=(0,r.useRef)(null);o(()=>{var e,t;n((t=null===(e=c.current)||void 0===e?void 0:e.clientHeight)?Number(t)+20:60)});let u=s.filter(e=>"none"!==e.type);return r.createElement("div",{ref:c,className:"flex items-center justify-end"},r.createElement(h,{categories:u.map(e=>e.value),colors:u.map(e=>t.get(e.value)),onClickLegendItem:a,activeLegend:i,enableLegendSlider:l}))}},98593:function(e,t,n){"use strict";n.d(t,{$B:function(){return s},ZP:function(){return u},zX:function(){return c}});var r=n(2265),o=n(7084),i=n(26898),a=n(97324),l=n(1153);let s=e=>{let{children:t}=e;return r.createElement("div",{className:(0,a.q)("rounded-tremor-default text-tremor-default border","bg-tremor-background shadow-tremor-dropdown border-tremor-border","dark:bg-dark-tremor-background dark:shadow-dark-tremor-dropdown dark:border-dark-tremor-border")},t)},c=e=>{let{value:t,name:n,color:o}=e;return r.createElement("div",{className:"flex items-center justify-between space-x-8"},r.createElement("div",{className:"flex items-center space-x-2"},r.createElement("span",{className:(0,a.q)("shrink-0 rounded-tremor-full border-2 h-3 w-3","border-tremor-background shadow-tremor-card","dark:border-dark-tremor-background dark:shadow-dark-tremor-card",(0,l.bM)(o,i.K.background).bgColor)}),r.createElement("p",{className:(0,a.q)("text-right whitespace-nowrap","text-tremor-content","dark:text-dark-tremor-content")},n)),r.createElement("p",{className:(0,a.q)("font-medium tabular-nums text-right whitespace-nowrap","text-tremor-content-emphasis","dark:text-dark-tremor-content-emphasis")},t))},u=e=>{let{active:t,payload:n,label:i,categoryColors:l,valueFormatter:u}=e;if(t&&n){let e=n.filter(e=>"none"!==e.type);return r.createElement(s,null,r.createElement("div",{className:(0,a.q)("border-tremor-border border-b px-4 py-2","dark:border-dark-tremor-border")},r.createElement("p",{className:(0,a.q)("font-medium","text-tremor-content-emphasis","dark:text-dark-tremor-content-emphasis")},i)),r.createElement("div",{className:(0,a.q)("px-4 py-2 space-y-1")},e.map((e,t)=>{var n;let{value:i,name:a}=e;return r.createElement(c,{key:"id-".concat(t),value:u(i),name:a,color:null!==(n=l.get(a))&&void 0!==n?n:o.fr.Blue})})))}return null}},69448:function(e,t,n){"use strict";n.d(t,{Z:function(){return f}});var r=n(97324),o=n(2265),i=n(5853);let a=(0,n(1153).fn)("Flex"),l={start:"justify-start",end:"justify-end",center:"justify-center",between:"justify-between",around:"justify-around",evenly:"justify-evenly"},s={start:"items-start",end:"items-end",center:"items-center",baseline:"items-baseline",stretch:"items-stretch"},c={row:"flex-row",col:"flex-col","row-reverse":"flex-row-reverse","col-reverse":"flex-col-reverse"},u=o.forwardRef((e,t)=>{let{flexDirection:n="row",justifyContent:u="between",alignItems:d="center",children:f,className:p}=e,h=(0,i._T)(e,["flexDirection","justifyContent","alignItems","children","className"]);return o.createElement("div",Object.assign({ref:t,className:(0,r.q)(a("root"),"flex w-full",c[n],l[u],s[d],p)},h),f)});u.displayName="Flex";var d=n(84264);let f=e=>{let{noDataText:t="No data"}=e;return o.createElement(u,{alignItems:"center",justifyContent:"center",className:(0,r.q)("w-full h-full border border-dashed rounded-tremor-default","border-tremor-border","dark:border-dark-tremor-border")},o.createElement(d.Z,{className:(0,r.q)("text-tremor-content","dark:text-dark-tremor-content")},t))}},32644:function(e,t,n){"use strict";n.d(t,{FB:function(){return i},i4:function(){return o},me:function(){return r},vZ:function(){return function e(t,n){if(t===n)return!0;if("object"!=typeof t||"object"!=typeof n||null===t||null===n)return!1;let r=Object.keys(t),o=Object.keys(n);if(r.length!==o.length)return!1;for(let i of r)if(!o.includes(i)||!e(t[i],n[i]))return!1;return!0}}});let r=(e,t)=>{let n=new Map;return e.forEach((e,r)=>{n.set(e,t[r])}),n},o=(e,t,n)=>[e?"auto":null!=t?t:0,null!=n?n:"auto"];function i(e,t){let n=[];for(let r of e)if(Object.prototype.hasOwnProperty.call(r,t)&&(n.push(r[t]),n.length>1))return!1;return!0}},47323:function(e,t,n){"use strict";n.d(t,{Z:function(){return m}});var r=n(5853),o=n(2265),i=n(1526),a=n(7084),l=n(97324),s=n(1153),c=n(26898);let u={xs:{paddingX:"px-1.5",paddingY:"py-1.5"},sm:{paddingX:"px-1.5",paddingY:"py-1.5"},md:{paddingX:"px-2",paddingY:"py-2"},lg:{paddingX:"px-2",paddingY:"py-2"},xl:{paddingX:"px-2.5",paddingY:"py-2.5"}},d={xs:{height:"h-3",width:"w-3"},sm:{height:"h-5",width:"w-5"},md:{height:"h-5",width:"w-5"},lg:{height:"h-7",width:"w-7"},xl:{height:"h-9",width:"w-9"}},f={simple:{rounded:"",border:"",ring:"",shadow:""},light:{rounded:"rounded-tremor-default",border:"",ring:"",shadow:""},shadow:{rounded:"rounded-tremor-default",border:"border",ring:"",shadow:"shadow-tremor-card dark:shadow-dark-tremor-card"},solid:{rounded:"rounded-tremor-default",border:"border-2",ring:"ring-1",shadow:""},outlined:{rounded:"rounded-tremor-default",border:"border",ring:"ring-2",shadow:""}},p=(e,t)=>{switch(e){case"simple":return{textColor:t?(0,s.bM)(t,c.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:"",borderColor:"",ringColor:""};case"light":return{textColor:t?(0,s.bM)(t,c.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:t?(0,l.q)((0,s.bM)(t,c.K.background).bgColor,"bg-opacity-20"):"bg-tremor-brand-muted dark:bg-dark-tremor-brand-muted",borderColor:"",ringColor:""};case"shadow":return{textColor:t?(0,s.bM)(t,c.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:t?(0,l.q)((0,s.bM)(t,c.K.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:"border-tremor-border dark:border-dark-tremor-border",ringColor:""};case"solid":return{textColor:t?(0,s.bM)(t,c.K.text).textColor:"text-tremor-brand-inverted dark:text-dark-tremor-brand-inverted",bgColor:t?(0,l.q)((0,s.bM)(t,c.K.background).bgColor,"bg-opacity-20"):"bg-tremor-brand dark:bg-dark-tremor-brand",borderColor:"border-tremor-brand-inverted dark:border-dark-tremor-brand-inverted",ringColor:"ring-tremor-ring dark:ring-dark-tremor-ring"};case"outlined":return{textColor:t?(0,s.bM)(t,c.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:t?(0,l.q)((0,s.bM)(t,c.K.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:t?(0,s.bM)(t,c.K.ring).borderColor:"border-tremor-brand-subtle dark:border-dark-tremor-brand-subtle",ringColor:t?(0,l.q)((0,s.bM)(t,c.K.ring).ringColor,"ring-opacity-40"):"ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted"}}},h=(0,s.fn)("Icon"),m=o.forwardRef((e,t)=>{let{icon:n,variant:c="simple",tooltip:m,size:g=a.u8.SM,color:v,className:y}=e,b=(0,r._T)(e,["icon","variant","tooltip","size","color","className"]),x=p(c,v),{tooltipProps:w,getReferenceProps:k}=(0,i.l)();return o.createElement("span",Object.assign({ref:(0,s.lq)([t,w.refs.setReference]),className:(0,l.q)(h("root"),"inline-flex flex-shrink-0 items-center",x.bgColor,x.textColor,x.borderColor,x.ringColor,f[c].rounded,f[c].border,f[c].shadow,f[c].ring,u[g].paddingX,u[g].paddingY,y)},k,b),o.createElement(i.Z,Object.assign({text:m},w)),o.createElement(n,{className:(0,l.q)(h("icon"),"shrink-0",d[g].height,d[g].width)}))});m.displayName="Icon"},53003:function(e,t,n){"use strict";let r,o,i;n.d(t,{Z:function(){return nF}});var a,l,s,c,u=n(5853),d=n(2265),f=n(54887),p=n(13323),h=n(64518),m=n(96822),g=n(40293);function v(){for(var e=arguments.length,t=Array(e),n=0;n(0,g.r)(...t),[...t])}var y=n(72238),b=n(93689);let x=(0,d.createContext)(!1);var w=n(61424),k=n(27847);let S=d.Fragment,E=d.Fragment,O=(0,d.createContext)(null),C=(0,d.createContext)(null);Object.assign((0,k.yV)(function(e,t){var n;let r,o,i=(0,d.useRef)(null),a=(0,b.T)((0,b.h)(e=>{i.current=e}),t),l=v(i),s=function(e){let t=(0,d.useContext)(x),n=(0,d.useContext)(O),r=v(e),[o,i]=(0,d.useState)(()=>{if(!t&&null!==n||w.O.isServer)return null;let e=null==r?void 0:r.getElementById("headlessui-portal-root");if(e)return e;if(null===r)return null;let o=r.createElement("div");return o.setAttribute("id","headlessui-portal-root"),r.body.appendChild(o)});return(0,d.useEffect)(()=>{null!==o&&(null!=r&&r.body.contains(o)||null==r||r.body.appendChild(o))},[o,r]),(0,d.useEffect)(()=>{t||null!==n&&i(n.current)},[n,i,t]),o}(i),[c]=(0,d.useState)(()=>{var e;return w.O.isServer?null:null!=(e=null==l?void 0:l.createElement("div"))?e:null}),u=(0,d.useContext)(C),g=(0,y.H)();return(0,h.e)(()=>{!s||!c||s.contains(c)||(c.setAttribute("data-headlessui-portal",""),s.appendChild(c))},[s,c]),(0,h.e)(()=>{if(c&&u)return u.register(c)},[u,c]),n=()=>{var e;s&&c&&(c instanceof Node&&s.contains(c)&&s.removeChild(c),s.childNodes.length<=0&&(null==(e=s.parentElement)||e.removeChild(s)))},r=(0,p.z)(n),o=(0,d.useRef)(!1),(0,d.useEffect)(()=>(o.current=!1,()=>{o.current=!0,(0,m.Y)(()=>{o.current&&r()})}),[r]),g&&s&&c?(0,f.createPortal)((0,k.sY)({ourProps:{ref:a},theirProps:e,defaultTag:S,name:"Portal"}),c):null}),{Group:(0,k.yV)(function(e,t){let{target:n,...r}=e,o={ref:(0,b.T)(t)};return d.createElement(O.Provider,{value:n},(0,k.sY)({ourProps:o,theirProps:r,defaultTag:E,name:"Popover.Group"}))})});var j=n(31948),_=n(17684),P=n(98505),N=n(80004),T=n(38198),A=n(3141),M=((r=M||{})[r.Forwards=0]="Forwards",r[r.Backwards=1]="Backwards",r);function I(){let e=(0,d.useRef)(0);return(0,A.s)("keydown",t=>{"Tab"===t.key&&(e.current=t.shiftKey?1:0)},!0),e}var R=n(37863),D=n(47634),L=n(37105),Z=n(24536),z=n(37388),B=((o=B||{})[o.Open=0]="Open",o[o.Closed=1]="Closed",o),F=((i=F||{})[i.TogglePopover=0]="TogglePopover",i[i.ClosePopover=1]="ClosePopover",i[i.SetButton=2]="SetButton",i[i.SetButtonId=3]="SetButtonId",i[i.SetPanel=4]="SetPanel",i[i.SetPanelId=5]="SetPanelId",i);let H={0:e=>{let t={...e,popoverState:(0,Z.E)(e.popoverState,{0:1,1:0})};return 0===t.popoverState&&(t.__demoMode=!1),t},1:e=>1===e.popoverState?e:{...e,popoverState:1},2:(e,t)=>e.button===t.button?e:{...e,button:t.button},3:(e,t)=>e.buttonId===t.buttonId?e:{...e,buttonId:t.buttonId},4:(e,t)=>e.panel===t.panel?e:{...e,panel:t.panel},5:(e,t)=>e.panelId===t.panelId?e:{...e,panelId:t.panelId}},q=(0,d.createContext)(null);function U(e){let t=(0,d.useContext)(q);if(null===t){let t=Error("<".concat(e," /> is missing a parent component."));throw Error.captureStackTrace&&Error.captureStackTrace(t,U),t}return t}q.displayName="PopoverContext";let W=(0,d.createContext)(null);function K(e){let t=(0,d.useContext)(W);if(null===t){let t=Error("<".concat(e," /> is missing a parent component."));throw Error.captureStackTrace&&Error.captureStackTrace(t,K),t}return t}W.displayName="PopoverAPIContext";let $=(0,d.createContext)(null);function V(){return(0,d.useContext)($)}$.displayName="PopoverGroupContext";let X=(0,d.createContext)(null);function G(e,t){return(0,Z.E)(t.type,H,e,t)}X.displayName="PopoverPanelContext";let Y=k.AN.RenderStrategy|k.AN.Static,Q=k.AN.RenderStrategy|k.AN.Static,J=Object.assign((0,k.yV)(function(e,t){var n,r,o,i;let a,l,s,c,u,f;let{__demoMode:h=!1,...m}=e,g=(0,d.useRef)(null),y=(0,b.T)(t,(0,b.h)(e=>{g.current=e})),x=(0,d.useRef)([]),w=(0,d.useReducer)(G,{__demoMode:h,popoverState:h?0:1,buttons:x,button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:(0,d.createRef)(),afterPanelSentinel:(0,d.createRef)()}),[{popoverState:S,button:E,buttonId:O,panel:_,panelId:N,beforePanelSentinel:A,afterPanelSentinel:M},I]=w,D=v(null!=(n=g.current)?n:E),z=(0,d.useMemo)(()=>{if(!E||!_)return!1;for(let e of document.querySelectorAll("body > *"))if(Number(null==e?void 0:e.contains(E))^Number(null==e?void 0:e.contains(_)))return!0;let e=(0,L.GO)(),t=e.indexOf(E),n=(t+e.length-1)%e.length,r=(t+1)%e.length,o=e[n],i=e[r];return!_.contains(o)&&!_.contains(i)},[E,_]),B=(0,j.E)(O),F=(0,j.E)(N),H=(0,d.useMemo)(()=>({buttonId:B,panelId:F,close:()=>I({type:1})}),[B,F,I]),U=V(),K=null==U?void 0:U.registerPopover,$=(0,p.z)(()=>{var e;return null!=(e=null==U?void 0:U.isFocusWithinPopoverGroup())?e:(null==D?void 0:D.activeElement)&&((null==E?void 0:E.contains(D.activeElement))||(null==_?void 0:_.contains(D.activeElement)))});(0,d.useEffect)(()=>null==K?void 0:K(H),[K,H]);let[Y,Q]=(a=(0,d.useContext)(C),l=(0,d.useRef)([]),s=(0,p.z)(e=>(l.current.push(e),a&&a.register(e),()=>c(e))),c=(0,p.z)(e=>{let t=l.current.indexOf(e);-1!==t&&l.current.splice(t,1),a&&a.unregister(e)}),u=(0,d.useMemo)(()=>({register:s,unregister:c,portals:l}),[s,c,l]),[l,(0,d.useMemo)(()=>function(e){let{children:t}=e;return d.createElement(C.Provider,{value:u},t)},[u])]),J=function(){var e;let{defaultContainers:t=[],portals:n,mainTreeNodeRef:r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=(0,d.useRef)(null!=(e=null==r?void 0:r.current)?e:null),i=v(o),a=(0,p.z)(()=>{var e,r,a;let l=[];for(let e of t)null!==e&&(e instanceof HTMLElement?l.push(e):"current"in e&&e.current instanceof HTMLElement&&l.push(e.current));if(null!=n&&n.current)for(let e of n.current)l.push(e);for(let t of null!=(e=null==i?void 0:i.querySelectorAll("html > *, body > *"))?e:[])t!==document.body&&t!==document.head&&t instanceof HTMLElement&&"headlessui-portal-root"!==t.id&&(t.contains(o.current)||t.contains(null==(a=null==(r=o.current)?void 0:r.getRootNode())?void 0:a.host)||l.some(e=>t.contains(e))||l.push(t));return l});return{resolveContainers:a,contains:(0,p.z)(e=>a().some(t=>t.contains(e))),mainTreeNodeRef:o,MainTreeNode:(0,d.useMemo)(()=>function(){return null!=r?null:d.createElement(T._,{features:T.A.Hidden,ref:o})},[o,r])}}({mainTreeNodeRef:null==U?void 0:U.mainTreeNodeRef,portals:Y,defaultContainers:[E,_]});r=null==D?void 0:D.defaultView,o="focus",i=e=>{var t,n,r,o;e.target!==window&&e.target instanceof HTMLElement&&0===S&&($()||E&&_&&(J.contains(e.target)||null!=(n=null==(t=A.current)?void 0:t.contains)&&n.call(t,e.target)||null!=(o=null==(r=M.current)?void 0:r.contains)&&o.call(r,e.target)||I({type:1})))},f=(0,j.E)(i),(0,d.useEffect)(()=>{function e(e){f.current(e)}return(r=null!=r?r:window).addEventListener(o,e,!0),()=>r.removeEventListener(o,e,!0)},[r,o,!0]),(0,P.O)(J.resolveContainers,(e,t)=>{I({type:1}),(0,L.sP)(t,L.tJ.Loose)||(e.preventDefault(),null==E||E.focus())},0===S);let ee=(0,p.z)(e=>{I({type:1});let t=e?e instanceof HTMLElement?e:"current"in e&&e.current instanceof HTMLElement?e.current:E:E;null==t||t.focus()}),et=(0,d.useMemo)(()=>({close:ee,isPortalled:z}),[ee,z]),en=(0,d.useMemo)(()=>({open:0===S,close:ee}),[S,ee]);return d.createElement(X.Provider,{value:null},d.createElement(q.Provider,{value:w},d.createElement(W.Provider,{value:et},d.createElement(R.up,{value:(0,Z.E)(S,{0:R.ZM.Open,1:R.ZM.Closed})},d.createElement(Q,null,(0,k.sY)({ourProps:{ref:y},theirProps:m,slot:en,defaultTag:"div",name:"Popover"}),d.createElement(J.MainTreeNode,null))))))}),{Button:(0,k.yV)(function(e,t){let n=(0,_.M)(),{id:r="headlessui-popover-button-".concat(n),...o}=e,[i,a]=U("Popover.Button"),{isPortalled:l}=K("Popover.Button"),s=(0,d.useRef)(null),c="headlessui-focus-sentinel-".concat((0,_.M)()),u=V(),f=null==u?void 0:u.closeOthers,h=null!==(0,d.useContext)(X);(0,d.useEffect)(()=>{if(!h)return a({type:3,buttonId:r}),()=>{a({type:3,buttonId:null})}},[h,r,a]);let[m]=(0,d.useState)(()=>Symbol()),g=(0,b.T)(s,t,h?null:e=>{if(e)i.buttons.current.push(m);else{let e=i.buttons.current.indexOf(m);-1!==e&&i.buttons.current.splice(e,1)}i.buttons.current.length>1&&console.warn("You are already using a but only 1 is supported."),e&&a({type:2,button:e})}),y=(0,b.T)(s,t),x=v(s),w=(0,p.z)(e=>{var t,n,r;if(h){if(1===i.popoverState)return;switch(e.key){case z.R.Space:case z.R.Enter:e.preventDefault(),null==(n=(t=e.target).click)||n.call(t),a({type:1}),null==(r=i.button)||r.focus()}}else switch(e.key){case z.R.Space:case z.R.Enter:e.preventDefault(),e.stopPropagation(),1===i.popoverState&&(null==f||f(i.buttonId)),a({type:0});break;case z.R.Escape:if(0!==i.popoverState)return null==f?void 0:f(i.buttonId);if(!s.current||null!=x&&x.activeElement&&!s.current.contains(x.activeElement))return;e.preventDefault(),e.stopPropagation(),a({type:1})}}),S=(0,p.z)(e=>{h||e.key===z.R.Space&&e.preventDefault()}),E=(0,p.z)(t=>{var n,r;(0,D.P)(t.currentTarget)||e.disabled||(h?(a({type:1}),null==(n=i.button)||n.focus()):(t.preventDefault(),t.stopPropagation(),1===i.popoverState&&(null==f||f(i.buttonId)),a({type:0}),null==(r=i.button)||r.focus()))}),O=(0,p.z)(e=>{e.preventDefault(),e.stopPropagation()}),C=0===i.popoverState,j=(0,d.useMemo)(()=>({open:C}),[C]),P=(0,N.f)(e,s),A=h?{ref:y,type:P,onKeyDown:w,onClick:E}:{ref:g,id:i.buttonId,type:P,"aria-expanded":0===i.popoverState,"aria-controls":i.panel?i.panelId:void 0,onKeyDown:w,onKeyUp:S,onClick:E,onMouseDown:O},R=I(),B=(0,p.z)(()=>{let e=i.panel;e&&(0,Z.E)(R.current,{[M.Forwards]:()=>(0,L.jA)(e,L.TO.First),[M.Backwards]:()=>(0,L.jA)(e,L.TO.Last)})===L.fE.Error&&(0,L.jA)((0,L.GO)().filter(e=>"true"!==e.dataset.headlessuiFocusGuard),(0,Z.E)(R.current,{[M.Forwards]:L.TO.Next,[M.Backwards]:L.TO.Previous}),{relativeTo:i.button})});return d.createElement(d.Fragment,null,(0,k.sY)({ourProps:A,theirProps:o,slot:j,defaultTag:"button",name:"Popover.Button"}),C&&!h&&l&&d.createElement(T._,{id:c,features:T.A.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:B}))}),Overlay:(0,k.yV)(function(e,t){let n=(0,_.M)(),{id:r="headlessui-popover-overlay-".concat(n),...o}=e,[{popoverState:i},a]=U("Popover.Overlay"),l=(0,b.T)(t),s=(0,R.oJ)(),c=null!==s?(s&R.ZM.Open)===R.ZM.Open:0===i,u=(0,p.z)(e=>{if((0,D.P)(e.currentTarget))return e.preventDefault();a({type:1})}),f=(0,d.useMemo)(()=>({open:0===i}),[i]);return(0,k.sY)({ourProps:{ref:l,id:r,"aria-hidden":!0,onClick:u},theirProps:o,slot:f,defaultTag:"div",features:Y,visible:c,name:"Popover.Overlay"})}),Panel:(0,k.yV)(function(e,t){let n=(0,_.M)(),{id:r="headlessui-popover-panel-".concat(n),focus:o=!1,...i}=e,[a,l]=U("Popover.Panel"),{close:s,isPortalled:c}=K("Popover.Panel"),u="headlessui-focus-sentinel-before-".concat((0,_.M)()),f="headlessui-focus-sentinel-after-".concat((0,_.M)()),m=(0,d.useRef)(null),g=(0,b.T)(m,t,e=>{l({type:4,panel:e})}),y=v(m),x=(0,k.Y2)();(0,h.e)(()=>(l({type:5,panelId:r}),()=>{l({type:5,panelId:null})}),[r,l]);let w=(0,R.oJ)(),S=null!==w?(w&R.ZM.Open)===R.ZM.Open:0===a.popoverState,E=(0,p.z)(e=>{var t;if(e.key===z.R.Escape){if(0!==a.popoverState||!m.current||null!=y&&y.activeElement&&!m.current.contains(y.activeElement))return;e.preventDefault(),e.stopPropagation(),l({type:1}),null==(t=a.button)||t.focus()}});(0,d.useEffect)(()=>{var t;e.static||1===a.popoverState&&(null==(t=e.unmount)||t)&&l({type:4,panel:null})},[a.popoverState,e.unmount,e.static,l]),(0,d.useEffect)(()=>{if(a.__demoMode||!o||0!==a.popoverState||!m.current)return;let e=null==y?void 0:y.activeElement;m.current.contains(e)||(0,L.jA)(m.current,L.TO.First)},[a.__demoMode,o,m,a.popoverState]);let O=(0,d.useMemo)(()=>({open:0===a.popoverState,close:s}),[a,s]),C={ref:g,id:r,onKeyDown:E,onBlur:o&&0===a.popoverState?e=>{var t,n,r,o,i;let s=e.relatedTarget;s&&m.current&&(null!=(t=m.current)&&t.contains(s)||(l({type:1}),(null!=(r=null==(n=a.beforePanelSentinel.current)?void 0:n.contains)&&r.call(n,s)||null!=(i=null==(o=a.afterPanelSentinel.current)?void 0:o.contains)&&i.call(o,s))&&s.focus({preventScroll:!0})))}:void 0,tabIndex:-1},j=I(),P=(0,p.z)(()=>{let e=m.current;e&&(0,Z.E)(j.current,{[M.Forwards]:()=>{var t;(0,L.jA)(e,L.TO.First)===L.fE.Error&&(null==(t=a.afterPanelSentinel.current)||t.focus())},[M.Backwards]:()=>{var e;null==(e=a.button)||e.focus({preventScroll:!0})}})}),N=(0,p.z)(()=>{let e=m.current;e&&(0,Z.E)(j.current,{[M.Forwards]:()=>{var e;if(!a.button)return;let t=(0,L.GO)(),n=t.indexOf(a.button),r=t.slice(0,n+1),o=[...t.slice(n+1),...r];for(let t of o.slice())if("true"===t.dataset.headlessuiFocusGuard||null!=(e=a.panel)&&e.contains(t)){let e=o.indexOf(t);-1!==e&&o.splice(e,1)}(0,L.jA)(o,L.TO.First,{sorted:!1})},[M.Backwards]:()=>{var t;(0,L.jA)(e,L.TO.Previous)===L.fE.Error&&(null==(t=a.button)||t.focus())}})});return d.createElement(X.Provider,{value:r},S&&c&&d.createElement(T._,{id:u,ref:a.beforePanelSentinel,features:T.A.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:P}),(0,k.sY)({mergeRefs:x,ourProps:C,theirProps:i,slot:O,defaultTag:"div",features:Q,visible:S,name:"Popover.Panel"}),S&&c&&d.createElement(T._,{id:f,ref:a.afterPanelSentinel,features:T.A.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:N}))}),Group:(0,k.yV)(function(e,t){let n;let r=(0,d.useRef)(null),o=(0,b.T)(r,t),[i,a]=(0,d.useState)([]),l={mainTreeNodeRef:n=(0,d.useRef)(null),MainTreeNode:(0,d.useMemo)(()=>function(){return d.createElement(T._,{features:T.A.Hidden,ref:n})},[n])},s=(0,p.z)(e=>{a(t=>{let n=t.indexOf(e);if(-1!==n){let e=t.slice();return e.splice(n,1),e}return t})}),c=(0,p.z)(e=>(a(t=>[...t,e]),()=>s(e))),u=(0,p.z)(()=>{var e;let t=(0,g.r)(r);if(!t)return!1;let n=t.activeElement;return!!(null!=(e=r.current)&&e.contains(n))||i.some(e=>{var r,o;return(null==(r=t.getElementById(e.buttonId.current))?void 0:r.contains(n))||(null==(o=t.getElementById(e.panelId.current))?void 0:o.contains(n))})}),f=(0,p.z)(e=>{for(let t of i)t.buttonId.current!==e&&t.close()}),h=(0,d.useMemo)(()=>({registerPopover:c,unregisterPopover:s,isFocusWithinPopoverGroup:u,closeOthers:f,mainTreeNodeRef:l.mainTreeNodeRef}),[c,s,u,f,l.mainTreeNodeRef]),m=(0,d.useMemo)(()=>({}),[]);return d.createElement($.Provider,{value:h},(0,k.sY)({ourProps:{ref:o},theirProps:e,slot:m,defaultTag:"div",name:"Popover.Group"}),d.createElement(l.MainTreeNode,null))})});var ee=n(33044),et=n(28517);let en=e=>{var t=(0,u._T)(e,[]);return d.createElement("svg",Object.assign({},t,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}),d.createElement("path",{fillRule:"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z",clipRule:"evenodd"}))};var er=n(4537),eo=n(99735),ei=n(7656);function ea(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e);return t.setHours(0,0,0,0),t}function el(){return ea(Date.now())}function es(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e);return t.setDate(1),t.setHours(0,0,0,0),t}var ec=n(97324),eu=n(96398),ed=n(41154);function ef(e){var t,n;if((0,ei.Z)(1,arguments),e&&"function"==typeof e.forEach)t=e;else{if("object"!==(0,ed.Z)(e)||null===e)return new Date(NaN);t=Array.prototype.slice.call(e)}return t.forEach(function(e){var t=(0,eo.Z)(e);(void 0===n||nt||isNaN(t.getDate()))&&(n=t)}),n||new Date(NaN)}var eh=n(25721),em=n(47869);function eg(e,t){(0,ei.Z)(2,arguments);var n=(0,em.Z)(t);return(0,eh.Z)(e,-n)}var ev=n(55463);function ey(e,t){if((0,ei.Z)(2,arguments),!t||"object"!==(0,ed.Z)(t))return new Date(NaN);var n=t.years?(0,em.Z)(t.years):0,r=t.months?(0,em.Z)(t.months):0,o=t.weeks?(0,em.Z)(t.weeks):0,i=t.days?(0,em.Z)(t.days):0,a=t.hours?(0,em.Z)(t.hours):0,l=t.minutes?(0,em.Z)(t.minutes):0,s=t.seconds?(0,em.Z)(t.seconds):0;return new Date(eg(function(e,t){(0,ei.Z)(2,arguments);var n=(0,em.Z)(t);return(0,ev.Z)(e,-n)}(e,r+12*n),i+7*o).getTime()-1e3*(s+60*(l+60*a)))}function eb(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e),n=new Date(0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}function ex(e){return(0,ei.Z)(1,arguments),e instanceof Date||"object"===(0,ed.Z)(e)&&"[object Date]"===Object.prototype.toString.call(e)}function ew(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e),n=t.getUTCDay();return t.setUTCDate(t.getUTCDate()-((n<1?7:0)+n-1)),t.setUTCHours(0,0,0,0),t}function ek(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e),n=t.getUTCFullYear(),r=new Date(0);r.setUTCFullYear(n+1,0,4),r.setUTCHours(0,0,0,0);var o=ew(r),i=new Date(0);i.setUTCFullYear(n,0,4),i.setUTCHours(0,0,0,0);var a=ew(i);return t.getTime()>=o.getTime()?n+1:t.getTime()>=a.getTime()?n:n-1}var eS={};function eE(e,t){(0,ei.Z)(1,arguments);var n,r,o,i,a,l,s,c,u=(0,em.Z)(null!==(n=null!==(r=null!==(o=null!==(i=null==t?void 0:t.weekStartsOn)&&void 0!==i?i:null==t?void 0:null===(a=t.locale)||void 0===a?void 0:null===(l=a.options)||void 0===l?void 0:l.weekStartsOn)&&void 0!==o?o:eS.weekStartsOn)&&void 0!==r?r:null===(s=eS.locale)||void 0===s?void 0:null===(c=s.options)||void 0===c?void 0:c.weekStartsOn)&&void 0!==n?n:0);if(!(u>=0&&u<=6))throw RangeError("weekStartsOn must be between 0 and 6 inclusively");var d=(0,eo.Z)(e),f=d.getUTCDay();return d.setUTCDate(d.getUTCDate()-((f=1&&f<=7))throw RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setUTCFullYear(d+1,0,f),p.setUTCHours(0,0,0,0);var h=eE(p,t),m=new Date(0);m.setUTCFullYear(d,0,f),m.setUTCHours(0,0,0,0);var g=eE(m,t);return u.getTime()>=h.getTime()?d+1:u.getTime()>=g.getTime()?d:d-1}function eC(e,t){for(var n=Math.abs(e).toString();n.length0?n:1-n;return eC("yy"===t?r%100:r,t.length)},M:function(e,t){var n=e.getUTCMonth();return"M"===t?String(n+1):eC(n+1,2)},d:function(e,t){return eC(e.getUTCDate(),t.length)},h:function(e,t){return eC(e.getUTCHours()%12||12,t.length)},H:function(e,t){return eC(e.getUTCHours(),t.length)},m:function(e,t){return eC(e.getUTCMinutes(),t.length)},s:function(e,t){return eC(e.getUTCSeconds(),t.length)},S:function(e,t){var n=t.length;return eC(Math.floor(e.getUTCMilliseconds()*Math.pow(10,n-3)),t.length)}},e_={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"};function eP(e,t){var n=e>0?"-":"+",r=Math.abs(e),o=Math.floor(r/60),i=r%60;return 0===i?n+String(o):n+String(o)+(t||"")+eC(i,2)}function eN(e,t){return e%60==0?(e>0?"-":"+")+eC(Math.abs(e)/60,2):eT(e,t)}function eT(e,t){var n=Math.abs(e);return(e>0?"-":"+")+eC(Math.floor(n/60),2)+(t||"")+eC(n%60,2)}var eA={G:function(e,t,n){var r=e.getUTCFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if("yo"===t){var r=e.getUTCFullYear();return n.ordinalNumber(r>0?r:1-r,{unit:"year"})}return ej.y(e,t)},Y:function(e,t,n,r){var o=eO(e,r),i=o>0?o:1-o;return"YY"===t?eC(i%100,2):"Yo"===t?n.ordinalNumber(i,{unit:"year"}):eC(i,t.length)},R:function(e,t){return eC(ek(e),t.length)},u:function(e,t){return eC(e.getUTCFullYear(),t.length)},Q:function(e,t,n){var r=Math.ceil((e.getUTCMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return eC(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){var r=Math.ceil((e.getUTCMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return eC(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){var r=e.getUTCMonth();switch(t){case"M":case"MM":return ej.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){var r=e.getUTCMonth();switch(t){case"L":return String(r+1);case"LL":return eC(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){var o=function(e,t){(0,ei.Z)(1,arguments);var n=(0,eo.Z)(e);return Math.round((eE(n,t).getTime()-(function(e,t){(0,ei.Z)(1,arguments);var n,r,o,i,a,l,s,c,u=(0,em.Z)(null!==(n=null!==(r=null!==(o=null!==(i=null==t?void 0:t.firstWeekContainsDate)&&void 0!==i?i:null==t?void 0:null===(a=t.locale)||void 0===a?void 0:null===(l=a.options)||void 0===l?void 0:l.firstWeekContainsDate)&&void 0!==o?o:eS.firstWeekContainsDate)&&void 0!==r?r:null===(s=eS.locale)||void 0===s?void 0:null===(c=s.options)||void 0===c?void 0:c.firstWeekContainsDate)&&void 0!==n?n:1),d=eO(e,t),f=new Date(0);return f.setUTCFullYear(d,0,u),f.setUTCHours(0,0,0,0),eE(f,t)})(n,t).getTime())/6048e5)+1}(e,r);return"wo"===t?n.ordinalNumber(o,{unit:"week"}):eC(o,t.length)},I:function(e,t,n){var r=function(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e);return Math.round((ew(t).getTime()-(function(e){(0,ei.Z)(1,arguments);var t=ek(e),n=new Date(0);return n.setUTCFullYear(t,0,4),n.setUTCHours(0,0,0,0),ew(n)})(t).getTime())/6048e5)+1}(e);return"Io"===t?n.ordinalNumber(r,{unit:"week"}):eC(r,t.length)},d:function(e,t,n){return"do"===t?n.ordinalNumber(e.getUTCDate(),{unit:"date"}):ej.d(e,t)},D:function(e,t,n){var r=function(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e),n=t.getTime();return t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0),Math.floor((n-t.getTime())/864e5)+1}(e);return"Do"===t?n.ordinalNumber(r,{unit:"dayOfYear"}):eC(r,t.length)},E:function(e,t,n){var r=e.getUTCDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){var o=e.getUTCDay(),i=(o-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return eC(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){var o=e.getUTCDay(),i=(o-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return eC(i,t.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(e,t,n){var r=e.getUTCDay(),o=0===r?7:r;switch(t){case"i":return String(o);case"ii":return eC(o,t.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){var r=e.getUTCHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(e,t,n){var r,o=e.getUTCHours();switch(r=12===o?e_.noon:0===o?e_.midnight:o/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,n){var r,o=e.getUTCHours();switch(r=o>=17?e_.evening:o>=12?e_.afternoon:o>=4?e_.morning:e_.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,n){if("ho"===t){var r=e.getUTCHours()%12;return 0===r&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return ej.h(e,t)},H:function(e,t,n){return"Ho"===t?n.ordinalNumber(e.getUTCHours(),{unit:"hour"}):ej.H(e,t)},K:function(e,t,n){var r=e.getUTCHours()%12;return"Ko"===t?n.ordinalNumber(r,{unit:"hour"}):eC(r,t.length)},k:function(e,t,n){var r=e.getUTCHours();return(0===r&&(r=24),"ko"===t)?n.ordinalNumber(r,{unit:"hour"}):eC(r,t.length)},m:function(e,t,n){return"mo"===t?n.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):ej.m(e,t)},s:function(e,t,n){return"so"===t?n.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):ej.s(e,t)},S:function(e,t){return ej.S(e,t)},X:function(e,t,n,r){var o=(r._originalDate||e).getTimezoneOffset();if(0===o)return"Z";switch(t){case"X":return eN(o);case"XXXX":case"XX":return eT(o);default:return eT(o,":")}},x:function(e,t,n,r){var o=(r._originalDate||e).getTimezoneOffset();switch(t){case"x":return eN(o);case"xxxx":case"xx":return eT(o);default:return eT(o,":")}},O:function(e,t,n,r){var o=(r._originalDate||e).getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+eP(o,":");default:return"GMT"+eT(o,":")}},z:function(e,t,n,r){var o=(r._originalDate||e).getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+eP(o,":");default:return"GMT"+eT(o,":")}},t:function(e,t,n,r){return eC(Math.floor((r._originalDate||e).getTime()/1e3),t.length)},T:function(e,t,n,r){return eC((r._originalDate||e).getTime(),t.length)}},eM=function(e,t){switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},eI=function(e,t){switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},eR={p:eI,P:function(e,t){var n,r=e.match(/(P+)(p+)?/)||[],o=r[1],i=r[2];if(!i)return eM(e,t);switch(o){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",eM(o,t)).replace("{{time}}",eI(i,t))}};function eD(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}var eL=["D","DD"],eZ=["YY","YYYY"];function ez(e,t,n){if("YYYY"===e)throw RangeError("Use `yyyy` instead of `YYYY` (in `".concat(t,"`) for formatting years to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("YY"===e)throw RangeError("Use `yy` instead of `YY` (in `".concat(t,"`) for formatting years to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("D"===e)throw RangeError("Use `d` instead of `D` (in `".concat(t,"`) for formatting days of the month to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("DD"===e)throw RangeError("Use `dd` instead of `DD` (in `".concat(t,"`) for formatting days of the month to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}var eB={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function eF(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var eH={date:eF({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:eF({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:eF({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},eq={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function eU(e){return function(t,n){var r;if("formatting"===(null!=n&&n.context?String(n.context):"standalone")&&e.formattingValues){var o=e.defaultFormattingWidth||e.defaultWidth,i=null!=n&&n.width?String(n.width):o;r=e.formattingValues[i]||e.formattingValues[o]}else{var a=e.defaultWidth,l=null!=n&&n.width?String(n.width):e.defaultWidth;r=e.values[l]||e.values[a]}return r[e.argumentCallback?e.argumentCallback(t):t]}}function eW(e){return function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.width,i=o&&e.matchPatterns[o]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;var l=a[0],s=o&&e.parsePatterns[o]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?function(e,t){for(var n=0;n0?"in "+r:r+" ago":r},formatLong:eH,formatRelative:function(e,t,n,r){return eq[e]},localize:{ordinalNumber:function(e,t){var n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:eU({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:eU({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:eU({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:eU({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:eU({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(a={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}},function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.match(a.matchPattern);if(!n)return null;var r=n[0],o=e.match(a.parsePattern);if(!o)return null;var i=a.valueCallback?a.valueCallback(o[0]):o[0];return{value:i=t.valueCallback?t.valueCallback(i):i,rest:e.slice(r.length)}}),era:eW({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:eW({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:eW({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:eW({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:eW({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},e$=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,eV=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,eX=/^'([^]*?)'?$/,eG=/''/g,eY=/[a-zA-Z]/;function eQ(e,t,n){(0,ei.Z)(2,arguments);var r,o,i,a,l,s,c,u,d,f,p,h,m,g,v,y,b,x,w=String(t),k=null!==(r=null!==(o=null==n?void 0:n.locale)&&void 0!==o?o:eS.locale)&&void 0!==r?r:eK,S=(0,em.Z)(null!==(i=null!==(a=null!==(l=null!==(s=null==n?void 0:n.firstWeekContainsDate)&&void 0!==s?s:null==n?void 0:null===(c=n.locale)||void 0===c?void 0:null===(u=c.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==l?l:eS.firstWeekContainsDate)&&void 0!==a?a:null===(d=eS.locale)||void 0===d?void 0:null===(f=d.options)||void 0===f?void 0:f.firstWeekContainsDate)&&void 0!==i?i:1);if(!(S>=1&&S<=7))throw RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var E=(0,em.Z)(null!==(p=null!==(h=null!==(m=null!==(g=null==n?void 0:n.weekStartsOn)&&void 0!==g?g:null==n?void 0:null===(v=n.locale)||void 0===v?void 0:null===(y=v.options)||void 0===y?void 0:y.weekStartsOn)&&void 0!==m?m:eS.weekStartsOn)&&void 0!==h?h:null===(b=eS.locale)||void 0===b?void 0:null===(x=b.options)||void 0===x?void 0:x.weekStartsOn)&&void 0!==p?p:0);if(!(E>=0&&E<=6))throw RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!k.localize)throw RangeError("locale must contain localize property");if(!k.formatLong)throw RangeError("locale must contain formatLong property");var O=(0,eo.Z)(e);if(!function(e){return(0,ei.Z)(1,arguments),(!!ex(e)||"number"==typeof e)&&!isNaN(Number((0,eo.Z)(e)))}(O))throw RangeError("Invalid time value");var C=eD(O),j=function(e,t){return(0,ei.Z)(2,arguments),function(e,t){return(0,ei.Z)(2,arguments),new Date((0,eo.Z)(e).getTime()+(0,em.Z)(t))}(e,-(0,em.Z)(t))}(O,C),_={firstWeekContainsDate:S,weekStartsOn:E,locale:k,_originalDate:O};return w.match(eV).map(function(e){var t=e[0];return"p"===t||"P"===t?(0,eR[t])(e,k.formatLong):e}).join("").match(e$).map(function(r){if("''"===r)return"'";var o,i=r[0];if("'"===i)return(o=r.match(eX))?o[1].replace(eG,"'"):r;var a=eA[i];if(a)return null!=n&&n.useAdditionalWeekYearTokens||-1===eZ.indexOf(r)||ez(r,t,String(e)),null!=n&&n.useAdditionalDayOfYearTokens||-1===eL.indexOf(r)||ez(r,t,String(e)),a(j,r,k.localize,_);if(i.match(eY))throw RangeError("Format string contains an unescaped latin alphabet character `"+i+"`");return r}).join("")}var eJ=n(1153);let e0=(0,eJ.fn)("DateRangePicker"),e1=(e,t,n,r)=>{var o;if(n&&(e=null===(o=r.get(n))||void 0===o?void 0:o.from),e)return ea(e&&!t?e:ef([e,t]))},e2=(e,t,n,r)=>{var o,i;if(n&&(e=ea(null!==(i=null===(o=r.get(n))||void 0===o?void 0:o.to)&&void 0!==i?i:el())),e)return ea(e&&!t?e:ep([e,t]))},e4=[{value:"tdy",text:"Today",from:el()},{value:"w",text:"Last 7 days",from:ey(el(),{days:7})},{value:"t",text:"Last 30 days",from:ey(el(),{days:30})},{value:"m",text:"Month to Date",from:es(el())},{value:"y",text:"Year to Date",from:eb(el())}],e6=(e,t,n,r)=>{let o=(null==n?void 0:n.code)||"en-US";if(!e&&!t)return"";if(e&&!t)return r?eQ(e,r):e.toLocaleDateString(o,{year:"numeric",month:"short",day:"numeric"});if(e&&t){if(function(e,t){(0,ei.Z)(2,arguments);var n=(0,eo.Z)(e),r=(0,eo.Z)(t);return n.getTime()===r.getTime()}(e,t))return r?eQ(e,r):e.toLocaleDateString(o,{year:"numeric",month:"short",day:"numeric"});if(e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear())return r?"".concat(eQ(e,r)," - ").concat(eQ(t,r)):"".concat(e.toLocaleDateString(o,{month:"short",day:"numeric"})," - \n ").concat(t.getDate(),", ").concat(t.getFullYear());{if(r)return"".concat(eQ(e,r)," - ").concat(eQ(t,r));let n={year:"numeric",month:"short",day:"numeric"};return"".concat(e.toLocaleDateString(o,n)," - \n ").concat(t.toLocaleDateString(o,n))}}return""};function e3(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function e8(e,t){(0,ei.Z)(2,arguments);var n=(0,eo.Z)(e),r=(0,em.Z)(t),o=n.getFullYear(),i=n.getDate(),a=new Date(0);a.setFullYear(o,r,15),a.setHours(0,0,0,0);var l=function(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e),n=t.getFullYear(),r=t.getMonth(),o=new Date(0);return o.setFullYear(n,r+1,0),o.setHours(0,0,0,0),o.getDate()}(a);return n.setMonth(r,Math.min(i,l)),n}function e5(e,t){(0,ei.Z)(2,arguments);var n=(0,eo.Z)(e),r=(0,em.Z)(t);return isNaN(n.getTime())?new Date(NaN):(n.setFullYear(r),n)}function e7(e,t){(0,ei.Z)(2,arguments);var n=(0,eo.Z)(e),r=(0,eo.Z)(t);return 12*(n.getFullYear()-r.getFullYear())+(n.getMonth()-r.getMonth())}function e9(e,t){(0,ei.Z)(2,arguments);var n=(0,eo.Z)(e),r=(0,eo.Z)(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()}function te(e,t){(0,ei.Z)(2,arguments);var n=(0,eo.Z)(e),r=(0,eo.Z)(t);return n.getTime()=0&&u<=6))throw RangeError("weekStartsOn must be between 0 and 6 inclusively");var d=(0,eo.Z)(e),f=d.getDay();return d.setDate(d.getDate()-((fr.getTime()}function ti(e,t){(0,ei.Z)(2,arguments);var n=ea(e),r=ea(t);return Math.round((n.getTime()-eD(n)-(r.getTime()-eD(r)))/864e5)}function ta(e,t){(0,ei.Z)(2,arguments);var n=(0,em.Z)(t);return(0,eh.Z)(e,7*n)}function tl(e,t){(0,ei.Z)(2,arguments);var n=(0,em.Z)(t);return(0,ev.Z)(e,12*n)}function ts(e,t){(0,ei.Z)(1,arguments);var n,r,o,i,a,l,s,c,u=(0,em.Z)(null!==(n=null!==(r=null!==(o=null!==(i=null==t?void 0:t.weekStartsOn)&&void 0!==i?i:null==t?void 0:null===(a=t.locale)||void 0===a?void 0:null===(l=a.options)||void 0===l?void 0:l.weekStartsOn)&&void 0!==o?o:eS.weekStartsOn)&&void 0!==r?r:null===(s=eS.locale)||void 0===s?void 0:null===(c=s.options)||void 0===c?void 0:c.weekStartsOn)&&void 0!==n?n:0);if(!(u>=0&&u<=6))throw RangeError("weekStartsOn must be between 0 and 6 inclusively");var d=(0,eo.Z)(e),f=d.getDay();return d.setDate(d.getDate()+((fe7(l,a)&&(a=(0,ev.Z)(l,-1*((void 0===c?1:c)-1))),s&&0>e7(a,s)&&(a=s),u=es(a),f=t.month,h=(p=(0,d.useState)(u))[0],m=[void 0===f?h:f,p[1]])[0],v=m[1],[g,function(e){if(!t.disableNavigation){var n,r=es(e);v(r),null===(n=t.onMonthChange)||void 0===n||n.call(t,r)}}]),x=b[0],w=b[1],k=function(e,t){for(var n=t.reverseMonths,r=t.numberOfMonths,o=es(e),i=e7(es((0,ev.Z)(o,r)),o),a=[],l=0;l=e7(i,n)))return(0,ev.Z)(i,-(r?void 0===o?1:o:1))}}(x,y),O=function(e){return k.some(function(t){return e9(e,t)})};return th.jsx(tP.Provider,{value:{currentMonth:x,displayMonths:k,goToMonth:w,goToDate:function(e,t){O(e)||(t&&te(e,t)?w((0,ev.Z)(e,1+-1*y.numberOfMonths)):w(e))},previousMonth:E,nextMonth:S,isDateDisplayed:O},children:e.children})}function tT(){var e=(0,d.useContext)(tP);if(!e)throw Error("useNavigation must be used within a NavigationProvider");return e}function tA(e){var t,n=tS(),r=n.classNames,o=n.styles,i=n.components,a=tT().goToMonth,l=function(t){a((0,ev.Z)(t,e.displayIndex?-e.displayIndex:0))},s=null!==(t=null==i?void 0:i.CaptionLabel)&&void 0!==t?t:tE,c=th.jsx(s,{id:e.id,displayMonth:e.displayMonth});return th.jsxs("div",{className:r.caption_dropdowns,style:o.caption_dropdowns,children:[th.jsx("div",{className:r.vhidden,children:c}),th.jsx(tj,{onChange:l,displayMonth:e.displayMonth}),th.jsx(t_,{onChange:l,displayMonth:e.displayMonth})]})}function tM(e){return th.jsx("svg",tu({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:th.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function tI(e){return th.jsx("svg",tu({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:th.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var tR=(0,d.forwardRef)(function(e,t){var n=tS(),r=n.classNames,o=n.styles,i=[r.button_reset,r.button];e.className&&i.push(e.className);var a=i.join(" "),l=tu(tu({},o.button_reset),o.button);return e.style&&Object.assign(l,e.style),th.jsx("button",tu({},e,{ref:t,type:"button",className:a,style:l}))});function tD(e){var t,n,r=tS(),o=r.dir,i=r.locale,a=r.classNames,l=r.styles,s=r.labels,c=s.labelPrevious,u=s.labelNext,d=r.components;if(!e.nextMonth&&!e.previousMonth)return th.jsx(th.Fragment,{});var f=c(e.previousMonth,{locale:i}),p=[a.nav_button,a.nav_button_previous].join(" "),h=u(e.nextMonth,{locale:i}),m=[a.nav_button,a.nav_button_next].join(" "),g=null!==(t=null==d?void 0:d.IconRight)&&void 0!==t?t:tI,v=null!==(n=null==d?void 0:d.IconLeft)&&void 0!==n?n:tM;return th.jsxs("div",{className:a.nav,style:l.nav,children:[!e.hidePrevious&&th.jsx(tR,{name:"previous-month","aria-label":f,className:p,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:"rtl"===o?th.jsx(g,{className:a.nav_icon,style:l.nav_icon}):th.jsx(v,{className:a.nav_icon,style:l.nav_icon})}),!e.hideNext&&th.jsx(tR,{name:"next-month","aria-label":h,className:m,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:"rtl"===o?th.jsx(v,{className:a.nav_icon,style:l.nav_icon}):th.jsx(g,{className:a.nav_icon,style:l.nav_icon})})]})}function tL(e){var t=tS().numberOfMonths,n=tT(),r=n.previousMonth,o=n.nextMonth,i=n.goToMonth,a=n.displayMonths,l=a.findIndex(function(t){return e9(e.displayMonth,t)}),s=0===l,c=l===a.length-1;return th.jsx(tD,{displayMonth:e.displayMonth,hideNext:t>1&&(s||!c),hidePrevious:t>1&&(c||!s),nextMonth:o,previousMonth:r,onPreviousClick:function(){r&&i(r)},onNextClick:function(){o&&i(o)}})}function tZ(e){var t,n,r=tS(),o=r.classNames,i=r.disableNavigation,a=r.styles,l=r.captionLayout,s=r.components,c=null!==(t=null==s?void 0:s.CaptionLabel)&&void 0!==t?t:tE;return n=i?th.jsx(c,{id:e.id,displayMonth:e.displayMonth}):"dropdown"===l?th.jsx(tA,{displayMonth:e.displayMonth,id:e.id}):"dropdown-buttons"===l?th.jsxs(th.Fragment,{children:[th.jsx(tA,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),th.jsx(tL,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):th.jsxs(th.Fragment,{children:[th.jsx(c,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),th.jsx(tL,{displayMonth:e.displayMonth,id:e.id})]}),th.jsx("div",{className:o.caption,style:a.caption,children:n})}function tz(e){var t=tS(),n=t.footer,r=t.styles,o=t.classNames.tfoot;return n?th.jsx("tfoot",{className:o,style:r.tfoot,children:th.jsx("tr",{children:th.jsx("td",{colSpan:8,children:n})})}):th.jsx(th.Fragment,{})}function tB(){var e=tS(),t=e.classNames,n=e.styles,r=e.showWeekNumber,o=e.locale,i=e.weekStartsOn,a=e.ISOWeek,l=e.formatters.formatWeekdayName,s=e.labels.labelWeekday,c=function(e,t,n){for(var r=n?tn(new Date):tt(new Date,{locale:e,weekStartsOn:t}),o=[],i=0;i<7;i++){var a=(0,eh.Z)(r,i);o.push(a)}return o}(o,i,a);return th.jsxs("tr",{style:n.head_row,className:t.head_row,children:[r&&th.jsx("td",{style:n.head_cell,className:t.head_cell}),c.map(function(e,r){return th.jsx("th",{scope:"col",className:t.head_cell,style:n.head_cell,"aria-label":s(e,{locale:o}),children:l(e,{locale:o})},r)})]})}function tF(){var e,t=tS(),n=t.classNames,r=t.styles,o=t.components,i=null!==(e=null==o?void 0:o.HeadRow)&&void 0!==e?e:tB;return th.jsx("thead",{style:r.head,className:n.head,children:th.jsx(i,{})})}function tH(e){var t=tS(),n=t.locale,r=t.formatters.formatDay;return th.jsx(th.Fragment,{children:r(e.date,{locale:n})})}var tq=(0,d.createContext)(void 0);function tU(e){return tm(e.initialProps)?th.jsx(tW,{initialProps:e.initialProps,children:e.children}):th.jsx(tq.Provider,{value:{selected:void 0,modifiers:{disabled:[]}},children:e.children})}function tW(e){var t=e.initialProps,n=e.children,r=t.selected,o=t.min,i=t.max,a={disabled:[]};return r&&a.disabled.push(function(e){var t=i&&r.length>i-1,n=r.some(function(t){return tr(t,e)});return!!(t&&!n)}),th.jsx(tq.Provider,{value:{selected:r,onDayClick:function(e,n,a){if(null===(l=t.onDayClick)||void 0===l||l.call(t,e,n,a),(!n.selected||!o||(null==r?void 0:r.length)!==o)&&(n.selected||!i||(null==r?void 0:r.length)!==i)){var l,s,c=r?td([],r,!0):[];if(n.selected){var u=c.findIndex(function(t){return tr(e,t)});c.splice(u,1)}else c.push(e);null===(s=t.onSelect)||void 0===s||s.call(t,c,e,n,a)}},modifiers:a},children:n})}function tK(){var e=(0,d.useContext)(tq);if(!e)throw Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}var t$=(0,d.createContext)(void 0);function tV(e){return tg(e.initialProps)?th.jsx(tX,{initialProps:e.initialProps,children:e.children}):th.jsx(t$.Provider,{value:{selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}},children:e.children})}function tX(e){var t=e.initialProps,n=e.children,r=t.selected,o=r||{},i=o.from,a=o.to,l=t.min,s=t.max,c={range_start:[],range_end:[],range_middle:[],disabled:[]};if(i?(c.range_start=[i],a?(c.range_end=[a],tr(i,a)||(c.range_middle=[{after:i,before:a}])):c.range_end=[i]):a&&(c.range_start=[a],c.range_end=[a]),l&&(i&&!a&&c.disabled.push({after:eg(i,l-1),before:(0,eh.Z)(i,l-1)}),i&&a&&c.disabled.push({after:i,before:(0,eh.Z)(i,l-1)}),!i&&a&&c.disabled.push({after:eg(a,l-1),before:(0,eh.Z)(a,l-1)})),s){if(i&&!a&&(c.disabled.push({before:(0,eh.Z)(i,-s+1)}),c.disabled.push({after:(0,eh.Z)(i,s-1)})),i&&a){var u=s-(ti(a,i)+1);c.disabled.push({before:eg(i,u)}),c.disabled.push({after:(0,eh.Z)(a,u)})}!i&&a&&(c.disabled.push({before:(0,eh.Z)(a,-s+1)}),c.disabled.push({after:(0,eh.Z)(a,s-1)}))}return th.jsx(t$.Provider,{value:{selected:r,onDayClick:function(e,n,o){null===(s=t.onDayClick)||void 0===s||s.call(t,e,n,o);var i,a,l,s,c,u=(a=(i=r||{}).from,l=i.to,a&&l?tr(l,e)&&tr(a,e)?void 0:tr(l,e)?{from:l,to:void 0}:tr(a,e)?void 0:to(a,e)?{from:e,to:l}:{from:a,to:e}:l?to(e,l)?{from:l,to:e}:{from:e,to:l}:a?te(e,a)?{from:e,to:a}:{from:a,to:e}:{from:e,to:void 0});null===(c=t.onSelect)||void 0===c||c.call(t,u,e,n,o)},modifiers:c},children:n})}function tG(){var e=(0,d.useContext)(t$);if(!e)throw Error("useSelectRange must be used within a SelectRangeProvider");return e}function tY(e){return Array.isArray(e)?td([],e,!0):void 0!==e?[e]:[]}(l=c||(c={})).Outside="outside",l.Disabled="disabled",l.Selected="selected",l.Hidden="hidden",l.Today="today",l.RangeStart="range_start",l.RangeEnd="range_end",l.RangeMiddle="range_middle";var tQ=c.Selected,tJ=c.Disabled,t0=c.Hidden,t1=c.Today,t2=c.RangeEnd,t4=c.RangeMiddle,t6=c.RangeStart,t3=c.Outside,t8=(0,d.createContext)(void 0);function t5(e){var t,n,r,o=tS(),i=tK(),a=tG(),l=((t={})[tQ]=tY(o.selected),t[tJ]=tY(o.disabled),t[t0]=tY(o.hidden),t[t1]=[o.today],t[t2]=[],t[t4]=[],t[t6]=[],t[t3]=[],o.fromDate&&t[tJ].push({before:o.fromDate}),o.toDate&&t[tJ].push({after:o.toDate}),tm(o)?t[tJ]=t[tJ].concat(i.modifiers[tJ]):tg(o)&&(t[tJ]=t[tJ].concat(a.modifiers[tJ]),t[t6]=a.modifiers[t6],t[t4]=a.modifiers[t4],t[t2]=a.modifiers[t2]),t),s=(n=o.modifiers,r={},Object.entries(n).forEach(function(e){var t=e[0],n=e[1];r[t]=tY(n)}),r),c=tu(tu({},l),s);return th.jsx(t8.Provider,{value:c,children:e.children})}function t7(){var e=(0,d.useContext)(t8);if(!e)throw Error("useModifiers must be used within a ModifiersProvider");return e}function t9(e,t,n){var r=Object.keys(t).reduce(function(n,r){return t[r].some(function(t){if("boolean"==typeof t)return t;if(ex(t))return tr(e,t);if(Array.isArray(t)&&t.every(ex))return t.includes(e);if(t&&"object"==typeof t&&"from"in t)return r=t.from,o=t.to,r&&o?(0>ti(o,r)&&(r=(n=[o,r])[0],o=n[1]),ti(e,r)>=0&&ti(o,e)>=0):o?tr(o,e):!!r&&tr(r,e);if(t&&"object"==typeof t&&"dayOfWeek"in t)return t.dayOfWeek.includes(e.getDay());if(t&&"object"==typeof t&&"before"in t&&"after"in t){var n,r,o,i=ti(t.before,e),a=ti(t.after,e),l=i>0,s=a<0;return to(t.before,t.after)?s&&l:l||s}return t&&"object"==typeof t&&"after"in t?ti(e,t.after)>0:t&&"object"==typeof t&&"before"in t?ti(t.before,e)>0:"function"==typeof t&&t(e)})&&n.push(r),n},[]),o={};return r.forEach(function(e){return o[e]=!0}),n&&!e9(e,n)&&(o.outside=!0),o}var ne=(0,d.createContext)(void 0);function nt(e){var t=tT(),n=t7(),r=(0,d.useState)(),o=r[0],i=r[1],a=(0,d.useState)(),l=a[0],s=a[1],c=function(e,t){for(var n,r,o=es(e[0]),i=e3(e[e.length-1]),a=o;a<=i;){var l=t9(a,t);if(!(!l.disabled&&!l.hidden)){a=(0,eh.Z)(a,1);continue}if(l.selected)return a;l.today&&!r&&(r=a),n||(n=a),a=(0,eh.Z)(a,1)}return r||n}(t.displayMonths,n),u=(null!=o?o:l&&t.isDateDisplayed(l))?l:c,f=function(e){i(e)},p=tS(),h=function(e,r){if(o){var i=function e(t,n){var r=n.moveBy,o=n.direction,i=n.context,a=n.modifiers,l=n.retry,s=void 0===l?{count:0,lastFocused:t}:l,c=i.weekStartsOn,u=i.fromDate,d=i.toDate,f=i.locale,p=({day:eh.Z,week:ta,month:ev.Z,year:tl,startOfWeek:function(e){return i.ISOWeek?tn(e):tt(e,{locale:f,weekStartsOn:c})},endOfWeek:function(e){return i.ISOWeek?tc(e):ts(e,{locale:f,weekStartsOn:c})}})[r](t,"after"===o?1:-1);"before"===o&&u?p=ef([u,p]):"after"===o&&d&&(p=ep([d,p]));var h=!0;if(a){var m=t9(p,a);h=!m.disabled&&!m.hidden}return h?p:s.count>365?s.lastFocused:e(p,{moveBy:r,direction:o,context:i,modifiers:a,retry:tu(tu({},s),{count:s.count+1})})}(o,{moveBy:e,direction:r,context:p,modifiers:n});tr(o,i)||(t.goToDate(i,o),f(i))}};return th.jsx(ne.Provider,{value:{focusedDay:o,focusTarget:u,blur:function(){s(o),i(void 0)},focus:f,focusDayAfter:function(){return h("day","after")},focusDayBefore:function(){return h("day","before")},focusWeekAfter:function(){return h("week","after")},focusWeekBefore:function(){return h("week","before")},focusMonthBefore:function(){return h("month","before")},focusMonthAfter:function(){return h("month","after")},focusYearBefore:function(){return h("year","before")},focusYearAfter:function(){return h("year","after")},focusStartOfWeek:function(){return h("startOfWeek","before")},focusEndOfWeek:function(){return h("endOfWeek","after")}},children:e.children})}function nn(){var e=(0,d.useContext)(ne);if(!e)throw Error("useFocusContext must be used within a FocusProvider");return e}var nr=(0,d.createContext)(void 0);function no(e){return tv(e.initialProps)?th.jsx(ni,{initialProps:e.initialProps,children:e.children}):th.jsx(nr.Provider,{value:{selected:void 0},children:e.children})}function ni(e){var t=e.initialProps,n=e.children,r={selected:t.selected,onDayClick:function(e,n,r){var o,i,a;if(null===(o=t.onDayClick)||void 0===o||o.call(t,e,n,r),n.selected&&!t.required){null===(i=t.onSelect)||void 0===i||i.call(t,void 0,e,n,r);return}null===(a=t.onSelect)||void 0===a||a.call(t,e,e,n,r)}};return th.jsx(nr.Provider,{value:r,children:n})}function na(){var e=(0,d.useContext)(nr);if(!e)throw Error("useSelectSingle must be used within a SelectSingleProvider");return e}function nl(e){var t,n,r,o,i,a,l,s,u,f,p,h,m,g,v,y,b,x,w,k,S,E,O,C,j,_,P,N,T,A,M,I,R,D,L,Z,z,B,F,H,q,U,W=(0,d.useRef)(null),K=(t=e.date,n=e.displayMonth,a=tS(),l=nn(),s=t9(t,t7(),n),u=tS(),f=na(),p=tK(),h=tG(),g=(m=nn()).focusDayAfter,v=m.focusDayBefore,y=m.focusWeekAfter,b=m.focusWeekBefore,x=m.blur,w=m.focus,k=m.focusMonthBefore,S=m.focusMonthAfter,E=m.focusYearBefore,O=m.focusYearAfter,C=m.focusStartOfWeek,j=m.focusEndOfWeek,_={onClick:function(e){var n,r,o,i;tv(u)?null===(n=f.onDayClick)||void 0===n||n.call(f,t,s,e):tm(u)?null===(r=p.onDayClick)||void 0===r||r.call(p,t,s,e):tg(u)?null===(o=h.onDayClick)||void 0===o||o.call(h,t,s,e):null===(i=u.onDayClick)||void 0===i||i.call(u,t,s,e)},onFocus:function(e){var n;w(t),null===(n=u.onDayFocus)||void 0===n||n.call(u,t,s,e)},onBlur:function(e){var n;x(),null===(n=u.onDayBlur)||void 0===n||n.call(u,t,s,e)},onKeyDown:function(e){var n;switch(e.key){case"ArrowLeft":e.preventDefault(),e.stopPropagation(),"rtl"===u.dir?g():v();break;case"ArrowRight":e.preventDefault(),e.stopPropagation(),"rtl"===u.dir?v():g();break;case"ArrowDown":e.preventDefault(),e.stopPropagation(),y();break;case"ArrowUp":e.preventDefault(),e.stopPropagation(),b();break;case"PageUp":e.preventDefault(),e.stopPropagation(),e.shiftKey?E():k();break;case"PageDown":e.preventDefault(),e.stopPropagation(),e.shiftKey?O():S();break;case"Home":e.preventDefault(),e.stopPropagation(),C();break;case"End":e.preventDefault(),e.stopPropagation(),j()}null===(n=u.onDayKeyDown)||void 0===n||n.call(u,t,s,e)},onKeyUp:function(e){var n;null===(n=u.onDayKeyUp)||void 0===n||n.call(u,t,s,e)},onMouseEnter:function(e){var n;null===(n=u.onDayMouseEnter)||void 0===n||n.call(u,t,s,e)},onMouseLeave:function(e){var n;null===(n=u.onDayMouseLeave)||void 0===n||n.call(u,t,s,e)},onPointerEnter:function(e){var n;null===(n=u.onDayPointerEnter)||void 0===n||n.call(u,t,s,e)},onPointerLeave:function(e){var n;null===(n=u.onDayPointerLeave)||void 0===n||n.call(u,t,s,e)},onTouchCancel:function(e){var n;null===(n=u.onDayTouchCancel)||void 0===n||n.call(u,t,s,e)},onTouchEnd:function(e){var n;null===(n=u.onDayTouchEnd)||void 0===n||n.call(u,t,s,e)},onTouchMove:function(e){var n;null===(n=u.onDayTouchMove)||void 0===n||n.call(u,t,s,e)},onTouchStart:function(e){var n;null===(n=u.onDayTouchStart)||void 0===n||n.call(u,t,s,e)}},P=tS(),N=na(),T=tK(),A=tG(),M=tv(P)?N.selected:tm(P)?T.selected:tg(P)?A.selected:void 0,I=!!(a.onDayClick||"default"!==a.mode),(0,d.useEffect)(function(){var e;!s.outside&&l.focusedDay&&I&&tr(l.focusedDay,t)&&(null===(e=W.current)||void 0===e||e.focus())},[l.focusedDay,t,W,I,s.outside]),D=(R=[a.classNames.day],Object.keys(s).forEach(function(e){var t=a.modifiersClassNames[e];if(t)R.push(t);else if(Object.values(c).includes(e)){var n=a.classNames["day_".concat(e)];n&&R.push(n)}}),R).join(" "),L=tu({},a.styles.day),Object.keys(s).forEach(function(e){var t;L=tu(tu({},L),null===(t=a.modifiersStyles)||void 0===t?void 0:t[e])}),Z=L,z=!!(s.outside&&!a.showOutsideDays||s.hidden),B=null!==(i=null===(o=a.components)||void 0===o?void 0:o.DayContent)&&void 0!==i?i:tH,F={style:Z,className:D,children:th.jsx(B,{date:t,displayMonth:n,activeModifiers:s}),role:"gridcell"},H=l.focusTarget&&tr(l.focusTarget,t)&&!s.outside,q=l.focusedDay&&tr(l.focusedDay,t),U=tu(tu(tu({},F),((r={disabled:s.disabled,role:"gridcell"})["aria-selected"]=s.selected,r.tabIndex=q||H?0:-1,r)),_),{isButton:I,isHidden:z,activeModifiers:s,selectedDays:M,buttonProps:U,divProps:F});return K.isHidden?th.jsx("div",{role:"gridcell"}):K.isButton?th.jsx(tR,tu({name:"day",ref:W},K.buttonProps)):th.jsx("div",tu({},K.divProps))}function ns(e){var t=e.number,n=e.dates,r=tS(),o=r.onWeekNumberClick,i=r.styles,a=r.classNames,l=r.locale,s=r.labels.labelWeekNumber,c=(0,r.formatters.formatWeekNumber)(Number(t),{locale:l});if(!o)return th.jsx("span",{className:a.weeknumber,style:i.weeknumber,children:c});var u=s(Number(t),{locale:l});return th.jsx(tR,{name:"week-number","aria-label":u,className:a.weeknumber,style:i.weeknumber,onClick:function(e){o(t,n,e)},children:c})}function nc(e){var t,n,r,o=tS(),i=o.styles,a=o.classNames,l=o.showWeekNumber,s=o.components,c=null!==(t=null==s?void 0:s.Day)&&void 0!==t?t:nl,u=null!==(n=null==s?void 0:s.WeekNumber)&&void 0!==n?n:ns;return l&&(r=th.jsx("td",{className:a.cell,style:i.cell,children:th.jsx(u,{number:e.weekNumber,dates:e.dates})})),th.jsxs("tr",{className:a.row,style:i.row,children:[r,e.dates.map(function(t){return th.jsx("td",{className:a.cell,style:i.cell,role:"presentation",children:th.jsx(c,{displayMonth:e.displayMonth,date:t})},function(e){return(0,ei.Z)(1,arguments),Math.floor(function(e){return(0,ei.Z)(1,arguments),(0,eo.Z)(e).getTime()}(e)/1e3)}(t))})]})}function nu(e,t,n){for(var r=(null==n?void 0:n.ISOWeek)?tc(t):ts(t,n),o=(null==n?void 0:n.ISOWeek)?tn(e):tt(e,n),i=ti(r,o),a=[],l=0;l<=i;l++)a.push((0,eh.Z)(o,l));return a.reduce(function(e,t){var r=(null==n?void 0:n.ISOWeek)?function(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e);return Math.round((tn(t).getTime()-(function(e){(0,ei.Z)(1,arguments);var t=function(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e),n=t.getFullYear(),r=new Date(0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);var o=tn(r),i=new Date(0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);var a=tn(i);return t.getTime()>=o.getTime()?n+1:t.getTime()>=a.getTime()?n:n-1}(e),n=new Date(0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),tn(n)})(t).getTime())/6048e5)+1}(t):function(e,t){(0,ei.Z)(1,arguments);var n=(0,eo.Z)(e);return Math.round((tt(n,t).getTime()-(function(e,t){(0,ei.Z)(1,arguments);var n,r,o,i,a,l,s,c,u=(0,em.Z)(null!==(n=null!==(r=null!==(o=null!==(i=null==t?void 0:t.firstWeekContainsDate)&&void 0!==i?i:null==t?void 0:null===(a=t.locale)||void 0===a?void 0:null===(l=a.options)||void 0===l?void 0:l.firstWeekContainsDate)&&void 0!==o?o:eS.firstWeekContainsDate)&&void 0!==r?r:null===(s=eS.locale)||void 0===s?void 0:null===(c=s.options)||void 0===c?void 0:c.firstWeekContainsDate)&&void 0!==n?n:1),d=function(e,t){(0,ei.Z)(1,arguments);var n,r,o,i,a,l,s,c,u=(0,eo.Z)(e),d=u.getFullYear(),f=(0,em.Z)(null!==(n=null!==(r=null!==(o=null!==(i=null==t?void 0:t.firstWeekContainsDate)&&void 0!==i?i:null==t?void 0:null===(a=t.locale)||void 0===a?void 0:null===(l=a.options)||void 0===l?void 0:l.firstWeekContainsDate)&&void 0!==o?o:eS.firstWeekContainsDate)&&void 0!==r?r:null===(s=eS.locale)||void 0===s?void 0:null===(c=s.options)||void 0===c?void 0:c.firstWeekContainsDate)&&void 0!==n?n:1);if(!(f>=1&&f<=7))throw RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setFullYear(d+1,0,f),p.setHours(0,0,0,0);var h=tt(p,t),m=new Date(0);m.setFullYear(d,0,f),m.setHours(0,0,0,0);var g=tt(m,t);return u.getTime()>=h.getTime()?d+1:u.getTime()>=g.getTime()?d:d-1}(e,t),f=new Date(0);return f.setFullYear(d,0,u),f.setHours(0,0,0,0),tt(f,t)})(n,t).getTime())/6048e5)+1}(t,n),o=e.find(function(e){return e.weekNumber===r});return o?o.dates.push(t):e.push({weekNumber:r,dates:[t]}),e},[])}function nd(e){var t,n,r,o=tS(),i=o.locale,a=o.classNames,l=o.styles,s=o.hideHead,c=o.fixedWeeks,u=o.components,d=o.weekStartsOn,f=o.firstWeekContainsDate,p=o.ISOWeek,h=function(e,t){var n=nu(es(e),e3(e),t);if(null==t?void 0:t.useFixedWeeks){var r=function(e,t){return(0,ei.Z)(1,arguments),function(e,t,n){(0,ei.Z)(2,arguments);var r=tt(e,n),o=tt(t,n);return Math.round((r.getTime()-eD(r)-(o.getTime()-eD(o)))/6048e5)}(function(e){(0,ei.Z)(1,arguments);var t=(0,eo.Z)(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(0,0,0,0),t}(e),es(e),t)+1}(e,t);if(r<6){var o=n[n.length-1],i=o.dates[o.dates.length-1],a=ta(i,6-r),l=nu(ta(i,1),a,t);n.push.apply(n,l)}}return n}(e.displayMonth,{useFixedWeeks:!!c,ISOWeek:p,locale:i,weekStartsOn:d,firstWeekContainsDate:f}),m=null!==(t=null==u?void 0:u.Head)&&void 0!==t?t:tF,g=null!==(n=null==u?void 0:u.Row)&&void 0!==n?n:nc,v=null!==(r=null==u?void 0:u.Footer)&&void 0!==r?r:tz;return th.jsxs("table",{id:e.id,className:a.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!s&&th.jsx(m,{}),th.jsx("tbody",{className:a.tbody,style:l.tbody,children:h.map(function(t){return th.jsx(g,{displayMonth:e.displayMonth,dates:t.dates,weekNumber:t.weekNumber},t.weekNumber)})}),th.jsx(v,{displayMonth:e.displayMonth})]})}var nf="undefined"!=typeof window&&window.document&&window.document.createElement?d.useLayoutEffect:d.useEffect,np=!1,nh=0;function nm(){return"react-day-picker-".concat(++nh)}function ng(e){var t,n,r,o,i,a,l,s,c=tS(),u=c.dir,f=c.classNames,p=c.styles,h=c.components,m=tT().displayMonths,g=(r=null!=(t=c.id?"".concat(c.id,"-").concat(e.displayIndex):void 0)?t:np?nm():null,i=(o=(0,d.useState)(r))[0],a=o[1],nf(function(){null===i&&a(nm())},[]),(0,d.useEffect)(function(){!1===np&&(np=!0)},[]),null!==(n=null!=t?t:i)&&void 0!==n?n:void 0),v=c.id?"".concat(c.id,"-grid-").concat(e.displayIndex):void 0,y=[f.month],b=p.month,x=0===e.displayIndex,w=e.displayIndex===m.length-1,k=!x&&!w;"rtl"===u&&(w=(l=[x,w])[0],x=l[1]),x&&(y.push(f.caption_start),b=tu(tu({},b),p.caption_start)),w&&(y.push(f.caption_end),b=tu(tu({},b),p.caption_end)),k&&(y.push(f.caption_between),b=tu(tu({},b),p.caption_between));var S=null!==(s=null==h?void 0:h.Caption)&&void 0!==s?s:tZ;return th.jsxs("div",{className:y.join(" "),style:b,children:[th.jsx(S,{id:g,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),th.jsx(nd,{id:v,"aria-labelledby":g,displayMonth:e.displayMonth})]},e.displayIndex)}function nv(e){var t=tS(),n=t.classNames,r=t.styles;return th.jsx("div",{className:n.months,style:r.months,children:e.children})}function ny(e){var t,n,r=e.initialProps,o=tS(),i=nn(),a=tT(),l=(0,d.useState)(!1),s=l[0],c=l[1];(0,d.useEffect)(function(){o.initialFocus&&i.focusTarget&&(s||(i.focus(i.focusTarget),c(!0)))},[o.initialFocus,s,i.focus,i.focusTarget,i]);var u=[o.classNames.root,o.className];o.numberOfMonths>1&&u.push(o.classNames.multiple_months),o.showWeekNumber&&u.push(o.classNames.with_weeknumber);var f=tu(tu({},o.styles.root),o.style),p=Object.keys(r).filter(function(e){return e.startsWith("data-")}).reduce(function(e,t){var n;return tu(tu({},e),((n={})[t]=r[t],n))},{}),h=null!==(n=null===(t=r.components)||void 0===t?void 0:t.Months)&&void 0!==n?n:nv;return th.jsx("div",tu({className:u.join(" "),style:f,dir:o.dir,id:o.id,nonce:r.nonce,title:r.title,lang:r.lang},p,{children:th.jsx(h,{children:a.displayMonths.map(function(e,t){return th.jsx(ng,{displayIndex:t,displayMonth:e},t)})})}))}function nb(e){var t=e.children,n=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,r=Object.getOwnPropertySymbols(e);ot.indexOf(r[o])&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}(e,["children"]);return th.jsx(tk,{initialProps:n,children:th.jsx(tN,{children:th.jsx(no,{initialProps:n,children:th.jsx(tU,{initialProps:n,children:th.jsx(tV,{initialProps:n,children:th.jsx(t5,{children:th.jsx(nt,{children:t})})})})})})})}function nx(e){return th.jsx(nb,tu({},e,{children:th.jsx(ny,{initialProps:e})}))}let nw=e=>{var t=(0,u._T)(e,[]);return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),d.createElement("path",{d:"M10.8284 12.0007L15.7782 16.9504L14.364 18.3646L8 12.0007L14.364 5.63672L15.7782 7.05093L10.8284 12.0007Z"}))},nk=e=>{var t=(0,u._T)(e,[]);return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),d.createElement("path",{d:"M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z"}))},nS=e=>{var t=(0,u._T)(e,[]);return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),d.createElement("path",{d:"M4.83582 12L11.0429 18.2071L12.4571 16.7929L7.66424 12L12.4571 7.20712L11.0429 5.79291L4.83582 12ZM10.4857 12L16.6928 18.2071L18.107 16.7929L13.3141 12L18.107 7.20712L16.6928 5.79291L10.4857 12Z"}))},nE=e=>{var t=(0,u._T)(e,[]);return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),d.createElement("path",{d:"M19.1642 12L12.9571 5.79291L11.5429 7.20712L16.3358 12L11.5429 16.7929L12.9571 18.2071L19.1642 12ZM13.5143 12L7.30722 5.79291L5.89301 7.20712L10.6859 12L5.89301 16.7929L7.30722 18.2071L13.5143 12Z"}))};var nO=n(84264);n(41649);var nC=n(1526),nj=n(7084),n_=n(26898);let nP={xs:{paddingX:"px-2",paddingY:"py-0.5",fontSize:"text-xs"},sm:{paddingX:"px-2.5",paddingY:"py-1",fontSize:"text-sm"},md:{paddingX:"px-3",paddingY:"py-1.5",fontSize:"text-md"},lg:{paddingX:"px-3.5",paddingY:"py-1.5",fontSize:"text-lg"},xl:{paddingX:"px-3.5",paddingY:"py-1.5",fontSize:"text-xl"}},nN={xs:{paddingX:"px-2",paddingY:"py-0.5",fontSize:"text-xs"},sm:{paddingX:"px-2.5",paddingY:"py-0.5",fontSize:"text-sm"},md:{paddingX:"px-3",paddingY:"py-0.5",fontSize:"text-md"},lg:{paddingX:"px-3.5",paddingY:"py-0.5",fontSize:"text-lg"},xl:{paddingX:"px-4",paddingY:"py-1",fontSize:"text-xl"}},nT={xs:{height:"h-4",width:"w-4"},sm:{height:"h-4",width:"w-4"},md:{height:"h-4",width:"w-4"},lg:{height:"h-5",width:"w-5"},xl:{height:"h-6",width:"w-6"}},nA={[nj.wu.Increase]:{bgColor:(0,eJ.bM)(nj.fr.Emerald,n_.K.background).bgColor,textColor:(0,eJ.bM)(nj.fr.Emerald,n_.K.text).textColor},[nj.wu.ModerateIncrease]:{bgColor:(0,eJ.bM)(nj.fr.Emerald,n_.K.background).bgColor,textColor:(0,eJ.bM)(nj.fr.Emerald,n_.K.text).textColor},[nj.wu.Decrease]:{bgColor:(0,eJ.bM)(nj.fr.Rose,n_.K.background).bgColor,textColor:(0,eJ.bM)(nj.fr.Rose,n_.K.text).textColor},[nj.wu.ModerateDecrease]:{bgColor:(0,eJ.bM)(nj.fr.Rose,n_.K.background).bgColor,textColor:(0,eJ.bM)(nj.fr.Rose,n_.K.text).textColor},[nj.wu.Unchanged]:{bgColor:(0,eJ.bM)(nj.fr.Orange,n_.K.background).bgColor,textColor:(0,eJ.bM)(nj.fr.Orange,n_.K.text).textColor}},nM={[nj.wu.Increase]:e=>{var t=(0,u._T)(e,[]);return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),d.createElement("path",{d:"M13.0001 7.82843V20H11.0001V7.82843L5.63614 13.1924L4.22192 11.7782L12.0001 4L19.7783 11.7782L18.3641 13.1924L13.0001 7.82843Z"}))},[nj.wu.ModerateIncrease]:e=>{var t=(0,u._T)(e,[]);return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),d.createElement("path",{d:"M16.0037 9.41421L7.39712 18.0208L5.98291 16.6066L14.5895 8H7.00373V6H18.0037V17H16.0037V9.41421Z"}))},[nj.wu.Decrease]:e=>{var t=(0,u._T)(e,[]);return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),d.createElement("path",{d:"M13.0001 16.1716L18.3641 10.8076L19.7783 12.2218L12.0001 20L4.22192 12.2218L5.63614 10.8076L11.0001 16.1716V4H13.0001V16.1716Z"}))},[nj.wu.ModerateDecrease]:e=>{var t=(0,u._T)(e,[]);return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),d.createElement("path",{d:"M14.5895 16.0032L5.98291 7.39664L7.39712 5.98242L16.0037 14.589V7.00324H18.0037V18.0032H7.00373V16.0032H14.5895Z"}))},[nj.wu.Unchanged]:e=>{var t=(0,u._T)(e,[]);return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),d.createElement("path",{d:"M16.1716 10.9999L10.8076 5.63589L12.2218 4.22168L20 11.9999L12.2218 19.778L10.8076 18.3638L16.1716 12.9999H4V10.9999H16.1716Z"}))}},nI=(0,eJ.fn)("BadgeDelta");d.forwardRef((e,t)=>{let{deltaType:n=nj.wu.Increase,isIncreasePositive:r=!0,size:o=nj.u8.SM,tooltip:i,children:a,className:l}=e,s=(0,u._T)(e,["deltaType","isIncreasePositive","size","tooltip","children","className"]),c=nM[n],f=(0,eJ.Fo)(n,r),p=a?nN:nP,{tooltipProps:h,getReferenceProps:m}=(0,nC.l)();return d.createElement("span",Object.assign({ref:(0,eJ.lq)([t,h.refs.setReference]),className:(0,ec.q)(nI("root"),"w-max flex-shrink-0 inline-flex justify-center items-center cursor-default rounded-tremor-full bg-opacity-20 dark:bg-opacity-25",nA[f].bgColor,nA[f].textColor,p[o].paddingX,p[o].paddingY,p[o].fontSize,l)},m,s),d.createElement(nC.Z,Object.assign({text:i},h)),d.createElement(c,{className:(0,ec.q)(nI("icon"),"shrink-0",a?(0,ec.q)("-ml-1 mr-1.5"):nT[o].height,nT[o].width)}),a?d.createElement("p",{className:(0,ec.q)(nI("text"),"text-sm whitespace-nowrap")},a):null)}).displayName="BadgeDelta";var nR=n(47323);let nD=e=>{var{onClick:t,icon:n}=e,r=(0,u._T)(e,["onClick","icon"]);return d.createElement("button",Object.assign({type:"button",className:(0,ec.q)("flex items-center justify-center p-1 h-7 w-7 outline-none focus:ring-2 transition duration-100 border border-tremor-border dark:border-dark-tremor-border hover:bg-tremor-background-muted dark:hover:bg-dark-tremor-background-muted rounded-tremor-small focus:border-tremor-brand-subtle select-none dark:focus:border-dark-tremor-brand-subtle focus:ring-tremor-brand-muted dark:focus:ring-dark-tremor-brand-muted text-tremor-content-subtle dark:text-dark-tremor-content-subtle hover:text-tremor-content dark:hover:text-dark-tremor-content")},r),d.createElement(nR.Z,{onClick:t,icon:n,variant:"simple",color:"slate",size:"sm"}))};function nL(e){var{mode:t,defaultMonth:n,selected:r,onSelect:o,locale:i,disabled:a,enableYearNavigation:l,classNames:s,weekStartsOn:c=0}=e,f=(0,u._T)(e,["mode","defaultMonth","selected","onSelect","locale","disabled","enableYearNavigation","classNames","weekStartsOn"]);return d.createElement(nx,Object.assign({showOutsideDays:!0,mode:t,defaultMonth:n,selected:r,onSelect:o,locale:i,disabled:a,weekStartsOn:c,classNames:Object.assign({months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-2 relative items-center",caption_label:"text-tremor-default text-tremor-content-emphasis dark:text-dark-tremor-content-emphasis font-medium",nav:"space-x-1 flex items-center",nav_button:"flex items-center justify-center p-1 h-7 w-7 outline-none focus:ring-2 transition duration-100 border border-tremor-border dark:border-dark-tremor-border hover:bg-tremor-background-muted dark:hover:bg-dark-tremor-background-muted rounded-tremor-small focus:border-tremor-brand-subtle dark:focus:border-dark-tremor-brand-subtle focus:ring-tremor-brand-muted dark:focus:ring-dark-tremor-brand-muted text-tremor-content-subtle dark:text-dark-tremor-content-subtle hover:text-tremor-content dark:hover:text-dark-tremor-content",nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"w-9 font-normal text-center text-tremor-content-subtle dark:text-dark-tremor-content-subtle",row:"flex w-full mt-0.5",cell:"text-center p-0 relative focus-within:relative text-tremor-default text-tremor-content-emphasis dark:text-dark-tremor-content-emphasis",day:"h-9 w-9 p-0 hover:bg-tremor-background-subtle dark:hover:bg-dark-tremor-background-subtle outline-tremor-brand dark:outline-dark-tremor-brand rounded-tremor-default",day_today:"font-bold",day_selected:"aria-selected:bg-tremor-background-emphasis aria-selected:text-tremor-content-inverted dark:aria-selected:bg-dark-tremor-background-emphasis dark:aria-selected:text-dark-tremor-content-inverted ",day_disabled:"text-tremor-content-subtle dark:text-dark-tremor-content-subtle disabled:hover:bg-transparent",day_outside:"text-tremor-content-subtle dark:text-dark-tremor-content-subtle"},s),components:{IconLeft:e=>{var t=(0,u._T)(e,[]);return d.createElement(nw,Object.assign({className:"h-4 w-4"},t))},IconRight:e=>{var t=(0,u._T)(e,[]);return d.createElement(nk,Object.assign({className:"h-4 w-4"},t))},Caption:e=>{var t=(0,u._T)(e,[]);let{goToMonth:n,nextMonth:r,previousMonth:o,currentMonth:a}=tT();return d.createElement("div",{className:"flex justify-between items-center"},d.createElement("div",{className:"flex items-center space-x-1"},l&&d.createElement(nD,{onClick:()=>a&&n(tl(a,-1)),icon:nS}),d.createElement(nD,{onClick:()=>o&&n(o),icon:nw})),d.createElement(nO.Z,{className:"text-tremor-default tabular-nums capitalize text-tremor-content-emphasis dark:text-dark-tremor-content-emphasis font-medium"},eQ(t.displayMonth,"LLLL yyy",{locale:i})),d.createElement("div",{className:"flex items-center space-x-1"},d.createElement(nD,{onClick:()=>r&&n(r),icon:nk}),l&&d.createElement(nD,{onClick:()=>a&&n(tl(a,1)),icon:nE})))}}},f))}nL.displayName="DateRangePicker",n(27281);var nZ=n(57365),nz=n(44140);let nB=el(),nF=d.forwardRef((e,t)=>{var n,r;let{value:o,defaultValue:i,onValueChange:a,enableSelect:l=!0,minDate:s,maxDate:c,placeholder:f="Select range",selectPlaceholder:p="Select range",disabled:h=!1,locale:m=eK,enableClear:g=!0,displayFormat:v,children:y,className:b,enableYearNavigation:x=!1,weekStartsOn:w=0,disabledDates:k}=e,S=(0,u._T)(e,["value","defaultValue","onValueChange","enableSelect","minDate","maxDate","placeholder","selectPlaceholder","disabled","locale","enableClear","displayFormat","children","className","enableYearNavigation","weekStartsOn","disabledDates"]),[E,O]=(0,nz.Z)(i,o),[C,j]=(0,d.useState)(!1),[_,P]=(0,d.useState)(!1),N=(0,d.useMemo)(()=>{let e=[];return s&&e.push({before:s}),c&&e.push({after:c}),[...e,...null!=k?k:[]]},[s,c,k]),T=(0,d.useMemo)(()=>{let e=new Map;return y?d.Children.forEach(y,t=>{var n;e.set(t.props.value,{text:null!==(n=(0,eu.qg)(t))&&void 0!==n?n:t.props.value,from:t.props.from,to:t.props.to})}):e4.forEach(t=>{e.set(t.value,{text:t.text,from:t.from,to:nB})}),e},[y]),A=(0,d.useMemo)(()=>{if(y)return(0,eu.sl)(y);let e=new Map;return e4.forEach(t=>e.set(t.value,t.text)),e},[y]),M=(null==E?void 0:E.selectValue)||"",I=e1(null==E?void 0:E.from,s,M,T),R=e2(null==E?void 0:E.to,c,M,T),D=I||R?e6(I,R,m,v):f,L=es(null!==(r=null!==(n=null!=R?R:I)&&void 0!==n?n:c)&&void 0!==r?r:nB),Z=g&&!h;return d.createElement("div",Object.assign({ref:t,className:(0,ec.q)("w-full min-w-[10rem] relative flex justify-between text-tremor-default max-w-sm shadow-tremor-input dark:shadow-dark-tremor-input rounded-tremor-default",b)},S),d.createElement(J,{as:"div",className:(0,ec.q)("w-full",l?"rounded-l-tremor-default":"rounded-tremor-default",C&&"ring-2 ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted z-10")},d.createElement("div",{className:"relative w-full"},d.createElement(J.Button,{onFocus:()=>j(!0),onBlur:()=>j(!1),disabled:h,className:(0,ec.q)("w-full outline-none text-left whitespace-nowrap truncate focus:ring-2 transition duration-100 rounded-l-tremor-default flex flex-nowrap border pl-3 py-2","rounded-l-tremor-default border-tremor-border text-tremor-content-emphasis focus:border-tremor-brand-subtle focus:ring-tremor-brand-muted","dark:border-dark-tremor-border dark:text-dark-tremor-content-emphasis dark:focus:border-dark-tremor-brand-subtle dark:focus:ring-dark-tremor-brand-muted",l?"rounded-l-tremor-default":"rounded-tremor-default",Z?"pr-8":"pr-4",(0,eu.um)((0,eu.Uh)(I||R),h))},d.createElement(en,{className:(0,ec.q)(e0("calendarIcon"),"flex-none shrink-0 h-5 w-5 -ml-0.5 mr-2","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle"),"aria-hidden":"true"}),d.createElement("p",{className:"truncate"},D)),Z&&I?d.createElement("button",{type:"button",className:(0,ec.q)("absolute outline-none inset-y-0 right-0 flex items-center transition duration-100 mr-4"),onClick:e=>{e.preventDefault(),null==a||a({}),O({})}},d.createElement(er.Z,{className:(0,ec.q)(e0("clearIcon"),"flex-none h-4 w-4","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})):null),d.createElement(ee.u,{className:"absolute z-10 min-w-min left-0",enter:"transition ease duration-100 transform",enterFrom:"opacity-0 -translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"transition ease duration-100 transform",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-4"},d.createElement(J.Panel,{focus:!0,className:(0,ec.q)("divide-y overflow-y-auto outline-none rounded-tremor-default p-3 border my-1","bg-tremor-background border-tremor-border divide-tremor-border shadow-tremor-dropdown","dark:bg-dark-tremor-background dark:border-dark-tremor-border dark:divide-dark-tremor-border dark:shadow-dark-tremor-dropdown")},d.createElement(nL,Object.assign({mode:"range",showOutsideDays:!0,defaultMonth:L,selected:{from:I,to:R},onSelect:e=>{null==a||a({from:null==e?void 0:e.from,to:null==e?void 0:e.to}),O({from:null==e?void 0:e.from,to:null==e?void 0:e.to})},locale:m,disabled:N,enableYearNavigation:x,classNames:{day_range_middle:(0,ec.q)("!rounded-none aria-selected:!bg-tremor-background-subtle aria-selected:dark:!bg-dark-tremor-background-subtle aria-selected:!text-tremor-content aria-selected:dark:!bg-dark-tremor-background-subtle"),day_range_start:"rounded-r-none rounded-l-tremor-small aria-selected:text-tremor-brand-inverted dark:aria-selected:text-dark-tremor-brand-inverted",day_range_end:"rounded-l-none rounded-r-tremor-small aria-selected:text-tremor-brand-inverted dark:aria-selected:text-dark-tremor-brand-inverted"},weekStartsOn:w},e))))),l&&d.createElement(et.R,{as:"div",className:(0,ec.q)("w-48 -ml-px rounded-r-tremor-default",_&&"ring-2 ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted z-10"),value:M,onChange:e=>{let{from:t,to:n}=T.get(e),r=null!=n?n:nB;null==a||a({from:t,to:r,selectValue:e}),O({from:t,to:r,selectValue:e})},disabled:h},e=>{var t;let{value:n}=e;return d.createElement(d.Fragment,null,d.createElement(et.R.Button,{onFocus:()=>P(!0),onBlur:()=>P(!1),className:(0,ec.q)("w-full outline-none text-left whitespace-nowrap truncate rounded-r-tremor-default transition duration-100 border px-4 py-2","border-tremor-border shadow-tremor-input text-tremor-content-emphasis focus:border-tremor-brand-subtle","dark:border-dark-tremor-border dark:shadow-dark-tremor-input dark:text-dark-tremor-content-emphasis dark:focus:border-dark-tremor-brand-subtle",(0,eu.um)((0,eu.Uh)(n),h))},n&&null!==(t=A.get(n))&&void 0!==t?t:p),d.createElement(ee.u,{className:"absolute z-10 w-full inset-x-0 right-0",enter:"transition ease duration-100 transform",enterFrom:"opacity-0 -translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"transition ease duration-100 transform",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-4"},d.createElement(et.R.Options,{className:(0,ec.q)("divide-y overflow-y-auto outline-none border my-1","shadow-tremor-dropdown bg-tremor-background border-tremor-border divide-tremor-border rounded-tremor-default","dark:shadow-dark-tremor-dropdown dark:bg-dark-tremor-background dark:border-dark-tremor-border dark:divide-dark-tremor-border")},null!=y?y:e4.map(e=>d.createElement(nZ.Z,{key:e.value,value:e.value},e.text)))))}))});nF.displayName="DateRangePicker"},92414:function(e,t,n){"use strict";n.d(t,{Z:function(){return v}});var r=n(5853),o=n(2265);n(42698),n(64016),n(8710);var i=n(33232),a=n(44140),l=n(58747);let s=e=>{var t=(0,r._T)(e,[]);return o.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),o.createElement("path",{d:"M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6146 17.2475 15.8748 16.0247L16.0247 15.8748Z"}))};var c=n(4537),u=n(28517),d=n(33044);let f=e=>{var t=(0,r._T)(e,[]);return o.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:"100%",height:"100%",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},t),o.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))};var p=n(97324),h=n(1153),m=n(96398);let g=(0,h.fn)("MultiSelect"),v=o.forwardRef((e,t)=>{let{defaultValue:n,value:h,onValueChange:v,placeholder:y="Select...",placeholderSearch:b="Search",disabled:x=!1,icon:w,children:k,className:S}=e,E=(0,r._T)(e,["defaultValue","value","onValueChange","placeholder","placeholderSearch","disabled","icon","children","className"]),[O,C]=(0,a.Z)(n,h),{reactElementChildren:j,optionsAvailable:_}=(0,o.useMemo)(()=>{let e=o.Children.toArray(k).filter(o.isValidElement);return{reactElementChildren:e,optionsAvailable:(0,m.n0)("",e)}},[k]),[P,N]=(0,o.useState)(""),T=(null!=O?O:[]).length>0,A=(0,o.useMemo)(()=>P?(0,m.n0)(P,j):_,[P,j,_]),M=()=>{N("")};return o.createElement(u.R,Object.assign({as:"div",ref:t,defaultValue:O,value:O,onChange:e=>{null==v||v(e),C(e)},disabled:x,className:(0,p.q)("w-full min-w-[10rem] relative text-tremor-default",S)},E,{multiple:!0}),e=>{let{value:t}=e;return o.createElement(o.Fragment,null,o.createElement(u.R.Button,{className:(0,p.q)("w-full outline-none text-left whitespace-nowrap truncate rounded-tremor-default focus:ring-2 transition duration-100 border pr-8 py-1.5","border-tremor-border shadow-tremor-input focus:border-tremor-brand-subtle focus:ring-tremor-brand-muted","dark:border-dark-tremor-border dark:shadow-dark-tremor-input dark:focus:border-dark-tremor-brand-subtle dark:focus:ring-dark-tremor-brand-muted",w?"pl-11 -ml-0.5":"pl-3",(0,m.um)(t.length>0,x))},w&&o.createElement("span",{className:(0,p.q)("absolute inset-y-0 left-0 flex items-center ml-px pl-2.5")},o.createElement(w,{className:(0,p.q)(g("Icon"),"flex-none h-5 w-5","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})),o.createElement("div",{className:"h-6 flex items-center"},t.length>0?o.createElement("div",{className:"flex flex-nowrap overflow-x-scroll [&::-webkit-scrollbar]:hidden [scrollbar-width:none] gap-x-1 mr-5 -ml-1.5 relative"},_.filter(e=>t.includes(e.props.value)).map((e,n)=>{var r;return o.createElement("div",{key:n,className:(0,p.q)("max-w-[100px] lg:max-w-[200px] flex justify-center items-center pl-2 pr-1.5 py-1 font-medium","rounded-tremor-small","bg-tremor-background-muted dark:bg-dark-tremor-background-muted","bg-tremor-background-subtle dark:bg-dark-tremor-background-subtle","text-tremor-content-default dark:text-dark-tremor-content-default","text-tremor-content-emphasis dark:text-dark-tremor-content-emphasis")},o.createElement("div",{className:"text-xs truncate "},null!==(r=e.props.children)&&void 0!==r?r:e.props.value),o.createElement("div",{onClick:n=>{n.preventDefault();let r=t.filter(t=>t!==e.props.value);null==v||v(r),C(r)}},o.createElement(f,{className:(0,p.q)(g("clearIconItem"),"cursor-pointer rounded-tremor-full w-3.5 h-3.5 ml-2","text-tremor-content-subtle hover:text-tremor-content","dark:text-dark-tremor-content-subtle dark:hover:text-tremor-content")})))})):o.createElement("span",null,y)),o.createElement("span",{className:(0,p.q)("absolute inset-y-0 right-0 flex items-center mr-2.5")},o.createElement(l.Z,{className:(0,p.q)(g("arrowDownIcon"),"flex-none h-5 w-5","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")}))),T&&!x?o.createElement("button",{type:"button",className:(0,p.q)("absolute inset-y-0 right-0 flex items-center mr-8"),onClick:e=>{e.preventDefault(),C([]),null==v||v([])}},o.createElement(c.Z,{className:(0,p.q)(g("clearIconAllItems"),"flex-none h-4 w-4","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})):null,o.createElement(d.u,{className:"absolute z-10 w-full",enter:"transition ease duration-100 transform",enterFrom:"opacity-0 -translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"transition ease duration-100 transform",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-4"},o.createElement(u.R.Options,{className:(0,p.q)("divide-y overflow-y-auto outline-none rounded-tremor-default max-h-[228px] left-0 border my-1","bg-tremor-background border-tremor-border divide-tremor-border shadow-tremor-dropdown","dark:bg-dark-tremor-background dark:border-dark-tremor-border dark:divide-dark-tremor-border dark:shadow-dark-tremor-dropdown")},o.createElement("div",{className:(0,p.q)("flex items-center w-full px-2.5","bg-tremor-background-muted","dark:bg-dark-tremor-background-muted")},o.createElement("span",null,o.createElement(s,{className:(0,p.q)("flex-none w-4 h-4 mr-2","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})),o.createElement("input",{name:"search",type:"input",autoComplete:"off",placeholder:b,className:(0,p.q)("w-full focus:outline-none focus:ring-none bg-transparent text-tremor-default py-2","text-tremor-content-emphasis","dark:text-dark-tremor-content-emphasis"),onKeyDown:e=>{"Space"===e.code&&""!==e.target.value&&e.stopPropagation()},onChange:e=>N(e.target.value),value:P})),o.createElement(i.Z.Provider,Object.assign({},{onBlur:{handleResetSearch:M}},{value:{selectedValue:t}}),A))))})});v.displayName="MultiSelect"},46030:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(5853);n(42698),n(64016),n(8710);var o=n(33232),i=n(2265),a=n(97324),l=n(1153),s=n(28517);let c=(0,l.fn)("MultiSelectItem"),u=i.forwardRef((e,t)=>{let{value:n,className:u,children:d}=e,f=(0,r._T)(e,["value","className","children"]),{selectedValue:p}=(0,i.useContext)(o.Z),h=(0,l.NZ)(n,p);return i.createElement(s.R.Option,Object.assign({className:(0,a.q)(c("root"),"flex justify-start items-center cursor-default text-tremor-default p-2.5","ui-active:bg-tremor-background-muted ui-active:text-tremor-content-strong ui-selected:text-tremor-content-strong text-tremor-content-emphasis","dark:ui-active:bg-dark-tremor-background-muted dark:ui-active:text-dark-tremor-content-strong dark:ui-selected:text-dark-tremor-content-strong dark:ui-selected:bg-dark-tremor-background-muted dark:text-dark-tremor-content-emphasis",u),ref:t,key:n,value:n},f),i.createElement("input",{type:"checkbox",className:(0,a.q)(c("checkbox"),"flex-none focus:ring-none focus:outline-none cursor-pointer mr-2.5","accent-tremor-brand","dark:accent-dark-tremor-brand"),checked:h,readOnly:!0}),i.createElement("span",{className:"whitespace-nowrap truncate"},null!=d?d:n))});u.displayName="MultiSelectItem"},30150:function(e,t,n){"use strict";n.d(t,{Z:function(){return f}});var r=n(5853),o=n(2265);let i=e=>{var t=(0,r._T)(e,[]);return o.createElement("svg",Object.assign({},t,{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5"}),o.createElement("path",{d:"M12 4v16m8-8H4"}))},a=e=>{var t=(0,r._T)(e,[]);return o.createElement("svg",Object.assign({},t,{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5"}),o.createElement("path",{d:"M20 12H4"}))};var l=n(97324),s=n(1153),c=n(69262);let u="flex mx-auto text-tremor-content-subtle dark:text-dark-tremor-content-subtle",d="cursor-pointer hover:text-tremor-content dark:hover:text-dark-tremor-content",f=o.forwardRef((e,t)=>{let{onSubmit:n,enableStepper:f=!0,disabled:p,onValueChange:h,onChange:m}=e,g=(0,r._T)(e,["onSubmit","enableStepper","disabled","onValueChange","onChange"]),v=(0,o.useRef)(null),[y,b]=o.useState(!1),x=o.useCallback(()=>{b(!0)},[]),w=o.useCallback(()=>{b(!1)},[]),[k,S]=o.useState(!1),E=o.useCallback(()=>{S(!0)},[]),O=o.useCallback(()=>{S(!1)},[]);return o.createElement(c.Z,Object.assign({type:"number",ref:(0,s.lq)([v,t]),disabled:p,makeInputClassName:(0,s.fn)("NumberInput"),onKeyDown:e=>{var t;if("Enter"===e.key&&!e.ctrlKey&&!e.altKey&&!e.shiftKey){let e=null===(t=v.current)||void 0===t?void 0:t.value;null==n||n(parseFloat(null!=e?e:""))}"ArrowDown"===e.key&&x(),"ArrowUp"===e.key&&E()},onKeyUp:e=>{"ArrowDown"===e.key&&w(),"ArrowUp"===e.key&&O()},onChange:e=>{p||(null==h||h(parseFloat(e.target.value)),null==m||m(e))},stepper:f?o.createElement("div",{className:(0,l.q)("flex justify-center align-middle")},o.createElement("div",{tabIndex:-1,onClick:e=>e.preventDefault(),onMouseDown:e=>e.preventDefault(),onTouchStart:e=>{e.cancelable&&e.preventDefault()},onMouseUp:()=>{var e,t;p||(null===(e=v.current)||void 0===e||e.stepDown(),null===(t=v.current)||void 0===t||t.dispatchEvent(new Event("input",{bubbles:!0})))},className:(0,l.q)(!p&&d,u,"group py-[10px] px-2.5 border-l border-tremor-border dark:border-dark-tremor-border")},o.createElement(a,{"data-testid":"step-down",className:(y?"scale-95":"")+" h-4 w-4 duration-75 transition group-active:scale-95"})),o.createElement("div",{tabIndex:-1,onClick:e=>e.preventDefault(),onMouseDown:e=>e.preventDefault(),onTouchStart:e=>{e.cancelable&&e.preventDefault()},onMouseUp:()=>{var e,t;p||(null===(e=v.current)||void 0===e||e.stepUp(),null===(t=v.current)||void 0===t||t.dispatchEvent(new Event("input",{bubbles:!0})))},className:(0,l.q)(!p&&d,u,"group py-[10px] px-2.5 border-l border-tremor-border dark:border-dark-tremor-border")},o.createElement(i,{"data-testid":"step-up",className:(k?"scale-95":"")+" h-4 w-4 duration-75 transition group-active:scale-95"}))):null},g))});f.displayName="NumberInput"},27281:function(e,t,n){"use strict";n.d(t,{Z:function(){return h}});var r=n(5853),o=n(2265),i=n(58747),a=n(4537),l=n(97324),s=n(1153),c=n(96398),u=n(28517),d=n(33044),f=n(44140);let p=(0,s.fn)("Select"),h=o.forwardRef((e,t)=>{let{defaultValue:n,value:s,onValueChange:h,placeholder:m="Select...",disabled:g=!1,icon:v,enableClear:y=!0,children:b,className:x}=e,w=(0,r._T)(e,["defaultValue","value","onValueChange","placeholder","disabled","icon","enableClear","children","className"]),[k,S]=(0,f.Z)(n,s),E=(0,o.useMemo)(()=>{let e=o.Children.toArray(b).filter(o.isValidElement);return(0,c.sl)(e)},[b]);return o.createElement(u.R,Object.assign({as:"div",ref:t,defaultValue:k,value:k,onChange:e=>{null==h||h(e),S(e)},disabled:g,className:(0,l.q)("w-full min-w-[10rem] relative text-tremor-default",x)},w),e=>{var t;let{value:n}=e;return o.createElement(o.Fragment,null,o.createElement(u.R.Button,{className:(0,l.q)("w-full outline-none text-left whitespace-nowrap truncate rounded-tremor-default focus:ring-2 transition duration-100 border pr-8 py-2","border-tremor-border shadow-tremor-input focus:border-tremor-brand-subtle focus:ring-tremor-brand-muted","dark:border-dark-tremor-border dark:shadow-dark-tremor-input dark:focus:border-dark-tremor-brand-subtle dark:focus:ring-dark-tremor-brand-muted",v?"pl-10":"pl-3",(0,c.um)((0,c.Uh)(n),g))},v&&o.createElement("span",{className:(0,l.q)("absolute inset-y-0 left-0 flex items-center ml-px pl-2.5")},o.createElement(v,{className:(0,l.q)(p("Icon"),"flex-none h-5 w-5","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})),o.createElement("span",{className:"w-[90%] block truncate"},n&&null!==(t=E.get(n))&&void 0!==t?t:m),o.createElement("span",{className:(0,l.q)("absolute inset-y-0 right-0 flex items-center mr-3")},o.createElement(i.Z,{className:(0,l.q)(p("arrowDownIcon"),"flex-none h-5 w-5","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")}))),y&&k?o.createElement("button",{type:"button",className:(0,l.q)("absolute inset-y-0 right-0 flex items-center mr-8"),onClick:e=>{e.preventDefault(),S(""),null==h||h("")}},o.createElement(a.Z,{className:(0,l.q)(p("clearIcon"),"flex-none h-4 w-4","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})):null,o.createElement(d.u,{className:"absolute z-10 w-full",enter:"transition ease duration-100 transform",enterFrom:"opacity-0 -translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"transition ease duration-100 transform",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-4"},o.createElement(u.R.Options,{className:(0,l.q)("divide-y overflow-y-auto outline-none rounded-tremor-default max-h-[228px] left-0 border my-1","bg-tremor-background border-tremor-border divide-tremor-border shadow-tremor-dropdown","dark:bg-dark-tremor-background dark:border-dark-tremor-border dark:divide-dark-tremor-border dark:shadow-dark-tremor-dropdown")},b)))})});h.displayName="Select"},57365:function(e,t,n){"use strict";n.d(t,{Z:function(){return s}});var r=n(5853),o=n(2265),i=n(28517),a=n(97324);let l=(0,n(1153).fn)("SelectItem"),s=o.forwardRef((e,t)=>{let{value:n,icon:s,className:c,children:u}=e,d=(0,r._T)(e,["value","icon","className","children"]);return o.createElement(i.R.Option,Object.assign({className:(0,a.q)(l("root"),"flex justify-start items-center cursor-default text-tremor-default px-2.5 py-2.5","ui-active:bg-tremor-background-muted ui-active:text-tremor-content-strong ui-selected:text-tremor-content-strong ui-selected:bg-tremor-background-muted text-tremor-content-emphasis","dark:ui-active:bg-dark-tremor-background-muted dark:ui-active:text-dark-tremor-content-strong dark:ui-selected:text-dark-tremor-content-strong dark:ui-selected:bg-dark-tremor-background-muted dark:text-dark-tremor-content-emphasis",c),ref:t,key:n,value:n},d),s&&o.createElement(s,{className:(0,a.q)(l("icon"),"flex-none w-5 h-5 mr-1.5","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")}),o.createElement("span",{className:"whitespace-nowrap truncate"},null!=u?u:n))});s.displayName="SelectItem"},92858:function(e,t,n){"use strict";n.d(t,{Z:function(){return N}});var r=n(5853),o=n(2265),i=n(62963),a=n(90945),l=n(13323),s=n(17684),c=n(80004),u=n(93689),d=n(38198),f=n(47634),p=n(56314),h=n(27847),m=n(64518);let g=(0,o.createContext)(null),v=Object.assign((0,h.yV)(function(e,t){let n=(0,s.M)(),{id:r="headlessui-description-".concat(n),...i}=e,a=function e(){let t=(0,o.useContext)(g);if(null===t){let t=Error("You used a component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,e),t}return t}(),l=(0,u.T)(t);(0,m.e)(()=>a.register(r),[r,a.register]);let c={ref:l,...a.props,id:r};return(0,h.sY)({ourProps:c,theirProps:i,slot:a.slot||{},defaultTag:"p",name:a.name||"Description"})}),{});var y=n(37388);let b=(0,o.createContext)(null),x=Object.assign((0,h.yV)(function(e,t){let n=(0,s.M)(),{id:r="headlessui-label-".concat(n),passive:i=!1,...a}=e,l=function e(){let t=(0,o.useContext)(b);if(null===t){let t=Error("You used a