feat: Support enable_card for v3/chat#107
Conversation
- 在 api/pom.xml 中将版本号从 0.3.2 修改为 0.3.3 - 新增 version.properties 文件,用于存储版本号 - 新增 VersionUtils 工具类,用于动态获取版本号 - 在 UserAgentInterceptor 中使用 VersionUtils 替代硬编码版本号 - 更新 example/pom.xml 中的 coze-api 依赖版本为 0.3.3
WalkthroughThe project version was incremented from 0.3.2 to 0.3.3 across relevant files. A new utility for dynamically retrieving the SDK version from a properties file was introduced, and the user agent logic now uses this dynamic version. Additionally, a new field was added to the chat request class, and resource filtering was enabled. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant CreateChatReq
participant UserAgentInterceptor
participant VersionUtils
participant version.properties
Client->>CreateChatReq: Set enableCard (optional)
UserAgentInterceptor->>VersionUtils: getVersion()
VersionUtils->>version.properties: Load sdk.version
VersionUtils-->>UserAgentInterceptor: Return version string
UserAgentInterceptor-->>Client: Set User-Agent header with version
Possibly related PRs
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)
⏰ Context from checks skipped due to timeout of 90000ms (7)
✨ 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.
Actionable comments posted: 2
🧹 Nitpick comments (3)
api/src/main/resources/version.properties (1)
1-1: Terminate file with a newline to avoid toolchain warningsSome build tools and POSIX-compliant utilities expect text files to end with a trailing newline.
Consider adding one to avoid git diff noise and potential linter complaints.sdk.version=${project.version} +api/src/main/java/com/coze/openapi/service/utils/VersionUtils.java (1)
6-8: Declare the utility classfinaland hide the public constructorUtility classes should be non-instantiable. Declaring the class
finaland adding a private constructor communicates intent and prevents accidental subclassing/instantiation.-public class VersionUtils { +public final class VersionUtils { + + private VersionUtils() { + // no-op – prevents instantiation + }api/src/main/java/com/coze/openapi/client/chat/CreateChatReq.java (1)
80-85: ClarifyenableCardsemantics and default value
Booleanallows three states (true,false,null).
Ifnullis meaningful (e.g. “use server default”), add a javadoc note; otherwise prefer the primitivebooleanwith a sensible default to avoid NPEs in downstream logic.- @JsonProperty("enable_card") - private Boolean enableCard; + /** + * If {@code true}, responses may contain card-type content. + * {@code null} delegates to the server default. + */ + @JsonProperty("enable_card") + private Boolean enableCard; // consider `boolean` with default = false
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
api/pom.xml(2 hunks)api/src/main/java/com/coze/openapi/client/chat/CreateChatReq.java(1 hunks)api/src/main/java/com/coze/openapi/service/utils/UserAgentInterceptor.java(1 hunks)api/src/main/java/com/coze/openapi/service/utils/VersionUtils.java(1 hunks)api/src/main/resources/version.properties(1 hunks)example/pom.xml(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
api/src/main/java/com/coze/openapi/service/utils/UserAgentInterceptor.java (1)
api/src/main/java/com/coze/openapi/service/utils/VersionUtils.java (1)
VersionUtils(6-26)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: test (Java 17 on Windows)
- GitHub Check: test (Java 17 on macOS)
- GitHub Check: test (Java 8 on macOS)
- GitHub Check: test (Java 17 on Ubuntu)
- GitHub Check: test (Java 11 on Ubuntu)
- GitHub Check: test (Java 11 on Windows)
- GitHub Check: test (Java 11 on macOS)
🔇 Additional comments (2)
example/pom.xml (1)
19-19: Dependency version bump looks correctThe example module now aligns with the API artefact
0.3.3. No further action needed.api/src/main/java/com/coze/openapi/service/utils/UserAgentInterceptor.java (1)
27-27: LGTM! Excellent refactoring to centralize version management.Replacing the hardcoded version string with
VersionUtils.getVersion()is a significant improvement that:
- Eliminates manual version updates across multiple files
- Centralizes version management through the properties file approach
- Maintains proper error handling with fallback to "unknown" if the properties file is unavailable
This change aligns well with the overall architectural improvement described in the PR.
- 在 pom.xml 中添加 version.properties 文件的包含规则 - 在 VersionUtils 类中增加日志记录功能 - 优化版本信息读取逻辑,处理读取异常情况
api/src/main/java/com/coze/openapi/service/utils/VersionUtils.java
Outdated
Show resolved
Hide resolved
|
@chyroc 你好,这个可以帮忙发一个release吗? |
|
好了 |
|
谢谢 |
Support enable_card for CreateChatReq #106