files.py 684 B

12345678910111213141516171819202122232425262728
  1. from dataclasses import dataclass
  2. from openhands.core.schema import ObservationType
  3. from openhands.events.observation.observation import Observation
  4. @dataclass
  5. class FileReadObservation(Observation):
  6. """This data class represents the content of a file."""
  7. path: str
  8. observation: str = ObservationType.READ
  9. @property
  10. def message(self) -> str:
  11. return f'I read the file {self.path}.'
  12. @dataclass
  13. class FileWriteObservation(Observation):
  14. """This data class represents a file write operation"""
  15. path: str
  16. observation: str = ObservationType.WRITE
  17. @property
  18. def message(self) -> str:
  19. return f'I wrote to the file {self.path}.'