Skip to content

Commit

Permalink
feature 1.0.9 fine tune删除接口修改
Browse files Browse the repository at this point in the history
  • Loading branch information
guorutao committed Apr 3, 2023
1 parent 179ae5e commit 8b7d29b
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/unfbx/chatgpt/OpenAiApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.unfbx.chatgpt.entity.files.UploadFileResponse;
import com.unfbx.chatgpt.entity.fineTune.Event;
import com.unfbx.chatgpt.entity.fineTune.FineTune;
import com.unfbx.chatgpt.entity.fineTune.FineTuneDeleteResponse;
import com.unfbx.chatgpt.entity.fineTune.FineTuneResponse;
import com.unfbx.chatgpt.entity.images.Image;
import com.unfbx.chatgpt.entity.images.ImageResponse;
Expand Down Expand Up @@ -237,7 +238,7 @@ Single<UploadFileResponse> uploadFile(@Part MultipartBody.Part file,
* @return Single DeleteResponse
*/
@GET("v1/models/{model}")
Single<DeleteResponse> deleteFineTuneModel(@Path("model") String model);
Single<FineTuneDeleteResponse> deleteFineTuneModel(@Path("model") String model);


/**
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/unfbx/chatgpt/OpenAiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.unfbx.chatgpt.entity.files.UploadFileResponse;
import com.unfbx.chatgpt.entity.fineTune.Event;
import com.unfbx.chatgpt.entity.fineTune.FineTune;
import com.unfbx.chatgpt.entity.fineTune.FineTuneDeleteResponse;
import com.unfbx.chatgpt.entity.fineTune.FineTuneResponse;
import com.unfbx.chatgpt.entity.images.*;
import com.unfbx.chatgpt.entity.models.Model;
Expand Down Expand Up @@ -551,10 +552,10 @@ public List<Event> fineTuneEvents(String fineTuneId) {
* Delete a fine-tuned model. You must have the Owner role in your organization.
*
* @param model
* @return DeleteResponse
* @return FineTuneDeleteResponse
*/
public DeleteResponse deleteFineTuneModel(String model) {
Single<DeleteResponse> delete = this.openAiApi.deleteFineTuneModel(model);
public FineTuneDeleteResponse deleteFineTuneModel(String model) {
Single<FineTuneDeleteResponse> delete = this.openAiApi.deleteFineTuneModel(model);
return delete.blockingGet();
}

Expand Down Expand Up @@ -671,10 +672,12 @@ private void checkSpeechFileSize(java.io.File file) {
}

/**
* ## 官方已经禁止使用此api
* OpenAi账户余额查询
*
* @return
*/
@Deprecated
public CreditGrantsResponse creditGrants() {
Single<CreditGrantsResponse> creditGrants = this.openAiApi.creditGrants();
return creditGrants.blockingGet();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/unfbx/chatgpt/OpenAiStreamClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,12 @@ public void streamChatCompletion(List<Message> messages, EventSourceListener eve
}

/**
* ## 官方已经禁止使用此api
* OpenAi账户余额查询
*
* @return 余额信息
*/
@SneakyThrows
@Deprecated
public CreditGrantsResponse creditGrants() {
Request request = new Request.Builder()
.url(this.apiHost + "dashboard/billing/credit_grants")
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/com/unfbx/chatgpt/config/OpenAiOkhttpClient.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.unfbx.chatgpt.entity.fineTune;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.unfbx.chatgpt.entity.models.Permission;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class FineTuneDeleteResponse implements Serializable {

private String id;

private String object;

private long created;

@JsonProperty("owned_by")
private String ownedBy;

@JsonProperty("permission")
private List<Permission> permission;

private String root;

private String parent;

}
3 changes: 3 additions & 0 deletions src/main/java/com/unfbx/chatgpt/exception/BaseException.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.unfbx.chatgpt.exception;

import lombok.Getter;

/**
* 描述: 异常
*
* @author https:www.unfbx.com
* 2023-02-11
*/
@Getter
public class BaseException extends RuntimeException {

private String msg;
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/com/unfbx/chatgpt/OpenAiClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.unfbx.chatgpt.entity.files.UploadFileResponse;
import com.unfbx.chatgpt.entity.fineTune.Event;
import com.unfbx.chatgpt.entity.fineTune.FineTune;
import com.unfbx.chatgpt.entity.fineTune.FineTuneDeleteResponse;
import com.unfbx.chatgpt.entity.fineTune.FineTuneResponse;
import com.unfbx.chatgpt.entity.images.*;
import com.unfbx.chatgpt.entity.models.Model;
Expand Down Expand Up @@ -377,7 +378,7 @@ public void fineTuneEvents() {

@Test
public void deleteFineTuneModel() {
DeleteResponse deleteResponse = v2.deleteFineTuneModel("ft-KohbEOCbPyNTyQmt5UV1F1cb");
FineTuneDeleteResponse deleteResponse = v2.deleteFineTuneModel("curie:ft-winter-2023-02-16-10-24-10");
System.out.println(deleteResponse);
}
}

0 comments on commit 8b7d29b

Please sign in to comment.