Fix: generation config empty for batch

This commit is contained in:
Sameer Kankute 2026-01-22 14:32:44 +05:30
parent 5ea031eaf6
commit c374345e12
3 changed files with 50 additions and 1 deletions

View file

@ -404,6 +404,7 @@ def _handle_retrieve_batch_providers_without_provider_config(
_retrieve_batch_request: RetrieveBatchRequest,
_is_async: bool,
custom_llm_provider: Literal["openai", "azure", "vertex_ai", "bedrock", "hosted_vllm", "anthropic"] = "openai",
logging_obj: Optional[Any] = None,
):
api_base: Optional[str] = None
if custom_llm_provider in OPENAI_COMPATIBLE_BATCH_AND_FILES_PROVIDERS:
@ -499,6 +500,7 @@ def _handle_retrieve_batch_providers_without_provider_config(
vertex_credentials=vertex_credentials,
timeout=timeout,
max_retries=optional_params.max_retries,
logging_obj=logging_obj,
)
elif custom_llm_provider == "anthropic":
api_base = (
@ -662,6 +664,7 @@ def retrieve_batch(
_retrieve_batch_request=_retrieve_batch_request,
_is_async=_is_async,
timeout=timeout,
logging_obj=litellm_logging_obj,
)
except Exception as e:

View file

@ -142,6 +142,7 @@ class VertexAIBatchPrediction(VertexLLM):
vertex_location: Optional[str],
timeout: Union[float, httpx.Timeout],
max_retries: Optional[int],
logging_obj: Optional[Any] = None,
) -> Union[LiteLLMBatch, Coroutine[Any, Any, LiteLLMBatch]]:
sync_handler = _get_httpx_client()
@ -187,8 +188,30 @@ class VertexAIBatchPrediction(VertexLLM):
return self._async_retrieve_batch(
api_base=api_base,
headers=headers,
logging_obj=logging_obj,
)
# Log the request using logging_obj if available
if logging_obj is not None:
from litellm.litellm_core_utils.litellm_logging import Logging
if isinstance(logging_obj, Logging):
logging_obj.pre_call(
input="",
api_key="",
additional_args={
"complete_input_dict": {},
"api_base": api_base,
"headers": headers,
"request_str": (
f"\nGET Request Sent from LiteLLM:\n"
f"curl -X GET \\\n"
f"{api_base} \\\n"
f"-H 'Authorization: Bearer ***REDACTED***' \\\n"
f"-H 'Content-Type: application/json; charset=utf-8'\n"
),
},
)
response = sync_handler.get(
url=api_base,
headers=headers,
@ -207,10 +230,33 @@ class VertexAIBatchPrediction(VertexLLM):
self,
api_base: str,
headers: Dict[str, str],
logging_obj: Optional[Any] = None,
) -> LiteLLMBatch:
client = get_async_httpx_client(
llm_provider=litellm.LlmProviders.VERTEX_AI,
)
# Log the request using logging_obj if available
if logging_obj is not None:
from litellm.litellm_core_utils.litellm_logging import Logging
if isinstance(logging_obj, Logging):
logging_obj.pre_call(
input="",
api_key="",
additional_args={
"complete_input_dict": {},
"api_base": api_base,
"headers": headers,
"request_str": (
f"\nGET Request Sent from LiteLLM:\n"
f"curl -X GET \\\n"
f"{api_base} \\\n"
f"-H 'Authorization: Bearer ***REDACTED***' \\\n"
f"-H 'Content-Type: application/json; charset=utf-8'\n"
),
},
)
response = await client.get(
url=api_base,
headers=headers,

View file

@ -591,7 +591,7 @@ def _transform_request_body(
data["toolConfig"] = tool_choice
if safety_settings is not None:
data["safetySettings"] = safety_settings
if generation_config is not None:
if generation_config is not None and len(generation_config) > 0:
data["generationConfig"] = generation_config
if cached_content is not None:
data["cachedContent"] = cached_content