Skip to content

chore(wren-ai-service): minor updates (ai-env-changed)#1549

Merged
cyyeh merged 2 commits into
mainfrom
chore/ai-service/improve-text2sql
Apr 15, 2025
Merged

chore(wren-ai-service): minor updates (ai-env-changed)#1549
cyyeh merged 2 commits into
mainfrom
chore/ai-service/improve-text2sql

Conversation

@cyyeh
Copy link
Copy Markdown
Member

@cyyeh cyyeh commented Apr 15, 2025

  • improve text2sql prompt
  • improve sql functions prompt
  • setup new openai llm

Summary by CodeRabbit

  • New Features
    • Enhanced SQL generation prompts with clearer instructions and new rules for handling date/time columns stored as numeric types, including examples for timestamp conversion functions.
    • Added a "GENERAL RULES" section to SQL generation prompts to improve guidance and consistency.
    • Expanded LLM provider configurations with three new GPT-4.1 models, including a new default model with detailed parameter settings.
    • Added new selectable OpenAI generation models in the user prompt and validation logic.
  • Refactor
    • Simplified SQL function metadata extraction and string representation for improved clarity.
    • Updated handling of SQL function definitions to filter out incomplete entries and use a more structured input format.
    • Improved configuration file handling to dynamically map default model names.
  • Bug Fixes
    • Improved prompt wording for better accuracy and adherence to provided instructions.

@cyyeh cyyeh added module/ai-service ai-service related ci/ai-service ai-service related labels Apr 15, 2025
@cyyeh cyyeh requested a review from imAsterSun April 15, 2025 07:09
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2025

Walkthrough

This update revises prompt instructions and internal documentation across several SQL generation and reasoning pipeline modules. It introduces stricter adherence to provided INSTRUCTIONS sections, clarifies references to SQL SAMPLES, and adds a GENERAL RULES section to the SQL prompt. The SQL rules now include explicit guidance on converting date/time columns stored as numeric types to TIMESTAMP using appropriate functions. The SqlFunction class and related utilities are refactored to simplify metadata extraction, update input expectations, and filter out incomplete function definitions. Additionally, new LLM models are added to configuration files and launcher utilities, expanding model options and updating default aliases.

Changes

File(s) Change Summary
wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py
wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py
Updated system prompt instructions: inserted a new step requiring strict adherence to any INSTRUCTIONS section, clarified SQL SAMPLES references, and renumbered subsequent steps. No logic or control flow changes.
wren-ai-service/src/pipelines/generation/utils/sql.py Updated SQL rules documentation: renamed header, added rule for converting date/time columns stored as numeric types to TIMESTAMP with examples, and appended a GENERAL RULES section to the prompt. No code logic changes.
wren-ai-service/src/pipelines/retrieval/sql_functions.py Refactored SqlFunction class to simplify metadata extraction; changed string representation; added empty class method; updated get_functions and sql_functions to expect and filter lists of dictionaries, not strings. No changes to public function signatures except parameter type updates.
deployment/kustomizations/base/cm.yaml
docker/config.example.yaml
wren-ai-service/tools/config/config.example.yaml
wren-ai-service/tools/config/config.full.yaml
Added three new LLM models (gpt-4.1-nano-2025-04-14, gpt-4.1-mini-2025-04-14, gpt-4.1-2025-04-14) with detailed parameters and set the nano model as the new default. Removed default alias from older model gpt-4o-mini-2024-07-18. Updated model parameter consistency and ordering. No changes to exported code entities.
wren-launcher/commands/launch.go Expanded selectable OpenAI generation models to include the three new gpt-4.1-* models and updated validation logic to accept them. No signature changes.
wren-launcher/utils/docker.go Added mappings for the three new generation models to their dated names. Updated PrepareConfigFileForOpenAI to replace "litellm_llm.default" with the mapped model name based on the selected generation model. No other logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Pipeline
    participant PromptEngine
    participant SqlFunctionUtil

    User->>Pipeline: Submit SQL generation request with INSTRUCTIONS, SAMPLES, etc.
    Pipeline->>PromptEngine: Build prompt with GENERAL RULES and SQL RULES
    PromptEngine->>Pipeline: Return constructed prompt
    Pipeline->>SqlFunctionUtil: Retrieve and filter SQL functions
    SqlFunctionUtil->>Pipeline: Return valid SQL function metadata
    Pipeline->>User: Return generated SQL and reasoning
Loading

Poem

In the warren where SQL bunnies dwell,
New rules and prompts now ring a bell.
Dates as numbers? Cast them right!
INSTRUCTIONS followed, day and night.
Functions pruned, descriptions neat—
This code hop brings a tidy feat!
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ 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.

@cyyeh cyyeh changed the title chore(wren-ai-service): improve text2sql prompt chore(wren-ai-service): minor updates Apr 15, 2025
@github-actions github-actions Bot changed the title chore(wren-ai-service): minor updates chore(wren-ai-service): minor updates (ai-env-changed) Apr 15, 2025
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6a0c141 and 56c9964.

📒 Files selected for processing (6)
  • deployment/kustomizations/base/cm.yaml (1 hunks)
  • docker/config.example.yaml (1 hunks)
  • wren-ai-service/tools/config/config.example.yaml (1 hunks)
  • wren-ai-service/tools/config/config.full.yaml (1 hunks)
  • wren-launcher/commands/launch.go (2 hunks)
  • wren-launcher/utils/docker.go (2 hunks)
✅ Files skipped from review due to trivial changes (3)
  • wren-ai-service/tools/config/config.example.yaml
  • docker/config.example.yaml
  • wren-ai-service/tools/config/config.full.yaml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: pytest
🔇 Additional comments (3)
wren-launcher/utils/docker.go (1)

33-40: New GPT-4.1 model series added to model mapping.

The code adds three new GPT-4.1 series models to the generationModelToModelName map, expanding the available model options. This is a good addition that keeps the system up-to-date with newer OpenAI models.

wren-launcher/commands/launch.go (2)

109-112: New GPT-4.1 models added to user selection options.

The prompt selection options have been expanded to include the newer GPT-4.1 series models (nano, mini, and standard), providing users with more choices. This aligns well with the model mapping changes in docker.go.


302-309: Added validation for new GPT-4.1 models.

The validation map has been appropriately updated to include the new GPT-4.1 series models, ensuring consistency with the UI selection options. There's also a minor formatting adjustment for the existing model entries with their indentation.

Comment thread wren-launcher/utils/docker.go
Comment thread deployment/kustomizations/base/cm.yaml
Copy link
Copy Markdown
Contributor

@imAsterSun imAsterSun left a comment

Choose a reason for hiding this comment

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

lgtm

@cyyeh cyyeh merged commit 3202ff7 into main Apr 15, 2025
12 checks passed
@cyyeh cyyeh deleted the chore/ai-service/improve-text2sql branch April 15, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants