feat: Add plugin, workflow, and model config params to agent api#65
feat: Add plugin, workflow, and model config params to agent api#65chyroc merged 6 commits intocoze-dev:mainfrom
Conversation
…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
WalkthroughThis pull request extends bot configuration capabilities by adding new properties to the bot creation and update request classes. Three new properties— Changes
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
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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.
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
BotWorkflowIdInfoclass is well-structured with appropriate Lombok annotations for reducing boilerplate code. The class properly encapsulates a workflow ID with the@NotNullannotation 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
BotPluginIdInfoclass 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@NotNullif required.The
BotWorkflowIdListclass looks good, but there are two items to consider:
The field is named
idswhile the similar field inBotPluginIdListis namedidList. Consider standardizing the naming convention across similar classes for better maintainability.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@NotNullannotation if the list should never be null.The
BotPluginIdListclass implementation is clean, but unlike the fields inBotPluginIdInfo, theidListfield 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 fieldsWhile 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
📒 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 documentationThe
BotModelInfoConfigclass 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
@JsonPropertyannotations for JSON serialization/deserialization- Strategic use of
@NotNullconstraint on the requiredmodelIdfieldThe 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 classesThe 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 classesThe imports are appropriately added for the new fields being introduced.
43-54:⚠️ Potential issueFix 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:applyto fix the formatting violations detected by the CI pipeline.I noticed that fields in this class don't use the
privatemodifier, while the same fields inUpdateBotReqdo 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
privatemodifier from the fields inUpdateBotReqif 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 CollectionsProperly added the Collections import needed for the new code.
7-7: Updated model import with wildcardThe 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 configurationsGood 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 builderThe new configuration objects are correctly integrated into the request builder.
There was a problem hiding this comment.
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 EnglishThe 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 EnglishSimilar to the previous field, consider translating the Chinese comment to English for consistency.
- /** 智能体的工作流配置 */ + /** Bot workflow configuration */
52-54: Consider translating JavaDoc comments to EnglishSame 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 EnglishThe 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 EnglishSimilar to the previous field, consider translating the Chinese comment to English for consistency.
- /** 智能体的工作流配置 */ + /** Bot workflow configuration */
52-54: Consider translating JavaDoc comments to EnglishSame recommendation for this field's comment.
- /** 智能体的模型配置 */ + /** Bot model configuration */
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 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 classesThe 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 objectivesThe 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
@JsonPropertyfor proper serialization.api/src/main/java/com/coze/openapi/client/bots/UpdateBotReq.java (3)
3-8: Properly imported new model classesThe imports for the new model classes are correctly added, preparing the class for the new fields.
43-54: Fix formatting issues reported by SpotlessThe additions to the class are logically structured, but there appears to be a formatting issue reported by the CI pipeline.
Please run
mvn spotless:applyto 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 objectivesThe 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
@JsonPropertyfor proper serialization, maintaining consistency with the CreateBotReq class.
Codecov ReportAll modified and coverable lines are covered by tests ✅
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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@Minand@Maxfrom the Bean Validation API or providing validation in the builder.
61-73: Consider adding validation forresponseFormatvalues.Since
responseFormathas 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
📒 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
@Builderpattern will make it easy to construct instances with only the required fields.
28-35: Good use of@NonNullannotation.Marking
modelIdas@NonNullensures that this required field cannot be null. This adds compile-time safety when using the builder pattern.
| * 示例:text | ||
| */ | ||
| @JsonProperty("response_format") | ||
| private String responseFormat; |
There was a problem hiding this comment.
这里应该写成
- 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;
}
}
创建和更新智能体接口增加插件、工作流和模型配置参数 #62