mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 05:10:38 +08:00
rename vars
This commit is contained in:
@ -50,6 +50,7 @@ final_clip_factor = 0.9
|
|||||||
[pr_add_docs_prompt] # /add_docs #
|
[pr_add_docs_prompt] # /add_docs #
|
||||||
extra_instructions = ""
|
extra_instructions = ""
|
||||||
docs_style = "Google Style" # "Google Style", "Numpy Style", "Sphinx Style", "PEP257", "reStructuredText"
|
docs_style = "Google Style" # "Google Style", "Numpy Style", "Sphinx Style", "PEP257", "reStructuredText"
|
||||||
|
max_number_of_calls = 5
|
||||||
|
|
||||||
[pr_update_changelog] # /update_changelog #
|
[pr_update_changelog] # /update_changelog #
|
||||||
push_changelog_changes=false
|
push_changelog_changes=false
|
||||||
|
@ -67,7 +67,7 @@ class PRAddDocs:
|
|||||||
logging.info('Pushing PR review...')
|
logging.info('Pushing PR review...')
|
||||||
self.git_provider.remove_initial_comment()
|
self.git_provider.remove_initial_comment()
|
||||||
logging.info('Pushing inline code documentation...')
|
logging.info('Pushing inline code documentation...')
|
||||||
self.push_inline_docs_suggestions(data)
|
self.push_inline_docs(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Failed to generate code documentation for PR, error: {e}")
|
logging.error(f"Failed to generate code documentation for PR, error: {e}")
|
||||||
|
|
||||||
@ -103,8 +103,8 @@ class PRAddDocs:
|
|||||||
data = {'Code Documentation': data}
|
data = {'Code Documentation': data}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def push_inline_docs_suggestions(self, data):
|
def push_inline_docs(self, data):
|
||||||
code_suggestions = []
|
docs = []
|
||||||
|
|
||||||
if not data['Code Documentation']:
|
if not data['Code Documentation']:
|
||||||
return self.git_provider.publish_comment('No code documentation found to improve this PR.')
|
return self.git_provider.publish_comment('No code documentation found to improve this PR.')
|
||||||
@ -122,18 +122,18 @@ class PRAddDocs:
|
|||||||
add_original_line=True)
|
add_original_line=True)
|
||||||
|
|
||||||
body = f"**Suggestion:** Proposed documentation\n```suggestion\n" + new_code_snippet + "\n```"
|
body = f"**Suggestion:** Proposed documentation\n```suggestion\n" + new_code_snippet + "\n```"
|
||||||
code_suggestions.append({'body': body, 'relevant_file': relevant_file,
|
docs.append({'body': body, 'relevant_file': relevant_file,
|
||||||
'relevant_lines_start': relevant_line,
|
'relevant_lines_start': relevant_line,
|
||||||
'relevant_lines_end': relevant_line})
|
'relevant_lines_end': relevant_line})
|
||||||
except Exception:
|
except Exception:
|
||||||
if get_settings().config.verbosity_level >= 2:
|
if get_settings().config.verbosity_level >= 2:
|
||||||
logging.info(f"Could not parse code docs: {d}")
|
logging.info(f"Could not parse code docs: {d}")
|
||||||
|
|
||||||
is_successful = self.git_provider.publish_code_suggestions(code_suggestions)
|
is_successful = self.git_provider.publish_code_suggestions(docs)
|
||||||
if not is_successful:
|
if not is_successful:
|
||||||
logging.info("Failed to publish code docs, trying to publish each docs separately")
|
logging.info("Failed to publish code docs, trying to publish each docs separately")
|
||||||
for code_suggestion in code_suggestions:
|
for documentation in docs:
|
||||||
self.git_provider.publish_code_suggestions([code_suggestion])
|
self.git_provider.publish_code_suggestions([documentation])
|
||||||
|
|
||||||
def dedent_code(self, relevant_file, relevant_lines_start, new_code_snippet, doc_placement='after',
|
def dedent_code(self, relevant_file, relevant_lines_start, new_code_snippet, doc_placement='after',
|
||||||
add_original_line=False):
|
add_original_line=False):
|
||||||
@ -170,7 +170,7 @@ class PRAddDocs:
|
|||||||
async def _prepare_prediction_extended(self, model: str) -> dict:
|
async def _prepare_prediction_extended(self, model: str) -> dict:
|
||||||
logging.info('Getting PR diff...')
|
logging.info('Getting PR diff...')
|
||||||
patches_diff_list = get_pr_multi_diffs(self.git_provider, self.token_handler, model,
|
patches_diff_list = get_pr_multi_diffs(self.git_provider, self.token_handler, model,
|
||||||
max_calls=get_settings().pr_code_suggestions.max_number_of_calls)
|
max_calls=get_settings().pr_add_docs_prompt.max_number_of_calls)
|
||||||
|
|
||||||
logging.info('Getting multi AI predictions...')
|
logging.info('Getting multi AI predictions...')
|
||||||
prediction_list = []
|
prediction_list = []
|
||||||
|
Reference in New Issue
Block a user