update_settings_from_args

This commit is contained in:
mrT23
2023-07-30 11:43:44 +03:00
parent b564d8ac32
commit 3daf94954a
13 changed files with 74 additions and 22 deletions

View File

@ -8,19 +8,21 @@ from jinja2 import Environment, StrictUndefined
from pr_agent.algo.ai_handler import AiHandler
from pr_agent.algo.pr_processing import get_pr_diff, retry_with_fallback_models
from pr_agent.algo.token_handler import TokenHandler
from pr_agent.algo.utils import try_fix_json
from pr_agent.algo.utils import try_fix_json, update_settings_from_args
from pr_agent.config_loader import settings
from pr_agent.git_providers import BitbucketProvider, get_git_provider
from pr_agent.git_providers.git_provider import get_main_pr_language
class PRCodeSuggestions:
def __init__(self, pr_url: str, cli_mode=False):
def __init__(self, pr_url: str, cli_mode=False, args: list = None):
self.git_provider = get_git_provider()(pr_url)
self.main_language = get_main_pr_language(
self.git_provider.get_languages(), self.git_provider.get_files()
)
update_settings_from_args(args)
self.ai_handler = AiHandler()
self.patches_diff = None
self.prediction = None
@ -31,7 +33,8 @@ class PRCodeSuggestions:
"description": self.git_provider.get_pr_description(),
"language": self.main_language,
"diff": "", # empty diff for initial calculation
'num_code_suggestions': settings.pr_code_suggestions.num_code_suggestions,
"num_code_suggestions": settings.pr_code_suggestions.num_code_suggestions,
"extra_instructions": settings.pr_code_suggestions.extra_instructions,
}
self.token_handler = TokenHandler(self.git_provider.pr,
self.vars,
@ -137,3 +140,4 @@ class PRCodeSuggestions:
logging.info(f"Could not dedent code snippet for file {relevant_file}, error: {e}")
return new_code_snippet

View File

@ -8,6 +8,7 @@ from jinja2 import Environment, StrictUndefined
from pr_agent.algo.ai_handler import AiHandler
from pr_agent.algo.pr_processing import get_pr_diff, retry_with_fallback_models
from pr_agent.algo.token_handler import TokenHandler
from pr_agent.algo.utils import update_settings_from_args
from pr_agent.config_loader import settings
from pr_agent.git_providers import get_git_provider
from pr_agent.git_providers.git_provider import get_main_pr_language
@ -21,8 +22,8 @@ class PRDescription:
pr_url (str): The URL of the pull request.
args (list, optional): List of arguments passed to the PRDescription class. Defaults to None.
"""
self.parse_args(args)
update_settings_from_args(args)
# Initialize the git provider and main PR language
self.git_provider = get_git_provider()(pr_url)
self.main_pr_language = get_main_pr_language(
@ -39,6 +40,7 @@ class PRDescription:
"description": self.git_provider.get_pr_description(),
"language": self.main_pr_language,
"diff": "", # empty diff for initial calculation
"extra_instructions": settings.pr_description.extra_instructions,
}
# Initialize the token handler

View File

@ -14,7 +14,7 @@ from pr_agent.git_providers.git_provider import get_main_pr_language
class PRInformationFromUser:
def __init__(self, pr_url: str):
def __init__(self, pr_url: str, args: list = None):
self.git_provider = get_git_provider()(pr_url)
self.main_pr_language = get_main_pr_language(
self.git_provider.get_languages(), self.git_provider.get_files()

View File

@ -9,7 +9,7 @@ from jinja2 import Environment, StrictUndefined
from pr_agent.algo.ai_handler import AiHandler
from pr_agent.algo.pr_processing import get_pr_diff, retry_with_fallback_models
from pr_agent.algo.token_handler import TokenHandler
from pr_agent.algo.utils import convert_to_markdown, try_fix_json
from pr_agent.algo.utils import convert_to_markdown, try_fix_json, update_settings_from_args
from pr_agent.config_loader import settings
from pr_agent.git_providers import get_git_provider
from pr_agent.git_providers.git_provider import get_main_pr_language, IncrementalPR
@ -30,7 +30,8 @@ class PRReviewer:
is_answer (bool, optional): Indicates whether the review is being done in answer mode. Defaults to False.
args (list, optional): List of arguments passed to the PRReviewer class. Defaults to None.
"""
self.parse_args(args)
update_settings_from_args(args)
self.parse_args(args) # -i command
self.git_provider = get_git_provider()(pr_url, incremental=self.incremental)
self.main_language = get_main_pr_language(
@ -60,6 +61,7 @@ class PRReviewer:
'num_code_suggestions': settings.pr_reviewer.num_code_suggestions,
'question_str': question_str,
'answer_str': answer_str,
"extra_instructions": settings.pr_reviewer.extra_instructions,
}
self.token_handler = TokenHandler(

View File

@ -37,6 +37,7 @@ class PRUpdateChangelog:
"diff": "", # empty diff for initial calculation
"changelog_file_str": self.changelog_file_str,
"today": date.today(),
"extra_instructions": settings.pr_update_changelog_prompt.extra_instructions,
}
self.token_handler = TokenHandler(self.git_provider.pr,
self.vars,