From a24b43cbdfbe52c02dec8f6d61c005991db0c968 Mon Sep 17 00:00:00 2001 From: naaa760 Date: Tue, 25 Nov 2025 17:27:39 +0530 Subject: [PATCH] only added the helper that converts --- .../llms/vertex_ai/batches/transformation.py | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/litellm/llms/vertex_ai/batches/transformation.py b/litellm/llms/vertex_ai/batches/transformation.py index 22cd0bd402a..a0adb3e55a8 100644 --- a/litellm/llms/vertex_ai/batches/transformation.py +++ b/litellm/llms/vertex_ai/batches/transformation.py @@ -1,5 +1,5 @@ from litellm._uuid import uuid -from typing import Dict +from typing import Any, Dict from litellm.llms.vertex_ai.common_utils import ( _convert_vertex_datetime_to_openai_datetime, @@ -67,6 +67,33 @@ class VertexAIBatchTransformation: ), ) + @classmethod + def transform_vertex_ai_batch_list_response_to_openai_list_response( + cls, response: Dict[str, Any] + ) -> Dict[str, Any]: + """ + Transforms Vertex AI batch list response into OpenAI-compatible list response. + """ + + batch_jobs = response.get("batchPredictionJobs", []) or [] + data = [ + cls.transform_vertex_ai_batch_response_to_openai_batch_response(job) + for job in batch_jobs + ] + + first_id = data[0].id if len(data) > 0 else None + last_id = data[-1].id if len(data) > 0 else None + next_page_token = response.get("nextPageToken") + + return { + "object": "list", + "data": data, + "first_id": first_id, + "last_id": last_id, + "has_more": bool(next_page_token), + "next_page_token": next_page_token, + } + @classmethod def _get_batch_id_from_vertex_ai_batch_response( cls, response: VertexBatchPredictionResponse