mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(cost-tracking): price web search on dated search-preview map entries
This commit is contained in:
parent
ff547be3e3
commit
7e539405ed
3 changed files with 74 additions and 0 deletions
|
|
@ -23894,6 +23894,11 @@
|
|||
"mode": "chat",
|
||||
"output_cost_per_token": 6e-07,
|
||||
"output_cost_per_token_batches": 3e-07,
|
||||
"search_context_cost_per_query": {
|
||||
"search_context_size_high": 0.03,
|
||||
"search_context_size_low": 0.025,
|
||||
"search_context_size_medium": 0.0275
|
||||
},
|
||||
"supports_function_calling": true,
|
||||
"supports_parallel_function_calling": true,
|
||||
"supports_pdf_input": true,
|
||||
|
|
@ -24028,6 +24033,11 @@
|
|||
"mode": "chat",
|
||||
"output_cost_per_token": 1e-05,
|
||||
"output_cost_per_token_batches": 5e-06,
|
||||
"search_context_cost_per_query": {
|
||||
"search_context_size_high": 0.05,
|
||||
"search_context_size_low": 0.03,
|
||||
"search_context_size_medium": 0.035
|
||||
},
|
||||
"supports_function_calling": true,
|
||||
"supports_parallel_function_calling": true,
|
||||
"supports_pdf_input": true,
|
||||
|
|
|
|||
|
|
@ -23894,6 +23894,11 @@
|
|||
"mode": "chat",
|
||||
"output_cost_per_token": 6e-07,
|
||||
"output_cost_per_token_batches": 3e-07,
|
||||
"search_context_cost_per_query": {
|
||||
"search_context_size_high": 0.03,
|
||||
"search_context_size_low": 0.025,
|
||||
"search_context_size_medium": 0.0275
|
||||
},
|
||||
"supports_function_calling": true,
|
||||
"supports_parallel_function_calling": true,
|
||||
"supports_pdf_input": true,
|
||||
|
|
@ -24028,6 +24033,11 @@
|
|||
"mode": "chat",
|
||||
"output_cost_per_token": 1e-05,
|
||||
"output_cost_per_token_batches": 5e-06,
|
||||
"search_context_cost_per_query": {
|
||||
"search_context_size_high": 0.05,
|
||||
"search_context_size_low": 0.03,
|
||||
"search_context_size_medium": 0.035
|
||||
},
|
||||
"supports_function_calling": true,
|
||||
"supports_parallel_function_calling": true,
|
||||
"supports_pdf_input": true,
|
||||
|
|
|
|||
|
|
@ -730,6 +730,60 @@ def test_web_search_call_count_reads_dict_output_items(local_model_cost_map):
|
|||
)
|
||||
|
||||
|
||||
def test_dated_search_preview_entries_carry_search_pricing(local_model_cost_map):
|
||||
"""
|
||||
Regression for the live QA finding: OpenAI resolves gpt-4o-search-preview requests to the
|
||||
dated id gpt-4o-search-preview-2025-03-11, whose cost map entry lacked
|
||||
search_context_cost_per_query, so the default chat path silently billed the $0.035 search
|
||||
fee as $0. Dated entries must price identically to their undated siblings.
|
||||
"""
|
||||
from litellm.types.utils import Usage
|
||||
|
||||
for dated, undated in (
|
||||
("gpt-4o-search-preview-2025-03-11", "gpt-4o-search-preview"),
|
||||
("gpt-4o-mini-search-preview-2025-03-11", "gpt-4o-mini-search-preview"),
|
||||
):
|
||||
assert (
|
||||
litellm.get_model_info(dated)["search_context_cost_per_query"]
|
||||
== litellm.get_model_info(undated)["search_context_cost_per_query"]
|
||||
)
|
||||
|
||||
response = ModelResponse(
|
||||
model="gpt-4o-search-preview-2025-03-11",
|
||||
choices=[
|
||||
{
|
||||
"index": 0,
|
||||
"finish_reason": "stop",
|
||||
"message": {
|
||||
"role": "assistant",
|
||||
"content": "headlines",
|
||||
"annotations": [
|
||||
{
|
||||
"type": "url_citation",
|
||||
"url_citation": {
|
||||
"url": "https://example.com",
|
||||
"title": "t",
|
||||
"start_index": 0,
|
||||
"end_index": 1,
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
}
|
||||
],
|
||||
)
|
||||
cost = StandardBuiltInToolCostTracking.get_cost_for_built_in_tools(
|
||||
model="gpt-4o-search-preview-2025-03-11",
|
||||
response_object=response,
|
||||
usage=Usage(prompt_tokens=14, completion_tokens=825, total_tokens=839),
|
||||
custom_llm_provider="openai",
|
||||
standard_built_in_tools_params=None,
|
||||
)
|
||||
assert cost == pytest.approx(0.035), (
|
||||
f"dated search-preview id must bill the $0.035 search fee, got ${cost}"
|
||||
)
|
||||
|
||||
|
||||
# Note: File search integration test removed due to complex annotation detection logic
|
||||
# The unit tests in test_azure_assistant_cost_tracking.py provide comprehensive coverage
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue