π OpenHands: AI-Driven Development
Fix: local files in the browser (at least for Windows) (#839)
Redrum6249fd95cc35fb1
diff --git a/opendevin/action/browse.py b/opendevin/action/browse.pyindex b9e76114aa..f80eb6a678 100644--- a/opendevin/action/browse.py+++ b/opendevin/action/browse.py@@ -1,3 +1,4 @@+import osimport base64from dataclasses import dataclassfrom opendevin.observation import BrowserOutputObservation@@ -17,11 +18,14 @@ class BrowseURLAction(ExecutableAction):action: str = ActionType.BROWSEasync def run(self, controller: "AgentController") -> BrowserOutputObservation: # type: ignore+ asked_url = self.url+ if not asked_url.startswith("http"):+ asked_url = os.path.abspath(os.curdir) + self.urltry:async with async_playwright() as p:browser = await p.chromium.launch()page = await browser.new_page()- response = await page.goto(self.url)+ response = await page.goto(asked_url)# content = await page.content()inner_text = await page.evaluate("() => document.body.innerText")screenshot_bytes = await page.screenshot(full_page=True)@@ -31,14 +35,18 @@ class BrowseURLAction(ExecutableAction):return BrowserOutputObservation(content=inner_text, # HTML content of the pagescreenshot=screenshot_base64, # Base64-encoded screenshot- url=self.url,+ url=asked_url,status_code=response.status if response else 0, # HTTP status code)except Exception as e:return BrowserOutputObservation(- content=str(e), screenshot="", error=True, url=self.url+ content=str(e),+ screenshot="",+ error=True,+ url=asked_url)+@propertydef message(self) -> str:return f"Browsing URL: {self.url}"