π OpenHands: AI-Driven Development
fix file write observations (#225)
Robert Brennanea10809a96b9
diff --git a/opendevin/action/fileop.py b/opendevin/action/fileop.pyindex 29279c1629..2621513742 100644--- a/opendevin/action/fileop.py+++ b/opendevin/action/fileop.py@@ -1,7 +1,7 @@import osfrom dataclasses import dataclass-from opendevin.observation import Observation, FileReadObservation+from opendevin.observation import FileReadObservation, FileWriteObservationfrom .base import ExecutableAction# This is the path where the workspace is mounted in the container@@ -37,11 +37,11 @@ class FileWriteAction(ExecutableAction):contents: strbase_path: str = ""- def run(self, *args, **kwargs) -> Observation:+ def run(self, *args, **kwargs) -> FileWriteObservation:path = resolve_path(self.base_path, self.path)with open(path, 'w', encoding='utf-8') as file:file.write(self.contents)- return Observation(f"File written to {path}")+ return FileWriteObservation(content="", path=self.path)@propertydef message(self) -> str:diff --git a/opendevin/observation.py b/opendevin/observation.pyindex 38aa4ea805..bdc149648e 100644--- a/opendevin/observation.py+++ b/opendevin/observation.py@@ -61,6 +61,17 @@ class FileReadObservation(Observation):def message(self) -> str:return f"I read the file {self.path}."+@dataclass+class FileWriteObservation(Observation):+ """+ This data class represents a file write operation+ """++ path: str++ @property+ def message(self) -> str:+ return f"I wrote to the file {self.path}."@dataclassclass BrowserOutputObservation(Observation):