mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
fix(proxy): count PDF pages for deployments served under multi-segment model names
This commit is contained in:
parent
7729925ad7
commit
fd0527c3e7
2 changed files with 16 additions and 4 deletions
|
|
@ -758,8 +758,10 @@ def pdf_page_pricing(model: str | None) -> PdfPagePricing:
|
|||
|
||||
|
||||
def reads_pdf_pages(model: str) -> bool:
|
||||
entry: Final = _cost_map_entry(model) or _cost_map_entry(model.partition("/")[2])
|
||||
return entry.get("supports_pdf_input") is True
|
||||
segments: Final = model.split("/")
|
||||
names: Final = ("/".join(segments[start:]) for start in range(len(segments)))
|
||||
stated: Final = (_cost_map_entry(name).get("supports_pdf_input") for name in names)
|
||||
return next((support for support in stated if support is not None), False) is True
|
||||
|
||||
|
||||
def token_counter(
|
||||
|
|
|
|||
|
|
@ -75,8 +75,18 @@ def _router(*deployments: tuple[str, str]) -> Router:
|
|||
|
||||
@pytest.mark.parametrize(
|
||||
("group", "deployment_model"),
|
||||
[("gpt-4o", "anthropic/claude-haiku-5-5"), ("pdf-reports", "azure/gpt-5.6-sol")],
|
||||
ids=["gpt-named-group-served-by-claude", "custom-group-served-by-azure-gpt"],
|
||||
[
|
||||
("gpt-4o", "anthropic/claude-haiku-5-5"),
|
||||
("pdf-reports", "azure/gpt-5.6-sol"),
|
||||
("pdf-reports", "azure/responses/gpt-5.6-sol"),
|
||||
("pdf-reports", "openrouter/openai/gpt-5.6-sol"),
|
||||
],
|
||||
ids=[
|
||||
"gpt-named-group-served-by-claude",
|
||||
"custom-group-served-by-azure-gpt",
|
||||
"custom-group-served-by-azure-responses-gpt",
|
||||
"custom-group-served-by-openrouter-gpt",
|
||||
],
|
||||
)
|
||||
def test_a_model_group_counts_like_the_deployment_that_serves_it(group: str, deployment_model: str) -> None:
|
||||
request_body: Final = {"model": group, "messages": _one_page_pdf_message()}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue