Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix transform_retrieve_file_response

Ishaan Jaffer08271a8b281d
diff --git a/litellm/llms/gemini/files/transformation.py b/litellm/llms/gemini/files/transformation.py
index 861f7bd2f2b..37f1376c2b1 100644
--- a/litellm/llms/gemini/files/transformation.py
+++ b/litellm/llms/gemini/files/transformation.py
@@ -238,11 +238,13 @@ class GoogleAIStudioFilesHandler(GeminiModelInfo, BaseFilesConfig):
# Map Gemini state to OpenAI status
gemini_state = response_json.get("state", "STATE_UNSPECIFIED")
- status: Literal["uploaded", "processed", "error"] = "uploaded" # Default
+ # Explicitly type status as the Literal union
if gemini_state == "ACTIVE":
- status = "processed"
+ status: Literal["uploaded", "processed", "error"] = "processed"
elif gemini_state == "FAILED":
status = "error"
+ else:
+ status = "uploaded"
return OpenAIFileObject(
id=response_json.get("uri", ""),
diff --git a/litellm/proxy/common_utils/cache_coordinator.py b/litellm/proxy/common_utils/cache_coordinator.py
index 9b07def125b..4eceb83af5f 100644
--- a/litellm/proxy/common_utils/cache_coordinator.py
+++ b/litellm/proxy/common_utils/cache_coordinator.py
@@ -94,7 +94,7 @@ class EventDrivenCacheCoordinator:
verbose_proxy_logger.debug(
"%s Signal received, reading from cache", self._log_prefix
)
- value = await cache.async_get_cache(key=cache_key)
+ value: Optional[T] = await cache.async_get_cache(key=cache_key)
if value is not None and self._log_prefix:
verbose_proxy_logger.debug(
"%s Cache filled by other request, value: %s",
@@ -186,6 +186,7 @@ class EventDrivenCacheCoordinator:
)
try:
- return await self._load_and_cache(cache_key, cache, load_fn)
+ result = await self._load_and_cache(cache_key, cache, load_fn)
+ return result
finally:
await self._signal_done()