mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-17 09:34:48 +00:00
fix(huggingface): use typed registered-model lookup
This commit is contained in:
parent
dc9431bbf4
commit
170d2e6aee
2 changed files with 17 additions and 5 deletions
|
|
@ -6645,7 +6645,7 @@ def get_model_info_helper(
|
|||
e,
|
||||
)
|
||||
|
||||
if custom_llm_provider == "huggingface" and model not in litellm.model_cost:
|
||||
if custom_llm_provider == "huggingface" and get_model_cost_key(model) is None:
|
||||
max_tokens: Final = _get_max_position_embeddings(model_name=model)
|
||||
return ModelInfoBase(
|
||||
key=model,
|
||||
|
|
|
|||
|
|
@ -1559,7 +1559,18 @@ def test_tiered_pricing_only_deployment_completion_cost_is_nonzero():
|
|||
assert cost > 0
|
||||
|
||||
|
||||
def test_huggingface_rerank_uses_registered_input_cost_per_query():
|
||||
@pytest.mark.parametrize(
|
||||
("registered_model", "model"),
|
||||
[
|
||||
("hf-tei-rerank-deployment", "hf-tei-rerank-deployment"),
|
||||
("huggingface/hf-tei-rerank-deployment", "huggingface/hf-tei-rerank-deployment"),
|
||||
("hf-tei-rerank-deployment", "HF-TEI-RERANK-DEPLOYMENT"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("local_model_cost_map")
|
||||
def test_huggingface_rerank_uses_registered_input_cost_per_query(
|
||||
registered_model: str, model: str, request: pytest.FixtureRequest
|
||||
):
|
||||
"""Registered per-query price must apply for huggingface/TEI rerank (#45975).
|
||||
|
||||
``_get_model_info_helper`` used to return a synthetic zero-cost huggingface
|
||||
|
|
@ -1570,11 +1581,12 @@ def test_huggingface_rerank_uses_registered_input_cost_per_query():
|
|||
from litellm.utils import cached_get_model_info_helper
|
||||
|
||||
cached_get_model_info_helper.cache_clear()
|
||||
litellm.model_cost.pop("hf-tei-rerank-deployment", None)
|
||||
litellm.register_model({"hf-tei-rerank-deployment": {"input_cost_per_query": 0.001}})
|
||||
request.addfinalizer(cached_get_model_info_helper.cache_clear)
|
||||
litellm.model_cost.pop(registered_model, None)
|
||||
litellm.register_model({registered_model: {"input_cost_per_query": 0.001}})
|
||||
|
||||
cost = rerank_cost(
|
||||
model="hf-tei-rerank-deployment",
|
||||
model=model,
|
||||
custom_llm_provider="huggingface",
|
||||
billed_units={"search_units": 1},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue