From 40430dde10f3ddb860aa935a7f058a11b7ffd5e2 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 2 Aug 2024 18:16:14 -0700 Subject: [PATCH] add support for sync vertex ft --- litellm/llms/fine_tuning_apis/vertex_ai.py | 36 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/litellm/llms/fine_tuning_apis/vertex_ai.py b/litellm/llms/fine_tuning_apis/vertex_ai.py index 99b6ec15998..4158d3ef0c4 100644 --- a/litellm/llms/fine_tuning_apis/vertex_ai.py +++ b/litellm/llms/fine_tuning_apis/vertex_ai.py @@ -7,7 +7,7 @@ from openai.types.fine_tuning.fine_tuning_job import FineTuningJob, Hyperparamet from litellm._logging import verbose_logger from litellm.llms.base import BaseLLM -from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler +from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler from litellm.llms.vertex_httpx import VertexLLM from litellm.types.llms.openai import FineTuningJobCreate from litellm.types.llms.vertex_ai import ( @@ -170,8 +170,32 @@ class VertexFineTuningAPI(VertexLLM): headers=headers, request_data=fine_tune_job, ) - # response = self.async_handler.post( - # url=fine_tuning_url, - # headers=headers, - # json=fine_tune_job, - # ) + sync_handler = HTTPHandler(timeout=httpx.Timeout(timeout=600.0, connect=5.0)) + + request_data = fine_tune_job + verbose_logger.debug( + "about to create fine tuning job: %s, request_data: %s", + fine_tuning_url, + request_data, + ) + response = self.sync_handler.post( + headers=headers, + url=fine_tuning_url, + json=request_data, + ) + + if response.status_code != 200: + raise Exception( + f"Error creating fine tuning job. Status code: {response.status_code}. Response: {response.text}" + ) + + verbose_logger.debug( + "got response from creating fine tuning job: %s", response.json() + ) + vertex_response = ResponseTuningJob(**response.json()) + + verbose_logger.debug("vertex_response %s", vertex_response) + open_ai_response = self.convert_vertex_response_to_open_ai_response( + vertex_response + ) + return open_ai_response