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/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", "失败"), 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 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; } 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; } }