mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-13 03:59:12 +00:00
test(decisions): send System One bodies to /v1/systemone in integration tests
This commit is contained in:
parent
b6bb885324
commit
77872f6cda
5 changed files with 13 additions and 11 deletions
|
|
@ -250,7 +250,7 @@ class CostTrackingTestCase(BaseModel):
|
||||||
"/v1/audio/speech",
|
"/v1/audio/speech",
|
||||||
"/v1/images/generations",
|
"/v1/images/generations",
|
||||||
"/v1/images/edits",
|
"/v1/images/edits",
|
||||||
"/v1/decisions",
|
"/v1/systemone",
|
||||||
]
|
]
|
||||||
| Annotated[str, Field(pattern=r"^/(gemini|anthropic|bedrock)/")]
|
| Annotated[str, Field(pattern=r"^/(gemini|anthropic|bedrock)/")]
|
||||||
) = "/v1/chat/completions"
|
) = "/v1/chat/completions"
|
||||||
|
|
|
||||||
|
|
@ -31207,7 +31207,7 @@
|
||||||
"name": "perplexity/pplx-decider-v1-27b-decisions",
|
"name": "perplexity/pplx-decider-v1-27b-decisions",
|
||||||
"covers": "quota_management.spend_tracking.decisions_costs",
|
"covers": "quota_management.spend_tracking.decisions_costs",
|
||||||
"model": "perplexity/pplx-decider-v1-27b",
|
"model": "perplexity/pplx-decider-v1-27b",
|
||||||
"endpoint": "/v1/decisions",
|
"endpoint": "/v1/systemone",
|
||||||
"request": {
|
"request": {
|
||||||
"model": "$MODEL",
|
"model": "$MODEL",
|
||||||
"state": {
|
"state": {
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ def test_case_bills_expected_cost(gateway: Gateway, case: CostTrackingTestCase)
|
||||||
assert row.spend == 0, f"{case.name}: failure spend was {row.spend}"
|
assert row.spend == 0, f"{case.name}: failure spend was {row.spend}"
|
||||||
return
|
return
|
||||||
assert response.is_success, f"{case.name}: proxy returned {response.status_code}: {response.text[:400]}"
|
assert response.is_success, f"{case.name}: proxy returned {response.status_code}: {response.text[:400]}"
|
||||||
if case.endpoint == "/v1/decisions":
|
if case.endpoint == "/v1/systemone":
|
||||||
observed: Final = JSON_OBJECT.validate_json(
|
observed: Final = JSON_OBJECT.validate_json(
|
||||||
httpx.get(f"{gateway.upstream_url}/__observations", timeout=5, trust_env=False).content
|
httpx.get(f"{gateway.upstream_url}/__observations", timeout=5, trust_env=False).content
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ _API_KEY: Final = "synthetic-decisions-key"
|
||||||
_JSON_OBJECT: Final = TypeAdapter(dict[str, JsonValue])
|
_JSON_OBJECT: Final = TypeAdapter(dict[str, JsonValue])
|
||||||
_STARTED_WORKER: Final = re.compile(r"Started server process \[(\d+)\]")
|
_STARTED_WORKER: Final = re.compile(r"Started server process \[(\d+)\]")
|
||||||
_QUESTIONS: Final[dict[str, JsonValue]] = {"fine": {"type": "noul", "instructions": "Is the state fine?"}}
|
_QUESTIONS: Final[dict[str, JsonValue]] = {"fine": {"type": "noul", "instructions": "Is the state fine?"}}
|
||||||
_ROUTES: Final = ("/v1/decisions", "/decisions")
|
_ROUTES: Final = ("/v1/systemone", "/systemone")
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, slots=True)
|
@dataclass(frozen=True, slots=True)
|
||||||
|
|
@ -221,7 +221,7 @@ async def test_worker_sigkill_mid_burst_leaves_the_sibling_serving_the_default_m
|
||||||
release.set()
|
release.set()
|
||||||
served: Final = await burst
|
served: Final = await burst
|
||||||
assert len(served) == held_by[survivor_pid], (held_by, len(served))
|
assert len(served) == held_by[survivor_pid], (held_by, len(served))
|
||||||
follow_up: Final = _Call(route="/decisions", marker=f"ok-{uuid.uuid4().hex}", fail=False)
|
follow_up: Final = _Call(route="/systemone", marker=f"ok-{uuid.uuid4().hex}", fail=False)
|
||||||
(answered,) = await _burst(base_url, candidate.key, None, (follow_up,))
|
(answered,) = await _burst(base_url, candidate.key, None, (follow_up,))
|
||||||
await asyncio.to_thread(
|
await asyncio.to_thread(
|
||||||
eventually,
|
eventually,
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ def _deployment(scenario: Scenario, handle: ScenarioHandle, provider: _Provider)
|
||||||
|
|
||||||
def _decide(gateway: Gateway, model: str, *, key: str | None = None, **extra: JsonValue) -> httpx.Response:
|
def _decide(gateway: Gateway, model: str, *, key: str | None = None, **extra: JsonValue) -> httpx.Response:
|
||||||
return gateway.request(
|
return gateway.request(
|
||||||
"POST", "/v1/decisions", {"model": model, "state": _STATE, "questions": _QUESTIONS, **extra}, key=key
|
"POST", "/v1/systemone", {"model": model, "state": _STATE, "questions": _QUESTIONS, **extra}, key=key
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -297,7 +297,7 @@ def test_invalid_bodies_are_refused_at_the_gateway_without_an_upstream_call(gate
|
||||||
handle: Final = _register(scenario, _answer_body(_PERPLEXITY))
|
handle: Final = _register(scenario, _answer_body(_PERPLEXITY))
|
||||||
model: Final = _deployment(scenario, handle, _PERPLEXITY)
|
model: Final = _deployment(scenario, handle, _PERPLEXITY)
|
||||||
for label, body in _INVALID_BODIES:
|
for label, body in _INVALID_BODIES:
|
||||||
response: Final = gateway.request("POST", "/v1/decisions", {"model": model, **body})
|
response: Final = gateway.request("POST", "/v1/systemone", {"model": model, **body})
|
||||||
assert response.status_code == 400, (label, response.text)
|
assert response.status_code == 400, (label, response.text)
|
||||||
assert "Invalid Decisions request" in response.text, (label, response.text)
|
assert "Invalid Decisions request" in response.text, (label, response.text)
|
||||||
assert _upstream_calls(gateway, handle) == []
|
assert _upstream_calls(gateway, handle) == []
|
||||||
|
|
@ -316,7 +316,7 @@ def test_key_checks_match_chat(gateway: Gateway) -> None:
|
||||||
handle: Final = _register(scenario, _answer_body(_PERPLEXITY))
|
handle: Final = _register(scenario, _answer_body(_PERPLEXITY))
|
||||||
model: Final = _deployment(scenario, handle, _PERPLEXITY)
|
model: Final = _deployment(scenario, handle, _PERPLEXITY)
|
||||||
anonymous: Final = gateway.client.post(
|
anonymous: Final = gateway.client.post(
|
||||||
"/v1/decisions", json={"model": model, "state": _STATE, "questions": _QUESTIONS}
|
"/v1/systemone", json={"model": model, "state": _STATE, "questions": _QUESTIONS}
|
||||||
)
|
)
|
||||||
assert anonymous.status_code == 401, anonymous.text
|
assert anonymous.status_code == 401, anonymous.text
|
||||||
restricted: Final = scenario.key(models=[f"other-{uuid.uuid4().hex}"])
|
restricted: Final = scenario.key(models=[f"other-{uuid.uuid4().hex}"])
|
||||||
|
|
@ -382,7 +382,7 @@ def test_a_deployment_opted_into_client_api_base_sends_decisions_and_chat_to_the
|
||||||
assert _calls_to(observed, configured) == []
|
assert _calls_to(observed, configured) == []
|
||||||
|
|
||||||
|
|
||||||
def test_a_config_pass_through_at_v1_decisions_keeps_answering_and_the_native_api_serves_decisions(
|
def test_a_config_pass_through_at_v1_decisions_keeps_answering_and_the_native_api_serves_system_one(
|
||||||
gateway: Gateway, tmp_path: Path
|
gateway: Gateway, tmp_path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
with gateway.scenario() as scenario:
|
with gateway.scenario() as scenario:
|
||||||
|
|
@ -394,9 +394,11 @@ def test_a_config_pass_through_at_v1_decisions_keeps_answering_and_the_native_ap
|
||||||
tmp_path, f"{pass_through_target.api_base()}/v1/decisions", native_target.api_base()
|
tmp_path, f"{pass_through_target.api_base()}/v1/decisions", native_target.api_base()
|
||||||
)
|
)
|
||||||
with owned_proxy_process(gateway, tmp_path, {}, config=config) as owned:
|
with owned_proxy_process(gateway, tmp_path, {}, config=config) as owned:
|
||||||
through: Final = _decide(owned.gateway, _PASS_THROUGH_MODEL)
|
through: Final = owned.gateway.request(
|
||||||
|
"POST", "/v1/decisions", {"model": _PASS_THROUGH_MODEL, "state": _STATE, "questions": _QUESTIONS}
|
||||||
|
)
|
||||||
native: Final = owned.gateway.request(
|
native: Final = owned.gateway.request(
|
||||||
"POST", "/decisions", {"model": _PASS_THROUGH_NEIGHBOUR, "state": _STATE, "questions": _QUESTIONS}
|
"POST", "/systemone", {"model": _PASS_THROUGH_NEIGHBOUR, "state": _STATE, "questions": _QUESTIONS}
|
||||||
)
|
)
|
||||||
assert through.status_code == 200, through.text
|
assert through.status_code == 200, through.text
|
||||||
assert through.json() == {"model": _PASS_THROUGH_MODEL, "answers": _ANSWERS, "usage": _USAGE}
|
assert through.json() == {"model": _PASS_THROUGH_MODEL, "answers": _ANSWERS, "usage": _USAGE}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue