mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix(cost): treat annotation-only deployment pricing as custom OCR pricing
This commit is contained in:
parent
433b436371
commit
763270e875
2 changed files with 19 additions and 0 deletions
|
|
@ -1999,6 +1999,7 @@ def ocr_cost(
|
|||
credits: Final = getattr(response.usage_info, "credits", None)
|
||||
has_custom_ocr_pricing: Final = model_info is not None and (
|
||||
model_info.get("ocr_cost_per_page") is not None
|
||||
or model_info.get("annotation_cost_per_page") is not None
|
||||
or (credits is not None and model_info.get("ocr_cost_per_credit") is not None)
|
||||
)
|
||||
pricing: Final = model_info if has_custom_ocr_pricing else _cost_map_model_info(model, custom_llm_provider)
|
||||
|
|
|
|||
|
|
@ -4795,6 +4795,24 @@ def test_ocr_cost_uses_deployment_per_page_pricing_for_unmapped_model(pages_proc
|
|||
assert cost == pytest.approx(0.004 * pages_processed)
|
||||
|
||||
|
||||
def test_ocr_cost_uses_deployment_annotation_only_pricing_for_unmapped_model():
|
||||
from litellm.cost_calculator import ocr_cost
|
||||
|
||||
assert UNMAPPED_OCR_MODEL not in litellm.model_cost
|
||||
response: Final = OCRResponse(
|
||||
pages=[OCRPage(index=index, markdown=f"page {index}") for index in range(3)],
|
||||
model=UNMAPPED_OCR_MODEL,
|
||||
usage_info=OCRUsageInfo(pages_processed=3, pages_processed_annotation=2),
|
||||
)
|
||||
cost, _ = ocr_cost(
|
||||
model=UNMAPPED_OCR_MODEL,
|
||||
custom_llm_provider="azure_ai",
|
||||
response=response,
|
||||
model_info={"annotation_cost_per_page": 0.01},
|
||||
)
|
||||
assert cost == pytest.approx(0.01 * 2)
|
||||
|
||||
|
||||
def test_ocr_cost_uses_deployment_per_credit_pricing_for_unmapped_model():
|
||||
from litellm.cost_calculator import ocr_cost
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue