From 222f2769595dd97e064f4a9cf4156687ab0a64d4 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 27 Feb 2025 10:29:05 +0200 Subject: [PATCH 1/5] docs: add language configuration documentation and update changelog --- README.md | 3 ++- docs/docs/usage-guide/additional_configurations.md | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6d0f1d66..ed4fdd8c 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ PR-Agent aims to help efficiently review and handle pull requests, by providing ### Feb 27, 2025 -Important updates and bug fixes for Azure DevOps, see [here](https://github.com/qodo-ai/pr-agent/pull/1583) +- Important updates and bug fixes for Azure DevOps, see [here](https://github.com/qodo-ai/pr-agent/pull/1583) +- Added support for adjusting the [response language](https://qodo-merge-docs.qodo.ai/usage-guide/additional_configurations/#language-settings) of the PR-Agent tools. ### Feb 6, 2025 New design for the `/improve` tool: diff --git a/docs/docs/usage-guide/additional_configurations.md b/docs/docs/usage-guide/additional_configurations.md index d71e5be0..5ff211c6 100644 --- a/docs/docs/usage-guide/additional_configurations.md +++ b/docs/docs/usage-guide/additional_configurations.md @@ -57,19 +57,20 @@ All Qodo Merge tools have a parameter called `extra_instructions`, that enables /update_changelog --pr_update_changelog.extra_instructions="Make sure to update also the version ..." ``` -## Localization +## Language Settings The default response language for Qodo Merge is **U.S. English**. However, some development teams may prefer to display information in a different language. For example, your team's workflow might improve if PR descriptions and code suggestions are set to your country's native language. To configure this, set the `response_language` parameter in the configuration file. This will prompt the model to respond in the specified language. Use a **standard locale code** based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166) (country codes) and [ISO 639](https://en.wikipedia.org/wiki/ISO_639) (language codes) to define a language-country pair. See this [comprehensive list of locale codes](https://simplelocalize.io/data/locales/). -### Example: +Example: -```yaml -response_language: "he-IL" +```toml +[config] +response_language: "ja-JP" ``` -This will set the response language globally for [describe](../tools/describe.md), [improve](../tools/improve.md), [add_docs](../tools/documentation.md), [update_changelog](../tools/update_changelog.md), [test](../tools/test.md) commands to Hebrew +This will set the response language globally for all the commands to Japanese. > **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. From af635650f1a189cf80cb35e66eec5e4008630f46 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 27 Feb 2025 10:50:28 +0200 Subject: [PATCH 2/5] fix: improve response language handling and configuration documentation --- docs/docs/usage-guide/additional_configurations.md | 6 +++--- pr_agent/agent/pr_agent.py | 12 ++++++++---- pr_agent/settings/configuration.toml | 10 +++++++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/docs/docs/usage-guide/additional_configurations.md b/docs/docs/usage-guide/additional_configurations.md index 5ff211c6..8021bccc 100644 --- a/docs/docs/usage-guide/additional_configurations.md +++ b/docs/docs/usage-guide/additional_configurations.md @@ -67,12 +67,12 @@ Example: ```toml [config] -response_language: "ja-JP" +response_language: "it-IT" ``` -This will set the response language globally for all the commands to Japanese. +This will set the response language globally for all the commands to Italian. -> **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 models response will remain in US English. In addition, the model you are using must support the specified language. ## Working with large PRs diff --git a/pr_agent/agent/pr_agent.py b/pr_agent/agent/pr_agent.py index 5b950339..7cae3839 100644 --- a/pr_agent/agent/pr_agent.py +++ b/pr_agent/agent/pr_agent.py @@ -74,14 +74,18 @@ class PRAgent: args = update_settings_from_args(args) # Append the response language in the extra instructions - response_language = get_settings().config.response_language - if response_language != 'en-us': + 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)) == "": 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}" + current_extra_instructions = setting.extra_instructions + if current_extra_instructions: + setting.extra_instructions = current_extra_instructions+ f"\n======\n\nIn addition, in your reply the generated answers MUST be in a language equivalent to locale code: {response_language}. This is crucial." + else: + setting.extra_instructions = f"The generated answers in your reply MUST be in a language equivalent to locale code: '{response_language}'. This is crucial." action = action.lstrip("/").lower() if action not in command2class: diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index fb4bbc4a..72ae4d35 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -1,15 +1,19 @@ +# Important: This file contains all available configuration options. +# Do not copy this entire file to your repository configuration. +# Your repository configuration should only include options you wish to override from the defaults. + [config] # models model="gpt-4o-2024-11-20" fallback_models=["gpt-4o-2024-08-06"] #model_weak="gpt-4o-mini-2024-07-18" # optional, a weaker model to use for some easier tasks -response_language="en-US" # Language locales code for PR responses in ISO 3166 and ISO 639 format (e.g., "en-US", "es-ES", "he-IL", "ar-IL", "zh-CN") +response_language="en-US" # Language locales code for PR responses in ISO 3166 and ISO 639 format (e.g., "en-US", "it-IT", "zh-CN", ...) # CLI git_provider="github" -publish_output=true +publish_output=false publish_output_progress=true publish_output_no_suggestions=true -verbosity_level=0 # 0,1,2 +verbosity_level=2 # 0,1,2 use_extra_bad_extensions=false # Configurations use_wiki_settings_file=true From 94a8606d241a8f0ac2d9654e8266409d7c7f0287 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 27 Feb 2025 10:52:20 +0200 Subject: [PATCH 3/5] fix: update default configuration values for publishing and verbosity --- pr_agent/settings/configuration.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 72ae4d35..27f17385 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -10,10 +10,10 @@ fallback_models=["gpt-4o-2024-08-06"] response_language="en-US" # Language locales code for PR responses in ISO 3166 and ISO 639 format (e.g., "en-US", "it-IT", "zh-CN", ...) # CLI git_provider="github" -publish_output=false +publish_output=true publish_output_progress=true publish_output_no_suggestions=true -verbosity_level=2 # 0,1,2 +verbosity_level=0 # 0,1,2 use_extra_bad_extensions=false # Configurations use_wiki_settings_file=true From 3817aa2868582e80abfeea663ac4aec11f2cfe19 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 27 Feb 2025 10:55:01 +0200 Subject: [PATCH 4/5] fix: remove redundant temperature logging in litellm handler --- pr_agent/algo/ai_handlers/litellm_ai_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/algo/ai_handlers/litellm_ai_handler.py b/pr_agent/algo/ai_handlers/litellm_ai_handler.py index ba557979..e2894f1b 100644 --- a/pr_agent/algo/ai_handlers/litellm_ai_handler.py +++ b/pr_agent/algo/ai_handlers/litellm_ai_handler.py @@ -232,7 +232,7 @@ class LiteLLMAIHandler(BaseAiHandler): # Add temperature only if model supports it if model not in self.no_support_temperature_models and not get_settings().config.custom_reasoning_model: - get_logger().info(f"Adding temperature with value {temperature} to model {model}.") + # get_logger().info(f"Adding temperature with value {temperature} to model {model}.") kwargs["temperature"] = temperature # Add reasoning_effort if model supports it From 8182a4afc0ce2f310b39d1be258e40d57a1f6cf2 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 27 Feb 2025 11:06:31 +0200 Subject: [PATCH 5/5] docs: update default model to o3-mini and improve language configuration instructions --- README.md | 2 +- docs/docs/usage-guide/additional_configurations.md | 2 +- pr_agent/agent/pr_agent.py | 4 ++-- pr_agent/settings/configuration.toml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ed4fdd8c..ddd77a23 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ PR-Agent aims to help efficiently review and handle pull requests, by providing ## News and Updates ### Feb 27, 2025 - +- Updated the default model to `o3-mini` for all tools. You can still use the `gpt-4o` as the default model by setting the `model` parameter in the configuration file. - Important updates and bug fixes for Azure DevOps, see [here](https://github.com/qodo-ai/pr-agent/pull/1583) - Added support for adjusting the [response language](https://qodo-merge-docs.qodo.ai/usage-guide/additional_configurations/#language-settings) of the PR-Agent tools. diff --git a/docs/docs/usage-guide/additional_configurations.md b/docs/docs/usage-guide/additional_configurations.md index 8021bccc..e8058eac 100644 --- a/docs/docs/usage-guide/additional_configurations.md +++ b/docs/docs/usage-guide/additional_configurations.md @@ -72,7 +72,7 @@ response_language: "it-IT" This will set the response language globally for all the commands to Italian. -> **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 models response will remain in US English. In addition, the model you are using must support the specified language. +> **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 models response will remain in US English. In addition, the model you are using must have good support for the specified language. ## Working with large PRs diff --git a/pr_agent/agent/pr_agent.py b/pr_agent/agent/pr_agent.py index 7cae3839..126452d2 100644 --- a/pr_agent/agent/pr_agent.py +++ b/pr_agent/agent/pr_agent.py @@ -83,9 +83,9 @@ class PRAgent: 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, in your reply the generated answers MUST be in a language equivalent to locale code: {response_language}. This is crucial." + 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"The generated answers in your reply MUST be in a language equivalent to locale code: '{response_language}'. This is crucial." + setting.extra_instructions = f"Your response MUST be written in the language corresponding to locale code: '{response_language}'. This is crucial." action = action.lstrip("/").lower() if action not in command2class: diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 27f17385..4e004722 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -4,8 +4,8 @@ [config] # models -model="gpt-4o-2024-11-20" -fallback_models=["gpt-4o-2024-08-06"] +model="o3-mini" +fallback_models=["gpt-4o-2024-11-20"] #model_weak="gpt-4o-mini-2024-07-18" # optional, a weaker model to use for some easier tasks response_language="en-US" # Language locales code for PR responses in ISO 3166 and ISO 639 format (e.g., "en-US", "it-IT", "zh-CN", ...) # CLI