mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-16 04:29:31 +00:00
chore: finish main merge conflict resolution for batch line items
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
15fa86c8ec
commit
1b63787eaa
2 changed files with 53 additions and 4 deletions
|
|
@ -464,7 +464,9 @@ def _provider_output_file_id(output_file_id: str) -> str:
|
|||
|
||||
async def _fetch_batch_managed_file_content(
|
||||
file_id: str,
|
||||
custom_llm_provider: Literal["openai", "azure", "vertex_ai", "hosted_vllm", "anthropic", "bedrock", "mistral"] = "openai",
|
||||
custom_llm_provider: Literal[
|
||||
"openai", "azure", "vertex_ai", "hosted_vllm", "anthropic", "bedrock", "mistral"
|
||||
] = "openai",
|
||||
litellm_params: Mapping[str, object] | None = None,
|
||||
) -> bytes:
|
||||
"""
|
||||
|
|
@ -495,7 +497,9 @@ async def _fetch_batch_managed_file_content(
|
|||
|
||||
async def _fetch_batch_output_file_content(
|
||||
batch: Batch,
|
||||
custom_llm_provider: Literal["openai", "azure", "vertex_ai", "hosted_vllm", "anthropic", "bedrock", "mistral"] = "openai",
|
||||
custom_llm_provider: Literal[
|
||||
"openai", "azure", "vertex_ai", "hosted_vllm", "anthropic", "bedrock", "mistral"
|
||||
] = "openai",
|
||||
litellm_params: Mapping[str, object] | None = None,
|
||||
) -> bytes:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1246,8 +1246,53 @@ def test_sync_deployment_callback_on_success_skips_batch_retrieves(
|
|||
== expected_successes
|
||||
)
|
||||
|
||||
get_parent_otel_span_from_kwargs,
|
||||
is_batch_line_item_event,
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_deployment_callbacks_skip_batch_line_items(monkeypatch: pytest.MonkeyPatch):
|
||||
"""
|
||||
Batch line-item callbacks carry call_type=acompletion plus
|
||||
litellm_params.batch_parent_id, so the call-type-only batch guards do not fire.
|
||||
They describe historical batch traffic already reported by the aggregate
|
||||
aretrieve_batch event and must not consume live TPM/RPM quota.
|
||||
"""
|
||||
monkeypatch.setattr(litellm, "store_batch_line_items_in_callbacks", True, raising=False)
|
||||
router = litellm.Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": _BATCH_GROUP,
|
||||
"litellm_params": {"model": _BATCH_DEPLOYMENT_MODEL, "api_base": _BATCH_API_BASE, "api_key": "sk-fake"},
|
||||
"model_info": {"id": "batch-dep"},
|
||||
}
|
||||
]
|
||||
)
|
||||
now = datetime.now()
|
||||
line_item_kwargs = {
|
||||
"call_type": "acompletion",
|
||||
"standard_logging_object": {"total_tokens": _BATCH_TOKENS_PER_ROW},
|
||||
"litellm_params": {
|
||||
"batch_parent_id": _BATCH_ID,
|
||||
"metadata": {"model_group": _BATCH_GROUP, "deployment": _BATCH_DEPLOYMENT_MODEL},
|
||||
"model_info": {"id": "batch-dep"},
|
||||
},
|
||||
}
|
||||
|
||||
await router.deployment_callback_on_success(
|
||||
kwargs=line_item_kwargs, completion_response=None, start_time=now, end_time=now
|
||||
)
|
||||
sync_key = router.sync_deployment_callback_on_success(
|
||||
kwargs=line_item_kwargs, completion_response=None, start_time=now, end_time=now
|
||||
)
|
||||
await router.async_deployment_callback_on_failure(
|
||||
kwargs=line_item_kwargs, completion_response=None, start_time=now, end_time=now
|
||||
)
|
||||
|
||||
assert sync_key is None
|
||||
assert (
|
||||
get_deployment_successes_for_current_minute(litellm_router_instance=router, deployment_id="batch-dep") == 0
|
||||
)
|
||||
assert await _moved_routing_counters(router) == []
|
||||
assert await _router_usage_keys(router) == []
|
||||
|
||||
_ROUTING_STRATEGY_CACHE_MARKERS = ("_map", "_request_count", ":tpm:", ":rpm:")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue