mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-11 08:38:24 +00:00
fix(get_model_cost_map): give an actionable message when bundled JSON is missing
Wrap the package-resource load so that a wheel built without the prerequisite cp step (e.g. a manual `uv build`) surfaces a message that names the missing file, points at the canonical build steps, and shows the one-liner fix. The original FileNotFoundError is preserved via `raise ... from e`. Addresses Greptile review P1.
This commit is contained in:
parent
19afe2b20c
commit
a2776fe7ca
1 changed files with 14 additions and 5 deletions
|
|
@ -51,11 +51,20 @@ class GetModelCostMap:
|
|||
verbose_logger.debug(
|
||||
"LiteLLM: loading local model cost map from bundled package resource"
|
||||
)
|
||||
return json.loads(
|
||||
files("litellm")
|
||||
.joinpath("model_prices_and_context_window_backup.json")
|
||||
.read_text(encoding="utf-8")
|
||||
)
|
||||
try:
|
||||
return json.loads(
|
||||
files("litellm")
|
||||
.joinpath("model_prices_and_context_window_backup.json")
|
||||
.read_text(encoding="utf-8")
|
||||
)
|
||||
except FileNotFoundError as e:
|
||||
raise FileNotFoundError(
|
||||
"litellm/model_prices_and_context_window_backup.json is missing from the installed package. "
|
||||
"This file is a build-time artefact — the `cp` step in .github/workflows/publish_to_pypi.yml "
|
||||
"and the source-build Dockerfiles materialize it before the wheel is built. If you ran "
|
||||
"`uv build` manually, first run: "
|
||||
"cp model_prices_and_context_window.json litellm/model_prices_and_context_window_backup.json"
|
||||
) from e
|
||||
|
||||
@classmethod
|
||||
def _get_backup_model_count(cls) -> int:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue