Skip to content

chore(wren-ai-service): improve sql pairs and instructions#1422

Merged
paopa merged 8 commits into
mainfrom
chore/ai-service/improve-instructions
Mar 18, 2025
Merged

chore(wren-ai-service): improve sql pairs and instructions#1422
paopa merged 8 commits into
mainfrom
chore/ai-service/improve-instructions

Conversation

@cyyeh
Copy link
Copy Markdown
Member

@cyyeh cyyeh commented Mar 18, 2025

Summary by CodeRabbit

  • New Features

    • SQL prompts now support optional instructions and sample sections, enriching the context for generated responses.
  • Refactor

    • Enhanced the clarity of query history displays by explicitly labeling questions and SQL segments.
    • Optimized asynchronous processing for more efficient, concurrent operations.
  • Chores

    • Removed legacy SQL explanation and regeneration services to streamline the experience.

These updates deliver a clearer, more informative SQL generation experience with improved responsiveness.

@cyyeh cyyeh added ci/ai-service ai-service related wren-ai-service labels Mar 18, 2025
@cyyeh cyyeh requested a review from paopa March 18, 2025 07:26
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 18, 2025

Walkthrough

The changes update multiple modules in the AI service pipeline. In the generation pipelines, the prompt and run functions now accept an optional instructions parameter and revised templates to improve clarity of user query history. The web service for asking queries has been modified to execute SQL sample and instructions retrieval concurrently using asyncio. Additionally, minor code reformatting was applied in the SQL generation reasoning, and services handling SQL explanation and SQL regeneration have been removed.

Changes

Files Change Summary
wren-ai-service/.../followup_sql_generation_reasoning.py, wren-ai-service/.../intent_classification.py Updated prompt and run signatures to include an instructions parameter (and sql_samples for intent classification), with modified templates and query history formatting.
wren-ai-service/.../sql_generation_reasoning.py, wren-ai-service/.../sql_generation.py, wren-ai-service/.../followup_sql_generation.py Changed parameter type annotations from List to built-in list types for improved clarity and modern syntax.
wren-ai-service/.../ask.py Introduced an instructions variable and modified control flow to execute SQL samples and instructions pipelines concurrently via asyncio.gather.
wren-ai-service/.../sql_explanation.py, wren-ai-service/.../sql_regeneration.py Removed entire services along with their data models and methods for SQL explanation and regeneration.
wren-ai-service/.../utils/sql.py Updated type annotations for sql_samples and instructions in construct_instructions function for enhanced type safety.
wren-ai-service/tests/pytest/services/test_ask.py Added new components to the ask_service fixture for SQL pairs and instructions retrieval, enhancing testing capabilities.
wren-ai-service/tests/pytest/services/mocks.py Introduced new mock classes for SQL pairs and instructions retrieval to facilitate testing.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant AskService
    participant SQLPipeline as "SQL Samples Pipeline"
    participant InstructionPipeline as "Instructions Pipeline"
    participant IntentClassification
    
    Client->>AskService: Send query request
    AskService->>SQLPipeline: Retrieve SQL samples (async)
    AskService->>InstructionPipeline: Retrieve instructions (async)
    SQLPipeline-->>AskService: Return SQL samples
    InstructionPipeline-->>AskService: Return instructions
    AskService->>IntentClassification: Process query with samples & instructions
    IntentClassification-->>AskService: Return classification result
    AskService-->>Client: Return aggregated response
Loading

Possibly related PRs

  • chore(wren-ai-service): minor update #1210: The changes in the main PR are related to those in the retrieved PR as both involve modifications to the construct_instructions function, specifically regarding the handling of the instructions parameter and its type annotations.
  • chore(wren-ai-service): minor updates #1389: The changes in the main PR are related to those in the retrieved PR as both involve modifications to the handling of instructions and sql_samples parameters in function signatures, indicating a shared focus on enhancing the SQL generation and intent classification functionalities.
  • feat(wren-ai-service): Implement Chat History Management with Max History Limit #1377: The changes in the main PR are related to those in the retrieved PR as both involve modifications to the handling of histories and the introduction of new parameters in the prompt and run functions, specifically regarding the instructions parameter.

Poem

I’m a rabbit, hopping through lines of code,
With fresh instructions lighting up my road.
SQL queries dance like carrots in a row,
Concurrency makes my little heart glow.
Code changes bloom—oh, what a joyful show!
🐇 Hop on, CodeRabbit sings as we go!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

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

🧹 Nitpick comments (9)
wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py (2)

130-132: Consider extracting the queue creation logic into a helper.

These lines are duplicated in _streaming_callback and get_streaming_results. A small helper function (e.g., _ensure_user_queue) would improve maintainability by eliminating redundant code.


143-145: Duplicate queue creation logic here as well.

Similar to lines 130-132, this block reimplements the queue creation. Consider the same helper approach to keep the code DRY and easier to maintain.

wren-ai-service/src/web/v1/services/ask.py (4)

214-214: Avoid hardcoding an empty list if instructions are not given.

You might default to an empty list in function parameters or handle it when passing arguments downstream. This ensures clarity about how "instructions" are set and reduces confusion in future refactoring.


267-272: Double-check assumptions about task outputs.

Here you map sql_samples_task["formatted_output"] and instructions_task["formatted_output"] to local variables. If the tasks return unexpected keys or structures, this may raise KeyError or TypeError. Consider validating the data shape before using it.


274-275: Consider logging or tracing the intent classification parameter.

When self._allow_intent_classification is True, we proceed to intent classification. Logging a message here (e.g. “intent classification started”) could help debug production issues if classification is unexpectedly skipped or triggered.


405-405: Check compatibility of instructions in sql_generation.

Similar to line 394, you’re passing instructions into sql_generation. Confirm that the pipeline handles or validates these instructions (e.g., logs them, ensures they are not empty).

wren-ai-service/src/pipelines/generation/intent_classification.py (1)

114-119: Document or validate the nature of instructions.

The template loops over each instruction and prints it. Make sure these instructions are consistently typed as strings and that no further structure is expected.

wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py (2)

53-58: New instructions section added to template

The addition of a conditional instructions section enhances the template's flexibility. This allows for dynamic behavior based on whether instructions are provided.

Consider adding code comments or documentation about what kind of instructions are expected and how they will be used in the reasoning process. This would help future developers understand the expected format and purpose of these instructions.


201-210: Consider updating dry_run_pipeline call

The dry_run_pipeline call doesn't include the new instructions parameter. While this won't cause issues since it's optional, consider updating it for consistency and testing purposes.

 dry_run_pipeline(
     FollowUpSQLGenerationReasoning,
     "followup_sql_generation_reasoning",
     query="this is a test query",
     histories=[],
     contexts=[],
+    instructions=["Sample instruction"],
 )
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4d4792e and ff12c46.

📒 Files selected for processing (6)
  • wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py (5 hunks)
  • wren-ai-service/src/pipelines/generation/intent_classification.py (4 hunks)
  • wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py (2 hunks)
  • wren-ai-service/src/web/v1/services/ask.py (4 hunks)
  • wren-ai-service/src/web/v1/services/sql_explanation.py (0 hunks)
  • wren-ai-service/src/web/v1/services/sql_regeneration.py (0 hunks)
💤 Files with no reviewable changes (2)
  • wren-ai-service/src/web/v1/services/sql_explanation.py
  • wren-ai-service/src/web/v1/services/sql_regeneration.py
⏰ 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 (9)
wren-ai-service/src/web/v1/services/ask.py (3)

253-255: Validate concurrent tasks more robustly.

You call asyncio.gather to fetch sql_pairs_retrieval and instructions_retrieval simultaneously. If one task fails, the entire call may raise an exception, masking partial results. Consider adding return_exceptions=True or explicit error handling blocks to gracefully degrade if one retrieval fails.

Also applies to: 256-263


280-281: Passing new parameters to intent classification.

These two lines effectively ensure sql_samples and instructions are provided to the pipeline. Confirm that downstream usage in intent_classification matches the expected format (e.g., list of dict vs list of strings) to avoid runtime confusion.


394-394: Maintain consistency when passing instructions.

Providing instructions=instructions in the follow-up call is a good step toward consistent usage. However, ensure all callers of this pipeline also handle instructions consistently (e.g., default empty list vs None).

wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py (6)

50-51: Proper formatting in SQL samples section

The code properly closes the iteration and conditional block for SQL samples, maintaining consistent template structure.


60-66: Improved query history section

Renaming from "CONTEXT" to "User's QUERY HISTORY" and reformatting with explicit "Question:" and "SQL:" labels improves clarity for both the LLM and developers.


84-84: Added instructions parameter to prompt function

The function signature has been properly updated to include the new instructions parameter.


93-93: Instructions parameter passed to prompt builder

The instructions parameter is correctly passed to the prompt_builder.run() function, ensuring it's incorporated into the generated prompt.


181-181: Added optional instructions parameter to run method

The run method signature has been appropriately updated to accept an optional instructions parameter, maintaining backward compatibility.


193-193: Instructions parameter handled in execute inputs

The instructions parameter is correctly handled with a default empty list when None is provided, ensuring the template can process it properly.

Comment thread wren-ai-service/src/pipelines/generation/intent_classification.py
Comment thread wren-ai-service/src/pipelines/generation/intent_classification.py Outdated
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: 1

🧹 Nitpick comments (1)
wren-ai-service/src/pipelines/generation/sql_generation.py (1)

63-64:

Details

❓ Verification inconclusive

Updated type annotations to use native Python types

Type annotations have been modernized by replacing List[str] with list[str] and List[Dict] with list[dict]. This follows Python 3.9+ best practices for type hinting.

However, there's a significant change in the instructions parameter type from List[Dict] | None to list[str] | None, which alters the expected data structure.

Also applies to: 67-69


🏁 Script executed:

#!/bin/bash
# Check if the construct_instructions function correctly handles the new instructions type
grep -r "def construct_instructions" --include="*.py" .

Length of output: 141


Verify that the updated type for instructions is intentional and compatible across the pipeline.

  • The changes replacing List[str] with list[str] (and similarly for dictionaries) follow Python 3.9+ best practices.
  • However, the modification of the instructions parameter type—from List[Dict] | None to list[str] | None—is significant. The construct_instructions function (located in wren-ai-service/src/pipelines/generation/utils/sql.py) appears to be downstream of this change.
  • Please review and confirm that construct_instructions (and any other related functionality) is correctly updated to handle a list[str] | None input rather than a list of dictionaries.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ff12c46 and a762e89.

📒 Files selected for processing (6)
  • wren-ai-service/src/pipelines/generation/followup_sql_generation.py (3 hunks)
  • wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py (6 hunks)
  • wren-ai-service/src/pipelines/generation/intent_classification.py (4 hunks)
  • wren-ai-service/src/pipelines/generation/sql_generation.py (3 hunks)
  • wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py (5 hunks)
  • wren-ai-service/src/pipelines/generation/utils/sql.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • wren-ai-service/src/pipelines/generation/followup_sql_generation.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • wren-ai-service/src/pipelines/generation/intent_classification.py
  • wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py
  • wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py
🧰 Additional context used
🧬 Code Definitions (1)
wren-ai-service/src/pipelines/generation/sql_generation.py (2)
wren-ai-service/src/web/v1/services/__init__.py (1) (1)
  • Configuration (25:45)
wren-ai-service/src/providers/__init__.py (1) (1)
  • Configuration (265:267)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: pytest
  • GitHub Check: Analyze (go)
🔇 Additional comments (4)
wren-ai-service/src/pipelines/generation/sql_generation.py (4)

3-3: Modernized import statements

The imports have been updated to use only Any and Optional from the typing module, removing List and Dict. This aligns with Python 3.9+ best practices where built-in collection types can be used directly in type annotations.


144-145: Consistent type annotation updates in the run method

The type annotations in the run method have been updated to match those in the prompt function, ensuring consistency throughout the codebase. The same change from List[Dict] | None to list[str] | None for the instructions parameter is applied here.

Also applies to: 147-149


158-165: Inputs dictionary correctly includes all parameters

The run method correctly passes all parameters to the pipeline execution, including the newly updated instructions parameter. This ensures the type changes are consistently propagated through the execution flow.


30-33:

Details

❓ Verification inconclusive

Instructions template usage matches new type

The template uses instructions directly without iteration, which aligns with the changed type from a list of dictionaries to a list of strings. However, it's not clear how multiple instructions in the list would be rendered - they would likely be concatenated or joined with newlines.


🏁 Script executed:

#!/bin/bash
# Check if there are calls to this function with instructions as list[str]
grep -r "instructions=" --include="*.py" . | grep -v "instructions=None" | grep -v "instructions=construct_instructions"

Length of output: 2971


Review Note: Verify Multiple Instructions Formatting

The template now directly outputs the instructions variable, which aligns with the change from a list of dictionaries to a list of strings, as confirmed by its consistent usage across the codebase. However, please verify that default rendering (using {{ instructions }}) meets your expectations when multiple strings are provided—even if they are simply concatenated—to ensure the output is formatted as intended. If a more user-friendly display is desired, consider iterating over each instruction or joining them with newlines.

Comment thread wren-ai-service/src/pipelines/generation/utils/sql.py Outdated
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/tests/pytest/services/test_ask.py (1)

105-156: Consider adding test coverage for the new retrieval components.

While the existing test structure remains functional with the new components, there's no specific test coverage for the sql_pairs_retrieval and instructions_retrieval functionality. Consider extending the test case to verify these new components are working as expected.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a762e89 and 806bf05.

📒 Files selected for processing (1)
  • wren-ai-service/tests/pytest/services/test_ask.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pytest
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
wren-ai-service/tests/pytest/services/test_ask.py (1)

55-60: LGTM! Good integration of new retrieval components.

The added components (sql_pairs_retrieval and instructions_retrieval) align well with the PR objectives to improve SQL pairs and instructions. The implementation correctly initializes both components with parameters from the corresponding pipe_components.

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 (2)
wren-ai-service/tests/pytest/services/mocks.py (2)

16-22: Avoid using mutable default arguments.

Using documents: list = [] can lead to unexpected side effects if the list is changed elsewhere. Prefer defaulting to None and assigning an empty list internally.

Proposed fix:

-class SqlPairsRetrievalMock(retrieval.SqlPairsRetrieval):
-    def __init__(self, documents: list = []):
-        self._documents = documents
+class SqlPairsRetrievalMock(retrieval.SqlPairsRetrieval):
+    def __init__(self, documents: Optional[list] = None):
+        if documents is None:
+            documents = []
+        self._documents = documents

24-29: Same note about mutable default arguments.

As with the SqlPairsRetrievalMock, defaulting to [] can introduce shared state issues. Use None instead.

Proposed fix:

-class InstructionsRetrievalMock(retrieval.Instructions):
-    def __init__(self, documents: list = []):
-        self._documents = documents
+class InstructionsRetrievalMock(retrieval.Instructions):
+    def __init__(self, documents: Optional[list] = None):
+        if documents is None:
+            documents = []
+        self._documents = documents
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5e7d3a6 and aebfd92.

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

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 (2)
wren-ai-service/src/web/v1/services/ask.py (1)

214-214: Add unit test coverage for the new variable.
Defining instructions = [] is fine, but ensure proper usage in the pipeline and test coverage for any logic relying on this variable.

wren-ai-service/src/pipelines/retrieval/historical_question_retrieval.py (1)

73-76: Consider more specific type annotations
Typing the retrievers as Any is workable but less precise. Encouraging a more specific interface/type for better maintainability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between aebfd92 and 73cd274.

📒 Files selected for processing (6)
  • wren-ai-service/src/pipelines/generation/intent_classification.py (7 hunks)
  • wren-ai-service/src/pipelines/retrieval/historical_question_retrieval.py (3 hunks)
  • wren-ai-service/src/pipelines/retrieval/retrieval.py (7 hunks)
  • wren-ai-service/src/pipelines/retrieval/sql_pairs_retrieval.py (3 hunks)
  • wren-ai-service/src/web/v1/services/ask.py (7 hunks)
  • wren-ai-service/tests/pytest/services/mocks.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • wren-ai-service/src/pipelines/generation/intent_classification.py
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pytest
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (19)
wren-ai-service/src/web/v1/services/ask.py (3)

254-264: Concurrent retrieval is well-structured.
Async gathering for sql_pairs_retrieval and instructions_retrieval improves efficiency. No issues found.


266-273: Check for empty output.
Extracting empty lists if nothing is retrieved is handled gracefully. Good defensive coding.


274-334: Intent classification with instructions.
The flow for handling MISLEADING_QUERY and GENERAL looks correct. Logic is consistent, and concurrency is integrated well.

wren-ai-service/tests/pytest/services/mocks.py (4)

12-12: Parameter rename maintains consistency.
Renaming id to project_id is clear and consistent. Looks good.


16-22: New mock helps test SQL pairs retrieval.
Implementation is straightforward. This mock is ready for integration tests.


24-30: New mock for instructions retrieval.
Great addition for testing the instructions pipeline.


36-36: Parameter rename in HistoricalQuestionMock.
Aligning with project_id naming. No issues.

wren-ai-service/src/pipelines/retrieval/sql_pairs_retrieval.py (3)

38-40: Apply consistent checks.
Using project_id as a filter is consistent with changes elsewhere. Ensure tests confirm the filter is correct.


63-64: Consistent embedding usage.
Including project_id in the filter logic is appropriate for scoping.


146-146: New run parameter.
Accepting project_id aligns with the rest of the pipeline. Straightforward change.

wren-ai-service/src/pipelines/retrieval/retrieval.py (4)

123-123: Streamlined list comprehension.
Extracting history.question in one line is neat and clear.


136-136: Parameter rename.
Switching id to project_id is consistent with new naming across modules.


168-168: Consistent filtering for dbschema retrieval.
Adding the project_id condition mirrors the pattern used elsewhere.

Also applies to: 191-192


479-479: Method signature alignment.
Updating run to include project_id is consistent with pipeline usage.

wren-ai-service/src/pipelines/retrieval/historical_question_retrieval.py (5)

44-44: Renaming to project_id improves clarity
The parameter rename from id to project_id is more descriptive and aligns well with the filters below.


50-50: Consistent filter usage
Referencing "project_id" here consistently applies the new naming. No issues found.


83-86: Project-based filtering logic looks correct
Using "project_id" in filters and conditionally applying them aligns with the rename. Implementation looks consistent.


171-171: Better param naming
Renaming the parameter to project_id clarifies intent of the function argument.


177-177: Verify use of empty string fallback
Using project_id or "" prevents errors when project_id is None. Confirm that an empty string behaves as intended downstream.

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 (2)
wren-ai-service/tests/pytest/services/mocks.py (2)

16-19: Avoid using a mutable list as a default argument.
Consider using documents: Optional[list] = None and initializing with an empty list inside the constructor to prevent shared state across instances.


24-27: Avoid mutable default argument.
Same concern as above; consider changing documents: list = [] to None and check for None inside __init__.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 73cd274 and ced4d57.

📒 Files selected for processing (1)
  • wren-ai-service/tests/pytest/services/mocks.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pytest
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (6)
wren-ai-service/tests/pytest/services/mocks.py (6)

12-12: Aligning method signature with project_id.
No issues spotted: this is consistent with the rest of the codebase.


20-21: Mock return structure looks good.
It correctly returns the _documents in the specified format. No concerns here.


28-29: Returning documents in desired format.
Implementation is straightforward; no additional concerns.


36-36: Project ID parameter updates.
Matches the changes above to unify the parameter name. Implementation is consistent.


47-47: New parameter matches pipeline changes.
The addition of project_id in the signature aligns with the broader refactor.


50-51: Optional parameters for SQL and instructions.
These new parameters in the mock help simulate real usage more accurately. Great addition.

Copy link
Copy Markdown
Contributor

@paopa paopa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@paopa paopa merged commit b443ba9 into main Mar 18, 2025
@paopa paopa deleted the chore/ai-service/improve-instructions branch March 18, 2025 09:06
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.

2 participants