Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API endpoints for resolver functionality #5058

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
73e190e
Add API endpoints for resolver functionality
openhands-agent Nov 15, 2024
fba35a4
Revert changes to send_pull_request.py
openhands-agent Nov 15, 2024
486355b
Improve process_single_issue return type and error handling
openhands-agent Nov 15, 2024
cb92518
Merge branch 'main' into add-resolver-api-endpoints
neubig Nov 15, 2024
66b4e5d
Fix failing tests in test_listen.py
openhands-agent Nov 15, 2024
abde56f
Update
neubig Nov 15, 2024
cfd3911
Refactor resolver endpoints to use data models (#5073)
neubig Nov 15, 2024
95884c1
Lint
neubig Nov 16, 2024
87925dd
Merge branch 'main' into add-resolver-api-endpoints
neubig Nov 16, 2024
c2265e8
Fix pr #5058: Add API endpoints for resolver functionality
openhands-agent Nov 16, 2024
a4f5772
Fix pr #5058: Add API endpoints for resolver functionality
openhands-agent Nov 16, 2024
27592c5
fix: Fix send-pr endpoint to use correct file path and update tests t…
openhands-agent Nov 16, 2024
f037482
Merge branch 'main' into add-resolver-api-endpoints
neubig Nov 16, 2024
031e201
feat: Combine resolve_issue and send_pull_request API calls into a si…
openhands-agent Nov 16, 2024
845f1b2
style: Fix linting issues
openhands-agent Nov 16, 2024
dbf560d
refactor: Improve resolver API endpoints
openhands-agent Nov 16, 2024
1f53c93
refactor: Remove unused SendPullRequestDataModel
openhands-agent Nov 16, 2024
45a1486
style: Format imports in listen.py
openhands-agent Nov 16, 2024
2ce806e
fix: Convert ResolverOutput to dict in response
openhands-agent Nov 16, 2024
c088a08
style: Fix linting in test_listen.py
openhands-agent Nov 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"APP_MODE": "oss",
"GITHUB_CLIENT_ID": "",
"POSTHOG_CLIENT_KEY": "phc_3ESMmY9SgqEAGBB6sMGK5ayYHkeUuknH2vP6FmWH9RA"
}
}
4 changes: 3 additions & 1 deletion openhands/agenthub/codeact_agent/codeact_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ def get_action_message(
)
]
elif isinstance(action, CmdRunAction) and action.source == 'user':
content = [TextContent(text=f'User executed the command:\n{action.command}')]
content = [
TextContent(text=f'User executed the command:\n{action.command}')
]
return [
Message(
role='user',
Expand Down
1 change: 1 addition & 0 deletions openhands/events/action/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def images_urls(self):
@images_urls.setter
def images_urls(self, value):
self.image_urls = value

def __str__(self) -> str:
ret = f'**MessageAction** (source={self.source})\n'
ret += f'CONTENT: {self.content}'
Expand Down
2 changes: 1 addition & 1 deletion openhands/events/serialization/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def action_from_dict(action: dict) -> Action:
# images_urls has been renamed to image_urls
if 'images_urls' in args:
args['image_urls'] = args.pop('images_urls')

try:
decoded_action = action_class(**args)
if 'timeout' in action:
Expand Down
4 changes: 2 additions & 2 deletions openhands/resolver/patching/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from .patch import parse_patch
from .apply import apply_diff
from .patch import parse_patch

__all__ = ["parse_patch", "apply_diff"]
__all__ = ['parse_patch', 'apply_diff']
34 changes: 17 additions & 17 deletions openhands/resolver/patching/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@

def _apply_diff_with_subprocess(diff, lines, reverse=False):
# call out to patch program
patchexec = which("patch")
patchexec = which('patch')
if not patchexec:
raise SubprocessException("cannot find patch program", code=-1)
raise SubprocessException('cannot find patch program', code=-1)

tempdir = tempfile.gettempdir()

filepath = os.path.join(tempdir, "wtp-" + str(hash(diff.header)))
oldfilepath = filepath + ".old"
newfilepath = filepath + ".new"
rejfilepath = filepath + ".rej"
patchfilepath = filepath + ".patch"
with open(oldfilepath, "w") as f:
f.write("\n".join(lines) + "\n")
filepath = os.path.join(tempdir, 'wtp-' + str(hash(diff.header)))
oldfilepath = filepath + '.old'
newfilepath = filepath + '.new'
rejfilepath = filepath + '.rej'
patchfilepath = filepath + '.patch'
with open(oldfilepath, 'w') as f:
f.write('\n'.join(lines) + '\n')

with open(patchfilepath, "w") as f:
with open(patchfilepath, 'w') as f:
f.write(diff.text)

args = [
patchexec,
"--reverse" if reverse else "--forward",
"--quiet",
"--no-backup-if-mismatch",
"-o",
'--reverse' if reverse else '--forward',
'--quiet',
'--no-backup-if-mismatch',
'-o',
newfilepath,
"-i",
'-i',
patchfilepath,
"-r",
'-r',
rejfilepath,
oldfilepath,
]
Expand All @@ -58,7 +58,7 @@ def _apply_diff_with_subprocess(diff, lines, reverse=False):

# do this last to ensure files get cleaned up
if ret != 0:
raise SubprocessException("patch program failed", code=ret)
raise SubprocessException('patch program failed', code=ret)

return lines, rejlines

Expand Down
2 changes: 1 addition & 1 deletion openhands/resolver/patching/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def __init__(self, msg, hunk=None):
self.hunk = hunk
if hunk is not None:
super(HunkException, self).__init__(
"{msg}, in hunk #{n}".format(msg=msg, n=hunk)
'{msg}, in hunk #{n}'.format(msg=msg, n=hunk)
)
else:
super(HunkException, self).__init__(msg)
Expand Down
Loading
Loading