From 7ee4c4aad1d4067dc6ac7cc5cc90f5911b457d06 Mon Sep 17 00:00:00 2001 From: Alessio <148966056+alessio-locatelli@users.noreply.github.com> Date: Tue, 17 Jun 2025 09:13:12 +0300 Subject: [PATCH 1/3] fix: yes/no spelling --- pr_agent/settings/pr_information_from_user_prompts.toml | 2 +- pr_agent/settings/pr_reviewer_prompts.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pr_agent/settings/pr_information_from_user_prompts.toml b/pr_agent/settings/pr_information_from_user_prompts.toml index 35ea5448..bbc321fe 100644 --- a/pr_agent/settings/pr_information_from_user_prompts.toml +++ b/pr_agent/settings/pr_information_from_user_prompts.toml @@ -2,7 +2,7 @@ system="""You are PR-Reviewer, a language model designed to review a Git Pull Request (PR). Given the PR Info and the PR Git Diff, generate 3 short questions about the PR code for the PR author. The goal of the questions is to help the language model understand the PR better, so the questions should be insightful, informative, non-trivial, and relevant to the PR. -You should prefer asking yes\\no questions, or multiple choice questions. Also add at least one open-ended question, but make sure they are not too difficult, and can be answered in a sentence or two. +You should prefer asking yes/no questions, or multiple choice questions. Also add at least one open-ended question, but make sure they are not too difficult, and can be answered in a sentence or two. Example output: diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index d4c0a523..f4ca1bde 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -93,7 +93,7 @@ class Review(BaseModel): score: str = Field(description="Rate this PR on a scale of 0-100 (inclusive), where 0 means the worst possible PR code, and 100 means PR code of the highest quality, without any bugs or performance issues, that is ready to be merged immediately and run in production at scale.") {%- endif %} {%- if require_tests %} - relevant_tests: str = Field(description="yes\\no question: does this PR have relevant tests added or updated ?") + relevant_tests: str = Field(description="yes/no question: does this PR have relevant tests added or updated ?") {%- endif %} {%- if question_str %} insights_from_user_answers: str = Field(description="shortly summarize the insights you gained from the user's answers to the questions") From 608065f2adb8d58d4f692466e1201e35d5eb9a8a Mon Sep 17 00:00:00 2001 From: Alessio <148966056+alessio-locatelli@users.noreply.github.com> Date: Tue, 17 Jun 2025 09:26:57 +0300 Subject: [PATCH 2/3] fix: typos --- docs/docs/usage-guide/changing_a_model.md | 2 +- pr_agent/algo/ai_handlers/litellm_ai_handler.py | 4 ++-- pr_agent/algo/utils.py | 2 +- pr_agent/settings/pr_help_prompts.toml | 4 ++-- pr_agent/tools/pr_help_docs.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/docs/usage-guide/changing_a_model.md b/docs/docs/usage-guide/changing_a_model.md index bfeb7c3a..46a72886 100644 --- a/docs/docs/usage-guide/changing_a_model.md +++ b/docs/docs/usage-guide/changing_a_model.md @@ -90,7 +90,7 @@ duplicate_examples=true # will duplicate the examples in the prompt, to help the api_base = "http://localhost:11434" # or whatever port you're running Ollama on ``` -By default, Ollama uses a context window size of 2048 tokens. In most cases this is not enough to cover pr-agent promt and pull-request diff. Context window size can be overridden with the `OLLAMA_CONTEXT_LENGTH` environment variable. For example, to set the default context length to 8K, use: `OLLAMA_CONTEXT_LENGTH=8192 ollama serve`. More information you can find on the [official ollama faq](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-specify-the-context-window-size). +By default, Ollama uses a context window size of 2048 tokens. In most cases this is not enough to cover pr-agent prompt and pull-request diff. Context window size can be overridden with the `OLLAMA_CONTEXT_LENGTH` environment variable. For example, to set the default context length to 8K, use: `OLLAMA_CONTEXT_LENGTH=8192 ollama serve`. More information you can find on the [official ollama faq](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-specify-the-context-window-size). Please note that the `custom_model_max_tokens` setting should be configured in accordance with the `OLLAMA_CONTEXT_LENGTH`. Failure to do so may result in unexpected model output. diff --git a/pr_agent/algo/ai_handlers/litellm_ai_handler.py b/pr_agent/algo/ai_handlers/litellm_ai_handler.py index f20b03f8..ec96d952 100644 --- a/pr_agent/algo/ai_handlers/litellm_ai_handler.py +++ b/pr_agent/algo/ai_handlers/litellm_ai_handler.py @@ -131,7 +131,7 @@ class LiteLLMAIHandler(BaseAiHandler): self.api_base = openrouter_api_base litellm.api_base = openrouter_api_base - # Models that only use user meessage + # Models that only use user message self.user_message_only_models = USER_MESSAGE_ONLY_MODELS # Model that doesn't support temperature argument @@ -212,7 +212,7 @@ class LiteLLMAIHandler(BaseAiHandler): return kwargs - def add_litellm_callbacks(selfs, kwargs) -> dict: + def add_litellm_callbacks(self, kwargs) -> dict: captured_extra = [] def capture_logs(message): diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 3e3103ad..58ca9cc5 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -1289,7 +1289,7 @@ def process_description(description_full: str) -> Tuple[str, List]: pattern_back = r'
\s*(.*?)
(.*?).*?
\s*
\s*(.*?)\n\n\s*(.*?)
' res = re.search(pattern_back, file_data, re.DOTALL) if not res or res.lastindex != 4: - pattern_back = r'
\s*(.*?)\s*
(.*?).*?
\s*
\s*(.*?)\s*-\s*(.*?)\s*
' # looking for hypen ('- ') + pattern_back = r'
\s*(.*?)\s*
(.*?).*?
\s*
\s*(.*?)\s*-\s*(.*?)\s*
' # looking for hyphen ('- ') res = re.search(pattern_back, file_data, re.DOTALL) if res and res.lastindex == 4: short_filename = res.group(1).strip() diff --git a/pr_agent/settings/pr_help_prompts.toml b/pr_agent/settings/pr_help_prompts.toml index 8e4c7a28..8bd18200 100644 --- a/pr_agent/settings/pr_help_prompts.toml +++ b/pr_agent/settings/pr_help_prompts.toml @@ -1,12 +1,12 @@ [pr_help_prompts] system="""You are Doc-helper, a language models designed to answer questions about a documentation website for an open-soure project called "PR-Agent" (recently renamed to "Qodo Merge"). -You will recieve a question, and the full documentation website content. +You will receive a question, and the full documentation website content. Your goal is to provide the best answer to the question using the documentation provided. Additional instructions: - Try to be short and concise in your answers. Try to give examples if needed. - The main tools of PR-Agent are 'describe', 'review', 'improve'. If there is ambiguity to which tool the user is referring to, prioritize snippets of these tools over others. -- If the question has ambiguity and can relate to different tools or platfroms, provide the best answer possible based on what is available, but also state in your answer what additional information would be needed to give a more accurate answer. +- If the question has ambiguity and can relate to different tools or platforms, provide the best answer possible based on what is available, but also state in your answer what additional information would be needed to give a more accurate answer. The output must be a YAML object equivalent to type $DocHelper, according to the following Pydantic definitions: diff --git a/pr_agent/tools/pr_help_docs.py b/pr_agent/tools/pr_help_docs.py index 89849aa7..aa700218 100644 --- a/pr_agent/tools/pr_help_docs.py +++ b/pr_agent/tools/pr_help_docs.py @@ -21,7 +21,7 @@ from pr_agent.servers.help import HelpMessage #Common code that can be called from similar tools: def modify_answer_section(ai_response: str) -> str | None: - # Gets the model's answer and relevant sources section, repacing the heading of the answer section with: + # Gets the model's answer and relevant sources section, replacing the heading of the answer section with: # :bulb: Auto-generated documentation-based answer: """ For example: The following input: From 5b7f8a4bb663bda85cc8e8f0c5d76633018540ed Mon Sep 17 00:00:00 2001 From: Alessio <148966056+alessio-locatelli@users.noreply.github.com> Date: Tue, 17 Jun 2025 09:52:34 +0300 Subject: [PATCH 3/3] fix: grammar --- pr_agent/settings/pr_description_prompts.toml | 4 ++-- pr_agent/settings/pr_reviewer_prompts.toml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pr_agent/settings/pr_description_prompts.toml b/pr_agent/settings/pr_description_prompts.toml index 4c14abee..276c8ccd 100644 --- a/pr_agent/settings/pr_description_prompts.toml +++ b/pr_agent/settings/pr_description_prompts.toml @@ -1,6 +1,6 @@ [pr_description_prompt] system="""You are PR-Reviewer, a language model designed to review a Git Pull Request (PR). -Your task is to provide a full description for the PR content - type, description, title and files walkthrough. +Your task is to provide a full description for the PR content: type, description, title, and files walkthrough. - Focus on the new PR code (lines starting with '+' in the 'PR Git Diff' section). - Keep in mind that the 'Previous title', 'Previous description' and 'Commit messages' sections may be partial, simplistic, non-informative or out of date. Hence, compare them to the PR diff code, and use them only as a reference. - The generated title and description should prioritize the most significant changes. @@ -181,4 +181,4 @@ pr_files: Response (should be a valid YAML, and nothing else): ```yaml -""" \ No newline at end of file +""" diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index f4ca1bde..0b3e772f 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -37,9 +37,9 @@ __new hunk__ ====== - In the format above, the diff is organized into separate '__new hunk__' and '__old hunk__' sections for each code chunk. '__new hunk__' contains the updated code, while '__old hunk__' shows the removed code. If no code was removed in a specific chunk, the __old hunk__ section will be omitted. -- We also added line numbers for the '__new hunk__' code, to help you refer to the code lines in your suggestions. These line numbers are not part of the actual code, and should only used for reference. +- We also added line numbers for the '__new hunk__' code, to help you refer to the code lines in your suggestions. These line numbers are not part of the actual code, and should only be used for reference. - Code lines are prefixed with symbols ('+', '-', ' '). The '+' symbol indicates new code added in the PR, the '-' symbol indicates code removed in the PR, and the ' ' symbol indicates unchanged code. \ - The review should address new code added in the PR code diff (lines starting with '+') + The review should address new code added in the PR code diff (lines starting with '+'). {%- if is_ai_metadata %} - If available, an AI-generated summary will appear and provide a high-level overview of the file changes. Note that this summary may not be fully accurate or complete. {%- endif %} @@ -100,7 +100,7 @@ class Review(BaseModel): {%- endif %} key_issues_to_review: List[KeyIssuesComponentLink] = Field("A short and diverse list (0-{{ num_max_findings }} issues) of high-priority bugs, problems or performance concerns introduced in the PR code, which the PR reviewer should further focus on and validate during the review process.") {%- if require_security_review %} - security_concerns: str = Field(description="Does this PR code introduce possible vulnerabilities such as exposure of sensitive information (e.g., API keys, secrets, passwords), or security concerns like SQL injection, XSS, CSRF, and others ? Answer 'No' (without explaining why) if there are no possible issues. If there are security concerns or issues, start your answer with a short header, such as: 'Sensitive information exposure: ...', 'SQL injection: ...' etc. Explain your answer. Be specific and give examples if possible") + security_concerns: str = Field(description="Does this PR code introduce possible vulnerabilities such as exposure of sensitive information (e.g., API keys, secrets, passwords), or security concerns like SQL injection, XSS, CSRF, and others ? Answer 'No' (without explaining why) if there are no possible issues. If there are security concerns or issues, start your answer with a short header, such as: 'Sensitive information exposure: ...', 'SQL injection: ...', etc. Explain your answer. Be specific and give examples if possible") {%- endif %} {%- if require_can_be_split_review %} can_be_split: List[SubPR] = Field(min_items=0, max_items=3, description="Can this PR, which contains {{ num_pr_files }} changed files in total, be divided into smaller sub-PRs with distinct tasks that can be reviewed and merged independently, regardless of the order ? Make sure that the sub-PRs are indeed independent, with no code dependencies between them, and that each sub-PR represent a meaningful independent task. Output an empty list if the PR code does not need to be split.")