Skip to content

Commit fe97780

Browse files
author
guorutao
committed
Merge branch '1.1.3' into develop
# Conflicts: # README.md
2 parents 0fe5f32 + 5aca21a commit fe97780

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1977
-127
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ WebSocket参考:[OpenAIWebSocketEventSourceListener](https://github.com/Grt122
7979
- 支持全部OpenAI的Api
8080

8181
# 📑 更新日志
82-
- [x] 1.1.3 支持assistant Api
82+
- [x] 1.1.3 支持Assistant、Run、Thread、Message Api
8383
- [x] 1.1.2-beta0 支持附加图片的ChatCompletion、指定返回数据格式、Tool Call、Dall-e-3生成图片、FineTuneJob、文本转语音TTS。官方文档示例:[chatgpt-java.unfbx.com](https://chatgpt-java.unfbx.com/docs/category/-%E6%A0%B8%E5%BF%83%E5%8A%9F%E8%83%BD) 。测试案例[OpenAiClientTest](https://github.com/Grt1228/chatgpt-java/blob/develop/src/test/java/com/unfbx/chatgpt/v1_1_2/OpenAiClientTest.java)
8484
- [x] 1.1.1-beta0 function call改成GPT插件模式调用更加简单的调用方式.参考实现[PluginTest](https://github.com/Grt1228/chatgpt-java/blob/develop/src/test/java/com/unfbx/chatgpt/PluginTest.java)
8585
- [x] 1.0.15 moderations接口更新,代码优化,序列化修复。

README_EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ WebSocket Reference:[OpenAIWebSocketEventSourceListener](https://github.com/Gr
6565
- Supports all OpenAI APIs.
6666

6767
# 📑 Update Log
68+
- [x] 1.1.3 Upgrade to support Assistant、Run、Thread、Message Api
69+
- [x] 1.1.2-beta0 Upgrade to support chat completion with picture GPT-4V、return JSON model、Tool Call、Dall-e-3、Fine Tune Job、TTS.
6870
- [x] 1.1.1-beta0 function call update to GPT plugin model, so easy use the plugin api. eg: [PluginTest](https://github.com/Grt1228/chatgpt-java/blob/develop/src/test/java/com/unfbx/chatgpt/PluginTest.java)
6971
- [x] 1.0.15 moderations api update,code fix,bug fix
7072
- [x] 1.0.14 Upgrade to support the latest version gpt-3.5—0614、gpt-4.0—0614 models, support function-calling full test e.g.:[OpenAiClientFunctionTest](https://github.com/Grt1228/chatgpt-java/blob/main/src/test/java/com/unfbx/chatgpt/OpenAiClientFunctionTest.java)

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.unfbx</groupId>
77
<artifactId>chatgpt-java</artifactId>
8-
<version>1.1.2-beta0</version>
8+
<version>1.1.3</version>
99
<name>chatgpt-java</name>
1010
<description>OpenAI Java SDK, OpenAI Api for Java. ChatGPT Java SDK .</description>
1111
<url>https://chatgpt-java.unfbx.com</url>

src/main/java/com/unfbx/chatgpt/OpenAiApi.java

Lines changed: 218 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
import com.unfbx.chatgpt.entity.Tts.TextToSpeech;
44
import com.unfbx.chatgpt.entity.assistant.*;
5+
import com.unfbx.chatgpt.entity.assistant.message.MessageFileResponse;
6+
import com.unfbx.chatgpt.entity.assistant.message.MessageResponse;
7+
import com.unfbx.chatgpt.entity.assistant.message.ModifyMessage;
8+
import com.unfbx.chatgpt.entity.assistant.run.*;
9+
import com.unfbx.chatgpt.entity.assistant.thread.ThreadMessage;
510
import com.unfbx.chatgpt.entity.billing.BillingUsage;
611
import com.unfbx.chatgpt.entity.billing.CreditGrantsResponse;
712
import com.unfbx.chatgpt.entity.billing.Subscription;
@@ -33,9 +38,9 @@
3338
import com.unfbx.chatgpt.entity.models.ModelResponse;
3439
import com.unfbx.chatgpt.entity.moderations.Moderation;
3540
import com.unfbx.chatgpt.entity.moderations.ModerationResponse;
36-
import com.unfbx.chatgpt.entity.thread.ModifyThread;
37-
import com.unfbx.chatgpt.entity.thread.Thread;
38-
import com.unfbx.chatgpt.entity.thread.ThreadResponse;
41+
import com.unfbx.chatgpt.entity.assistant.thread.ModifyThread;
42+
import com.unfbx.chatgpt.entity.assistant.thread.Thread;
43+
import com.unfbx.chatgpt.entity.assistant.thread.ThreadResponse;
3944
import com.unfbx.chatgpt.entity.whisper.WhisperResponse;
4045
import io.reactivex.Single;
4146
import okhttp3.MultipartBody;
@@ -582,4 +587,214 @@ Single<AssistantListResponse<AssistantFileResponse>> assistantFiles(@Path("assis
582587
@DELETE("v1/threads/{thread_id}")
583588
@Headers("OpenAI-Beta: assistants=v1")
584589
Single<DeleteResponse> deleteThread(@Path("thread_id") String threadId);
590+
591+
/**
592+
* 为线程创建消息
593+
*
594+
* @param threadId 线程id
595+
* @param message message参数
596+
* @return
597+
* @since 1.1.3
598+
*/
599+
@POST("v1/threads/{thread_id}/messages")
600+
@Headers("OpenAI-Beta: assistants=v1")
601+
Single<MessageResponse> message(@Path("thread_id") String threadId, @Body ThreadMessage message);
602+
603+
/**
604+
* 检索某一个线程对应的消息详细信息
605+
*
606+
* @param threadId 线程id
607+
* @param messageId 消息id
608+
* @return
609+
* @since 1.1.3
610+
*/
611+
@GET("v1/threads/{thread_id}/messages/{message_id}")
612+
@Headers("OpenAI-Beta: assistants=v1")
613+
Single<MessageResponse> retrieveMessage(@Path("thread_id") String threadId, @Path("message_id") String messageId);
614+
615+
/**
616+
* 修改某一个线程对应的消息
617+
*
618+
* @param threadId 线程id
619+
* @param messageId 消息id
620+
* @param message 消息体
621+
* @return
622+
* @since 1.1.3
623+
*/
624+
@POST("v1/threads/{thread_id}/messages/{message_id}")
625+
@Headers("OpenAI-Beta: assistants=v1")
626+
Single<MessageResponse> modifyMessage(@Path("thread_id") String threadId, @Path("message_id") String messageId, @Body ModifyMessage message);
627+
628+
/**
629+
* 获取某一个线程的消息集合
630+
*
631+
* @param threadId 线程id
632+
* @param limit 一页数据大小
633+
* @param order 排序类型
634+
* @param before 分页参数,之前的id,默认值:null
635+
* @param after 分页参数,之后的id,默认值:null
636+
* @return
637+
* @since 1.1.3
638+
*/
639+
@GET("v1/threads/{thread_id}/messages")
640+
@Headers("OpenAI-Beta: assistants=v1")
641+
Single<AssistantListResponse<MessageResponse>> messages(@Path("thread_id") String threadId,
642+
@Query("limit") Integer limit, @Query("order") String order, @Query("before") String before, @Query("after") String after);
643+
644+
/**
645+
* 检索某一个线程对应某一个消息的一个文件信息
646+
*
647+
* @param threadId 线程id
648+
* @param messageId 消息id
649+
* @param fileId 文件id
650+
* @return
651+
* @since 1.1.3
652+
*/
653+
@GET("v1/threads/{thread_id}/messages/{message_id}/files/{file_id}")
654+
@Headers("OpenAI-Beta: assistants=v1")
655+
Single<MessageFileResponse> retrieveMessageFile(@Path("thread_id") String threadId, @Path("message_id") String messageId, @Path("file_id") String fileId);
656+
657+
/**
658+
* messageFiles集合
659+
*
660+
* @param threadId 线程id
661+
* @param messageId 消息id
662+
* @param limit 一页数据大小
663+
* @param order 排序类型
664+
* @param before 分页参数,之前的id,默认值:null
665+
* @param after 分页参数,之后的id,默认值:null
666+
* @return
667+
* @since 1.1.3
668+
*/
669+
@GET("v1/threads/{thread_id}/messages/{message_id}/files")
670+
@Headers("OpenAI-Beta: assistants=v1")
671+
Single<AssistantListResponse<MessageFileResponse>> messageFiles(@Path("thread_id") String threadId, @Path("message_id") String messageId,
672+
@Query("limit") Integer limit, @Query("order") String order, @Query("before") String before, @Query("after") String after);
673+
674+
675+
/**
676+
* 创建Run
677+
*
678+
* @param threadId 线程id
679+
* @param run run
680+
* @return
681+
* @since 1.1.3
682+
*/
683+
@POST("v1/threads/{thread_id}/runs")
684+
@Headers("OpenAI-Beta: assistants=v1")
685+
Single<RunResponse> run(@Path("thread_id") String threadId, @Body Run run);
686+
687+
688+
/**
689+
* 检索run详细信息
690+
*
691+
* @param threadId 线程id
692+
* @param runId run_id
693+
* @return
694+
* @since 1.1.3
695+
*/
696+
@GET("v1/threads/{thread_id}/runs/{run_id}")
697+
@Headers("OpenAI-Beta: assistants=v1")
698+
Single<RunResponse> retrieveRun(@Path("thread_id") String threadId, @Path("run_id") String runId);
699+
700+
/**
701+
* 修改某一个run
702+
*
703+
* @param threadId 线程id
704+
* @param runId run_id
705+
* @param run 消息体
706+
* @return
707+
* @since 1.1.3
708+
*/
709+
@POST("v1/threads/{thread_id}/runs/{run_id}")
710+
@Headers("OpenAI-Beta: assistants=v1")
711+
Single<RunResponse> modifyRun(@Path("thread_id") String threadId, @Path("run_id") String runId, @Body ModifyRun run);
712+
713+
714+
/**
715+
* 获取某一个线程的run集合
716+
*
717+
* @param threadId 线程id
718+
* @param limit 一页数据大小
719+
* @param order 排序类型
720+
* @param before 分页参数,之前的id,默认值:null
721+
* @param after 分页参数,之后的id,默认值:null
722+
* @return
723+
* @since 1.1.3
724+
*/
725+
@GET("v1/threads/{thread_id}/runs")
726+
@Headers("OpenAI-Beta: assistants=v1")
727+
Single<AssistantListResponse<RunResponse>> runs(@Path("thread_id") String threadId,
728+
@Query("limit") Integer limit, @Query("order") String order, @Query("before") String before, @Query("after") String after);
729+
730+
731+
/**
732+
* 获取某一个线程的run集合
733+
*
734+
* @param threadId 线程id
735+
* @param runId run id
736+
* @param toolOutputs 为其提交输出的工具列表。
737+
* @return
738+
* @since 1.1.3
739+
*/
740+
@POST("v1/threads/{thread_id}/runs/{run_id}/submit_tool_outputs")
741+
@Headers("OpenAI-Beta: assistants=v1")
742+
Single<RunResponse> submitToolOutputs(@Path("thread_id") String threadId, @Path("run_id") String runId, @Body ToolOutputBody toolOutputs);
743+
744+
745+
/**
746+
* 取消正在进行中的run
747+
*
748+
* @param threadId 线程id
749+
* @param runId run id
750+
* @return
751+
* @since 1.1.3
752+
*/
753+
@POST("v1/threads/{thread_id}/runs/{run_id}/cancel")
754+
@Headers("OpenAI-Beta: assistants=v1")
755+
Single<RunResponse> cancelRun(@Path("thread_id") String threadId, @Path("run_id") String runId);
756+
757+
758+
/**
759+
* 创建一个线程并在一个请求中运行它
760+
*
761+
* @param threadRun 对象
762+
* @return
763+
* @since 1.1.3
764+
*/
765+
@POST("v1/threads/runs")
766+
@Headers("OpenAI-Beta: assistants=v1")
767+
Single<RunResponse> threadRun(@Body ThreadRun threadRun);
768+
769+
/**
770+
* 检索run step详细信息
771+
*
772+
* @param threadId 线程id
773+
* @param runId run_id
774+
* @param stepId step_id
775+
* @return
776+
* @since 1.1.3
777+
*/
778+
@GET("v1/threads/{thread_id}/runs/{run_id}/steps/{step_id}")
779+
@Headers("OpenAI-Beta: assistants=v1")
780+
Single<RunStepResponse> retrieveRunStep(@Path("thread_id") String threadId, @Path("run_id") String runId, @Path("step_id") String stepId);
781+
782+
783+
/**
784+
* 获取某一个线程的run step集合
785+
*
786+
* @param threadId 线程id
787+
* @param runId run_id
788+
* @param limit 一页数据大小
789+
* @param order 排序类型
790+
* @param before 分页参数,之前的id,默认值:null
791+
* @param after 分页参数,之后的id,默认值:null
792+
* @return
793+
* @since 1.1.3
794+
*/
795+
@GET("v1/threads/{thread_id}/runs/{run_id}/steps")
796+
@Headers("OpenAI-Beta: assistants=v1")
797+
Single<AssistantListResponse<RunStepResponse>> runSteps(@Path("thread_id") String threadId, @Path("run_id") String runId,
798+
@Query("limit") Integer limit, @Query("order") String order, @Query("before") String before, @Query("after") String after);
799+
585800
}

0 commit comments

Comments
 (0)