diff --git a/README.md b/README.md index 58d8844..59a31ba 100644 --- a/README.md +++ b/README.md @@ -317,7 +317,6 @@ The ZaiClient provides access to comprehensive AI services: | **Assistants** | AI assistant management | Create, configure, and manage assistants | | **Agents** | Agent-based completions | Specialized agent interactions | | **Knowledge** | Knowledge base operations | Document indexing and retrieval | -| **Fine-tuning** | Model customization | Train custom models | | **Batch** | Batch processing | Bulk operations | | **Web Search** | Web search integration | Real-time web information | | **Videos** | Video processing | Video analysis and generation | diff --git a/core/src/main/java/ai/z/openapi/ZaiClient.java b/core/src/main/java/ai/z/openapi/ZaiClient.java index eb71261..c104efa 100644 --- a/core/src/main/java/ai/z/openapi/ZaiClient.java +++ b/core/src/main/java/ai/z/openapi/ZaiClient.java @@ -17,8 +17,6 @@ import ai.z.openapi.service.image.ImageServiceImpl; import ai.z.openapi.service.batches.BatchService; import ai.z.openapi.service.batches.BatchServiceImpl; -import ai.z.openapi.service.fine_turning.FineTuningService; -import ai.z.openapi.service.fine_turning.FineTuningServiceImpl; import ai.z.openapi.service.web_search.WebSearchService; import ai.z.openapi.service.web_search.WebSearchServiceImpl; import ai.z.openapi.service.videos.VideosService; @@ -112,9 +110,6 @@ public class ZaiClient extends AbstractClientBaseService { /** Batch service for batch processing operations */ private BatchService batchService; - /** Fine-tuning service for model customization */ - private FineTuningService fineTuningService; - /** Web search service for internet search capabilities */ private WebSearchService webSearchService; @@ -234,18 +229,6 @@ public synchronized BatchService batches() { return batchService; } - /** - * Returns the fine-tuning service for model customization. This service handles - * training custom models on user data. - * @return the FineTuningService instance (lazily initialized) - */ - public synchronized FineTuningService fineTuning() { - if (fineTuningService == null) { - this.fineTuningService = new FineTuningServiceImpl(this); - } - return fineTuningService; - } - /** * Returns the web search service for internet search capabilities. This service * provides AI-powered web search functionality. diff --git a/core/src/main/java/ai/z/openapi/api/fine_tuning/FineTuningApi.java b/core/src/main/java/ai/z/openapi/api/fine_tuning/FineTuningApi.java deleted file mode 100644 index f1e6f0c..0000000 --- a/core/src/main/java/ai/z/openapi/api/fine_tuning/FineTuningApi.java +++ /dev/null @@ -1,111 +0,0 @@ -package ai.z.openapi.api.fine_tuning; - -import ai.z.openapi.service.fine_turning.FineTunedModelsStatus; -import ai.z.openapi.service.fine_turning.FineTuningEvent; -import ai.z.openapi.service.fine_turning.FineTuningJob; -import ai.z.openapi.service.fine_turning.FineTuningJobRequest; -import ai.z.openapi.service.fine_turning.PersonalFineTuningJob; -import io.reactivex.Single; -import retrofit2.http.Body; -import retrofit2.http.DELETE; -import retrofit2.http.GET; -import retrofit2.http.POST; -import retrofit2.http.Path; -import retrofit2.http.Query; - -/** - * Fine-tuning API for advanced model customization Enables training custom models based - * on GLM-4, CodeGeeX-4, and other foundation models Supports domain-specific fine-tuning - * for chat, code generation, embedding, and specialized tasks Features LoRA (Low-Rank - * Adaptation) and full parameter fine-tuning with efficient data processing Optimized for - * Chinese and multilingual scenarios with robust training pipeline - */ -public interface FineTuningApi { - - /** - * Create a new fine-tuning job for model customization Initiates the training process - * for customizing GLM-4, CodeGeeX-4, or other base models Supports various - * fine-tuning strategies including LoRA, full parameter tuning, and adapter methods - * Enables domain adaptation for specific use cases like coding, conversation, or - * specialized knowledge - * @param request Fine-tuning job parameters including base model selection, training - * dataset, hyperparameters, and optimization settings - * @return Fine-tuning job information with unique job ID, status, and initial - * training configuration details - */ - @POST("fine_tuning/jobs") - Single createFineTuningJob(@Body FineTuningJobRequest request); - - /** - * List events for a specific fine-tuning job with detailed monitoring Retrieves - * comprehensive training progress including loss metrics, validation scores, and - * status updates Provides real-time monitoring of training convergence, learning rate - * schedules, and performance indicators Essential for tracking model quality and - * identifying potential training issues - * @param fineTuningJobId Unique identifier of the fine-tuning job - * @param limit Maximum number of events to return (recommended: 50-100 for efficient - * monitoring) - * @param after Cursor for pagination to get events after this timestamp - * @return List of fine-tuning events with timestamps, training metrics, validation - * results, and status details - */ - @GET("fine_tuning/jobs/{fine_tuning_job_id}/events") - Single listFineTuningJobEvents(@Path("fine_tuning_job_id") String fineTuningJobId, - @Query("limit") Integer limit, @Query("after") String after); - - /** - * Retrieve comprehensive details of a specific fine-tuning job Gets complete - * information about job status, training progress, model performance, and - * configuration Includes training metrics, validation results, estimated completion - * time, and resource usage Provides insights into model convergence and fine-tuning - * effectiveness - * @param fineTuningJobId Unique identifier of the fine-tuning job - * @param limit Maximum number of items to return in nested collections (events, - * checkpoints) - * @param after Cursor for pagination in nested collections - * @return Complete fine-tuning job details including status, metrics, configuration, - * and performance indicators - */ - @GET("fine_tuning/jobs/{fine_tuning_job_id}") - Single retrieveFineTuningJob(@Path("fine_tuning_job_id") String fineTuningJobId, - @Query("limit") Integer limit, @Query("after") String after); - - /** - * Query all personal fine-tuning jobs Lists all fine-tuning jobs created by the - * current user with pagination support - * @param limit Maximum number of jobs to return per page - * @param after Cursor for pagination to get jobs after this point - * @return Paginated list of personal fine-tuning jobs - */ - @GET("fine_tuning/jobs") - Single queryPersonalFineTuningJobs(@Query("limit") Integer limit, - @Query("after") String after); - - /** - * Cancel a running fine-tuning job Stops the training process and marks the job as - * cancelled - * @param fineTuningJobId Unique identifier of the fine-tuning job to cancel - * @return Updated fine-tuning job status after cancellation - */ - @POST("fine_tuning/jobs/{fine_tuning_job_id}/cancel") - Single cancelFineTuningJob(@Path("fine_tuning_job_id") String fineTuningJobId); - - /** - * Delete a fine-tuning job Permanently removes the fine-tuning job and associated - * metadata - * @param fineTuningJobId Unique identifier of the fine-tuning job to delete - * @return Confirmation of job deletion - */ - @DELETE("fine_tuning/jobs/{fine_tuning_job_id}") - Single deleteFineTuningJob(@Path("fine_tuning_job_id") String fineTuningJobId); - - /** - * Delete a fine-tuned model Permanently removes the custom model created from - * fine-tuning - * @param fineTunedModel Identifier of the fine-tuned model to delete - * @return Status confirmation of model deletion - */ - @DELETE("fine_tuning/fine_tuned_models/{fine_tuned_model}") - Single deleteFineTuningModel(@Path("fine_tuned_model") String fineTunedModel); - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/CreateFineTuningJobApiResponse.java b/core/src/main/java/ai/z/openapi/service/fine_turning/CreateFineTuningJobApiResponse.java deleted file mode 100644 index 5cfc8a7..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/CreateFineTuningJobApiResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import ai.z.openapi.core.model.ClientResponse; -import ai.z.openapi.service.model.ChatError; -import lombok.Data; - -@Data -public class CreateFineTuningJobApiResponse implements ClientResponse { - - private int code; - - private String msg; - - private boolean success; - - private FineTuningJob data; - - private ChatError error; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTunedModelsStatus.java b/core/src/main/java/ai/z/openapi/service/fine_turning/FineTunedModelsStatus.java deleted file mode 100644 index b56276c..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTunedModelsStatus.java +++ /dev/null @@ -1,31 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * Represents the status of a fine-tuned model. This class contains information about - * model deletion status and identification. - */ -@Data -public class FineTunedModelsStatus { - - /** - * Request ID. - */ - @JsonProperty("request_id") - private String requestId; - - /** - * Model name. - */ - @JsonProperty("model_name") - private String modelName; - - /** - * Deletion status: deleting (in progress), deleted (completed). - */ - @JsonProperty("delete_status") - private String deleteStatus; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTunedModelsStatusResponse.java b/core/src/main/java/ai/z/openapi/service/fine_turning/FineTunedModelsStatusResponse.java deleted file mode 100644 index d570813..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTunedModelsStatusResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import ai.z.openapi.core.model.ClientResponse; -import ai.z.openapi.service.model.ChatError; -import lombok.Data; - -@Data -public class FineTunedModelsStatusResponse implements ClientResponse { - - private int code; - - private String msg; - - private boolean success; - - private FineTunedModelsStatus data; - - private ChatError error; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningEvent.java b/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningEvent.java deleted file mode 100644 index 813212c..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningEvent.java +++ /dev/null @@ -1,28 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import com.fasterxml.jackson.annotation.JsonProperty; -import ai.z.openapi.service.model.ChatError; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * An object representing an event in the lifecycle of a fine-tuning job - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class FineTuningEvent { - - private String object; - - @JsonProperty("has_more") - private Boolean hasMore; - - private List data; - - private ChatError error; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningEventData.java b/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningEventData.java deleted file mode 100644 index 43f0a91..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningEventData.java +++ /dev/null @@ -1,49 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class FineTuningEventData { - - /** - * The type of object returned, should be "fine-tuneing.job.event". - */ - private String object; - - /** - * The ID of the fine-tuning event. - */ - private String id; - - /** - * The creation time in epoch seconds. - */ - @JsonProperty("created_at") - private Long createdAt; - - /** - * The log level of this message. - */ - private String level; - - /** - * The event message. - */ - private String message; - - /** - * The type of event, i.e. "message" - */ - private String type; - - /** - * The data of the event. - */ - private FineTuningEventMetric data; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningEventMetric.java b/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningEventMetric.java deleted file mode 100644 index 1bcab29..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningEventMetric.java +++ /dev/null @@ -1,46 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class FineTuningEventMetric { - - @JsonProperty("epoch") - private String epoch; - - @JsonProperty("current_steps") - private Integer currentSteps; - - @JsonProperty("total_steps") - private Integer totalSteps; - - @JsonProperty("elapsed_time") - private String elapsedTime; - - @JsonProperty("remaining_time") - private String remainingTime; - - @JsonProperty("trained_tokens") - private Integer trainedTokens; - - @JsonProperty("loss") - private Float loss; - - @JsonProperty("eval_loss") - private Float evalLoss; - - @JsonProperty("acc") - private Float acc; - - @JsonProperty("eval_acc") - private Float evalAcc; - - @JsonProperty("learning_rate") - private Float learningRate; - -} \ No newline at end of file diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJob.java b/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJob.java deleted file mode 100644 index 1ab0abb..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJob.java +++ /dev/null @@ -1,96 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import com.fasterxml.jackson.annotation.JsonProperty; -import ai.z.openapi.service.model.ChatError; -import lombok.Data; - -import java.util.List; - -/** - * Fine-tuning job - */ -@Data -public class FineTuningJob { - - /** - * The object identifier, which can be referenced in the API endpoints. - */ - String id; - - /** - * The object type, which is always "fine_tuning.job". - */ - String object; - - /** - * The unix timestamp for when the fine-tuning job was created. - */ - @JsonProperty("created_at") - Long createdAt; - - /** - * The unix timestamp for when the fine-tuning job was finished. - */ - @JsonProperty("finished_at") - Long finishedAt; - - /** - * The base model that is being fine-tuned. - */ - String model; - - /** - * The name of the fine-tuned model that is being created. Can be null if no - * fine-tuned model is created yet. - */ - @JsonProperty("fine_tuned_model") - String fine_tuned_model; - - /** - * The organization that owns the fine-tuning job. - */ - @JsonProperty("organization_id") - String organizationId; - - /** - * The current status of the fine-tuning job. Can be either created, pending, running, - * succeeded, failed, or cancelled. - */ - String status; - - /** - * The hyperparameters used for the fine-tuning job. See the fine-tuning guide for - * more details. - */ - Hyperparameters hyperparameters; - - /** - * The file ID used for training. - */ - @JsonProperty("training_file") - String training_file; - - /** - * The file ID used for validation. Can be null if validation is not used. - */ - @JsonProperty("validation_file") - String validation_file; - - /** - * The compiled results files for the fine-tuning job. - */ - @JsonProperty("result_files") - List result_files; - - /** - * The total number of billable tokens processed by this fine-tuning job. - */ - @JsonProperty("trained_tokens") - Integer trainedTokens; - - @JsonProperty("request_id") - String requestId; - - private ChatError error; - -} \ No newline at end of file diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJobIdRequest.java b/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJobIdRequest.java deleted file mode 100644 index f2e09c0..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJobIdRequest.java +++ /dev/null @@ -1,24 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import ai.z.openapi.core.model.ClientRequest; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import java.util.HashMap; -import java.util.Map; - -@EqualsAndHashCode(callSuper = false) -@SuperBuilder -@NoArgsConstructor -@AllArgsConstructor -@Data -public class FineTuningJobIdRequest implements ClientRequest { - - @JsonProperty("job_id") - private String jobId; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJobModelRequest.java b/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJobModelRequest.java deleted file mode 100644 index 6d2902e..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJobModelRequest.java +++ /dev/null @@ -1,24 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import ai.z.openapi.core.model.ClientRequest; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import java.util.HashMap; -import java.util.Map; - -@EqualsAndHashCode(callSuper = false) -@SuperBuilder -@NoArgsConstructor -@AllArgsConstructor -@Data -public class FineTuningJobModelRequest implements ClientRequest { - - @JsonProperty("fine_tuned_model") - private String fineTunedModel; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJobRequest.java b/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJobRequest.java deleted file mode 100644 index cafda78..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningJobRequest.java +++ /dev/null @@ -1,50 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import com.fasterxml.jackson.annotation.JsonProperty; -import ai.z.openapi.core.model.ClientRequest; -import lombok.*; - -/** - * ClientRequest to create a fine tuning job - */ -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Data -public class FineTuningJobRequest implements ClientRequest { - - /** - * The ID of an uploaded file that contains training data. - */ - @NonNull - @JsonProperty("training_file") - String training_file; - - /** - * The ID of an uploaded file that contains validation data. Optional. - */ - @JsonProperty("validation_file") - String validationFile; - - /** - * The name of the model to fine-tune. - */ - @NonNull - String model; - - /** - * The hyperparameters used for the fine-tuning job. - */ - Hyperparameters hyperparameters; - - /** - * A string of up to 40 characters that will be added to your fine-tuned model name. - */ - String suffix; - - /** - * Client request ID - */ - private String requestId; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningService.java b/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningService.java deleted file mode 100644 index ebea77d..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningService.java +++ /dev/null @@ -1,60 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -/** - * Fine-tuning service interface - */ -public interface FineTuningService { - - /** - * Creates a fine-tuning job. - * @param request the fine-tuning job creation request - * @return CreateFineTuningJobApiResponse containing the created job details - */ - CreateFineTuningJobApiResponse createFineTuningJob(FineTuningJobRequest request); - - /** - * Lists events for a fine-tuning job. - * @param queryFineTuningJobRequest the request parameters for listing events - * @return QueryFineTuningEventApiResponse containing the list of events - */ - QueryFineTuningEventApiResponse listFineTuningJobEvents(QueryFineTuningJobRequest queryFineTuningJobRequest); - - /** - * Retrieves a specific fine-tuning job. - * @param queryFineTuningJobRequest the request parameters for retrieving the job - * @return QueryFineTuningJobApiResponse containing the job details - */ - QueryFineTuningJobApiResponse retrieveFineTuningJob(QueryFineTuningJobRequest queryFineTuningJobRequest); - - /** - * Lists personal fine-tuning jobs. - * @param queryPersonalFineTuningJobRequest the request parameters for listing - * personal jobs - * @return QueryPersonalFineTuningJobApiResponse containing the list of personal - * fine-tuning jobs - */ - QueryPersonalFineTuningJobApiResponse listPersonalFineTuningJobs( - QueryPersonalFineTuningJobRequest queryPersonalFineTuningJobRequest); - - /** - * Cancels a fine-tuning job. - * @param fineTuningJobIdRequest the request containing the job ID to cancel - * @return QueryFineTuningJobApiResponse containing the cancellation result - */ - QueryFineTuningJobApiResponse cancelFineTuningJob(FineTuningJobIdRequest fineTuningJobIdRequest); - - /** - * Deletes a fine-tuning job. - * @param fineTuningJobIdRequest the request containing the job ID to delete - * @return QueryFineTuningJobApiResponse containing the deletion result - */ - QueryFineTuningJobApiResponse deleteFineTuningJob(FineTuningJobIdRequest fineTuningJobIdRequest); - - /** - * Deletes a fine-tuned model. - * @param fineTuningJobModelRequest the request containing the model to delete - * @return FineTunedModelsStatusResponse containing the deletion status - */ - FineTunedModelsStatusResponse deleteFineTunedModel(FineTuningJobModelRequest fineTuningJobModelRequest); - -} \ No newline at end of file diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningServiceImpl.java b/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningServiceImpl.java deleted file mode 100644 index 5ad42b1..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/FineTuningServiceImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import ai.z.openapi.ZaiClient; -import ai.z.openapi.api.fine_tuning.FineTuningApi; -import ai.z.openapi.utils.RequestSupplier; - -/** - * Fine-tuning service implementation - */ -public class FineTuningServiceImpl implements FineTuningService { - - private final ZaiClient zAiClient; - - private final FineTuningApi fineTuningApi; - - public FineTuningServiceImpl(ZaiClient zAiClient) { - this.zAiClient = zAiClient; - this.fineTuningApi = zAiClient.retrofit().create(FineTuningApi.class); - } - - @Override - public CreateFineTuningJobApiResponse createFineTuningJob(FineTuningJobRequest request) { - validateRequest(request, "FineTuningJobRequest"); - RequestSupplier supplier = fineTuningApi::createFineTuningJob; - return this.zAiClient.executeRequest(request, supplier, CreateFineTuningJobApiResponse.class); - } - - @Override - public QueryFineTuningEventApiResponse listFineTuningJobEvents( - QueryFineTuningJobRequest queryFineTuningJobRequest) { - validateRequest(queryFineTuningJobRequest, "QueryFineTuningJobRequest"); - RequestSupplier supplier = (params) -> fineTuningApi - .listFineTuningJobEvents(params.getJobId(), params.getLimit(), params.getAfter()); - return this.zAiClient.executeRequest(queryFineTuningJobRequest, supplier, - QueryFineTuningEventApiResponse.class); - } - - @Override - public QueryFineTuningJobApiResponse retrieveFineTuningJob(QueryFineTuningJobRequest queryFineTuningJobRequest) { - validateRequest(queryFineTuningJobRequest, "QueryFineTuningJobRequest"); - RequestSupplier supplier = (params) -> fineTuningApi - .retrieveFineTuningJob(params.getJobId(), params.getLimit(), params.getAfter()); - return this.zAiClient.executeRequest(queryFineTuningJobRequest, supplier, QueryFineTuningJobApiResponse.class); - } - - @Override - public QueryPersonalFineTuningJobApiResponse listPersonalFineTuningJobs( - QueryPersonalFineTuningJobRequest queryPersonalFineTuningJobRequest) { - validateRequest(queryPersonalFineTuningJobRequest, "QueryPersonalFineTuningJobRequest"); - RequestSupplier supplier = (params) -> fineTuningApi - .queryPersonalFineTuningJobs(params.getLimit(), params.getAfter()); - return this.zAiClient.executeRequest(queryPersonalFineTuningJobRequest, supplier, - QueryPersonalFineTuningJobApiResponse.class); - } - - @Override - public QueryFineTuningJobApiResponse cancelFineTuningJob(FineTuningJobIdRequest fineTuningJobIdRequest) { - validateRequest(fineTuningJobIdRequest, "FineTuningJobIdRequest"); - RequestSupplier supplier = (params) -> fineTuningApi - .cancelFineTuningJob(params.getJobId()); - return this.zAiClient.executeRequest(fineTuningJobIdRequest, supplier, QueryFineTuningJobApiResponse.class); - } - - @Override - public QueryFineTuningJobApiResponse deleteFineTuningJob(FineTuningJobIdRequest fineTuningJobIdRequest) { - validateRequest(fineTuningJobIdRequest, "FineTuningJobIdRequest"); - RequestSupplier supplier = (params) -> fineTuningApi - .deleteFineTuningJob(params.getJobId()); - return this.zAiClient.executeRequest(fineTuningJobIdRequest, supplier, QueryFineTuningJobApiResponse.class); - } - - @Override - public FineTunedModelsStatusResponse deleteFineTunedModel(FineTuningJobModelRequest fineTuningJobModelRequest) { - validateRequest(fineTuningJobModelRequest, "FineTuningJobModelRequest"); - RequestSupplier supplier = (params) -> fineTuningApi - .deleteFineTuningModel(params.getFineTunedModel()); - return this.zAiClient.executeRequest(fineTuningJobModelRequest, supplier, FineTunedModelsStatusResponse.class); - } - - private void validateRequest(Object request, String requestType) { - if (request == null) { - throw new IllegalArgumentException(requestType + " cannot be null"); - } - } - -} \ No newline at end of file diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/Hyperparameters.java b/core/src/main/java/ai/z/openapi/service/fine_turning/Hyperparameters.java deleted file mode 100644 index f25965f..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/Hyperparameters.java +++ /dev/null @@ -1,27 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * Hyperparameters for a fine-tuning job - */ -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Data -public class Hyperparameters { - - /** - * The number of epochs to train the model for. An epoch refers to one full cycle - * through the training dataset. "Auto" decides the optimal number of epochs based on - * the size of the dataset. If setting the number manually, we support any number - * between 1 and 50 epochs. - */ - @JsonProperty("n_epochs") - Integer nEpochs; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/PersonalFineTuningJob.java b/core/src/main/java/ai/z/openapi/service/fine_turning/PersonalFineTuningJob.java deleted file mode 100644 index e828610..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/PersonalFineTuningJob.java +++ /dev/null @@ -1,17 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import lombok.Data; - -import java.util.List; - -/** - * Fine-tuning job - */ -@Data -public class PersonalFineTuningJob { - - String object; - - private List data; - -} \ No newline at end of file diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/QueryFineTuningEventApiResponse.java b/core/src/main/java/ai/z/openapi/service/fine_turning/QueryFineTuningEventApiResponse.java deleted file mode 100644 index aa97168..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/QueryFineTuningEventApiResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import ai.z.openapi.core.model.ClientResponse; -import ai.z.openapi.service.model.ChatError; -import lombok.Data; - -@Data -public class QueryFineTuningEventApiResponse implements ClientResponse { - - private int code; - - private String msg; - - private boolean success; - - private FineTuningEvent data; - - private ChatError error; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/QueryFineTuningJobApiResponse.java b/core/src/main/java/ai/z/openapi/service/fine_turning/QueryFineTuningJobApiResponse.java deleted file mode 100644 index fc9e43f..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/QueryFineTuningJobApiResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import ai.z.openapi.core.model.ClientResponse; -import ai.z.openapi.service.model.ChatError; -import lombok.Data; - -@Data -public class QueryFineTuningJobApiResponse implements ClientResponse { - - private int code; - - private String msg; - - private boolean success; - - private FineTuningJob data; - - private ChatError error; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/QueryFineTuningJobRequest.java b/core/src/main/java/ai/z/openapi/service/fine_turning/QueryFineTuningJobRequest.java deleted file mode 100644 index 5da6df6..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/QueryFineTuningJobRequest.java +++ /dev/null @@ -1,29 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import ai.z.openapi.core.model.ClientRequest; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.HashMap; -import java.util.Map; - -/** - * ClientRequest to create a fine tuning job - */ -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Data -public class QueryFineTuningJobRequest implements ClientRequest { - - @JsonProperty("job_id") - private String jobId; - - private Integer limit; - - private String after; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/QueryPersonalFineTuningJobApiResponse.java b/core/src/main/java/ai/z/openapi/service/fine_turning/QueryPersonalFineTuningJobApiResponse.java deleted file mode 100644 index 1061bcb..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/QueryPersonalFineTuningJobApiResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import ai.z.openapi.core.model.ClientResponse; -import ai.z.openapi.service.model.ChatError; -import lombok.Data; - -@Data -public class QueryPersonalFineTuningJobApiResponse implements ClientResponse { - - private int code; - - private String msg; - - private boolean success; - - private PersonalFineTuningJob data; - - private ChatError error; - -} diff --git a/core/src/main/java/ai/z/openapi/service/fine_turning/QueryPersonalFineTuningJobRequest.java b/core/src/main/java/ai/z/openapi/service/fine_turning/QueryPersonalFineTuningJobRequest.java deleted file mode 100644 index 70f9509..0000000 --- a/core/src/main/java/ai/z/openapi/service/fine_turning/QueryPersonalFineTuningJobRequest.java +++ /dev/null @@ -1,22 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import ai.z.openapi.core.model.ClientRequest; -import lombok.*; - -import java.util.HashMap; -import java.util.Map; - -/** - * ClientRequest to create a fine tuning job - */ -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Data -public class QueryPersonalFineTuningJobRequest implements ClientRequest { - - private Integer limit; - - private String after; - -} diff --git a/core/src/test/java/ai/z/openapi/service/fine_turning/FineTuningServiceTest.java b/core/src/test/java/ai/z/openapi/service/fine_turning/FineTuningServiceTest.java deleted file mode 100644 index 789412b..0000000 --- a/core/src/test/java/ai/z/openapi/service/fine_turning/FineTuningServiceTest.java +++ /dev/null @@ -1,282 +0,0 @@ -package ai.z.openapi.service.fine_turning; - -import ai.z.openapi.ZaiClient; -import ai.z.openapi.core.config.ZaiConfig; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.junit.jupiter.api.Assertions.*; - -/** - * FineTuningService test class for testing various functionalities of FineTuningService - * and FineTuningServiceImpl - */ -@DisplayName("FineTuningService Tests") -public class FineTuningServiceTest { - - private static final Logger logger = LoggerFactory.getLogger(FineTuningServiceTest.class); - - private static final ObjectMapper mapper = new ObjectMapper(); - - private FineTuningService fineTuningService; - - // Request ID template - private static final String REQUEST_ID_TEMPLATE = "fine-tuning-test-%d"; - - @BeforeEach - void setUp() { - ZaiConfig zaiConfig = new ZaiConfig(); - String apiKey = zaiConfig.getApiKey(); - if (apiKey == null) { - zaiConfig.setApiKey("id.test-api-key"); - } - ZaiClient client = new ZaiClient(zaiConfig); - fineTuningService = client.fineTuning(); - } - - @Test - @DisplayName("Test FineTuningService Instantiation") - void testFineTuningServiceInstantiation() { - assertNotNull(fineTuningService, "FineTuningService should be properly instantiated"); - assertInstanceOf(FineTuningServiceImpl.class, fineTuningService, - "FineTuningService should be an instance of FineTuningServiceImpl"); - } - - @Test - @DisplayName("Test Create Fine-Tuning Job") - @EnabledIfEnvironmentVariable(named = "ZAI_API_KEY", matches = "^[^.]+\\.[^.]+$") - void testCreateFineTuningJob() throws JsonProcessingException { - // Prepare test data - String requestId = String.format(REQUEST_ID_TEMPLATE, System.currentTimeMillis()); - - FineTuningJobRequest request = FineTuningJobRequest.builder() - .requestId(requestId) - .model("chatglm3-6b") - .training_file("file-test-training-data") - .build(); - - // Execute test - CreateFineTuningJobApiResponse response = fineTuningService.createFineTuningJob(request); - - // Verify results - assertNotNull(response, "Response should not be null"); - logger.info("Create fine-tuning job response: {}", mapper.writeValueAsString(response)); - } - - @Test - @DisplayName("Test Retrieve Fine-Tuning Job") - @EnabledIfEnvironmentVariable(named = "ZAI_API_KEY", matches = "^[^.]+\\.[^.]+$") - void testRetrieveFineTuningJob() throws JsonProcessingException { - // Prepare test data - QueryFineTuningJobRequest request = QueryFineTuningJobRequest.builder().jobId("ftjob-test-job-id").build(); - - // Execute test - QueryFineTuningJobApiResponse response = fineTuningService.retrieveFineTuningJob(request); - - // Verify results - assertNotNull(response, "Response should not be null"); - logger.info("Retrieve fine-tuning job response: {}", mapper.writeValueAsString(response)); - } - - @Test - @DisplayName("Test List Fine-Tuning Job Events") - @EnabledIfEnvironmentVariable(named = "ZAI_API_KEY", matches = "^[^.]+\\.[^.]+$") - void testListFineTuningJobEvents() throws JsonProcessingException { - // Prepare test data - QueryFineTuningJobRequest request = QueryFineTuningJobRequest.builder() - .jobId("ftjob-test-job-id") - .limit(10) - .build(); - - // Execute test - QueryFineTuningEventApiResponse response = fineTuningService.listFineTuningJobEvents(request); - - // Verify results - assertNotNull(response, "Response should not be null"); - logger.info("List fine-tuning job events response: {}", mapper.writeValueAsString(response)); - } - - @Test - @DisplayName("Test List Personal Fine-Tuning Jobs") - @EnabledIfEnvironmentVariable(named = "ZAI_API_KEY", matches = "^[^.]+\\.[^.]+$") - void testListPersonalFineTuningJobs() throws JsonProcessingException { - // Prepare test data - QueryPersonalFineTuningJobRequest request = QueryPersonalFineTuningJobRequest.builder().limit(5).build(); - - // Execute test - QueryPersonalFineTuningJobApiResponse response = fineTuningService.listPersonalFineTuningJobs(request); - - // Verify results - assertNotNull(response, "Response should not be null"); - logger.info("List personal fine-tuning jobs response: {}", mapper.writeValueAsString(response)); - } - - @Test - @DisplayName("Test Cancel Fine-Tuning Job") - @EnabledIfEnvironmentVariable(named = "ZAI_API_KEY", matches = "^[^.]+\\.[^.]+$") - void testCancelFineTuningJob() throws JsonProcessingException { - // Prepare test data - FineTuningJobIdRequest request = FineTuningJobIdRequest.builder().jobId("ftjob-test-job-id").build(); - - // Execute test - QueryFineTuningJobApiResponse response = fineTuningService.cancelFineTuningJob(request); - - // Verify results - assertNotNull(response, "Response should not be null"); - logger.info("Cancel fine-tuning job response: {}", mapper.writeValueAsString(response)); - } - - @Test - @DisplayName("Test Delete Fine-Tuning Job") - @EnabledIfEnvironmentVariable(named = "ZAI_API_KEY", matches = "^[^.]+\\.[^.]+$") - void testDeleteFineTuningJob() throws JsonProcessingException { - // Prepare test data - FineTuningJobIdRequest request = FineTuningJobIdRequest.builder().jobId("ftjob-test-job-id").build(); - - // Execute test - QueryFineTuningJobApiResponse response = fineTuningService.deleteFineTuningJob(request); - - // Verify results - assertNotNull(response, "Response should not be null"); - logger.info("Delete fine-tuning job response: {}", mapper.writeValueAsString(response)); - } - - @Test - @DisplayName("Test Delete Fine-Tuned Model") - @EnabledIfEnvironmentVariable(named = "ZAI_API_KEY", matches = "^[^.]+\\.[^.]+$") - void testDeleteFineTunedModel() throws JsonProcessingException { - // Prepare test data - FineTuningJobModelRequest request = FineTuningJobModelRequest.builder() - .fineTunedModel("test-fine-tuned-model") - .build(); - - // Execute test - FineTunedModelsStatusResponse response = fineTuningService.deleteFineTunedModel(request); - - // Verify results - assertNotNull(response, "Response should not be null"); - logger.info("Delete fine-tuned model response: {}", mapper.writeValueAsString(response)); - } - - @Test - @DisplayName("Test Parameter Validation - Null Request for Create Job") - void testValidation_NullCreateJobRequest() { - assertThrows(IllegalArgumentException.class, () -> { - fineTuningService.createFineTuningJob(null); - }, "Null request should throw IllegalArgumentException"); - } - - @Test - @DisplayName("Test Parameter Validation - Null Request for Retrieve Job") - void testValidation_NullRetrieveJobRequest() { - assertThrows(IllegalArgumentException.class, () -> { - fineTuningService.retrieveFineTuningJob(null); - }, "Null request should throw IllegalArgumentException"); - } - - @Test - @DisplayName("Test Parameter Validation - Null Request for List Events") - void testValidation_NullListEventsRequest() { - assertThrows(IllegalArgumentException.class, () -> { - fineTuningService.listFineTuningJobEvents(null); - }, "Null request should throw IllegalArgumentException"); - } - - @Test - @DisplayName("Test Parameter Validation - Null Request for List Personal Jobs") - void testValidation_NullListPersonalJobsRequest() { - assertThrows(IllegalArgumentException.class, () -> { - fineTuningService.listPersonalFineTuningJobs(null); - }, "Null request should throw IllegalArgumentException"); - } - - @Test - @DisplayName("Test Parameter Validation - Null Request for Cancel Job") - void testValidation_NullCancelJobRequest() { - assertThrows(IllegalArgumentException.class, () -> { - fineTuningService.cancelFineTuningJob(null); - }, "Null request should throw IllegalArgumentException"); - } - - @Test - @DisplayName("Test Parameter Validation - Null Request for Delete Job") - void testValidation_NullDeleteJobRequest() { - assertThrows(IllegalArgumentException.class, () -> { - fineTuningService.deleteFineTuningJob(null); - }, "Null request should throw IllegalArgumentException"); - } - - @Test - @DisplayName("Test Parameter Validation - Null Request for Delete Model") - void testValidation_NullDeleteModelRequest() { - assertThrows(IllegalArgumentException.class, () -> { - fineTuningService.deleteFineTunedModel(null); - }, "Null request should throw IllegalArgumentException"); - } - - @Test - @DisplayName("Test Create Fine-Tuning Job with Validation File") - @EnabledIfEnvironmentVariable(named = "ZAI_API_KEY", matches = "^[^.]+\\.[^.]+$") - void testCreateFineTuningJobWithValidationFile() throws JsonProcessingException { - // Prepare test data - String requestId = String.format(REQUEST_ID_TEMPLATE, System.currentTimeMillis()); - - FineTuningJobRequest request = FineTuningJobRequest.builder() - .requestId(requestId) - .model("chatglm3-6b") - .training_file("file-test-training-data") - .validationFile("file-test-validation-data") - .build(); - - // Execute test - CreateFineTuningJobApiResponse response = fineTuningService.createFineTuningJob(request); - - // Verify results - assertNotNull(response, "Response should not be null"); - logger.info("Create fine-tuning job with validation file response: {}", mapper.writeValueAsString(response)); - } - - @Test - @DisplayName("Test List Fine-Tuning Job Events with Pagination") - @EnabledIfEnvironmentVariable(named = "ZAI_API_KEY", matches = "^[^.]+\\.[^.]+$") - void testListFineTuningJobEventsWithPagination() throws JsonProcessingException { - // Prepare test data - QueryFineTuningJobRequest request = QueryFineTuningJobRequest.builder() - .jobId("ftjob-test-job-id") - .limit(5) - .after("event-cursor-id") - .build(); - - // Execute test - QueryFineTuningEventApiResponse response = fineTuningService.listFineTuningJobEvents(request); - - // Verify results - assertNotNull(response, "Response should not be null"); - logger.info("List fine-tuning job events with pagination response: {}", mapper.writeValueAsString(response)); - } - - @Test - @DisplayName("Test List Personal Fine-Tuning Jobs with Pagination") - @EnabledIfEnvironmentVariable(named = "ZAI_API_KEY", matches = "^[^.]+\\.[^.]+$") - void testListPersonalFineTuningJobsWithPagination() throws JsonProcessingException { - // Prepare test data - QueryPersonalFineTuningJobRequest request = QueryPersonalFineTuningJobRequest.builder() - .limit(3) - .after("job-cursor-id") - .build(); - - // Execute test - QueryPersonalFineTuningJobApiResponse response = fineTuningService.listPersonalFineTuningJobs(request); - - // Verify results - assertNotNull(response, "Response should not be null"); - logger.info("List personal fine-tuning jobs with pagination response: {}", mapper.writeValueAsString(response)); - } - -} \ No newline at end of file