Skip to content

Conversation

@cyyeh
Copy link
Member

@cyyeh cyyeh commented Mar 27, 2025

  • add sql_pair related fields to ask response
  • allow running usecase tests using different languages

Summary by CodeRabbit

  • New Features

    • Enhanced response results by introducing an optional SQL pair identifier, enabling result types to now include "llm", "view", or "sql_pair" based on content.
    • Multilingual support added for question-asking functionality, allowing users to specify the language of their queries.
  • Refactor

    • Streamlined document processing with a more concise method for constructing response lists, improving output consistency.
    • Updated logic for determining result types in the AskResult class to enhance flexibility.
    • Improved test command functionality to allow language specification for test cases.

@cyyeh cyyeh added module/ai-service ai-service related ci/ai-service ai-service related labels Mar 27, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 27, 2025

Walkthrough

This pull request refactors the document formatting logic and updates result type determination. In the document retrieval pipeline, a loop is replaced with a list comprehension, and a new "sqlpairId" field is added to each formatted document. Similarly, in the ask service, the AskResult model now supports a new type "sql_pair" with an associated sqlpairId attribute, and the logic in the ask method is modified to conditionally set the result type based on the presence of viewId or sqlpairId. Additionally, the testing framework is updated to accommodate language specifications.

Changes

File(s) Changed Summary of Changes
wren-ai-service/.../historical_question_retrieval.py Refactored OutputFormatter.run: replaced loop with list comprehension and added "sqlpairId": doc.meta.get("sql_pair_id", "") to the formatted document dictionary.
wren-ai-service/.../ask.py Updated AskResult to include sqlpairId and expanded type literal to include "sql_pair". Modified ask logic to determine type dynamically based on viewId or sqlpairId.
wren-ai-service/Justfile Modified test-usecases command to include an additional argument lang='en' for specifying language in test cases.
wren-ai-service/tests/pytest/test_usecases.py Added lang parameter to ask_question and ask_questions functions, defaulting to "English", and updated command-line argument parsing for language support.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant A as AskService
    participant H as HistoricalQuestionRetrieval
    participant R as AskResult Model

    C->>A: Send ask request
    A->>H: Process historical question retrieval
    H-->>A: Return result with metadata
    alt viewId exists
        A->>R: Create AskResult(type="view")
    else if sqlpairId exists
        A->>R: Create AskResult(type="sql_pair", sqlpairId)
    else 
        A->>R: Create AskResult(type="llm")
    end
    A-->>C: Return AskResult
Loading

Possibly related PRs

Suggested labels

wren-ui

Suggested reviewers

  • paopa

Poem

I'm a rabbit, hopping with glee,
Code refreshed and sprightly, you see.
New SQL pairs join the lively spree,
List comprehensions now roam so free,
Cheers to clean changes from my burrow, whee! 🐇✨


📜 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 f78c2fa and 7e53f0d.

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

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

@cyyeh cyyeh changed the title chore(wren-ai-service): add sql_pair related fields to ask response chore(wren-ai-service): minor updates Mar 27, 2025
@cyyeh cyyeh merged commit 831f714 into main Mar 27, 2025
11 checks passed
@cyyeh cyyeh deleted the chore/ai-service/minor-update branch March 27, 2025 08:11
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