browse.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from dataclasses import dataclass
  2. from typing import ClassVar
  3. from opendevin.core.schema import ActionType
  4. from .action import Action
  5. @dataclass
  6. class BrowseURLAction(Action):
  7. url: str
  8. thought: str = ''
  9. action: str = ActionType.BROWSE
  10. runnable: ClassVar[bool] = True
  11. @property
  12. def message(self) -> str:
  13. return f'Browsing URL: {self.url}'
  14. def __str__(self) -> str:
  15. ret = '**BrowseURLAction**\n'
  16. if self.thought:
  17. ret += f'THOUGHT: {self.thought}\n'
  18. ret += f'URL: {self.url}'
  19. return ret
  20. @dataclass
  21. class BrowseInteractiveAction(Action):
  22. browser_actions: str
  23. thought: str = ''
  24. browsergym_send_msg_to_user: str = ''
  25. action: str = ActionType.BROWSE_INTERACTIVE
  26. runnable: ClassVar[bool] = True
  27. @property
  28. def message(self) -> str:
  29. return f'Executing browser actions: {self.browser_actions}'
  30. def __str__(self) -> str:
  31. ret = '**BrowseInteractiveAction**\n'
  32. if self.thought:
  33. ret += f'THOUGHT: {self.thought}\n'
  34. ret += f'BROWSER_ACTIONS: {self.browser_actions}'
  35. return ret