66import cn .hutool .json .JSONUtil ;
77import com .unfbx .chatgpt .constant .OpenAIConst ;
88import com .unfbx .chatgpt .entity .Tts .TextToSpeech ;
9- import com .unfbx .chatgpt .entity .assistant .Assistant ;
10- import com .unfbx .chatgpt .entity .assistant .AssistantResponse ;
9+ import com .unfbx .chatgpt .entity .assistant .*;
1110import com .unfbx .chatgpt .entity .billing .BillingUsage ;
1211import com .unfbx .chatgpt .entity .billing .CreditGrantsResponse ;
1312import com .unfbx .chatgpt .entity .billing .Subscription ;
1413import com .unfbx .chatgpt .entity .chat .*;
1514import com .unfbx .chatgpt .entity .common .DeleteResponse ;
1615import com .unfbx .chatgpt .entity .common .OpenAiResponse ;
16+ import com .unfbx .chatgpt .entity .common .PageRequest ;
1717import com .unfbx .chatgpt .entity .completions .Completion ;
1818import com .unfbx .chatgpt .entity .completions .CompletionResponse ;
1919import com .unfbx .chatgpt .entity .edits .Edit ;
3636import com .unfbx .chatgpt .entity .models .ModelResponse ;
3737import com .unfbx .chatgpt .entity .moderations .Moderation ;
3838import com .unfbx .chatgpt .entity .moderations .ModerationResponse ;
39+ import com .unfbx .chatgpt .entity .thread .ModifyThread ;
40+ import com .unfbx .chatgpt .entity .thread .Thread ;
41+ import com .unfbx .chatgpt .entity .thread .ThreadResponse ;
3942import com .unfbx .chatgpt .entity .whisper .Transcriptions ;
4043import com .unfbx .chatgpt .entity .whisper .Translations ;
4144import com .unfbx .chatgpt .entity .whisper .WhisperResponse ;
5053import com .unfbx .chatgpt .plugin .PluginParam ;
5154import io .reactivex .Single ;
5255import lombok .Getter ;
53- import lombok .SneakyThrows ;
5456import lombok .extern .slf4j .Slf4j ;
5557import okhttp3 .*;
5658import org .jetbrains .annotations .NotNull ;
5759import retrofit2 .Call ;
5860import retrofit2 .Callback ;
59- import retrofit2 .Response ;
6061import retrofit2 .Retrofit ;
6162import retrofit2 .adapter .rxjava2 .RxJava2CallAdapterFactory ;
6263import retrofit2 .converter .jackson .JacksonConverterFactory ;
6364
64- import java .io .IOException ;
65- import java .io .InputStream ;
6665import java .time .LocalDate ;
6766import java .util .*;
6867import java .util .concurrent .TimeUnit ;
@@ -118,8 +117,8 @@ public class OpenAiClient {
118117 *
119118 * @return OpenAiClient.Builder
120119 */
121- public static OpenAiClient . Builder builder () {
122- return new OpenAiClient . Builder ();
120+ public static Builder builder () {
121+ return new Builder ();
123122 }
124123
125124 /**
@@ -1013,11 +1012,153 @@ public void textToSpeech(TextToSpeech textToSpeech, Callback callback) {
10131012 * @return 返回助手信息
10141013 * @since 1.1.2
10151014 */
1016- public AssistantResponse assistants (Assistant assistant ) {
1017- Single <AssistantResponse > assistants = this .openAiApi .assistant (assistant );
1015+ public AssistantResponse assistant (Assistant assistant ) {
1016+ Single <AssistantResponse > assistantResponse = this .openAiApi .assistant (assistant );
1017+ return assistantResponse .blockingGet ();
1018+ }
1019+
1020+ /**
1021+ * 获取助手详细信息
1022+ *
1023+ * @param assistantId 助手id
1024+ * @return 助手信息
1025+ * @since 1.1.3
1026+ */
1027+ public AssistantResponse retrieveAssistant (String assistantId ) {
1028+ Single <AssistantResponse > assistant = this .openAiApi .retrieveAssistant (assistantId );
1029+ return assistant .blockingGet ();
1030+ }
1031+
1032+
1033+ /**
1034+ * 修改助手信息
1035+ *
1036+ * @param assistantId 助手id
1037+ * @param assistant 修改助手参数
1038+ * @return 助手信息
1039+ * @since 1.1.3
1040+ */
1041+ public AssistantResponse modifyAssistant (String assistantId , Assistant assistant ) {
1042+ Single <AssistantResponse > assistantResponse = this .openAiApi .modifyAssistant (assistantId , assistant );
1043+ return assistantResponse .blockingGet ();
1044+ }
1045+
1046+ /**
1047+ * 删除助手
1048+ *
1049+ * @param assistantId 助手id
1050+ * @return 删除状态
1051+ * @since 1.1.3
1052+ */
1053+ public DeleteResponse deleteAssistant (String assistantId ) {
1054+ Single <DeleteResponse > deleteAssistant = this .openAiApi .deleteAssistant (assistantId );
1055+ return deleteAssistant .blockingGet ();
1056+ }
1057+
1058+ /**
1059+ * 助手列表
1060+ *
1061+ * @param pageRequest 分页信息
1062+ * @return AssistantListResponse #AssistantResponse
1063+ * @since 1.1.3
1064+ */
1065+ public AssistantListResponse <AssistantResponse > assistants (PageRequest pageRequest ) {
1066+ Single <AssistantListResponse <AssistantResponse >> assistants = this .openAiApi .assistants (pageRequest .getLimit (), pageRequest .getOrder (), pageRequest .getBefore (), pageRequest .getAfter ());
10181067 return assistants .blockingGet ();
10191068 }
10201069
1070+ /**
1071+ * 创建助手文件
1072+ *
1073+ * @param assistantId 助手id
1074+ * @param assistantId 文件信息
1075+ * @return 返回信息AssistantResponse
1076+ */
1077+ public AssistantFileResponse assistantFile (String assistantId , AssistantFile assistantFile ) {
1078+ Single <AssistantFileResponse > assistantFileResponse = this .openAiApi .assistantFile (assistantId , assistantFile );
1079+ return assistantFileResponse .blockingGet ();
1080+ }
1081+
1082+ /**
1083+ * 检索助手文件
1084+ *
1085+ * @param assistantId 助手id
1086+ * @param fileId 文件信息
1087+ * @return 助手文件信息
1088+ */
1089+ public AssistantFileResponse retrieveAssistantFile (String assistantId , String fileId ) {
1090+ Single <AssistantFileResponse > assistantFileResponse = this .openAiApi .retrieveAssistantFile (assistantId , fileId );
1091+ return assistantFileResponse .blockingGet ();
1092+ }
1093+
1094+ /**
1095+ * 删除助手文件
1096+ *
1097+ * @param assistantId 助手id
1098+ * @param fileId 文件信息
1099+ * @return 删除状态
1100+ */
1101+ public DeleteResponse deleteAssistantFile (String assistantId , String fileId ) {
1102+ Single <DeleteResponse > deleteResponse = this .openAiApi .deleteAssistantFile (assistantId , fileId );
1103+ return deleteResponse .blockingGet ();
1104+ }
1105+
1106+ /**
1107+ * 助手文件列表
1108+ *
1109+ * @param assistantId 助手id
1110+ * @param pageRequest 分页信息
1111+ * @return 助手文件列表
1112+ */
1113+ public AssistantListResponse <AssistantFileResponse > assistantFiles (String assistantId , PageRequest pageRequest ) {
1114+ Single <AssistantListResponse <AssistantFileResponse >> deleteResponse = this .openAiApi .assistantFiles (assistantId , pageRequest .getLimit (), pageRequest .getOrder (), pageRequest .getBefore (), pageRequest .getAfter ());
1115+ return deleteResponse .blockingGet ();
1116+ }
1117+
1118+ /**
1119+ * 创建线程
1120+ *
1121+ * @param thread 创建线程参数
1122+ * @return 线程信息
1123+ * @since 1.1.3
1124+ */
1125+ public ThreadResponse thread (Thread thread ) {
1126+ return this .openAiApi .thread (thread ).blockingGet ();
1127+ }
1128+
1129+ /**
1130+ * 获取线程详细信息
1131+ *
1132+ * @param threadId 线程id
1133+ * @return 线程信息
1134+ * @since 1.1.3
1135+ */
1136+ public ThreadResponse retrieveThread (String threadId ) {
1137+ return this .openAiApi .retrieveThread (threadId ).blockingGet ();
1138+ }
1139+
1140+ /**
1141+ * 修改线程信息
1142+ *
1143+ * @param threadId 线程id
1144+ * @param thread 线程信息
1145+ * @return 线程信息
1146+ * @since 1.1.3
1147+ */
1148+ public ThreadResponse modifyThread (String threadId , ModifyThread thread ) {
1149+ return this .openAiApi .modifyThread (threadId , thread ).blockingGet ();
1150+ }
1151+
1152+ /**
1153+ * 删除线程
1154+ *
1155+ * @param threadId 线程id
1156+ * @return 删除状态
1157+ * @since 1.1.3
1158+ */
1159+ public DeleteResponse deleteThread (String threadId ) {
1160+ return this .openAiApi .deleteThread (threadId ).blockingGet ();
1161+ }
10211162
10221163
10231164 public static final class Builder {
@@ -1028,7 +1169,7 @@ public static final class Builder {
10281169 /**
10291170 * api请求地址,结尾处有斜杠
10301171 *
1031- * @see com.unfbx.chatgpt.constant. OpenAIConst
1172+ * @see OpenAIConst
10321173 */
10331174 private String apiHost ;
10341175 /**
@@ -1052,7 +1193,7 @@ public Builder() {
10521193 /**
10531194 * @param val api请求地址,结尾处有斜杠
10541195 * @return Builder对象
1055- * @see com.unfbx.chatgpt.constant. OpenAIConst
1196+ * @see OpenAIConst
10561197 */
10571198 public Builder apiHost (String val ) {
10581199 apiHost = val ;
0 commit comments