mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-01 01:18:34 +00:00
* feat(rust-bridge): scope catalog rules with a contextvar Co-Authored-By: Yujong Lee <yujong@berri.ai> * test(rust-bridge): select native integration routes with scoped rules Co-Authored-By: Yujong Lee <yujong@berri.ai> * test(rust-bridge): run the Rust extension suite without LITELLM_RUST Co-Authored-By: Yujong Lee <yujong@berri.ai> * test(rust-bridge): use scoped catalog rules in dispatch tests Co-Authored-By: Yujong Lee <yujong@berri.ai> * refactor(rust-bridge): keep catalog rules a static global and override them once per test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
import asyncio
|
|
from typing import Final
|
|
|
|
import pytest
|
|
from pydantic import TypeAdapter
|
|
|
|
import litellm
|
|
from litellm.types.utils import ModelResponse
|
|
from tests.test_litellm_rust.messages.data import MESSAGES, MESSAGES_MODEL, MESSAGES_TEXT
|
|
from tests.test_litellm_rust.support.recording_server import RecordingServer
|
|
from tests.test_litellm_rust.support.routing import assert_served_natively
|
|
|
|
pytestmark = pytest.mark.requires_rust_extension
|
|
|
|
_OBJECT: Final = TypeAdapter(dict[str, object])
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.parametrize("asynchronous", (False, True))
|
|
async def test_positional_parameters_reach_the_wire(server: RecordingServer, asynchronous: bool) -> None:
|
|
temperature: Final = 0.35
|
|
arguments: Final = (
|
|
(MESSAGES_MODEL, list(MESSAGES), None, None, 12.0, temperature)
|
|
if asynchronous
|
|
else (MESSAGES_MODEL, list(MESSAGES), 12.0, temperature)
|
|
)
|
|
supplied: Final = {"base_url": server.base_url, "api_key": "test-key", "max_tokens": 32}
|
|
|
|
result: Final = (
|
|
await litellm.acompletion(*arguments, **supplied)
|
|
if asynchronous
|
|
else await asyncio.to_thread(litellm.completion, *arguments, **supplied)
|
|
)
|
|
|
|
assert isinstance(result, ModelResponse)
|
|
assert result.choices[0].message.content == MESSAGES_TEXT
|
|
assert_served_natively(server)
|
|
body: Final = _OBJECT.validate_python(server.requests[0].body)
|
|
assert body["temperature"] == temperature
|
|
assert body["max_tokens"] == supplied["max_tokens"]
|