litellm/tests
Oscar Craviotto 323cabb98d
fix: ensure Gemini calls include a user message (fixes #9733)
When a Gemini model supports system messages, messages with the
system role get filtered out from the list of messages, so never
appended to the content (and passed as system_instructions instead).

This causes a 400 error, as both generateContent and streamGenerateContent
require contents (the systemInstruction object is optional).

This is a quick fix that does not check whether there was a system msg
or if the model supports it. It simply makes sure that if the list
of messages passed to  _gemini_convert_messages_with_history()
yields no contents, that there is at least a single (empty space)
user message set to prevent the call from failing.

The potential side effect of this is that we will not fail
a call lacking any message at all, but if that needs to be checked
(and AFAIU the OpenAI spec messages are required) it should be done
elsewhere (e.g. validate_and_fix_openai_messages() @ litellm/utils.py).

PS: Applied `make format` (`poetry run black [file changed]`) only to
files changed by me. The `make lint` command identified a bunch of
files requiring formatting that I am not modifying as I did not touch
them.
2025-08-29 20:41:58 +03:00
..
basic_proxy_startup_tests
batches_tests [Perf] Improvements for Async Success Handler (Logging Callbacks) - Approx +130 RPS (#13905) 2025-08-23 13:13:23 -07:00
code_coverage_tests bump up boto3 and aioboto3 versions (#13665) 2025-08-15 17:06:08 -07:00
documentation_tests
enterprise test mapped test fixes 2025-08-23 17:04:23 -07:00
guardrails_tests
image_gen_tests Merge branch 'main' into fix/gemini-imagen-model-name-validation 2025-08-27 21:52:47 +02:00
litellm/llms/gradient_ai/chat Add digitalocean provider (#12169) 2025-08-09 16:26:33 -07:00
litellm_utils_tests Merge pull request #13808 from mainred/validate_api_version 2025-08-22 23:59:38 -07:00
litellm-proxy-extras
llm_responses_api_testing [Perf] Improvements for Async Success Handler (Logging Callbacks) - Approx +130 RPS (#13905) 2025-08-23 13:13:23 -07:00
llm_translation fix: ensure Gemini calls include a user message (fixes #9733) 2025-08-29 20:41:58 +03:00
load_tests
local_testing [Bug] Fix: Vertex Mistral not working for streaming (#13952) 2025-08-25 17:39:40 -07:00
logging_callback_tests Switch to string constant based truncation 2025-08-28 16:28:36 -06:00
mcp_tests [Perf] Improvements for Async Success Handler (Logging Callbacks) - Approx +130 RPS (#13905) 2025-08-23 13:13:23 -07:00
multi_instance_e2e_tests
old_proxy_tests/tests
openai_endpoints_tests [Feat] Add support for returning images with gemini/gemini-2.5-flash-image-preview with /chat/completions (#13983) 2025-08-27 16:16:19 -07:00
otel_tests
pass_through_tests test: update test - anthropic returns input tokens in final usage chunk now 2025-08-16 12:31:52 -07:00
pass_through_unit_tests [Bug fix] - Fix /messages fallback from Anthropic API -> Bedrock API (#13946) 2025-08-25 13:44:54 -07:00
proxy_admin_ui_tests
proxy_security_tests
proxy_unit_tests [Feat] GEMINI CLI - Add Token Counter for VertexAI Models (#13558) 2025-08-12 20:53:47 -07:00
router_unit_tests [Perf] Improvements for Async Success Handler (Logging Callbacks) - Approx +130 RPS (#13905) 2025-08-23 13:13:23 -07:00
scim_tests
spend_tracking_tests
store_model_in_db_tests [MCP Gateway] fix auth on ui for bearer servers (#13312) 2025-08-06 09:46:10 -07:00
test_litellm Merge pull request #14036 from gotsysdba/main 2025-08-29 06:27:09 -07:00
unified_google_tests [Perf] Improvements for Async Success Handler (Logging Callbacks) - Approx +130 RPS (#13905) 2025-08-23 13:13:23 -07:00
vector_store_tests [Bug Fix] Bedrock KB - Using LiteLLM Managed Credentials for Query (#13787) 2025-08-19 15:39:36 -07:00
windows_tests
__init__.py
gettysburg.wav
large_text.py
openai_batch_completions.jsonl
README.MD
test_budget_management.py
test_callbacks_on_proxy.py
test_config.py
test_debug_warning.py
test_end_users.py
test_entrypoint.py
test_fallbacks.py
test_health.py
test_keys.py
test_logging.conf
test_models.py
test_openai_endpoints.py
test_organizations.py
test_passthrough_endpoints.py
test_ratelimit.py
test_resource_cleanup.py
test_spend_logs.py Revert "Allow configuration to on what threshold to try truncating request content in db" 2025-08-28 16:12:42 -06:00
test_team_logging.py
test_team_members.py
test_team.py
test_users.py

In total litellm runs 1000+ tests

[02/20/2025] Update:

To make it easier to contribute and map what behavior is tested,

we've started mapping the litellm directory in tests/litellm

This folder can only run mock tests.