mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-21 10:15:47 +00:00
Merge 9f85881730 into dddbaa803d
This commit is contained in:
commit
5941cafb4c
2 changed files with 14 additions and 1 deletions
|
|
@ -6054,7 +6054,7 @@ def completion(
|
|||
custom_llm_provider=custom_llm_provider,
|
||||
model_id=optional_params.get("model_id"),
|
||||
)
|
||||
if mock_response or mock_tool_calls or mock_timeout:
|
||||
if mock_response is not None or mock_tool_calls or mock_timeout:
|
||||
kwargs.pop("mock_timeout", None) # remove for any fallbacks triggered
|
||||
return mock_completion(
|
||||
model,
|
||||
|
|
|
|||
|
|
@ -157,6 +157,19 @@ def test_post_call_rule_rejects_mock_response(monkeypatch: pytest.MonkeyPatch) -
|
|||
)
|
||||
|
||||
|
||||
def test_completion_empty_string_mock_response_does_not_make_request() -> None:
|
||||
response = litellm.completion(
|
||||
model="openai/gpt-4o-mini",
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
mock_response="",
|
||||
api_base="http://127.0.0.1:9",
|
||||
api_key="sk-test",
|
||||
num_retries=0,
|
||||
)
|
||||
|
||||
assert response.choices[0].message.content == ""
|
||||
|
||||
|
||||
def test_post_call_rule_rejects_streaming_mock_response(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(litellm, "pre_call_rules", [])
|
||||
monkeypatch.setattr(litellm, "post_call_rules", [_reject_short_post_call_response])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue