Skip to content

Commit

Permalink
fix weird descriptions and use new steps for ResolveIssue
Browse files Browse the repository at this point in the history
  • Loading branch information
CTY-git committed Jan 6, 2025
1 parent b923a2f commit 3ffa2e1
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 14 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ jobs:
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --only main --extras rag

# disabled because this currently takes too long
# - name: Resolve issue
# run: |
# poetry run patchwork ResolveIssue --log debug \
# --patched_api_key=${{ secrets.PATCHED_API_KEY }} \
# --github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
# --issue_url=https://github.com/patched-codes/patchwork/issues/1039 \
# --disable_telemetry
- name: Resolve issue
run: |
poetry run patchwork ResolveIssue --log debug \
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--issue_url=https://github.com/patched-codes/patchwork/issues/1039 \
--disable_telemetry
--max_llm_calls=10
main-test:
runs-on: ubuntu-latest
Expand Down
5 changes: 2 additions & 3 deletions patchwork/common/tools/code_edit_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def json_schema(self) -> dict:
* If `path` is a file, `view` displays the result of applying `cat -n`. If `path` is a directory, `view` lists non-hidden files and directories up to 2 levels deep
* The `create` command cannot be used if the specified `path` already exists as a file
* If a `command` generates a long output, it will be truncated and marked with `<response clipped>`
* The `undo_edit` command will revert the last edit made to the file at `path`
* The working directory is always {self.repo_path}
Notes for using the `str_replace` command:
Expand All @@ -36,8 +35,8 @@ def json_schema(self) -> dict:
"properties": {
"command": {
"type": "string",
"enum": ["view", "create", "str_replace", "insert", "undo_edit"],
"description": "The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.",
"enum": ["view", "create", "str_replace", "insert"],
"description": "The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`.",
},
"file_text": {
"description": "Required parameter of `create` command, with the content of the file to be created.",
Expand Down
107 changes: 104 additions & 3 deletions patchwork/patchflows/ResolveIssue/ResolveIssue.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from patchwork.common.utils.progress_bar import PatchflowProgressBar
from patchwork.common.utils.step_typing import validate_steps_with_inputs
from patchwork.step import Step
from patchwork.steps import PR, FixIssue, ReadIssues
from patchwork.steps import PR, AgenticLLM, FixIssue, ReadIssues, SimplifiedLLMOnce

_DEFAULT_INPUT_FILE = Path(__file__).parent / "defaults.yml"

Expand All @@ -30,13 +30,114 @@ def __init__(self, inputs: dict):
PR,
)

# currently only support claude
final_inputs["model"] = "claude-3-5-sonnet-latest"
self.inputs = final_inputs

def run(self) -> dict:
outputs = ReadIssues(self.inputs).run()
self.inputs["issue_description"] = outputs
outputs = FixIssue(self.inputs).run()
self.inputs.update(outputs)

outputs = AgenticLLM(
dict(
**self.inputs,
prompt_value=dict(
path=self.inputs.get("base_path", str(Path.cwd())),
issue=outputs["issue_description"],
),
system_prompt="""\
You are a senior software engineer tasked to analyze a issue.
Your analysis will be used to guide the junior engineer to resolve this issue.
""",
user_prompt="""\
<uploaded_files>
{{path}}
</uploaded_files>
I've uploaded a code repository in the current working directory.
Consider the following issue:
<issue_description>
{{issue}}
</issue_description>
Let's first explore and analyze the repository to understand where the issue is located.
Please analyze the repository structure and try to locate the specific files and code sections that need to be modified.
1. First explore the repo structure
2. Identify the relevant files that likely need changes
3. Once you've confirmed the error, identify the specific code sections that need to be modified
Provide your findings in this format:
<analysis>
<files>List the relevant files that need changes</files>
<changes_needed>Description of the specific changes needed</changes_needed>
</analysis>
""",
max_llm_calls=200,
)
).run()
outputs = SimplifiedLLMOnce(
dict(
**self.inputs,
json_schema=dict(
files=["The files to be changed"], changes_needed="Description of the specific changes needed"
),
user_prompt="""\
From the following conversation history extract the following information:
<analysis>
<files>List the relevant files that need changes</files>
<changes_needed>Description of the specific changes needed</changes_needed>
</analysis>
<conversation_history>
{{conversation_history}}
</conversation_history>
""",
prompt_value=outputs,
)
).run()

outputs = AgenticLLM(
dict(
**self.inputs,
prompt_value=dict(
path=self.inputs.get("base_path", str(Path.cwd())),
analysis_result=outputs,
),
system_prompt="""\
You are a senior software engineer assigned to fix an issue. Your lead engineer have already analyzed the issue and provided his analysis for you for reference.
""",
user_prompt="""\
<uploaded_files>
{{path}}
</uploaded_files>
I've uploaded a code repository in the current working directory.
Based on our analysis:
<lead_analysis>
<files_to_be_changed>
{{analysis_result.files}}
</files_to_be_changed>
<change_description>
{{analysis_result.changes_needed}}
</change_description>
</lead_analysis>
Let's implement the necessary changes:
1. Edit the sourcecode of the repo to resolve the issue
2. Think about edge cases and make sure your fix handles them as well
I've already taken care of all changes to any of the test files described in the PR.
This means you DON'T have to modify the testing logic or any of the tests in any way!
""",
max_llm_calls=200,
)
).run()
self.inputs["modified_files"] = outputs["tool_records"]

outputs = PR(self.inputs).run()
self.inputs.update(outputs)

Expand Down

0 comments on commit 3ffa2e1

Please sign in to comment.