Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新官方稳定模型列表 #291

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/main/java/com/unfbx/chatgpt/OpenAiApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -669,7 +672,7 @@ Single<AssistantListResponse<MessageResponse>> messages(@Path("thread_id") Strin
@GET("v1/threads/{thread_id}/messages/{message_id}/files")
@Headers("OpenAI-Beta: assistants=v1")
Single<AssistantListResponse<MessageFileResponse>> 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);


/**
Expand Down Expand Up @@ -797,4 +800,28 @@ Single<AssistantListResponse<RunResponse>> runs(@Path("thread_id") String thread
Single<AssistantListResponse<RunStepResponse>> 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<BatchesResponse> createBatch(@Body BatchesRequest batchesRequest);

/**
* 取消批处理
*/
@POST("v1/batches/{batch_id}/cancel")
Single<BatchesResponse> cancelBatche(@Path("batch_id") String batchId);

/**
* 查询批处理
*/
@GET("v1/batches/{batch_id}")
Single<BatchesResponse> retrieveBatche(@Path("batch_id") String batchId);

/**
* 分页查询批处理
*/
@GET("v1/batches")
Single<BatchesListResponse> listBatch(@Query("after") String after, @Query("limit") Integer limit);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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", "失败"),
Expand Down
Original file line number Diff line number Diff line change
@@ -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<BatchesResponse> data;
@JsonProperty("first_id")
private String firstId;
@JsonProperty("last_id")
private String lastId;
@JsonProperty("has_more")
private Boolean hasMore;

}
22 changes: 22 additions & 0 deletions src/main/java/com/unfbx/chatgpt/entity/batch/BatchesRequest.java
Original file line number Diff line number Diff line change
@@ -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<String, String> metadata;

}
66 changes: 66 additions & 0 deletions src/main/java/com/unfbx/chatgpt/entity/batch/BatchesResponse.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
26 changes: 26 additions & 0 deletions src/main/java/com/unfbx/chatgpt/entity/batch/Metadata.java
Original file line number Diff line number Diff line change
@@ -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<String, String> {

public Metadata() {
super();
}

public Metadata(int initialCapacity) {
super(initialCapacity);
}

public Metadata(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor);
}

public Metadata(HashMap<? extends String, ? extends String> m) {
super(m);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/**
* 指定模型必须输出的格式的对象。
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}