Skip to content

chore(wren-ai-service): minor updates #1843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2025
Merged

Conversation

cyyeh
Copy link
Member

@cyyeh cyyeh commented Jul 21, 2025

Summary by CodeRabbit

  • Refactor

    • Updated several request models to inherit from a new base request type and removed certain optional fields from these models.
    • Added a new boolean field to the question recommendation request model.
    • Adjusted default values for specific fields in request models.
  • Documentation

    • Removed detailed module-level docstrings and explanatory comments from multiple API routers. Endpoints and usage remain unchanged.

@cyyeh cyyeh requested a review from yichieh-lu July 21, 2025 01:57
@cyyeh cyyeh added module/ai-service ai-service related ci/ai-service ai-service related labels Jul 21, 2025
Copy link
Contributor

coderabbitai bot commented Jul 21, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This change removes detailed module-level docstrings from multiple API router modules and updates several request model classes to inherit from BaseRequest instead of BaseModel. Additionally, various request models have fields such as project_id and configuration removed, and some new fields are introduced or modified.

Changes

Files/Paths Change Summary
.../routers/ask.py, .../routers/semantics_preparation.py, .../routers/sql_answers.py, .../routers/sql_question.py Removed comprehensive module-level docstrings describing endpoints, requests, and responses. No code logic changed.
.../routers/instructions.py, .../routers/sql_pairs.py Removed docstrings. Changed PostRequest and DeleteRequest to inherit from BaseRequest instead of BaseModel. Removed project_id field.
.../routers/question_recommendation.py, .../routers/relationship_recommendation.py, .../routers/semantics_description.py Removed docstrings. Changed PostRequest to inherit from BaseRequest instead of BaseModel. Removed project_id and configuration fields. Added/modified fields as noted.
.../routers/sql_corrections.py Removed docstring. Changed PostRequest to inherit from BaseRequest instead of BaseModel. Removed project_id field.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API_Router
    participant RequestModel

    Client->>API_Router: Sends POST/DELETE request
    API_Router->>RequestModel: Instantiates BaseRequest-based model
    RequestModel-->>API_Router: Validated request (no project_id/configuration fields)
    API_Router-->>Client: Processes and responds
Loading

Possibly related PRs

Suggested reviewers

  • imAsterSun

Poem

A bunny with code in its paws,
Hopped through routers, fixing flaws.
Out went the docs, so long and deep,
And models got lighter, a promise to keep.
With BaseRequest now leading the way,
The code is much simpler—hip hip hooray!
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4984721 and 23c3220.

📒 Files selected for processing (1)
  • wren-ai-service/src/web/v1/routers/relationship_recommendation.py (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/ai-service/minor-updates

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 generate unit tests to generate unit tests 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.

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
Contributor

@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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between adf7975 and 4984721.

📒 Files selected for processing (10)
  • wren-ai-service/src/web/v1/routers/ask.py (0 hunks)
  • wren-ai-service/src/web/v1/routers/instructions.py (2 hunks)
  • wren-ai-service/src/web/v1/routers/question_recommendation.py (1 hunks)
  • wren-ai-service/src/web/v1/routers/relationship_recommendation.py (1 hunks)
  • wren-ai-service/src/web/v1/routers/semantics_description.py (1 hunks)
  • wren-ai-service/src/web/v1/routers/semantics_preparation.py (0 hunks)
  • wren-ai-service/src/web/v1/routers/sql_answers.py (0 hunks)
  • wren-ai-service/src/web/v1/routers/sql_corrections.py (1 hunks)
  • wren-ai-service/src/web/v1/routers/sql_pairs.py (2 hunks)
  • wren-ai-service/src/web/v1/routers/sql_question.py (0 hunks)
💤 Files with no reviewable changes (4)
  • wren-ai-service/src/web/v1/routers/semantics_preparation.py
  • wren-ai-service/src/web/v1/routers/sql_answers.py
  • wren-ai-service/src/web/v1/routers/sql_question.py
  • wren-ai-service/src/web/v1/routers/ask.py
🧰 Additional context used
🧠 Learnings (6)
wren-ai-service/src/web/v1/routers/relationship_recommendation.py (1)
Learnt from: cyyeh
PR: Canner/WrenAI#1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/web/v1/routers/sql_corrections.py (2)
Learnt from: cyyeh
PR: Canner/WrenAI#1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
Learnt from: cyyeh
PR: Canner/WrenAI#1112
File: wren-ai-service/src/web/v1/services/sql_question.py:17-28
Timestamp: 2025-01-14T07:45:32.410Z
Learning: In the SqlQuestionRequest model (Python/FastAPI), the query_id field is implemented using a protected _query_id attribute with getter/setter properties, rather than a direct field, as per the team's preference.
wren-ai-service/src/web/v1/routers/instructions.py (3)
Learnt from: onlyjackfrost
PR: Canner/WrenAI#1392
File: wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts:477-494
Timestamp: 2025-03-12T09:51:33.688Z
Learning: The instruction deletion API in the WrenAI service handles bulk deletion atomically - either all instructions are deleted or none are. There's no need for handling partial deletion scenarios.
Learnt from: paopa
PR: Canner/WrenAI#1376
File: wren-ai-service/src/pipelines/indexing/instructions.py:100-107
Timestamp: 2025-03-13T03:48:24.664Z
Learning: The `InstructionsCleaner.run()` method in the instructions indexing pipeline only accepts `instruction_ids` and `project_id` parameters, and doesn't support a `delete_all` parameter for unconditional deletion.
Learnt from: onlyjackfrost
PR: Canner/WrenAI#1392
File: wren-ui/src/apollo/server/services/instructionService.ts:107-146
Timestamp: 2025-03-17T09:16:53.878Z
Learning: In the WrenAI project, the instructionResolver merges the instruction ID (from args.where) and project ID (from the current project context) with instruction data before passing to the instructionService, allowing the GraphQL schema to have separate input types while the service layer works with complete objects.
wren-ai-service/src/web/v1/routers/semantics_description.py (1)
Learnt from: cyyeh
PR: Canner/WrenAI#1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/web/v1/routers/sql_pairs.py (2)
Learnt from: cyyeh
PR: Canner/WrenAI#1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
Learnt from: cyyeh
PR: Canner/WrenAI#1112
File: wren-ai-service/src/web/v1/routers/sql_question.py:59-66
Timestamp: 2025-01-14T07:45:11.981Z
Learning: In the WrenAI codebase, UUID validation for query IDs in API endpoints is not required, as demonstrated in the SQL question router's GET endpoint.
wren-ai-service/src/web/v1/routers/question_recommendation.py (1)
Learnt from: cyyeh
PR: Canner/WrenAI#1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
🧬 Code Graph Analysis (1)
wren-ai-service/src/web/v1/routers/instructions.py (2)
wren-ai-service/src/web/v1/services/__init__.py (1)
  • BaseRequest (47-63)
wren-ai-service/src/web/v1/services/instructions.py (2)
  • InstructionsService (16-176)
  • DeleteRequest (123-125)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: pytest
  • GitHub Check: pytest
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (19)
wren-ai-service/src/web/v1/routers/instructions.py (5)

14-14: LGTM! Import updated correctly for BaseRequest inheritance.

The import change properly supports the refactoring to use BaseRequest as the base class for request models.


19-21: LGTM! Proper inheritance from BaseRequest.

Inheriting from BaseRequest provides access to common fields like project_id, configurations, and thread_id while maintaining the specific instructions field. This standardizes the request model and eliminates code duplication.


50-52: LGTM! Consistent inheritance from BaseRequest.

The DeleteRequest class correctly inherits from BaseRequest, providing access to common fields like project_id which is essential for properly scoping instruction deletions. This maintains consistency with the PostRequest refactoring.


38-40: Endpoint logic works correctly with BaseRequest inheritance.

The use of **request.model_dump() properly includes all fields from the BaseRequest base class when creating the InstructionsService.IndexRequest. This ensures fields like project_id and configurations are passed to the service layer.


65-68: Delete endpoint logic maintains consistency.

The delete endpoint correctly uses the same **request.model_dump() pattern to include all BaseRequest fields when creating the service request. This ensures proper project scoping for instruction deletions.

wren-ai-service/src/web/v1/routers/sql_corrections.py (3)

14-14: LGTM: Import statement properly updated for BaseRequest.

The addition of BaseRequest to the import statement aligns with the class inheritance change below.


19-19: LGTM: Class inheritance change aligns with codebase refactoring.

The change from BaseModel to BaseRequest is consistent with the broader refactoring effort mentioned in the summary across multiple router modules. This standardization improves consistency across the API.


42-44: No action needed: BaseRequest still provides model_dump()

BaseRequest inherits from Pydantic’s BaseModel (see wren-ai-service/src/web/v1/services/init.py), so model_dump() remains available on all subclasses, including PostRequest.

wren-ai-service/src/web/v1/routers/question_recommendation.py (4)

14-14: LGTM! Import updated to support class inheritance change.

The import change from Configuration to BaseRequest aligns with the updated PostRequest class inheritance and removes unused imports.


21-21: Good field improvements for request flexibility.

The default empty list for previous_questions and the new allow_data_preview boolean field with default True improve the API's usability by making these parameters optional with sensible defaults.

Also applies to: 25-25


18-18: Documentation cleanup aligns with broader standardization effort.

The removal of the module-level docstring is consistent with the broader documentation standardization across router modules mentioned in the AI summary.


19-19: Confirm BaseRequest Handles All Required Fields

Verified that BaseRequest (in wren-ai-service/src/web/v1/services/__init__.py) already declares and manages the following, covering the previously removed fields:

  • project_id: Optional[str]
  • configurations: Configuration (alias supports both configuration and configurations)
  • thread_id: Optional[str]
  • _query_id with corresponding query_id property

No further action required—this refactoring correctly centralizes common request parameters. Changes approved.

wren-ai-service/src/web/v1/routers/semantics_description.py (2)

14-14: LGTM! Import standardization aligns with refactoring effort.

The change from importing Configuration to BaseRequest is consistent with the broader refactoring effort to standardize request models across router modules.


19-19: BaseRequest already includes project_id and configurations.

The BaseRequest class in src/web/v1/services/__init__.py defines both project_id: Optional[str] and configurations: Configuration, so your PostRequest(BaseRequest) inherits the necessary fields. No further changes needed.

wren-ai-service/src/web/v1/routers/sql_pairs.py (3)

15-15: Import change supports the refactoring correctly.

The addition of BaseRequest to the import statement is appropriate and necessary for the inheritance changes in the request models.


49-50: Inheritance change is consistent with PostRequest.

The change from BaseModel to BaseRequest maintains consistency with the PostRequest class and supports the codebase standardization effort.


20-21: BaseRequest correctly inherits from Pydantic BaseModel

Verified that BaseRequest is defined as class BaseRequest(BaseModel) and includes all required fields and methods (e.g., model_dump), so PostRequest(BaseRequest) retains full Pydantic validation/serialization. No further changes needed.

wren-ai-service/src/web/v1/routers/relationship_recommendation.py (2)

14-14: Import change looks good for the refactoring.

The switch from importing Configuration to BaseRequest aligns with the standardization effort across router modules.


44-46: Verify field access matches the updated request model.

The endpoint is accessing request.project_id and request.configuration, but these fields were removed from PostRequest. If BaseRequest provides these fields, this should work correctly, but it needs verification.

@cyyeh cyyeh merged commit 3489daf into main Jul 21, 2025
9 of 10 checks passed
@cyyeh cyyeh deleted the chore/ai-service/minor-updates branch July 21, 2025 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/ai-service ai-service related module/ai-service ai-service related wren-ai-service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants