From 62d83160382a74e5b0764e357f313dd5c99e3c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E5=90=8D=EF=BC=88=E5=BC=A0=E7=91=9C=EF=BC=89?= Date: Wed, 7 Aug 2024 10:51:51 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0finetune=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/unfbx/chatgpt/entity/fineTune/job/FineTuneJob.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/unfbx/chatgpt/entity/fineTune/job/FineTuneJob.java b/src/main/java/com/unfbx/chatgpt/entity/fineTune/job/FineTuneJob.java index 45c2564..f454924 100644 --- a/src/main/java/com/unfbx/chatgpt/entity/fineTune/job/FineTuneJob.java +++ b/src/main/java/com/unfbx/chatgpt/entity/fineTune/job/FineTuneJob.java @@ -42,12 +42,14 @@ public class FineTuneJob implements Serializable { @Getter @AllArgsConstructor public enum Model { + GPT_4O_MINI_2024_07_18("gpt-4o-mini-2024-07-18"), + GPT_3_5_TURBO_0125("gpt-3.5-turbo-0125"), GPT_3_5_TURBO_1106("gpt-3.5-turbo-1106"), GPT_3_5_TURBO_0613("gpt-3.5-turbo-0613"), BABBAGE_002("babbage-002"), - GPT_4_0613("gpt-4-0613"), DAVINCI_002("davinci-002"), - ; + GPT_4_0613("gpt-4-0613"), + GPT_4O_2024_05_13("gpt-4o-2024-05-13"); private final String name; } } From b3b0706abdd37bae696f3949b0736a33f6f5fc6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E5=90=8D=EF=BC=88=E5=BC=A0=E7=91=9C=EF=BC=89?= Date: Wed, 7 Aug 2024 10:52:02 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=AE=98?= =?UTF-8?q?=E6=96=B9=E7=A8=B3=E5=AE=9A=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatgpt/entity/chat/BaseChatCompletion.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/unfbx/chatgpt/entity/chat/BaseChatCompletion.java b/src/main/java/com/unfbx/chatgpt/entity/chat/BaseChatCompletion.java index 071c168..f213e5a 100644 --- a/src/main/java/com/unfbx/chatgpt/entity/chat/BaseChatCompletion.java +++ b/src/main/java/com/unfbx/chatgpt/entity/chat/BaseChatCompletion.java @@ -28,7 +28,7 @@ public class BaseChatCompletion implements Serializable { @NonNull @Builder.Default - private String model = Model.GPT_3_5_TURBO.getName(); + private String model = Model.GPT_4O_MINI.getName(); /** * 指定模型必须输出的格式的对象。 @@ -223,6 +223,16 @@ public enum Model { * 支持图片 */ GPT_4_VISION_PREVIEW("gpt-4-vision-preview"), + + GPT_4O("gpt-4o"), + + GPT_4O_2024_05_13("gpt-4o-2024-05-13"), + + GPT_4O_2024_08_06("gpt-4o-2024-08-06"), + + GPT_4O_MINI("gpt-4o-mini"), + + GPT_4O_MINI_2024_07_18("gpt-4o-mini-2024-07-18"), ; private final String name; } From 27bc4d78ca7210b6367afe1218c10feec5b10324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E5=90=8D=EF=BC=88=E5=BC=A0=E7=91=9C=EF=BC=89?= Date: Wed, 7 Aug 2024 13:42:10 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=89=B9?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/unfbx/chatgpt/OpenAiApi.java | 29 +++++++- .../entity/batch/BatchesListResponse.java | 24 +++++++ .../chatgpt/entity/batch/BatchesRequest.java | 22 +++++++ .../chatgpt/entity/batch/BatchesResponse.java | 66 +++++++++++++++++++ .../unfbx/chatgpt/entity/batch/Metadata.java | 26 ++++++++ 5 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/unfbx/chatgpt/entity/batch/BatchesListResponse.java create mode 100644 src/main/java/com/unfbx/chatgpt/entity/batch/BatchesRequest.java create mode 100644 src/main/java/com/unfbx/chatgpt/entity/batch/BatchesResponse.java create mode 100644 src/main/java/com/unfbx/chatgpt/entity/batch/Metadata.java diff --git a/src/main/java/com/unfbx/chatgpt/OpenAiApi.java b/src/main/java/com/unfbx/chatgpt/OpenAiApi.java index a51f3f2..b344d3d 100644 --- a/src/main/java/com/unfbx/chatgpt/OpenAiApi.java +++ b/src/main/java/com/unfbx/chatgpt/OpenAiApi.java @@ -7,6 +7,9 @@ import com.unfbx.chatgpt.entity.assistant.message.ModifyMessage; import com.unfbx.chatgpt.entity.assistant.run.*; import com.unfbx.chatgpt.entity.assistant.thread.ThreadMessage; +import com.unfbx.chatgpt.entity.batch.BatchesListResponse; +import com.unfbx.chatgpt.entity.batch.BatchesRequest; +import com.unfbx.chatgpt.entity.batch.BatchesResponse; import com.unfbx.chatgpt.entity.billing.BillingUsage; import com.unfbx.chatgpt.entity.billing.CreditGrantsResponse; import com.unfbx.chatgpt.entity.billing.Subscription; @@ -669,7 +672,7 @@ Single> messages(@Path("thread_id") Strin @GET("v1/threads/{thread_id}/messages/{message_id}/files") @Headers("OpenAI-Beta: assistants=v1") Single> messageFiles(@Path("thread_id") String threadId, @Path("message_id") String messageId, - @Query("limit") Integer limit, @Query("order") String order, @Query("before") String before, @Query("after") String after); + @Query("limit") Integer limit, @Query("order") String order, @Query("before") String before, @Query("after") String after); /** @@ -797,4 +800,28 @@ Single> runs(@Path("thread_id") String thread Single> runSteps(@Path("thread_id") String threadId, @Path("run_id") String runId, @Query("limit") Integer limit, @Query("order") String order, @Query("before") String before, @Query("after") String after); + /** + * 创建批处理 + */ + @POST("v1/batches") + Single createBatch(@Body BatchesRequest batchesRequest); + + /** + * 取消批处理 + */ + @POST("v1/batches/{batch_id}/cancel") + Single cancelBatche(@Path("batch_id") String batchId); + + /** + * 查询批处理 + */ + @GET("v1/batches/{batch_id}") + Single retrieveBatche(@Path("batch_id") String batchId); + + /** + * 分页查询批处理 + */ + @GET("v1/batches") + Single listBatch(@Query("after") String after, @Query("limit") Integer limit); + } diff --git a/src/main/java/com/unfbx/chatgpt/entity/batch/BatchesListResponse.java b/src/main/java/com/unfbx/chatgpt/entity/batch/BatchesListResponse.java new file mode 100644 index 0000000..47dd347 --- /dev/null +++ b/src/main/java/com/unfbx/chatgpt/entity/batch/BatchesListResponse.java @@ -0,0 +1,24 @@ +package com.unfbx.chatgpt.entity.batch; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@NoArgsConstructor +@Data +public class BatchesListResponse { + + @JsonProperty("object") + private String object; + @JsonProperty("data") + private List data; + @JsonProperty("first_id") + private String firstId; + @JsonProperty("last_id") + private String lastId; + @JsonProperty("has_more") + private Boolean hasMore; + +} diff --git a/src/main/java/com/unfbx/chatgpt/entity/batch/BatchesRequest.java b/src/main/java/com/unfbx/chatgpt/entity/batch/BatchesRequest.java new file mode 100644 index 0000000..770c368 --- /dev/null +++ b/src/main/java/com/unfbx/chatgpt/entity/batch/BatchesRequest.java @@ -0,0 +1,22 @@ +package com.unfbx.chatgpt.entity.batch; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@NoArgsConstructor +@Data +public class BatchesRequest { + + @JsonProperty("input_file_id") + private String inputFileId; + @JsonProperty("endpoint") + private String endpoint; + @JsonProperty("completion_window") + private String completionWindow; + @JsonProperty("metadata") + private Map metadata; + +} diff --git a/src/main/java/com/unfbx/chatgpt/entity/batch/BatchesResponse.java b/src/main/java/com/unfbx/chatgpt/entity/batch/BatchesResponse.java new file mode 100644 index 0000000..00111c9 --- /dev/null +++ b/src/main/java/com/unfbx/chatgpt/entity/batch/BatchesResponse.java @@ -0,0 +1,66 @@ +package com.unfbx.chatgpt.entity.batch; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import java.util.HashMap; + +@NoArgsConstructor +@Data +public class BatchesResponse { + + @JsonProperty("id") + private String id; + @JsonProperty("object") + private String object; + @JsonProperty("endpoint") + private String endpoint; + @JsonProperty("errors") + private Object errors; + @JsonProperty("input_file_id") + private String inputFileId; + @JsonProperty("completion_window") + private String completionWindow; + @JsonProperty("status") + private String status; + @JsonProperty("output_file_id") + private Object outputFileId; + @JsonProperty("error_file_id") + private Object errorFileId; + @JsonProperty("created_at") + private Integer createdAt; + @JsonProperty("in_progress_at") + private Object inProgressAt; + @JsonProperty("expires_at") + private Object expiresAt; + @JsonProperty("finalizing_at") + private Object finalizingAt; + @JsonProperty("completed_at") + private Object completedAt; + @JsonProperty("failed_at") + private Object failedAt; + @JsonProperty("expired_at") + private Object expiredAt; + @JsonProperty("cancelling_at") + private Object cancellingAt; + @JsonProperty("cancelled_at") + private Object cancelledAt; + @JsonProperty("request_counts") + private RequestCountsDTO requestCounts; + @JsonProperty("metadata") + private Metadata metadata; + + @NoArgsConstructor + @Data + public static class RequestCountsDTO { + @JsonProperty("total") + private Integer total; + @JsonProperty("completed") + private Integer completed; + @JsonProperty("failed") + private Integer failed; + } + +} diff --git a/src/main/java/com/unfbx/chatgpt/entity/batch/Metadata.java b/src/main/java/com/unfbx/chatgpt/entity/batch/Metadata.java new file mode 100644 index 0000000..e34200d --- /dev/null +++ b/src/main/java/com/unfbx/chatgpt/entity/batch/Metadata.java @@ -0,0 +1,26 @@ +package com.unfbx.chatgpt.entity.batch; + +import lombok.ToString; + +import java.util.HashMap; + +@ToString(callSuper = true) +public class Metadata extends HashMap { + + public Metadata() { + super(); + } + + public Metadata(int initialCapacity) { + super(initialCapacity); + } + + public Metadata(int initialCapacity, float loadFactor) { + super(initialCapacity, loadFactor); + } + + public Metadata(HashMap m) { + super(m); + } + +} \ No newline at end of file From 219b4b5c1c5814f2ebd9d72b8731675fe5fd54e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E5=90=8D=EF=BC=88=E5=BC=A0=E7=91=9C=EF=BC=89?= Date: Thu, 8 Aug 2024 11:04:16 +0800 Subject: [PATCH 4/4] fix: --- .../com/unfbx/chatgpt/entity/assistant/run/RunResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/unfbx/chatgpt/entity/assistant/run/RunResponse.java b/src/main/java/com/unfbx/chatgpt/entity/assistant/run/RunResponse.java index ae52269..f0a7d00 100644 --- a/src/main/java/com/unfbx/chatgpt/entity/assistant/run/RunResponse.java +++ b/src/main/java/com/unfbx/chatgpt/entity/assistant/run/RunResponse.java @@ -100,7 +100,7 @@ public class RunResponse implements Serializable { public enum Status { QUEUED("queued", "排队"), IN_PROGRESS("in_progress", "进行中"), - REQUIRE_ACTION("require_action", "需要操作"), + REQUIRES_ACTION("requires_action", "需要操作"), CANCELLING("cancelling", "取消"), CANCELLED("cancelled", "已取消"), FAILED("failed", "失败"),