mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
Litellm dev 01 27 2025 p3 (#8047)
* docs(reliability.md): add doc on disabling fallbacks per request * feat(litellm_pre_call_utils.py): support reading request timeout from request headers - new `x-litellm-timeout` param Allows setting dynamic model timeouts from vercel's AI sdk * test(test_proxy_server.py): add simple unit test for reading request timeout * test(test_fallbacks.py): add e2e test to confirm timeout passed in request headers is correctly read * feat(main.py): support passing metadata to openai in preview Resolves https://github.com/BerriAI/litellm/issues/6022#issuecomment-2616119371 * fix(main.py): fix passing openai metadata * docs(request_headers.md): document new request headers * build: Merge branch 'main' into litellm_dev_01_27_2025_p3 * test: loosen test
This commit is contained in:
parent
9c20c69915
commit
d9eb8f42ff
11 changed files with 187 additions and 3 deletions
|
@ -4582,3 +4582,37 @@ def test_provider_specific_header(custom_llm_provider, expected_result):
|
|||
mock_post.assert_called_once()
|
||||
print(mock_post.call_args.kwargs["headers"])
|
||||
assert "anthropic-beta" in mock_post.call_args.kwargs["headers"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"enable_preview_features",
|
||||
[True, False],
|
||||
)
|
||||
def test_completion_openai_metadata(monkeypatch, enable_preview_features):
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI()
|
||||
|
||||
litellm.set_verbose = True
|
||||
|
||||
monkeypatch.setattr(litellm, "enable_preview_features", enable_preview_features)
|
||||
with patch.object(
|
||||
client.chat.completions.with_raw_response, "create", return_value=MagicMock()
|
||||
) as mock_completion:
|
||||
try:
|
||||
resp = litellm.completion(
|
||||
model="openai/gpt-3.5-turbo",
|
||||
messages=[{"role": "user", "content": "Hello world"}],
|
||||
metadata={"my-test-key": "my-test-value"},
|
||||
client=client,
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
mock_completion.assert_called_once()
|
||||
if enable_preview_features:
|
||||
assert mock_completion.call_args.kwargs["metadata"] == {
|
||||
"my-test-key": "my-test-value"
|
||||
}
|
||||
else:
|
||||
assert "metadata" not in mock_completion.call_args.kwargs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue