mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
Merge pull request #37218 from BerriAI/litellm_lit5675_rust_param_leak
fix: stop rust flag from leaking into upstream provider request bodies
This commit is contained in:
commit
6858fda3ee
3 changed files with 52 additions and 1 deletions
|
|
@ -3519,6 +3519,7 @@ all_litellm_params = (
|
|||
"litellm_session_id",
|
||||
"use_litellm_proxy",
|
||||
"use_chat_completions_api",
|
||||
"rust",
|
||||
"prompt_label",
|
||||
"shared_session",
|
||||
"search_tool_name",
|
||||
|
|
|
|||
|
|
@ -4795,3 +4795,49 @@ def test_bedrock_batch_params_never_reach_the_provider():
|
|||
"credential normalization dropped batch params before the transformation: "
|
||||
f"{sorted(f for f in bedrock_batch_litellm_params if normalized.get(f) != configured[f])}"
|
||||
)
|
||||
|
||||
|
||||
def test_rust_flag_not_forwarded_as_provider_param():
|
||||
forwarded = get_non_default_completion_params({"rust": True, "temperature": 0.5})
|
||||
assert "rust" not in forwarded
|
||||
|
||||
|
||||
def test_completion_does_not_leak_rust_flag_into_provider_request_body():
|
||||
mock_response = MagicMock()
|
||||
mock_response.model_dump.return_value = {
|
||||
"id": "chatcmpl-1",
|
||||
"object": "chat.completion",
|
||||
"created": 1234567890,
|
||||
"model": "gpt-4o-mini",
|
||||
"choices": [
|
||||
{
|
||||
"index": 0,
|
||||
"message": {"role": "assistant", "content": "hi"},
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
"usage": {
|
||||
"prompt_tokens": 1,
|
||||
"completion_tokens": 1,
|
||||
"total_tokens": 2,
|
||||
},
|
||||
}
|
||||
|
||||
mock_raw_response = MagicMock()
|
||||
mock_raw_response.headers = {}
|
||||
mock_raw_response.parse.return_value = mock_response
|
||||
|
||||
mock_client = MagicMock()
|
||||
mock_client.chat.completions.with_raw_response.create.return_value = mock_raw_response
|
||||
|
||||
litellm.completion(
|
||||
model="openai/gpt-4o-mini",
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
rust=True,
|
||||
api_key="sk-test",
|
||||
client=mock_client,
|
||||
)
|
||||
|
||||
create_kwargs = mock_client.chat.completions.with_raw_response.create.call_args.kwargs
|
||||
assert "rust" not in create_kwargs
|
||||
assert "rust" not in (create_kwargs.get("extra_body") or {})
|
||||
|
|
|
|||
|
|
@ -5,7 +5,11 @@ import pytest
|
|||
|
||||
sys.path.insert(0, os.path.abspath("../.."))
|
||||
|
||||
from litellm.types.utils import HiddenParams
|
||||
from litellm.types.utils import HiddenParams, all_litellm_params
|
||||
|
||||
|
||||
def test_rust_is_a_known_litellm_param():
|
||||
assert "rust" in all_litellm_params
|
||||
|
||||
|
||||
def test_hidden_params_response_ms():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue