feat: Initialize Java SDK with support for all Coze APIs#1
Merged
chyroc merged 19 commits intocoze-dev:mainfrom Dec 12, 2024
hanzeINGH:init_code
Merged
feat: Initialize Java SDK with support for all Coze APIs#1chyroc merged 19 commits intocoze-dev:mainfrom hanzeINGH:init_code
chyroc merged 19 commits intocoze-dev:mainfrom
hanzeINGH:init_code
Conversation
Contributor
|
在 ApiResponseCallAdapter 中的 TODO 注释("todo 添加日志")应该被实现或移除 |
Contributor
|
MyInterceptor 中的调试日志可能会记录敏感信息,建议在生产环境中完全移除 |
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
Change-Id: I191e5827d4362dce159c3f2d0306083a7b14cd14
Change-Id: I5c91800473c1031df7f9d3efe5e8f3836a1359cc
Change-Id: Icb1583d6a1bf2e3f4a282afefb428fe634be1d3b
Change-Id: I770693dd42982535b3ccc3e7fb8262121f0251b4
Change-Id: If4a92028dc7a725a865262c59d5e198170720519
Change-Id: Id12c3f2dd5d20b26fe09c22c8c114108ccf935d3
Change-Id: I887361495abb40023197763a197e2b46b0d978e7
Change-Id: I887361495abb40023197763a197e2b46b0d978e7
Change-Id: I23699ff6e3ca051fda8974ade055baa1e00b75bc
chyroc
reviewed
Dec 12, 2024
chyroc
reviewed
Dec 12, 2024
| .botID(botID) | ||
| .voiceID(voiceID) | ||
| .build(); | ||
| CreateRoomResp resp = coze.audio().rooms().create(req); |
chyroc
reviewed
Dec 12, 2024
|
|
||
| import java.io.IOException; | ||
|
|
||
| public class CreateSpeechExample { |
Contributor
There was a problem hiding this comment.
改成这个格式:
coze.audio().speech().create -> AudioSpeechCreateExample
There was a problem hiding this comment.
全改吗,我现在的 Example 都是动词在前,其实也是可以根据包名来区分实体的
Change-Id: Iabd29d9e741fb75f3c8534891ecee0dc9ca41d6c
chyroc
reviewed
Dec 12, 2024
| .auth(authCli) | ||
| .readTimeout(10000) | ||
| .build();; | ||
| String saveFilePath = System.getenv("SAVE_FILE_PATH"); |
chyroc
reviewed
Dec 12, 2024
| import com.coze.openapi.service.service.CozeAPI; | ||
| import com.coze.openapi.service.auth.TokenAuth; | ||
|
|
||
| public class CloneVoiceExample { |
chyroc
reviewed
Dec 12, 2024
| .language(LanguageCode.ZH) | ||
| .voiceID(System.getenv("COZE_VOICE_ID")) | ||
| .text("your text") | ||
| .previewText("your preview text") |
chyroc
reviewed
Dec 12, 2024
| .audioFormat(AudioFormat.M4A) | ||
| .language(LanguageCode.ZH) | ||
| .voiceID(System.getenv("COZE_VOICE_ID")) | ||
| .text("your text") |
chyroc
reviewed
Dec 12, 2024
|
|
||
| import java.util.Iterator; | ||
|
|
||
| public class ListVoiceExample { |
chyroc
reviewed
Dec 12, 2024
|
|
||
| PageResp<Voice> resp = coze.audio().voices().list(ListVoiceReq.builder().pageSize(10).build()); | ||
| Iterator<Voice> iterator = resp.getIterator(); | ||
| while (iterator.hasNext()) { |
There was a problem hiding this comment.
java 定义了迭代器,是一个 interface,我们可以自定义实现
chyroc
reviewed
Dec 12, 2024
| /* | ||
| * The space permissions for which the Access Token is granted can be specified. As following codes: | ||
| * */ | ||
| DeviceAuthResp wCodeResp = oauth.getDeviceCode("workspaceID"); |
Contributor
There was a problem hiding this comment.
这一行是不是应该注释?这个文件可以 run 起来吗,申请了两个 code?
chyroc
reviewed
Dec 12, 2024
| /* | ||
| * The space permissions for which the Access Token is granted can be specified. As following codes: | ||
| * */ | ||
| oauthURL = oauth.getOAuthURL(redirectURI, null, "workspaceID"); |
chyroc
reviewed
Dec 12, 2024
| import com.coze.openapi.client.common.BaseReq; | ||
| public interface BotAPI { | ||
| @GET("/v1/space/published_bots_list") | ||
| Call<BaseResponse<ListBotResp>> list(@Query("space_id") String spaceID, @Query("page_index") Integer page, @Query("page_size") Integer pageSize, @Tag BaseReq baseReq); |
There was a problem hiding this comment.
这整个目录对于使用者都是不感知的,这里可以理解成请求我们 openapi 的代码
chyroc
reviewed
Dec 12, 2024
| public interface ChatAPI { | ||
|
|
||
| @POST("/v3/chat") | ||
| Call<BaseResponse<Chat>> chat(@Query("conversation_id") String conversationID, @Body CreateChatReq req, @Tag BaseReq baseReq); |
chyroc
reviewed
Dec 12, 2024
| public interface CozeAuthAPI { | ||
| @Headers({"Content-Type: application/json"}) | ||
| @POST("/api/permission/oauth2/token") | ||
| Single<Response<OAuthToken>> retrieve(@HeaderMap Map<String, String> headers, @Body GetAccessTokenReq req); |
There was a problem hiding this comment.
刷新 token,获取 Access token 都是用这个接口,具体是做啥就由入参来控制,我就叫这个了
chyroc
reviewed
Dec 12, 2024
|
|
||
| @POST("/open_api/knowledge/document/create") | ||
| @Headers({"Content-Type: application/json","Agw-Js-Conv: str"}) | ||
| Call<CreateDocumentResp> CreateDocument(@Body CreateDocumentReq req, @Tag BaseReq baseReq); |
chyroc
reviewed
Dec 12, 2024
| public interface WorkflowRunAPI { | ||
|
|
||
| @POST("/v1/workflow/run") | ||
| Call<RunWorkflowResp> run(@Body RunWorkflowReq req, @Tag BaseReq baseReq); |
chyroc
reviewed
Dec 12, 2024
|
|
||
| @POST("/v1/workflow/stream_run") | ||
| @Streaming | ||
| Call<ResponseBody> stream(@Body RunWorkflowReq req, @Tag BaseReq baseReq); |
chyroc
reviewed
Dec 12, 2024
|
|
||
| @POST("/v1/workflow/stream_resume") | ||
| @Streaming | ||
| Call<ResponseBody> resume(@Body ResumeRunReq req, @Tag BaseReq baseReq); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.