Skip to content

Add a language configuration to translate language generated by QodoM…#1579

Merged
mrT23 merged 4 commits into
mainfrom
response-language-configuration
Feb 27, 2025
Merged

Add a language configuration to translate language generated by QodoM…#1579
mrT23 merged 4 commits into
mainfrom
response-language-configuration

Conversation

@AdamWalkerQodo

@AdamWalkerQodo AdamWalkerQodo commented Feb 26, 2025

Copy link
Copy Markdown
Contributor

User description

Add a configuration to translate the dynamic text generated by QodoMerge, such as the PR description and Code suggestions


PR Type

Enhancement


Description

  • Added support for language configuration in PR responses.

  • Introduced commands2instructions mapping for extra instructions.

  • Appended user language preference to extra instructions dynamically.

  • Updated configuration to include response_language setting.


Changes walkthrough 📝

Relevant files
Enhancement
pr_agent.py
Add language preference handling and command mappings       

pr_agent/agent/pr_agent.py

  • Added commands2instructions dictionary for mapping commands to
    instructions.
  • Appended user language preference to extra_instructions dynamically.
  • Enhanced request handling to include language-specific instructions.
  • +24/-0   
    Configuration changes
    configuration.toml
    Add response language configuration to settings                   

    pr_agent/settings/configuration.toml

  • Added response_language configuration for specifying response
    language.
  • Modified extra_instructions default value for testing purposes.
  • +2/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • …erge, such as suggestions and desciption text
    @qodo-free-for-open-source-projects

    Copy link
    Copy Markdown
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Language Code Validation

    The code does not validate the response_language format before using it. Invalid language codes could cause issues.

    if response_language != 'en-us':
        for key in get_settings():
            setting = get_settings().get(key)
            if str(type(setting)) == "<class 'dynaconf.utils.boxing.DynaBox'>":
                if hasattr(setting, 'extra_instructions'):
                    extra_instructions = get_settings()[key.lower()].extra_instructions
                    get_settings()[key.lower()].extra_instructions = f"{extra_instructions} \n======\n\nLanguage preference from the user\n======\n In your reply only use the lanaguage with locale code: {response_language}"
    String Comparison

    Using string comparison for type checking is fragile. Consider using isinstance() instead.

    if str(type(setting)) == "<class 'dynaconf.utils.boxing.DynaBox'>":

    @AdamWalkerQodo AdamWalkerQodo linked an issue Feb 26, 2025 that may be closed by this pull request
    @qodo-free-for-open-source-projects

    qodo-free-for-open-source-projects Bot commented Feb 26, 2025

    Copy link
    Copy Markdown
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Prevent potential KeyError access

    Fix potential KeyError by validating that the setting has 'extra_instructions'
    before attempting to concatenate the language preference.

    pr_agent/agent/pr_agent.py [95-97]

     if hasattr(setting, 'extra_instructions'):
    -    extra_instructions = get_settings()[key.lower()].extra_instructions
    -    get_settings()[key.lower()].extra_instructions = f"{extra_instructions} \n======\n\nLanguage preference from the user\n======\n In your reply only use the lanaguage with locale code: {response_language}"
    +    setting_key = key.lower()
    +    if setting_key in get_settings():
    +        extra_instructions = get_settings()[setting_key].extra_instructions
    +        get_settings()[setting_key].extra_instructions = f"{extra_instructions} \n======\n\nLanguage preference from the user\n======\n In your reply only use the language with locale code: {response_language}"
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion adds important defensive programming by checking if the setting key exists before accessing it, preventing potential runtime KeyError exceptions that could crash the application.

    Medium
    General
    Fix spelling error in message

    Fix typo in the word 'language' in the extra instructions message.

    pr_agent/agent/pr_agent.py [97]

    -get_settings()[key.lower()].extra_instructions = f"{extra_instructions} \n======\n\nLanguage preference from the user\n======\n In your reply only use the lanaguage with locale code: {response_language}"
    +get_settings()[key.lower()].extra_instructions = f"{extra_instructions} \n======\n\nLanguage preference from the user\n======\n In your reply only use the language with locale code: {response_language}"
    • Apply this suggestion
    Suggestion importance[1-10]: 3

    __

    Why: Fixes a minor typo in the word "lanaguage" in the user-facing message. While this improves professionalism, it's a low-impact change that doesn't affect functionality.

    Low
    • Update
    • Author self-review: I have reviewed the PR code suggestions, and addressed the relevant ones.

    @AdamWalkerQodo AdamWalkerQodo requested a review from mrT23 February 26, 2025 12:46
    @mrT23

    mrT23 commented Feb 26, 2025

    Copy link
    Copy Markdown
    Contributor

    Hi @AdamWalkerQodo

    1. please update the documentation

    2. have you tested this and made sure it works ?

    @mrT23 mrT23 merged commit 9a32e94 into main Feb 27, 2025
    @mrT23 mrT23 deleted the response-language-configuration branch February 27, 2025 06:01
    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.

    Dedicated Language Configuration

    3 participants