mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-16 04:29:31 +00:00
* test(rust-bridge): pin Messages and Responses callback contracts on the native path Each test runs the native route and asserts what the Python path does today, so a known gap is a strict xfail that names its reason and the exception it fails with Messages and Responses share one Surface and hook recorder in support/callbacks.py, and each surface folder lists its own expected counts and gaps. Body-level hooks from the function body (pre-request hook, websearch short-circuit, Messages interceptors, planned and legacy agentic loops, streaming deployment hook) are xfail until native runs them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(rust-bridge): give every route folder the same one-concern-per-file layout Route data, the route Surface and the server fixture move into each route folder, and support/ keeps only route-neutral helpers. test_inference.py splits into chat_completions/ and responses/, ocr/test_requests.py splits into requests, failures and settings, and Messages and Responses get streaming and body hook files. Messages request tests that duplicate inference-messages request.rs are removed, and drop_params read from litellm.drop_params is now covered Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(rust-bridge): expect the required-route decline error for unsupported Responses requests Co-Authored-By: Yujong Lee <yujong@berri.ai> * test(rust-bridge): import route data from the route folders in the secrets unit tests Co-Authored-By: Yujong Lee <yujong@berri.ai> * test(rust-bridge): import NoReturn in the OCR dispatch tests Co-Authored-By: Yujong Lee <yujong@berri.ai> * test(rust-bridge): move route-neutral helpers out of support/callbacks.py Co-Authored-By: Yujong Lee <yujong@berri.ai> * test(rust-bridge): cover deployment rejection and concurrent callbacks * test(rust-bridge): assert native serving via the x-litellm-rust marker in the route folder tests Co-Authored-By: Yujong Lee <yujong@berri.ai> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
75 lines
2.4 KiB
Python
75 lines
2.4 KiB
Python
from typing import Final
|
|
|
|
import litellm
|
|
from litellm.rust_bridge.catalog import Route
|
|
from tests.test_litellm_rust.support.gaps import gap
|
|
from tests.test_litellm_rust.support.recording_server import RecordingServer
|
|
from tests.test_litellm_rust.support.routing import call_natively
|
|
|
|
RESPONSES_MODEL: Final = "openai/gpt-6.1-sol"
|
|
RESPONSES_TEXT: Final = "Hello from native Responses"
|
|
RESPONSES_RESPONSE: Final = {
|
|
"id": "resp_native",
|
|
"object": "response",
|
|
"created_at": 1,
|
|
"status": "completed",
|
|
"model": RESPONSES_MODEL.removeprefix("openai/"),
|
|
"output": [
|
|
{
|
|
"id": "msg_native",
|
|
"type": "message",
|
|
"role": "assistant",
|
|
"status": "completed",
|
|
"content": [{"type": "output_text", "text": RESPONSES_TEXT, "annotations": []}],
|
|
}
|
|
],
|
|
"usage": {"input_tokens": 5, "output_tokens": 4, "total_tokens": 9},
|
|
}
|
|
RESPONSES_EVENTS: Final = (
|
|
(
|
|
"response.created",
|
|
{
|
|
"type": "response.created",
|
|
"sequence_number": 0,
|
|
"response": {**RESPONSES_RESPONSE, "status": "in_progress", "output": []},
|
|
},
|
|
),
|
|
(
|
|
"response.output_text.delta",
|
|
{
|
|
"type": "response.output_text.delta",
|
|
"sequence_number": 1,
|
|
"item_id": "msg_native",
|
|
"output_index": 0,
|
|
"content_index": 0,
|
|
"delta": RESPONSES_TEXT,
|
|
},
|
|
),
|
|
("response.completed", {"type": "response.completed", "sequence_number": 2, "response": RESPONSES_RESPONSE}),
|
|
)
|
|
|
|
|
|
def _error(kind: str) -> dict[str, object]:
|
|
return {"error": {"type": kind, "message": kind, "param": None, "code": None}}
|
|
|
|
|
|
REQUEST: Final = {"model": RESPONSES_MODEL, "input": "Hello"}
|
|
BAD_REQUEST: Final = _error("invalid_request_error")
|
|
RATE_LIMITED: Final = _error("rate_limit_exceeded")
|
|
|
|
|
|
async def call(server: RecordingServer, *, asynchronous: bool = True, **kwargs: object) -> object:
|
|
return await call_natively(
|
|
Route.RESPONSES,
|
|
litellm.responses,
|
|
litellm.aresponses,
|
|
REQUEST,
|
|
server,
|
|
asynchronous=asynchronous,
|
|
**kwargs,
|
|
)
|
|
|
|
|
|
SYNC_DEPLOYMENT_HOOK: Final = gap("native sync calls skip the async pre-call deployment hook")
|
|
STREAMING: Final = gap("native Responses streaming declines to Python", raises=RuntimeError)
|
|
BODY_HOOKS: Final = gap("native Responses does not run the handler body hooks")
|