Skip to content

fix: Fix folder hierarchy restrictions and add AI models#214

Merged
hexqi merged 98 commits intoopentiny:developfrom
lu-yg:develop
May 7, 2025
Merged

fix: Fix folder hierarchy restrictions and add AI models#214
hexqi merged 98 commits intoopentiny:developfrom
lu-yg:develop

Conversation

@lu-yg
Copy link
Collaborator

@lu-yg lu-yg commented May 7, 2025

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added support for the DEEPSEEK_V3 AI chat model, including configuration and integration options.
  • Bug Fixes

    • Prevented potential errors when accessing the home page property if it is null.
  • Improvements

    • Removed the restriction on maximum page depth, allowing for deeper page hierarchies.
    • Enhanced AI parameter handling by introducing a dedicated model field for improved data management.

lu-yg and others added 30 commits December 26, 2024 00:15
@coderabbitai
Copy link

coderabbitai bot commented May 7, 2025

Walkthrough

A new AI model, DEEPSEEK_V3, has been integrated across the codebase, including its enumeration, configuration, and DTO handling. The depth restriction in the page service has been removed, and a null check was added to prevent exceptions in the app service. No changes were made to method signatures.

Changes

File(s) Change Summary
.../common/enums/Enums.java Added DEEPSEEK_V3 constant to the FoundationModel enum.
.../config/AiChatConfig.java Introduced DEEPSEEK_V3_URL and extended getAiChatConfig to support DEEPSEEK_V3 with specific headers and config.
.../model/dto/AiParam.java Added private model field and initialized it in the constructor from the foundationModel map.
.../service/app/impl/PageServiceImpl.java Removed the maximum depth restriction in the getDepth method; now always returns success with the current depth.
.../service/app/impl/v1/AppV1ServiceImpl.java Added a null check before accessing app.getHomePage() in getSchemaComponentsTree to prevent NullPointerException.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant AiParam
    participant AiChatConfig
    participant FoundationModel

    Client->>FoundationModel: Select DEEPSEEK_V3
    Client->>AiParam: Construct with foundationModel map
    AiParam->>AiParam: Extract and set model field
    Client->>AiChatConfig: getAiChatConfig("DEEPSEEK_V3", token)
    AiChatConfig->>AiChatConfig: Set DeepSeek headers and URL
    AiChatConfig-->>Client: Return config for DEEPSEEK_V3
Loading

Poem

In the warren of code, a new model appears,
DEEPSEEK_V3 hops in, greeted with cheers!
No more depth limits to stifle our quest,
And null checks ensure the code runs its best.
With every new feature, we leap and we bound—
Hopping forward, where improvements are found! 🐇✨

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

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

@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 (2)
base/src/main/java/com/tinyengine/it/model/dto/AiParam.java (1)

34-34: Consider adding null check for model initialization

While the code works correctly, consider adding a null check when retrieving the "model" key from the foundationModel map to prevent potential NullPointerExceptions.

-this.model = foundationModel.get("model");
+this.model = foundationModel != null ? foundationModel.get("model") : null;
base/src/main/java/com/tinyengine/it/config/AiChatConfig.java (1)

54-54: Remove unnecessary empty line.

There's an extra empty line that appears to be unnecessary and inconsistent with the spacing pattern in the rest of the file.

52        Map<String, String> ernieBotHeaders = new HashMap<>();
53
-
55        config.put(Enums.FoundationModel.GPT_35_TURBO.getValue(), new AiChatConfigData(
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46d6cc1 and 15c6e8f.

📒 Files selected for processing (5)
  • base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/config/AiChatConfig.java (2 hunks)
  • base/src/main/java/com/tinyengine/it/model/dto/AiParam.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
base/src/main/java/com/tinyengine/it/config/AiChatConfig.java (1)
base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1)
  • Enums (20-911)
🔇 Additional comments (7)
base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java (1)

470-472: Good defensive programming with null check

Adding this null check is a good practice to prevent NullPointerExceptions when app.getHomePage() is null. This improves the robustness of the code.

base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1)

797-801: DEEPSEEK_V3 model addition looks good

The new AI model enum value is properly added with appropriate documentation and follows the existing pattern.

base/src/main/java/com/tinyengine/it/model/dto/AiParam.java (1)

29-29: New model field looks good

This field will store the foundation model identifier.

base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java (1)

448-448:

Details

❓ Verification inconclusive

Removed depth limit restriction

The depth limit check has been removed, allowing unlimited folder nesting depth. However, note that there's still a depth limit check in the getTreeNodes method at line 719 that throws an exception if level > 5. Consider whether this inconsistency is intentional or if both methods should have the same depth limit behavior.


🏁 Script executed:

#!/bin/bash
# Check for other depth limit checks in the codebase
rg -A 2 "Exceeded depth" --type java

Length of output: 666


Inconsistent depth limit enforcement in PageServiceImpl

The method at line 448 now returns unlimited depth (Result.success(depth)), whereas getTreeNodes (around line 719) still throws a ServiceException("Exceeded depth") when depth > 5 (and is covered by PageServiceImplTest). Please confirm the intended behavior and either:

  • Restore a consistent depth check in the first method, or
  • Remove/adjust the limit in getTreeNodes (and update its tests) if unlimited nesting is desired.

Locations to review:

  • base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java
    • Line 448: unlimited return
    • Line 719: throws on > 5
  • base/src/test/java/com/tinyengine/it/service/app/impl/PageServiceImplTest.java
    • Assertion for “Exceeded depth”
base/src/main/java/com/tinyengine/it/config/AiChatConfig.java (3)

28-28: API URL for DEEPSEEK_V3 model added correctly.

The constant follows the established naming convention and provides the base URL for the DeepSeek API.


48-50: Authentication headers for DEEPSEEK_V3 model implemented correctly.

The implementation follows the same pattern as other AI models, correctly setting up the authorization header with the API key when the DEEPSEEK_V3 model is selected.


61-62: Configuration for DEEPSEEK_V3 model added correctly.

The configuration correctly maps the DEEPSEEK_V3 model to its API endpoint, using the appropriate headers and manufacturer name. Note that the endpoint path differs slightly from other models ("/chat/completions" vs "/v1/chat/completions"), which appears to be specific to the DeepSeek API.

@hexqi hexqi merged commit 83bc77f into opentiny:develop May 7, 2025
1 check passed
lu-yg added a commit to lu-yg/tiny-engine-backend-java that referenced this pull request Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants