mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 12:20:38 +08:00
Add a language configuration to translate language generated by QodoMerge, such as suggestions and desciption text
This commit is contained in:
@ -44,6 +44,20 @@ command2class = {
|
|||||||
commands = list(command2class.keys())
|
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:
|
class PRAgent:
|
||||||
def __init__(self, ai_handler: partial[BaseAiHandler,] = LiteLLMAIHandler):
|
def __init__(self, ai_handler: partial[BaseAiHandler,] = LiteLLMAIHandler):
|
||||||
self.ai_handler = ai_handler # will be initialized in run_action
|
self.ai_handler = ai_handler # will be initialized in run_action
|
||||||
@ -72,6 +86,16 @@ class PRAgent:
|
|||||||
# Update settings from args
|
# Update settings from args
|
||||||
args = update_settings_from_args(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()
|
action = action.lstrip("/").lower()
|
||||||
if action not in command2class:
|
if action not in command2class:
|
||||||
get_logger().error(f"Unknown command: {action}")
|
get_logger().error(f"Unknown command: {action}")
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
model="gpt-4o-2024-11-20"
|
model="gpt-4o-2024-11-20"
|
||||||
fallback_models=["gpt-4o-2024-08-06"]
|
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
|
#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
|
# CLI
|
||||||
git_provider="github"
|
git_provider="github"
|
||||||
publish_output=true
|
publish_output=true
|
||||||
@ -64,7 +65,7 @@ require_security_review=true
|
|||||||
require_ticket_analysis_review=true
|
require_ticket_analysis_review=true
|
||||||
# general options
|
# general options
|
||||||
persistent_comment=true
|
persistent_comment=true
|
||||||
extra_instructions = ""
|
extra_instructions = "Blah blah do some custom shit please"
|
||||||
final_update_message = true
|
final_update_message = true
|
||||||
# review labels
|
# review labels
|
||||||
enable_review_labels_security=true
|
enable_review_labels_security=true
|
||||||
|
Reference in New Issue
Block a user