Skip to content

Conversation

jingxiang
Copy link
Contributor

Copy link

coderabbitai bot commented Jul 3, 2025

Walkthrough

This 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

File(s) Change Summary
.../api/BotAPI.java Added V2 list and retrieve methods; deprecated old methods.
.../client/bots/ListBotV2Req.java
.../ListBotV2Resp.java
.../RetrieveBotV2Req.java
.../RetrieveBotV2Resp.java
Added new V2 request/response classes for listing and retrieving bots.
.../client/bots/ListBotReq.java
.../ListBotResp.java
.../RetrieveBotReq.java
.../RetrieveBotResp.java
Marked old request/response classes as deprecated.
.../client/bots/model/Bot.java Added fields: variables, ownerUserId, voiceInfoList, backgroundImageInfo, defaultUserInputType.
.../client/bots/model/BotSimpleInfo.java Added new class for simplified bot info.
.../client/bots/model/BotVoice.java Added new class for bot voice information.
.../client/bots/model/BotVariable.java Added new class for bot variable metadata.
.../client/bots/model/BotBackgroundImageInfo.java Added new class for bot background image details, including nested classes for image positioning.
.../service/service/bots/BotService.java Added V2 list and retrieve methods using new models; updated imports.
example/src/main/java/example/bot/BotRetrieveV2Example.java Added example demonstrating V2 bot retrieval and listing with pagination.

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
Loading

Suggested labels

feature

Poem

In fields of code where bots now play,
New voices, backgrounds, variables sway.
V2 APIs hop in with glee,
Bringing paged lists for all to see.
Deprecated burrows left behind—
Onward, new features, swift as the wind!
🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 785d66d and 77b7120.

📒 Files selected for processing (1)
  • example/src/main/java/example/bot/BotRetrieveV2Example.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • example/src/main/java/example/bot/BotRetrieveV2Example.java
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ chyroc
❌ jingxiang
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

@coderabbitai coderabbitai bot left a 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

  1. 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.
  2. Add @JsonInclude(JsonInclude.Include.NON_NULL) to avoid serialising empty fields, matching the style of other DTOs in this module.
  3. Field naming is inconsistent with the rest of the SDK (botID, spaceID, etc.). Rename voiceIdvoiceID or, 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 message

The @Deprecated flag 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 counterpart

Same remark as above – add Javadoc @deprecated Use RetrieveBotV2Req so users can migrate quickly.

api/src/main/java/com/coze/openapi/client/bots/RetrieveBotResp.java (1)

12-12: Document deprecation

Please add a Javadoc deprecation tag pointing to RetrieveBotV2Resp to make IDE quick-fixes work.

api/src/main/java/com/coze/openapi/client/bots/ListBotReq.java (1)

11-11: Deprecation Javadoc missing

For completeness and better developer UX, annotate with @deprecated Use ListBotV2Req in Javadoc.

api/src/main/java/com/coze/openapi/client/bots/RetrieveBotV2Req.java (2)

18-23: Add basic validation annotations to prevent invalid requests early

botID cannot be blank and isPublished is 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.validation on the classpath, already used in other modules.)


24-26: of helper leaks nulls – offer overload without the Boolean

Most callers only care about the ID; forcing them to pass null is 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: Model publishStatus as an enum instead of raw String

Exposing 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/pageSize being null or ≤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 explicitness

Although 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

veriables in Bot is misspelled; keep simple info consistent (variables).

Also consider iconURL vs iconUrl camel-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

📥 Commits

Reviewing files that changed from the base of the PR and between b243e69 and 33c29f5.

📒 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 using Long for total to avoid overflow on large workspaces

total represents a record count that can easily exceed Integer.MAX_VALUE in big tenants.
Changing to Long future-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 with Bot model may confuse consumers

Bot exposes bot_id, while simple info uses id. 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 ListBotV2Resp is correctly added to support the new V2 API endpoint.


18-18: LGTM: Import addition for path parameter support.

The import for @Path annotation is correctly added to support path parameters in the new retrieve method.


23-23: LGTM: Proper deprecation marking.

The @Deprecated annotation 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 @Deprecated annotation is correctly applied to the old retrieve method, consistent with the migration strategy.

@jingxiang
Copy link
Contributor Author

@CLAassistant @chyroc any response?

@chyroc
Copy link
Contributor

chyroc commented Jul 11, 2025

先修复一下 ci 吧

@jingxiang
Copy link
Contributor Author

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants