Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ litellm_config.yaml
.cursor
litellm/proxy/to_delete_loadtest_work/*
update_model_cost_map.py
litellm/model_prices_and_context_window_backup.json
tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py
scripts/test_vertex_ai_search.py
LAZY_LOADING_IMPROVEMENTS.md
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ RUN uv sync --frozen --no-install-project --no-install-workspace --no-default-gr
# Copy full source tree
COPY . .

# Generate the model-cost backup artefact inside the package before the wheel build (mirrors publish_to_pypi.yml).
RUN cp model_prices_and_context_window.json litellm/model_prices_and_context_window_backup.json

# Build Admin UI before final sync
RUN sed -i 's/\r$//' docker/build_admin_ui.sh && chmod +x docker/build_admin_ui.sh && ./docker/build_admin_ui.sh

Expand Down
32 changes: 0 additions & 32 deletions ci_cd/check_files_match.py

This file was deleted.

3 changes: 3 additions & 0 deletions docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ RUN uv sync --frozen --no-install-project --no-install-workspace --no-default-gr
# Copy full source tree
COPY . .

# Generate the model-cost backup artefact inside the package before the wheel build (mirrors publish_to_pypi.yml).
RUN cp model_prices_and_context_window.json litellm/model_prices_and_context_window_backup.json

# Install project and workspace packages (fast - deps already cached)
RUN uv sync --frozen --no-default-groups --no-editable \
--extra proxy \
Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile.database
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ RUN uv sync --frozen --no-install-project --no-install-workspace --no-default-gr
# Copy full source tree
COPY . .

# Generate the model-cost backup artefact inside the package before the wheel build (mirrors publish_to_pypi.yml).
RUN cp model_prices_and_context_window.json litellm/model_prices_and_context_window_backup.json

# Build Admin UI before final sync
RUN sed -i 's/\r$//' docker/build_admin_ui.sh && chmod +x docker/build_admin_ui.sh && ./docker/build_admin_ui.sh

Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ RUN uv sync --frozen --no-install-project --no-install-workspace --no-default-gr
# Copy full source tree
COPY . .

# Generate the model-cost backup artefact inside the package before the wheel build (mirrors publish_to_pypi.yml).
RUN cp model_prices_and_context_window.json litellm/model_prices_and_context_window_backup.json

# Build Admin UI before final sync
RUN sed -i 's/\r$//' docker/build_admin_ui.sh && chmod +x docker/build_admin_ui.sh && ./docker/build_admin_ui.sh

Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile.non_root
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ RUN --mount=type=cache,target=/app/.cache/uv,id=litellm-uv-cache \
# Copy full source tree
COPY . .

# Generate the model-cost backup artefact inside the package before the wheel build (mirrors publish_to_pypi.yml).
RUN cp model_prices_and_context_window.json litellm/model_prices_and_context_window_backup.json

# Set non-root flag for build time consistency
ENV LITELLM_NON_ROOT=true

Expand Down
12 changes: 9 additions & 3 deletions litellm/litellm_core_utils/get_model_cost_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import json
import os
from importlib.resources import files
from pathlib import Path
from typing import Dict, List, Optional

import httpx
Expand All @@ -35,13 +36,18 @@ class GetModelCostMap:

@staticmethod
def load_local_model_cost_map() -> dict:
"""Load the local backup model cost map bundled with the package."""
content = json.loads(
"""Load the local model cost map: repo-root JSON in a source checkout, bundled package copy in an installed wheel."""
repo_root_json = (
Path(__file__).resolve().parents[2] / "model_prices_and_context_window.json"
)
if repo_root_json.is_file():
return json.loads(repo_root_json.read_text(encoding="utf-8"))
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

return json.loads(
files("litellm")
.joinpath("model_prices_and_context_window_backup.json")
.read_text(encoding="utf-8")
)
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
return content

@classmethod
def _get_backup_model_count(cls) -> int:
Expand Down
Loading
Loading