mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
only added the helper that converts
This commit is contained in:
parent
2cc2f67a76
commit
a24b43cbdf
1 changed files with 28 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue