Add a language configuration to translate language generated by QodoMerge, such as suggestions and desciption text

This commit is contained in:
AdamWalker-112358
2025-02-26 14:37:15 +02:00
parent e16c6d0b27
commit de80901284
2 changed files with 26 additions and 1 deletions

View File

@ -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)) == "<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}"
action = action.lstrip("/").lower()
if action not in command2class:
get_logger().error(f"Unknown command: {action}")