Skip to content

fix(wren-ai-service): fix global instructions indexing issue#1480

Merged
cyyeh merged 2 commits intomainfrom
fix/ai-service/instructions-indexing
Mar 28, 2025
Merged

fix(wren-ai-service): fix global instructions indexing issue#1480
cyyeh merged 2 commits intomainfrom
fix/ai-service/instructions-indexing

Conversation

@cyyeh
Copy link
Copy Markdown
Member

@cyyeh cyyeh commented Mar 28, 2025

Summary by CodeRabbit

  • Refactor
    • Enhanced the handling of instructions so that global guidelines now display a clear default message, while custom guidance is presented individually.
    • Streamlined the process for compiling instructions to ensure a more organized and consistent experience for users.

@cyyeh cyyeh added module/ai-service ai-service related ci/ai-service ai-service related labels Mar 28, 2025
@cyyeh cyyeh requested a review from wwwy3y3 March 28, 2025 02:48
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 28, 2025

Walkthrough

The changes update how instruction objects are processed. In the indexing pipeline, a print statement now logs the instructions parameter, and the document content is conditionally set based on whether the instruction is marked as default. In the web service, the logic for constructing instruction objects is refactored from a list comprehension to an explicit loop that distinguishes between default instructions (which receive an empty question) and non-default instructions (which use the provided questions). The error handling and public entity declarations remain unchanged.

Changes

File Path Change Summary
wren-ai-service/src/pipelines/.../instructions.py Added a print statement to log the instructions parameter. Modified the content assignment to conditionally use a default message for default instructions.
wren-ai-service/src/web/v1/services/instructions.py Refactored the index method to replace a list comprehension with an explicit loop that handles default instructions differently by creating a single instruction with an empty question, while iterating over questions for non-default instructions.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant InstructionsService
    participant InstructionsConverter
    participant Pipeline

    Client->>InstructionsService: Send request with instructions data
    InstructionsService->>InstructionsService: Parse request and loop through instructions
    alt Instruction is default
        InstructionsService->>InstructionsService: Create Instruction (empty question)
    else Instruction is non-default
        InstructionsService->>InstructionsService: Iterate each question, create Instruction
    end
    InstructionsService->>InstructionsConverter: Pass instructions for conversion
    InstructionsConverter->>Console: Log instructions parameter
    InstructionsConverter->>InstructionsConverter: Build addition dictionary
    alt Instruction is default
        InstructionsConverter->>InstructionsConverter: Set content to default message
    else Instruction is non-default
        InstructionsConverter->>InstructionsConverter: Set content from instruction.question
    end
    InstructionsConverter-->>Pipeline: Return Document
    Pipeline->>InstructionsService: Continue processing
Loading

Poem

I'm a hopping rabbit, quick on my feet,
Logging my steps so the code's complete.
Default instructions get a special note,
While non-default ones get the full quote.
Loops now dance in the service light,
Carrot-fueled fixes making everything right.
A joyful hop from my bunny byte!


📜 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 e001d49 and 9c3f63b.

📒 Files selected for processing (1)
  • wren-ai-service/src/pipelines/indexing/instructions.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • wren-ai-service/src/pipelines/indexing/instructions.py
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pytest
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)

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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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
Copy Markdown
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: 0

🧹 Nitpick comments (1)
wren-ai-service/src/pipelines/indexing/instructions.py (1)

36-36: Replace print statement with proper logger call.

Using print statements in production code is generally discouraged. Consider replacing this with a proper logging statement using the already defined logger.

-        print(f"instructions: {instructions}")
+        logger.debug(f"instructions: {instructions}")
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ccf8db7 and e001d49.

📒 Files selected for processing (2)
  • wren-ai-service/src/pipelines/indexing/instructions.py (2 hunks)
  • wren-ai-service/src/web/v1/services/instructions.py (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
wren-ai-service/src/web/v1/services/instructions.py (1)
wren-ai-service/src/pipelines/indexing/instructions.py (1)
  • Instruction (20-25)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pytest
  • GitHub Check: pytest
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
wren-ai-service/src/pipelines/indexing/instructions.py (1)

48-50: LGTM! Correctly handles default instructions.

This change properly distinguishes between default and non-default instructions when setting the content field. For default instructions, a clear message is used instead of an empty question string, which improves clarity and searchability.

wren-ai-service/src/web/v1/services/instructions.py (1)

77-97: LGTM! Fix correctly handles global instruction indexing.

This change properly fixes the global instructions indexing issue by:

  1. Creating a single instruction object with an empty question for default instructions
  2. Creating separate instruction objects for each question for non-default instructions

The explicit conditional approach is cleaner and more maintainable than the previous list comprehension, making the distinction between instruction types clear.

@cyyeh cyyeh merged commit adce12b into main Mar 28, 2025
11 checks passed
@cyyeh cyyeh deleted the fix/ai-service/instructions-indexing branch March 28, 2025 03:26
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.

3 participants