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

docs: add language configuration documentation and update changelog #1586

Merged
merged 5 commits into from
Feb 27, 2025

Conversation

mrT23
Copy link
Collaborator

@mrT23 mrT23 commented Feb 27, 2025

PR Type

  • Bug fix
  • Documentation
  • Enhancement

Description

  • 言語設定処理ロジックを改善

  • エージェントの応答言語ログ追加

  • 不要な温度ログ出力をコメント化

  • ドキュメントに新設定情報追加


Changes walkthrough 📝

Relevant files
Enhancement
pr_agent.py
応答言語設定処理の改善                                                                                           

pr_agent/agent/pr_agent.py

  • response_language取得方法をgetメソッド利用に変更
  • 応答言語が非英語の場合、ログ出力追加
  • extra_instructionsに言語指定案内を付加
  • +8/-4     
    Bug fix
    litellm_ai_handler.py
    温度ログ出力の無効化                                                                                             

    pr_agent/algo/ai_handlers/litellm_ai_handler.py

    • 不要な温度ログ出力のコメントアウト
    +1/-1     
    Documentation
    README.md
    READMEの更新と新情報追加                                                                                   

    README.md

    • デフォルトモデル変更情報と新設定案内を追加
    • Azure DevOps更新情報を保持
    +3/-2     
    additional_configurations.md
    言語設定ドキュメントの更新                                                                                       

    docs/docs/usage-guide/additional_configurations.md

    • セクション名を「言語設定」に変更
    • TOMLのコード例を更新
    • 注意文の文言を修正
    +7/-6     
    Configuration changes
    configuration.toml
    構成ファイルのモデル設定更新                                                                                     

    pr_agent/settings/configuration.toml

    • デフォルトモデルを'o3-mini'に変更
    • fallback_modelsの順序を更新
    • 応答言語コメント情報を修正
    +7/-3     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    qodo-merge-pro-for-open-source bot commented Feb 27, 2025

    PR Reviewer Guide 🔍

    (Review updated until commit 8182a4a)

    Here are some key observations to aid the review process:

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

    文字列連結

    設定オブジェクトの extra_instructions に新たな指示文を連結する処理が複数回実行された場合、意図しない重複やフォーマットの乱れが発生する可能性があります。実際の挙動を再確認してください。

    current_extra_instructions = setting.extra_instructions
    if current_extra_instructions:
        setting.extra_instructions = current_extra_instructions+ f"\n======\n\nIn addition, Your response MUST be written in the language corresponding to local code: {response_language}. This is crucial."
    else:
        setting.extra_instructions = f"Your response MUST be written in the language corresponding to locale code: '{response_language}'. This is crucial."
    ログ出力の変更

    温度パラメータの追加時のログ出力がコメントアウトされており、デバッグ情報が失われる可能性があります。変更の意図を再確認してください。

    # get_logger().info(f"Adding temperature with value {temperature} to model {model}.")

    @mrT23
    Copy link
    Collaborator Author

    mrT23 commented Feb 27, 2025

    PR Description updated to latest commit (222f276)

    @mrT23
    Copy link
    Collaborator Author

    mrT23 commented Feb 27, 2025

    PR Description updated to latest commit (94a8606)

    @mrT23
    Copy link
    Collaborator Author

    mrT23 commented Feb 27, 2025

    PR Description updated to latest commit (8182a4a)

    @mrT23
    Copy link
    Collaborator Author

    mrT23 commented Feb 27, 2025

    Persistent review updated to latest commit 8182a4a

    @mrT23
    Copy link
    Collaborator Author

    mrT23 commented Feb 27, 2025

    PR Code Suggestions ✨

    Latest suggestions up to 8182a4a

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Wrap instruction updates conditionally


    条件チェック(response_languageが'en-us'でない場合)内にextra_instructions更新のループを移動し、デフォルトの場合は不要な指示追加を避ける。

    pr_agent/agent/pr_agent.py [77-88]

     response_language = get_settings().config.get('response_language', 'en-us')
     if response_language.lower() != 'en-us':
         get_logger().info(f'User has set the response language to: {response_language}')
    -for key in get_settings():
    -     setting = get_settings().get(key)
    -     if str(type(setting)) == "<class 'dynaconf.utils.boxing.DynaBox'>":
    -         if hasattr(setting, 'extra_instructions'):
    -             current_extra_instructions = setting.extra_instructions
    -             if current_extra_instructions:
    -                 setting.extra_instructions = current_extra_instructions+ f"\n======\n\nIn addition, Your response MUST be written in the language corresponding to local code: {response_language}. This is crucial."
    -             else:
    -                 setting.extra_instructions = f"Your response MUST be written in the language corresponding to locale code: '{response_language}'. This is crucial."
    +    for key in get_settings():
    +        setting = get_settings().get(key)
    +        if str(type(setting)) == "<class 'dynaconf.utils.boxing.DynaBox'>":
    +            if hasattr(setting, 'extra_instructions'):
    +                current_extra_instructions = setting.extra_instructions
    +                if current_extra_instructions:
    +                    setting.extra_instructions = current_extra_instructions+ f"\n======\n\nIn addition, Your response MUST be written in the language corresponding to locale code: {response_language}. This is crucial."
    +                else:
    +                    setting.extra_instructions = f"Your response MUST be written in the language corresponding to locale code: '{response_language}'. This is crucial."
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion correctly identifies that updating extra_instructions should only occur when the response language is not the default 'en-us', thus improving logical flow. Moving the loop inside the conditional prevents unnecessary modifications when the default language is used.

    Medium
    General
    Remove redundant debug comment

    コメントアウトされたlogger呼び出しが不要であれば削除し、コードの可読性を向上させる。

    pr_agent/algo/ai_handlers/litellm_ai_handler.py [235]

    -# get_logger().info(f"Adding temperature with value {temperature} to model {model}.")
    +kwargs["temperature"] = temperature
    Suggestion importance[1-10]: 4

    __

    Why: Removing the commented out logger call improves code clarity, although the change is minor and has limited functional impact.

    Low

    Previous suggestions

    Suggestions up to commit 94a8606
    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Validate locale code format

    Add error handling for invalid locale codes to prevent runtime errors when users
    provide unsupported language codes.

    pr_agent/agent/pr_agent.py [77-79]

     response_language = get_settings().config.get('response_language', 'en-us')
    -if response_language.lower() != 'en-us':
    +if not re.match(r'^[a-z]{2}-[A-Z]{2}$', response_language):
    +    get_logger().warning(f'Invalid locale code format: {response_language}. Defaulting to en-US')
    +    response_language = 'en-US'
    +elif response_language.lower() != 'en-us':
         get_logger().info(f'User has set the response language to: {response_language}')
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion adds crucial input validation for locale codes, preventing potential runtime errors and improving system robustness by ensuring the language code follows the correct format before processing.

    Medium
    • Update
    Suggestions up to commit 222f276
    CategorySuggestion                                                                                                                                    Impact
    General
    Fix documentation typo

    Fix the typo in the word "modeles" to "model's" in the Important note section,
    as it affects documentation accuracy.

    docs/docs/usage-guide/additional_configurations.md [75]

    -> **Important:** Note that only dynamic text generated by the AI model is translated to the configured language. Static text such as labels and table headers that are  not part of the AI modeles response will remain in US English.
    +> **Important:** Note that only dynamic text generated by the AI model is translated to the configured language. Static text such as labels and table headers that are not part of the AI model's response will remain in US English.
    Suggestion importance[1-10]: 3

    __

    Why: The suggestion correctly identifies and fixes a minor typo ('modeles' to 'model's'), which improves documentation quality but has minimal functional impact.

    Low

    @mrT23 mrT23 merged commit e71c0f1 into main Feb 27, 2025
    2 checks passed
    @mrT23 mrT23 deleted the tr/docs245 branch February 27, 2025 09:10
    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.

    1 participant