OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

Fix: local files in the browser (at least for Windows)

Open Redrum624 opened this issue 1 year ago • 2 comments

The Browser works for screenshoting websites, but when the LLM tries to display a local file that he created, it can't access the full directory on Windows.

Redrum624 avatar Apr 07 '24 01:04 Redrum624

IIUC, the agent tried to browse: url=./file.html--but it needs to know cwd to see that file correctly. Seems like a good issue to fix.

For the "how", we can probably do a little pre-detection here, instead of doing a try/except. e.g. if not url.startswith("http") url = cwd + url

@Redrum624 do you want to continue iterating on this PR? Or would you rather open an issue and have someone else get to it?

rbren avatar Apr 09 '24 18:04 rbren

Updated it with your recommandations, works fine with "http" and local files. Did not use cwd because it would give this url .\opendevin\action\browse.py and the local file is in .\workspace, so I'm using os.path.abspath(os.curdir) to get the root path and add self.url which is .\workspace\index.html, for example, to display the local file. Tell me if I'm missing anything here, I'm just a beginner in Python.

Redrum624 avatar Apr 09 '24 19:04 Redrum624

This LGTM! Thanks for the adjustments!

rbren avatar Apr 12 '24 02:04 rbren