Skip to content
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

chore(wren-ai-service): allow generating rephrased question and intent reasoning using user's preferred language #1325

Closed
wants to merge 1 commit into from

Conversation

cyyeh
Copy link
Member

@cyyeh cyyeh commented Feb 22, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced language consistency: Now, both the explanatory reasoning and the rephrased user input are aligned with the user-defined language, ensuring that responses match language preferences.

@cyyeh cyyeh added module/ai-service ai-service related ci/ai-service ai-service related labels Feb 22, 2025
Copy link
Contributor

coderabbitai bot commented Feb 22, 2025

Walkthrough

The intent classification process now requires that both the reasoning behind the classification and the rephrased user question are expressed in the user-specified output language. The prompt template is updated to include the output language, and the function now accepts a new parameter language. There is no change to the underlying logic or control flow.

Changes

File(s) Change Summary
wren-ai-service/src/.../intent_classification.py Updated prompt template and function to include a new language parameter; enforces that both reasoning and rephrasing use the specified output language.

Possibly related PRs

Suggested reviewers

  • paopa

Poem

I'm a hopping bunny with code in my heart,
Leaping through changes with a joyful start.
The prompt now sings in the user's chosen tongue,
Where reasoning and rephrasing are perfectly strung.
With a cheerful hop, I celebrate this art!
(⁎˃ᴗ˂⁎)

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @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 bdaa1b1 and 984aa04.

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

40-41: LGTM! Clear language requirements added to system prompt.

The new requirements effectively mandate that both the intent classification reasoning and rephrased question must use the user's preferred language.


110-110: LGTM! Language parameter correctly added to user prompt template.

The language parameter is properly integrated into the INPUT section using correct Jinja2 syntax.

@@ -224,6 +227,7 @@ def prompt(
) -> dict:
return prompt_builder.run(
query=query,
language=configuration.language,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Add validation for language parameter.

Consider validating that configuration.language is not None before passing it to the prompt builder to prevent potential runtime errors.

Run this script to check if language is a required field in the Configuration class:


🏁 Script executed:

#!/bin/bash
# Description: Check if language is a required field in Configuration class
rg -A 5 'class Configuration' src/web/v1/services/

Length of output: 113


I'll run a broader search for the Configuration class to locate where it is defined and to verify if a validation for the language field is necessary.


🏁 Script executed:

#!/bin/bash
# Search entire repository for the definition of the Configuration class
rg -A 10 'class Configuration' .

Length of output: 1695


Validation of configuration.language Parameter Required

Please add explicit validation to ensure that configuration.language is not None before it is passed to the prompt builder. This change will help prevent potential runtime errors if the configuration does not include a valid language value. You might consider either enforcing a default value within the Configuration class or adding a guard clause right before the prompt builder invocation in wren-ai-service/src/pipelines/generation/intent_classification.py (around line 230).

@cyyeh cyyeh closed this Feb 23, 2025
@cyyeh cyyeh deleted the chore/ai-service/fix-intent-reasoning-lang branch February 23, 2025 03:39
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant