mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 21:30:40 +08:00
fix: Prevent duplicate language instructions in extra_instructions
This commit is contained in:
@ -84,10 +84,18 @@ class PRAgent:
|
|||||||
if str(type(setting)) == "<class 'dynaconf.utils.boxing.DynaBox'>":
|
if str(type(setting)) == "<class 'dynaconf.utils.boxing.DynaBox'>":
|
||||||
if hasattr(setting, 'extra_instructions'):
|
if hasattr(setting, 'extra_instructions'):
|
||||||
current_extra_instructions = 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."
|
# Define the language-specific instruction and the separator
|
||||||
else:
|
lang_instruction_text = f"Your response MUST be written in the language corresponding 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."
|
separator_text = "\n======\n\nIn addition, "
|
||||||
|
|
||||||
|
# Check if the specific language instruction is already present to avoid duplication
|
||||||
|
if lang_instruction_text not in str(current_extra_instructions):
|
||||||
|
if current_extra_instructions: # If there's existing text
|
||||||
|
setting.extra_instructions = str(current_extra_instructions) + separator_text + lang_instruction_text
|
||||||
|
else: # If extra_instructions was None or empty
|
||||||
|
setting.extra_instructions = lang_instruction_text
|
||||||
|
# If lang_instruction_text is already present, do nothing.
|
||||||
|
|
||||||
action = action.lstrip("/").lower()
|
action = action.lstrip("/").lower()
|
||||||
if action not in command2class:
|
if action not in command2class:
|
||||||
|
Reference in New Issue
Block a user