Skip to content

feat: Support enable_card for v3/chat#107

Merged
chyroc merged 4 commits intocoze-dev:mainfrom
ShalMing:feature
Jun 27, 2025
Merged

feat: Support enable_card for v3/chat#107
chyroc merged 4 commits intocoze-dev:mainfrom
ShalMing:feature

Conversation

@ShalMing
Copy link
Copy Markdown
Contributor

Support enable_card for CreateChatReq #106

ShalMing added 2 commits June 26, 2025 19:54
- 在 api/pom.xml 中将版本号从 0.3.2 修改为 0.3.3
- 新增 version.properties 文件,用于存储版本号
- 新增 VersionUtils 工具类,用于动态获取版本号
- 在 UserAgentInterceptor 中使用 VersionUtils 替代硬编码版本号
- 更新 example/pom.xml 中的 coze-api 依赖版本为 0.3.3
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 26, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jun 26, 2025

Walkthrough

The 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

File(s) Change Summary
api/pom.xml, example/pom.xml Incremented project and dependency version from 0.3.2 to 0.3.3; enabled resource filtering in api/pom.xml.
api/src/main/resources/version.properties Added new properties file exposing the SDK version as ${project.version}.
api/src/main/java/com/coze/openapi/service/utils/VersionUtils.java Added new utility class to load and provide the SDK version from version.properties.
api/src/main/java/com/coze/openapi/service/utils/UserAgentInterceptor.java Changed version field to use VersionUtils.getVersion() instead of a hardcoded string.
api/src/main/java/com/coze/openapi/client/chat/CreateChatReq.java Added new Boolean field enableCard with JSON property enable_card.

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
Loading

Possibly related PRs

Suggested labels

chore

Poem

A hop and a skip, a version anew,
Now 0.3.3 shines in full view!
With cards enabled and versions read,
From properties files, the SDK is fed.
The rabbit approves this clever tweak—
May your builds be smooth, and your code unique!
🐇✨


📜 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 fd235ff and 1e6d2b8.

📒 Files selected for processing (1)
  • api/src/main/java/com/coze/openapi/service/utils/VersionUtils.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • api/src/main/java/com/coze/openapi/service/utils/VersionUtils.java
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test (Java 17 on Windows)
  • GitHub Check: test (Java 17 on Ubuntu)
  • GitHub Check: test (Java 11 on Windows)
  • GitHub Check: test (Java 17 on macOS)
  • GitHub Check: test (Java 8 on macOS)
  • GitHub Check: test (Java 11 on macOS)
  • GitHub Check: test (Java 11 on Ubuntu)
✨ 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.

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: 2

🧹 Nitpick comments (3)
api/src/main/resources/version.properties (1)

1-1: Terminate file with a newline to avoid toolchain warnings

Some 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 class final and hide the public constructor

Utility classes should be non-instantiable. Declaring the class final and 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: Clarify enableCard semantics and default value

Boolean allows three states (true, false, null).
If null is meaningful (e.g. “use server default”), add a javadoc note; otherwise prefer the primitive boolean with 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

📥 Commits

Reviewing files that changed from the base of the PR and between b7e89b9 and b61a174.

📒 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 correct

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

@ShalMing ShalMing closed this Jun 26, 2025
@ShalMing ShalMing deleted the feature branch June 26, 2025 12:41
@ShalMing ShalMing restored the feature branch June 26, 2025 12:42
@ShalMing ShalMing reopened this Jun 26, 2025
- 在 pom.xml 中添加 version.properties 文件的包含规则
- 在 VersionUtils 类中增加日志记录功能
- 优化版本信息读取逻辑,处理读取异常情况
@chyroc chyroc added the feature label Jun 27, 2025
@chyroc chyroc changed the title feat: Support enable_card for CreateChatReq feat: Support enable_card for v3/chat Jun 27, 2025
@chyroc chyroc merged commit b243e69 into coze-dev:main Jun 27, 2025
12 checks passed
@ShalMing
Copy link
Copy Markdown
Contributor Author

ShalMing commented Jun 30, 2025

@chyroc 你好,这个可以帮忙发一个release吗?

@chyroc
Copy link
Copy Markdown
Contributor

chyroc commented Jun 30, 2025

好了

@ShalMing
Copy link
Copy Markdown
Contributor Author

谢谢

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