mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
Merge e7176cc105 into 559247fa84
This commit is contained in:
commit
1f76d6fc4c
2 changed files with 39 additions and 1 deletions
|
|
@ -3690,6 +3690,7 @@ all_litellm_params = (
|
|||
+ [
|
||||
"metadata",
|
||||
"litellm_metadata",
|
||||
"litellm_params",
|
||||
"keepalive_seconds",
|
||||
"allow_client_keepalive_override",
|
||||
"litellm_trace_id",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
from typing import Final
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
import litellm
|
||||
from litellm.types.utils import HiddenParams, all_litellm_params, text_tokens_without_nested_reasoning
|
||||
|
||||
|
||||
|
|
@ -10,6 +11,42 @@ def test_rust_is_a_known_litellm_param():
|
|||
assert "rust" in all_litellm_params
|
||||
|
||||
|
||||
def test_litellm_params_is_not_sent_to_the_provider():
|
||||
"""https://github.com/BerriAI/litellm/issues/40072"""
|
||||
parsed: Final = MagicMock()
|
||||
parsed.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},
|
||||
}
|
||||
raw_response: Final = MagicMock()
|
||||
raw_response.headers = {}
|
||||
raw_response.parse.return_value = parsed
|
||||
client: Final = MagicMock()
|
||||
client.chat.completions.with_raw_response.create.return_value = raw_response
|
||||
|
||||
litellm.completion(
|
||||
model="openai/gpt-4o-mini",
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
litellm_params={"api_key": "sk-deployment-credential"},
|
||||
api_key="sk-test",
|
||||
client=client,
|
||||
)
|
||||
|
||||
create_kwargs: Final = client.chat.completions.with_raw_response.create.call_args.kwargs
|
||||
assert "litellm_params" not in create_kwargs
|
||||
assert "litellm_params" not in (create_kwargs.get("extra_body") or {})
|
||||
|
||||
|
||||
def test_hidden_params_response_ms():
|
||||
hidden_params = HiddenParams()
|
||||
setattr(hidden_params, "_response_ms", 100)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue