mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* fix(gemini): accept text blocks in embedding input and answer 400 for unparseable media
Gemini and Vertex gemini-embedding inputs now take {"type": "text", "text": ...}
elements, sent as text parts without prefix detection or a Files API lookup and
counted as text for usage and the cache message limit. A bare data: or gs://
string whose media type cannot be parsed raises BadRequestError (400) instead of
surfacing as a retryable APIConnectionError (500).
* fix(gemini): validate text blocks before file lookups and keep cache item counting total
Malformed text blocks now answer 400 before any Files API lookup in the same
request. The cache message count compares the item type explicitly, so an
unhashable type value counts as a conversation item as before instead of raising.
Adds regression cases for empty text, drop_params with a non-string text, and
plain-text token counting for flat, grouped and mixed inputs.
* refactor(caching): use tuple membership for embedding block types
* test(gemini): cover image-only usage attribution for bare media strings
* fix(guardrails): scan and rewrite text blocks in embedding input
Embedding input that carries {"type": "text"} elements, first, after a string
or inside a group, now sends every string and text block text to the guardrail
in one call and writes the results back in place, keeping block keys, file blocks
and groups. A rewrite with the wrong number of texts fails closed through the
existing unappliable rewrite error. Inputs without text blocks keep their current
handling.
* refactor(guardrails): type the embedding list guardrail path as one flow
Folds the text block and plain string list paths back into _process_list_input,
typing the input as Sequence[object] and checking model is a string before
forwarding it, so no new helper takes a bare dict. A string-first list that holds
non-string items now scans its strings and keeps the other items instead of
handing them to the guardrail as texts. Adds regression cases for empty text,
malformed text blocks, file blocks after a string and plain string list counts.
* fix(guardrails): limit the embedding text block path to inputs that carry text blocks
Only an input holding a text block goes through slot extraction, the count check
and the in-place rewrite. Every other list keeps the baseline flow, handing the
raw input to the guardrail and writing its texts back as returned, with the same
model forwarding.
* test(guardrails): type request_data on the embedding guardrail test doubles
---------
Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| _event_loop_reuse.py | ||
| redis_batch_double.py | ||
| test_azure_blob_cache.py | ||
| test_cache_preset_key.py | ||
| test_caching.py | ||
| test_caching_handler.py | ||
| test_check_and_fix_namespace_none_guard.py | ||
| test_dual_cache.py | ||
| test_embedding_router.py | ||
| test_evicted_client_closer.py | ||
| test_gcs_cache.py | ||
| test_in_memory_cache.py | ||
| test_llm_caching_handler.py | ||
| test_llm_client_cache_e2e.py | ||
| test_qdrant_semantic_cache.py | ||
| test_redis_batch.py | ||
| test_redis_cache.py | ||
| test_redis_cluster_cache.py | ||
| test_redis_cluster_node_isolation.py | ||
| test_redis_connection_pool.py | ||
| test_redis_semantic_cache.py | ||
| test_request_redis_batch_post_call.py | ||
| test_request_redis_batch_pre_call.py | ||
| test_responses_stream_cache_keys.py | ||
| test_s3_cache.py | ||
| test_unit_test_caching.py | ||
| test_valkey_semantic_cache.py | ||