Skip to content

feat: Add plugin, workflow, and model config params to agent api#65

Merged
chyroc merged 6 commits intocoze-dev:mainfrom
c-der:feat_create_bot_params
Mar 12, 2025
Merged

feat: Add plugin, workflow, and model config params to agent api#65
chyroc merged 6 commits intocoze-dev:mainfrom
c-der:feat_create_bot_params

Conversation

@c-der
Copy link
Copy Markdown
Contributor

@c-der c-der commented Mar 12, 2025

创建和更新智能体接口增加插件、工作流和模型配置参数 #62

c-der added 3 commits March 11, 2025 14:33
…s, and model configuration related parameters
# Conflicts:
#	api/src/main/java/com/coze/openapi/client/bots/CreateBotReq.java
#	api/src/main/java/com/coze/openapi/client/bots/UpdateBotReq.java
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 12, 2025

Walkthrough

This pull request extends bot configuration capabilities by adding new properties to the bot creation and update request classes. Three new properties—pluginIdList, workflowIdList, and modelInfoConfig—are now part of both the Create and Update request objects. In addition, several supporting classes have been introduced to encapsulate details about model parameters, plugin IDs, and workflow IDs. The example code has been updated to demonstrate how to build these configurations using environment variables.

Changes

File(s) Change Summary
api/.../bots/CreateBotReq.java
api/.../bots/UpdateBotReq.java
Added three new properties/fields: pluginIdList, workflowIdList, and modelInfoConfig with @JsonProperty annotations for JSON serialization/deserialization.
api/.../bots/model/BotModelInfoConfig.java
api/.../bots/model/BotPluginIdInfo.java
api/.../bots/model/BotPluginIdList.java
api/.../bots/model/BotWorkflowIdInfo.java
api/.../bots/model/BotWorkflowIdList.java
Introduced new classes to encapsulate bot configuration details: model settings, plugin ID details, and workflow ID details. These classes use Lombok annotations and JSON mappings.
example/.../BotPublishExample.java Updated the example to demonstrate the use of the new configuration objects. It builds plugin, workflow, and model configurations using environment variables and integrates them into the bot creation request.

Sequence Diagram(s)

sequenceDiagram
    participant Env as Environment
    participant Ex as BotPublishExample
    participant Builder as CreateBotReq Builder

    Env->>Ex: Provide PLUGIN_API_ID, PLUGIN_ID, WORKFLOW_ID, MODEL_ID
    Ex->>Ex: Create BotPluginIdInfo and BotWorkflowIdInfo
    Ex->>Ex: Build BotPluginIdList and BotWorkflowIdList
    Ex->>Ex: Create BotModelInfoConfig
    Ex->>Builder: Set new configuration fields (plugin, workflow, model)
    Builder-->>Ex: Construct CreateBotReq object
Loading

Poem

Oh, what a hop, oh what a cheer,
New configs bloom, the path is clear.
Plugins, workflows, and model grace,
Adding flair to every place.
With each line of code, I dance with glee,
A rabbit's joy in our tech jubilee!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (5)
api/src/main/java/com/coze/openapi/client/bots/model/BotWorkflowIdInfo.java (1)

1-21: LGTM, consider adding English translations for comments.

The BotWorkflowIdInfo class is well-structured with appropriate Lombok annotations for reducing boilerplate code. The class properly encapsulates a workflow ID with the @NotNull annotation ensuring the ID cannot be null.

For better international developer experience, consider adding English translations alongside the Chinese comments.

-  /** 智能体绑定的工作流 ID */
+  /** 智能体绑定的工作流 ID (Workflow ID bound to the bot) */
api/src/main/java/com/coze/openapi/client/bots/model/BotPluginIdInfo.java (1)

1-27: Well-structured class with appropriate validations.

The BotPluginIdInfo class correctly implements the plugin ID configuration with both required fields properly marked as @NotNull. The JSON property mappings are explicitly defined with snake_case naming convention, consistent with API expectations.

As with the previous file, consider adding English translations for the comments to improve international developer experience.

-  /** 智能体绑定的插件工具 ID */
+  /** 智能体绑定的插件工具 ID (API ID for the plugin tool bound to the bot) */

-  /** 智能体绑定的插件 ID */
+  /** 智能体绑定的插件 ID (Plugin ID bound to the bot) */
api/src/main/java/com/coze/openapi/client/bots/model/BotWorkflowIdList.java (1)

1-20: Consider consistency in field naming and adding @NotNull if required.

The BotWorkflowIdList class looks good, but there are two items to consider:

  1. The field is named ids while the similar field in BotPluginIdList is named idList. Consider standardizing the naming convention across similar classes for better maintainability.

  2. Unlike the fields in BotWorkflowIdInfo, this field isn't marked as @NotNull. If this list should never be null, consider adding the annotation.

Also, adding English translations for comments would improve international developer experience.

-  /** 智能体的工作流列表配置 */
+  /** 智能体的工作流列表配置 (Workflow list configuration for the bot) */
+  @NotNull
   @JsonProperty("ids")
-  private List<BotWorkflowIdInfo> ids;
+  private List<BotWorkflowIdInfo> idList;
api/src/main/java/com/coze/openapi/client/bots/model/BotPluginIdList.java (1)

1-20: Consider adding @NotNull annotation if the list should never be null.

The BotPluginIdList class implementation is clean, but unlike the fields in BotPluginIdInfo, the idList field isn't marked as @NotNull. If this list should never be null in your application logic, consider adding this annotation for better type safety.

Additionally, adding English translations for comments would improve international developer experience.

-  /** 智能体的插件列表配置 */
+  /** 智能体的插件列表配置 (Plugin list configuration for the bot) */
+  @NotNull
   @JsonProperty("id_list")
   private List<BotPluginIdInfo> idList;
example/src/main/java/example/bot/BotPublishExample.java (1)

113-114: Consider updating the UpdateBotReq example with new fields

While the example properly shows how to use the new fields in the CreateBotReq, it doesn't demonstrate their use in UpdateBotReq.

Consider extending the UpdateBotReq example to demonstrate how to update the plugin, workflow, and model configurations:

UpdateBotReq updateReq =
    UpdateBotReq.builder()
        .botID(botID)
        .iconFileID(newAvatarInfo.getFileInfo().getID())
+       .pluginIdList(pluginIdList)
+       .workflowIdList(workflowIdList)
+       .modelInfoConfig(modelInfoConfig)
        .build();

This would provide a more complete example of how to use all the new features.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e429c5d and 2aa5b7c.

📒 Files selected for processing (8)
  • api/src/main/java/com/coze/openapi/client/bots/CreateBotReq.java (2 hunks)
  • api/src/main/java/com/coze/openapi/client/bots/UpdateBotReq.java (2 hunks)
  • api/src/main/java/com/coze/openapi/client/bots/model/BotModelInfoConfig.java (1 hunks)
  • api/src/main/java/com/coze/openapi/client/bots/model/BotPluginIdInfo.java (1 hunks)
  • api/src/main/java/com/coze/openapi/client/bots/model/BotPluginIdList.java (1 hunks)
  • api/src/main/java/com/coze/openapi/client/bots/model/BotWorkflowIdInfo.java (1 hunks)
  • api/src/main/java/com/coze/openapi/client/bots/model/BotWorkflowIdList.java (1 hunks)
  • example/src/main/java/example/bot/BotPublishExample.java (3 hunks)
🧰 Additional context used
🪛 GitHub Actions: CI
api/src/main/java/com/coze/openapi/client/bots/UpdateBotReq.java

[error] 1-11: Spotless formatting check failed. The following files had format violations: UpdateBotReq.java. Run 'mvn spotless:apply' to fix these violations.

api/src/main/java/com/coze/openapi/client/bots/CreateBotReq.java

[error] 1-10: Spotless formatting check failed. The following files had format violations: CreateBotReq.java. Run 'mvn spotless:apply' to fix these violations.

🔇 Additional comments (8)
api/src/main/java/com/coze/openapi/client/bots/model/BotModelInfoConfig.java (1)

1-95: Well-structured model class with comprehensive documentation

The BotModelInfoConfig class is well-designed with:

  • Appropriate use of Lombok annotations to reduce boilerplate code
  • Proper field types for each configuration parameter
  • Well-documented fields with descriptive comments and examples
  • Correct use of @JsonProperty annotations for JSON serialization/deserialization
  • Strategic use of @NotNull constraint on the required modelId field

The class provides a clean way to encapsulate all model-related configuration parameters.

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

6-8: Imports are correctly added for the new model classes

The imports are appropriately added for the new fields being introduced.

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

5-7: Imports are correctly added for the new model classes

The imports are appropriately added for the new fields being introduced.


43-54: ⚠️ Potential issue

Fix formatting issues and consider standardizing field declarations

The additions to the class are logically structured, but there appears to be a formatting issue reported by the CI pipeline.

Please run mvn spotless:apply to fix the formatting violations detected by the CI pipeline.

I noticed that fields in this class don't use the private modifier, while the same fields in UpdateBotReq do use it. Consider standardizing the approach for better consistency:

- @JsonProperty("plugin_id_list")
- BotPluginIdList pluginIdList;
+ @JsonProperty("plugin_id_list")
+ private BotPluginIdList pluginIdList;

- @JsonProperty("workflow_id_list")
- BotWorkflowIdList workflowIdList;
+ @JsonProperty("workflow_id_list")
+ private BotWorkflowIdList workflowIdList;

- @JsonProperty("model_info_config")
- BotModelInfoConfig modelInfoConfig;
+ @JsonProperty("model_info_config")
+ private BotModelInfoConfig modelInfoConfig;

Or alternatively, remove the private modifier from the fields in UpdateBotReq if that's the established pattern in your codebase.

Likely an incorrect or invalid review comment.

example/src/main/java/example/bot/BotPublishExample.java (4)

4-4: Updated import statement for Collections

Properly added the Collections import needed for the new code.


7-7: Updated model import with wildcard

The import has been updated to use a wildcard for the model package, which is appropriate given the multiple model classes now being used.


52-70: Well-structured example for plugin, workflow, and model configurations

Good implementation of the new configuration options with:

  • Clear section comments explaining each configuration block
  • Proper use of environment variables for sensitive/configurable values
  • Builder pattern properly utilized for object creation
  • Collections.singletonList() used appropriately for single-item lists

This provides a helpful example of how to use the new API features.


79-81: Configuration properly added to CreateBotReq builder

The new configuration objects are correctly integrated into the request builder.

Copy link
Copy Markdown

@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: 0

🧹 Nitpick comments (6)
api/src/main/java/com/coze/openapi/client/bots/CreateBotReq.java (3)

44-46: Consider translating JavaDoc comments to English

The JavaDoc comment "智能体的插件配置" is in Chinese, while the codebase appears to primarily use English. For consistency and broader accessibility, consider translating comments to English.

-  /** 智能体的插件配置 */
+  /** Bot plugin configuration */

48-50: Consider translating JavaDoc comments to English

Similar to the previous field, consider translating the Chinese comment to English for consistency.

-  /** 智能体的工作流配置 */
+  /** Bot workflow configuration */

52-54: Consider translating JavaDoc comments to English

Same recommendation for this field's comment.

-  /** 智能体的模型配置 */
+  /** Bot model configuration */
api/src/main/java/com/coze/openapi/client/bots/UpdateBotReq.java (3)

44-46: Consider translating JavaDoc comments to English

The JavaDoc comment "智能体的插件配置" is in Chinese, while the codebase appears to primarily use English. For consistency and broader accessibility, consider translating comments to English.

-  /** 智能体的插件配置 */
+  /** Bot plugin configuration */

48-50: Consider translating JavaDoc comments to English

Similar to the previous field, consider translating the Chinese comment to English for consistency.

-  /** 智能体的工作流配置 */
+  /** Bot workflow configuration */

52-54: Consider translating JavaDoc comments to English

Same recommendation for this field's comment.

-  /** 智能体的模型配置 */
+  /** Bot model configuration */
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2aa5b7c and cec468e.

📒 Files selected for processing (2)
  • api/src/main/java/com/coze/openapi/client/bots/CreateBotReq.java (2 hunks)
  • api/src/main/java/com/coze/openapi/client/bots/UpdateBotReq.java (2 hunks)
🔇 Additional comments (5)
api/src/main/java/com/coze/openapi/client/bots/CreateBotReq.java (2)

3-7: Properly imported new model classes

The imports for the new model classes are correctly added, preparing the class for the new fields.


44-54: The addition of new fields aligns with PR objectives

The three new fields for plugin configuration, workflow configuration, and model configuration properly implement the requested functionality from issue #62. The fields are correctly annotated with @JsonProperty for proper serialization.

api/src/main/java/com/coze/openapi/client/bots/UpdateBotReq.java (3)

3-8: Properly imported new model classes

The imports for the new model classes are correctly added, preparing the class for the new fields.


43-54: Fix formatting issues reported by Spotless

The additions to the class are logically structured, but there appears to be a formatting issue reported by the CI pipeline.

Please run mvn spotless:apply to fix the formatting violations detected by the CI pipeline. This is necessary to pass the build checks.


44-54: The addition of new fields aligns with PR objectives

The three new fields for plugin configuration, workflow configuration, and model configuration properly implement the requested functionality from issue #62. The fields are correctly annotated with @JsonProperty for proper serialization, maintaining consistency with the CreateBotReq class.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.70%. Comparing base (e429c5d) to head (5c2a3ae).
Report is 1 commits behind head on main.

@@            Coverage Diff            @@
##               main      #65   +/-   ##
=========================================
  Coverage     77.70%   77.70%           
  Complexity      321      321           
=========================================
  Files            61       61           
  Lines          1583     1583           
  Branches        102      102           
=========================================
  Hits           1230     1230           
  Misses          280      280           
  Partials         73       73           
Flag Coverage Δ Complexity Δ
unittests 77.70% <ø> (ø) 321.00 <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@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: 0

🧹 Nitpick comments (4)
api/src/main/java/com/coze/openapi/client/bots/model/BotModelInfoConfig.java (4)

12-18: Consider adding validation constraints and range information.

While the JavaDoc provides an example value for topK, it would be helpful to specify the valid range of values. Consider adding validation annotations like @Min and @Max from the Bean Validation API or providing validation in the builder.


61-73: Consider adding validation for responseFormat values.

Since responseFormat has a fixed set of valid values ("text", "markdown", "json"), consider adding validation to ensure only valid values are accepted.

  @JsonProperty("response_format")
  private String responseFormat;
+
+  public void setResponseFormat(String responseFormat) {
+    if (responseFormat != null && 
+        !responseFormat.equals("text") && 
+        !responseFormat.equals("markdown") && 
+        !responseFormat.equals("json")) {
+      throw new IllegalArgumentException(
+          "responseFormat must be one of: text, markdown, json");
+    }
+    this.responseFormat = responseFormat;
+  }

Alternatively, consider using an enum for type safety:

public enum ResponseFormat {
  @JsonProperty("text")
  TEXT,
  
  @JsonProperty("markdown")
  MARKDOWN,
  
  @JsonProperty("json")
  JSON
}

@JsonProperty("response_format")
private ResponseFormat responseFormat;

1-90: Consider adding default values for optional parameters.

Since many of these parameters are likely to have sensible defaults, consider providing static factory methods or default values in the builder to make the API more user-friendly.

Example implementation:

public static class BotModelInfoConfigBuilder {
    // Set default values
    private Integer topK = 1;
    private Double topP = 1.0;
    private Integer maxTokens = 4096;
    private Double temperature = 1.0;
    private Integer contextRound = 30;
    private String responseFormat = "text";
    private Double presencePenalty = 0.0;
    private Double frequencyPenalty = 0.0;
}

// Static factory method for common configurations
public static BotModelInfoConfig defaultConfig(String modelId) {
    return BotModelInfoConfig.builder()
        .modelId(modelId)
        .build();
}

12-87: Consider adding English translations for JavaDoc comments.

The JavaDoc comments are primarily in Chinese. For better international collaboration and broader community support, consider adding English translations alongside the existing comments.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0d968fe and 5c2a3ae.

📒 Files selected for processing (1)
  • api/src/main/java/com/coze/openapi/client/bots/model/BotModelInfoConfig.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test (Java 17 on Windows)
  • GitHub Check: test (Java 11 on Windows)
🔇 Additional comments (2)
api/src/main/java/com/coze/openapi/client/bots/model/BotModelInfoConfig.java (2)

1-11: Class structure and annotations look good.

The class uses Lombok annotations appropriately to reduce boilerplate code. The @Builder pattern will make it easy to construct instances with only the required fields.


28-35: Good use of @NonNull annotation.

Marking modelId as @NonNull ensures that this required field cannot be null. This adds compile-time safety when using the builder pattern.

@chyroc chyroc changed the title feat(bots): bot creation and update interfaces add params feat: Add plugin, workflow, and model config params to agent api Mar 12, 2025
@chyroc chyroc added the feature label Mar 12, 2025
@chyroc chyroc merged commit 5a5d290 into coze-dev:main Mar 12, 2025
13 of 14 checks passed
* 示例:text
*/
@JsonProperty("response_format")
private String responseFormat;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该写成

- private String responseFormat;
+ private BotResponseFormat responseFormat;

实体类如下:

@Getter
public class BotResponseFormat {
    public static final BotResponseFormat TEXT = new BotResponseFormat("text");

    private static final BotResponseFormat MARKDOWN = new BotResponseFormat("markdown");

    private static final BotResponseFormat JSON = new BotResponseFormat("json");

    public static final BotResponseFormat UNKNOWN = new BotResponseFormat("");

    private final String value;

    public BotResponseFormat(String value) {
        this.value = value;
    }

    @JsonValue
    public String getValue() {
        return value;
    }

    @JsonCreator
    public static BotResponseFormat fromString(String value) {
        BotResponseFormat[] formats = {
                TEXT, MARKDOWN, JSON, UNKNOWN
        };
        for (BotResponseFormat type : formats) {
            if (type.value.equals(value)) {
                return type;
            }
        }
        return UNKNOWN;
    }
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的 这样应该会更好,多谢指点

@c-der c-der deleted the feat_create_bot_params branch March 14, 2025 06:58
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.

3 participants