-
Notifications
You must be signed in to change notification settings - Fork 86
智能体相关:新增「查看智能体列表、「查看智能体配置」接口,均支持草稿态和已发布。旧接口「查看已发布智能体列表」以及「获取已发布智能体配置」即将在 7 月下线,请及时迁移Feature new apis #109
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis update introduces version 2 (V2) APIs for bot listing and retrieval, adds new request and response data models, and expands the bot model with additional fields for variables, ownership, voice, and background image information. Deprecated annotations are applied to older classes and methods. An example demonstrates the new V2 API usage. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant BotService
participant BotAPI
participant Server
Client->>BotService: list(ListBotV2Req)
BotService->>BotAPI: list(workspaceID, publishStatus, ...)
BotAPI->>Server: GET /v1/bots
Server-->>BotAPI: ListBotV2Resp
BotAPI-->>BotService: ListBotV2Resp
BotService-->>Client: PageResp<BotSimpleInfo>
Client->>BotService: retrieve(RetrieveBotV2Req)
BotService->>BotAPI: retrieve(botID, isPublished, ...)
BotAPI->>Server: GET /v1/bots/{bot_id}
Server-->>BotAPI: Bot
BotAPI-->>BotService: Bot
BotService-->>Client: RetrieveBotV2Resp
Suggested labels
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
🧹 Nitpick comments (13)
api/src/main/java/com/coze/openapi/client/bots/model/BotVoice.java (1)
10-20: Consider immutability & consistency improvements for the new model class
- If the value objects are not meant to be mutated after construction, prefer
@Value(or@Data @Builder(toBuilder = false) @AllArgsConstructor) instead of@Data+ setters to make the DTO immutable and thread-safe.- Add
@JsonInclude(JsonInclude.Include.NON_NULL)to avoid serialising empty fields, matching the style of other DTOs in this module.- Field naming is inconsistent with the rest of the SDK (
botID,spaceID, etc.). RenamevoiceId→voiceIDor, conversely, rename the older fields, to keep a single convention.api/src/main/java/com/coze/openapi/client/bots/ListBotResp.java (1)
16-16: Add migration hint in the deprecation messageThe
@Deprecatedflag is correct, but without a Javadoc note developers have no guidance on the replacement (ListBotV2Resp). Add a short Javadoc with@deprecated Use ListBotV2Resp instead.so IDEs show the migration path automatically.api/src/main/java/com/coze/openapi/client/bots/RetrieveBotReq.java (1)
12-12: Deprecation notice should reference the V2 counterpartSame remark as above – add Javadoc
@deprecated Use RetrieveBotV2Reqso users can migrate quickly.api/src/main/java/com/coze/openapi/client/bots/RetrieveBotResp.java (1)
12-12: Document deprecationPlease add a Javadoc deprecation tag pointing to
RetrieveBotV2Respto make IDE quick-fixes work.api/src/main/java/com/coze/openapi/client/bots/ListBotReq.java (1)
11-11: Deprecation Javadoc missingFor completeness and better developer UX, annotate with
@deprecated Use ListBotV2Reqin Javadoc.api/src/main/java/com/coze/openapi/client/bots/RetrieveBotV2Req.java (2)
18-23: Add basic validation annotations to prevent invalid requests early
botIDcannot be blank andisPublishedis optional. Adding Bean-Validation keeps bad requests from reaching the server layer.- @JsonProperty("bot_id") - private String botID; + @JsonProperty("bot_id") + @NotBlank + private String botID;(Requires
jakarta.validationon the classpath, already used in other modules.)
24-26:ofhelper leaks nulls – offer overload without the BooleanMost callers only care about the ID; forcing them to pass
nullis error-prone.public static RetrieveBotV2Req of(String botID, Boolean isPublished) { return RetrieveBotV2Req.builder().botID(botID).isPublished(isPublished).build(); } + + public static RetrieveBotV2Req of(String botID) { + return of(botID, null); + }api/src/main/java/com/coze/openapi/client/bots/ListBotV2Req.java (2)
18-23: ModelpublishStatusas an enum instead of rawStringExposing free-form strings invites typos and makes refactoring harder. Define an
enum PublishStatus { DRAFT, PUBLISHED }(or reuse existing one) and annotate with@JsonProperty.- @JsonProperty("publish_status") - private String publishStatus; + @JsonProperty("publish_status") + private PublishStatus publishStatus;
24-27: Default and guard paging parameters
pageNum/pageSizebeingnullor ≤0 will likely trigger server errors. Recommend defaulting in builder or adding validation annotations (@Min(1)).api/src/main/java/com/coze/openapi/client/bots/RetrieveBotV2Resp.java (1)
17-18: Minor: add@JsonProperty("bot")for explicitnessAlthough the name matches, being explicit avoids surprises if the field is ever renamed.
- private Bot bot; + @JsonProperty("bot") + private Bot bot;api/src/main/java/com/coze/openapi/client/bots/model/BotSimpleInfo.java (1)
30-37: Typos / naming
veriablesinBotis misspelled; keep simple info consistent (variables).Also consider
iconURLvsiconUrlcamel-case consistency across models. Harmonising now prevents future breaking changes.example/src/main/java/example/bot/BotRetrieveV2Example.java (2)
33-33: Remove extraneous semicolon.There's an unnecessary semicolon after the
build()method call.- .build(); - ; + .build();
55-57: Simplify iterator usage.The current iterator usage is unnecessarily complex. Since you're using
forEachRemaining(), there's no need for the while loop.- Iterator<BotSimpleInfo> iterator = botList.getIterator(); - while (iterator.hasNext()) { - iterator.forEachRemaining(System.out::println); - } + botList.getIterator().forEachRemaining(System.out::println);
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
api/src/main/java/com/coze/openapi/api/BotAPI.java(2 hunks)api/src/main/java/com/coze/openapi/client/bots/ListBotReq.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/ListBotResp.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/ListBotV2Req.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/ListBotV2Resp.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotReq.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotResp.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotV2Req.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotV2Resp.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/model/Bot.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/model/BotBackgroundImageInfo.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/model/BotSimpleInfo.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/model/BotVeriable.java(1 hunks)api/src/main/java/com/coze/openapi/client/bots/model/BotVoice.java(1 hunks)api/src/main/java/com/coze/openapi/service/service/bots/BotService.java(3 hunks)example/src/main/java/example/bot/BotRetrieveV2Example.java(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (10)
api/src/main/java/com/coze/openapi/client/bots/ListBotResp.java (3)
api/src/main/java/com/coze/openapi/client/bots/ListBotReq.java (1)
Deprecated(11-21)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotResp.java (1)
Deprecated(12-20)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotReq.java (1)
Deprecated(12-25)
api/src/main/java/com/coze/openapi/client/bots/RetrieveBotResp.java (3)
api/src/main/java/com/coze/openapi/client/bots/ListBotResp.java (1)
Deprecated(16-29)api/src/main/java/com/coze/openapi/client/bots/ListBotReq.java (1)
Deprecated(11-21)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotReq.java (1)
Deprecated(12-25)
api/src/main/java/com/coze/openapi/client/bots/ListBotV2Resp.java (1)
api/src/main/java/com/coze/openapi/client/bots/model/BotSimpleInfo.java (1)
Data(10-38)
api/src/main/java/com/coze/openapi/client/bots/RetrieveBotReq.java (3)
api/src/main/java/com/coze/openapi/client/bots/ListBotResp.java (1)
Deprecated(16-29)api/src/main/java/com/coze/openapi/client/bots/ListBotReq.java (1)
Deprecated(11-21)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotResp.java (1)
Deprecated(12-20)
api/src/main/java/com/coze/openapi/client/bots/ListBotReq.java (3)
api/src/main/java/com/coze/openapi/client/bots/ListBotResp.java (1)
Deprecated(16-29)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotResp.java (1)
Deprecated(12-20)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotReq.java (1)
Deprecated(12-25)
api/src/main/java/com/coze/openapi/client/bots/model/BotSimpleInfo.java (4)
api/src/main/java/com/coze/openapi/client/bots/ListBotV2Req.java (1)
Data(12-28)api/src/main/java/com/coze/openapi/client/bots/ListBotV2Resp.java (1)
Data(16-28)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotV2Resp.java (1)
Data(12-19)api/src/main/java/com/coze/openapi/client/bots/model/Bot.java (1)
Data(12-76)
api/src/main/java/com/coze/openapi/client/bots/RetrieveBotV2Req.java (3)
api/src/main/java/com/coze/openapi/client/bots/ListBotV2Req.java (1)
Data(12-28)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotV2Resp.java (1)
Data(12-19)api/src/main/java/com/coze/openapi/client/bots/model/Bot.java (1)
Data(12-76)
api/src/main/java/com/coze/openapi/api/BotAPI.java (4)
api/src/main/java/com/coze/openapi/client/bots/ListBotResp.java (1)
Deprecated(16-29)api/src/main/java/com/coze/openapi/client/bots/ListBotReq.java (1)
Deprecated(11-21)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotResp.java (1)
Deprecated(12-20)api/src/main/java/com/coze/openapi/client/bots/RetrieveBotReq.java (1)
Deprecated(12-25)
example/src/main/java/example/bot/BotRetrieveV2Example.java (2)
api/src/main/java/com/coze/openapi/service/auth/TokenAuth.java (1)
TokenAuth(3-13)api/src/main/java/com/coze/openapi/service/service/CozeAPI.java (1)
CozeAPI(35-278)
api/src/main/java/com/coze/openapi/service/service/bots/BotService.java (1)
api/src/main/java/com/coze/openapi/service/utils/Utils.java (1)
Utils(16-95)
🪛 GitHub Actions: CI
api/src/main/java/com/coze/openapi/client/bots/model/Bot.java
[error] 75-75: Spotless (google-java-format) formatting check failed. Error: expected token 'defaultUserInputType'; generated defaultUserInputType instead. Recommendation: Upgrade to google-java-format 1.15.0 to fix this issue on JVM 11+.
🔇 Additional comments (10)
api/src/main/java/com/coze/openapi/client/bots/ListBotV2Resp.java (1)
26-28: Consider usingLongfortotalto avoid overflow on large workspaces
totalrepresents a record count that can easily exceedInteger.MAX_VALUEin big tenants.
Changing toLongfuture-proofs the API without breaking JSON consumers (numbers are untyped there).- private Integer total; + private Long total;api/src/main/java/com/coze/openapi/client/bots/model/BotSimpleInfo.java (1)
15-20: Inconsistent ID key withBotmodel may confuse consumers
Botexposesbot_id, while simple info usesid. Aligning them avoids special-casing in client code.- @JsonProperty("id") - private String id; + @JsonProperty("bot_id") + private String botId;api/src/main/java/com/coze/openapi/service/service/bots/BotService.java (3)
85-104: Well-implemented V2 list method.The new
list(ListBotV2Req req)method correctly implements the V2 API pattern with proper pagination, error handling, and follows the established codebase conventions.
131-134: Well-implemented V2 retrieve method.The new
retrieve(RetrieveBotV2Req req)method correctly implements the V2 API pattern with proper parameter handling and follows the established codebase conventions.
106-124: Consistent implementation of page fetcher.The
getSimpleBotPageFetcher(ListBotV2Req req)method correctly implements the pagination logic consistent with the existing V1 implementation, properly handling workspace ID, publish status, and connector ID parameters.api/src/main/java/com/coze/openapi/api/BotAPI.java (5)
6-6: LGTM: Import addition for V2 response class.The import for
ListBotV2Respis correctly added to support the new V2 API endpoint.
18-18: LGTM: Import addition for path parameter support.The import for
@Pathannotation is correctly added to support path parameters in the new retrieve method.
23-23: LGTM: Proper deprecation marking.The
@Deprecatedannotation is correctly applied to the old list method, aligning with the PR objectives to phase out legacy APIs.
31-38: LGTM: Well-designed V2 list API method.The new list method provides enhanced functionality with:
- More flexible filtering options (workspace_id, publish_status, connector)
- Consistent parameter naming and pagination support
- Proper return type using V2 response class
The method signature provides good flexibility for various use cases.
40-40: LGTM: Proper deprecation marking.The
@Deprecatedannotation is correctly applied to the old retrieve method, consistent with the migration strategy.
api/src/main/java/com/coze/openapi/client/bots/model/BotVeriable.java
Outdated
Show resolved
Hide resolved
api/src/main/java/com/coze/openapi/client/bots/model/BotBackgroundImageInfo.java
Show resolved
Hide resolved
api/src/main/java/com/coze/openapi/client/bots/model/BotBackgroundImageInfo.java
Show resolved
Hide resolved
|
@CLAassistant @chyroc any response? |
|
先修复一下 ci 吧 |
|
done |
https://www.coze.cn/open/docs/developer_guides/published_bots_list
https://www.coze.cn/open/docs/developer_guides/published_bots_list