mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
test(integration): refuse a repeated delete in the scripted upstream and pin the settlement budget below one estimate
This commit is contained in:
parent
063c3dec77
commit
da2f5b73b3
2 changed files with 6 additions and 4 deletions
|
|
@ -329,7 +329,8 @@ class Provider:
|
|||
if state.delay_seconds:
|
||||
await asyncio.sleep(state.delay_seconds)
|
||||
if request.method == "DELETE":
|
||||
del self.interactions[interaction_id]
|
||||
if self.interactions.pop(interaction_id, None) is None:
|
||||
return JSONResponse(_interaction_not_found(interaction_id), status_code=404)
|
||||
return JSONResponse({})
|
||||
if state.get_status != 200:
|
||||
return JSONResponse(
|
||||
|
|
|
|||
|
|
@ -294,8 +294,9 @@ def _rates(replica: Gateway, model: str) -> tuple[float, float]:
|
|||
|
||||
|
||||
def _reservation_pin(replica: Gateway, model: str) -> float:
|
||||
"""What one background create reserves on the key before its usage is known: the output tokens the
|
||||
estimator assumes, at the deployment's output rate, with the prompt's few input tokens left as slack."""
|
||||
"""What one background create estimates before its usage is known: the output tokens the estimator assumes,
|
||||
at the deployment's output rate, with the prompt's few input tokens left as slack. A key budget below that
|
||||
is filled by the first create's reservation, so the next create is refused until a settlement releases it."""
|
||||
info: Final = _model_info(replica, model)
|
||||
max_output: Final = info["max_output_tokens"]
|
||||
output_rate: Final = info["output_cost_per_token"]
|
||||
|
|
@ -663,7 +664,7 @@ def test_identical_creates_settle_as_separate_interactions(rig: Rig) -> None:
|
|||
def test_settlement_on_another_replica_releases_the_creators_budget_reservation(rig: Rig) -> None:
|
||||
with rig.creator.scenario() as scenario:
|
||||
model: Final = rig.models.in_progress
|
||||
key: Final = scenario.key(max_budget=1.5 * _reservation_pin(rig.creator, model))
|
||||
key: Final = scenario.key(max_budget=0.5 * _reservation_pin(rig.creator, model))
|
||||
first: Final = _create(rig.creator, model, key)
|
||||
pinned: Final = rig.creator.request(
|
||||
"POST", "/v1beta/interactions", {"model": model, "input": "settle pinned", "background": True}, key=key
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue