diff --git a/pr_agent/agent/pr_agent.py b/pr_agent/agent/pr_agent.py index b340e8f8..078e82b3 100644 --- a/pr_agent/agent/pr_agent.py +++ b/pr_agent/agent/pr_agent.py @@ -44,6 +44,20 @@ command2class = { commands = list(command2class.keys()) +commands2instructions = { + # "auto_best_practices":"auto_best_practices", + "improve_component":"pr_improve_component", + "test":"pr_test", + "update_changelog":"pr_update_changelog", + "add_docs":"pr_add_docs", + "improve":"pr_code_suggestions", + "describe":"pr_description", + "review":"pr_reviewer" +} + +commands_with_extra_instructions = list(commands2instructions.keys()) + + class PRAgent: def __init__(self, ai_handler: partial[BaseAiHandler,] = LiteLLMAIHandler): self.ai_handler = ai_handler # will be initialized in run_action @@ -72,6 +86,16 @@ class PRAgent: # Update settings from args 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': + 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}" + action = action.lstrip("/").lower() if action not in command2class: get_logger().error(f"Unknown command: {action}") diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 890cff35..fc1e1542 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -3,6 +3,7 @@ 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") # CLI git_provider="github" publish_output=true @@ -64,7 +65,7 @@ require_security_review=true require_ticket_analysis_review=true # general options persistent_comment=true -extra_instructions = "" +extra_instructions = "Blah blah do some custom shit please" final_update_message = true # review labels enable_review_labels_security=true