forked from All-Hands-AI/OpenHands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browse.py
47 lines (37 loc) · 1.23 KB
/
browse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from dataclasses import dataclass
from typing import ClassVar
from openhands.core.schema import ActionType
from .action import Action, ActionSecurityRisk
@dataclass
class BrowseURLAction(Action):
url: str
thought: str = ''
action: str = ActionType.BROWSE
runnable: ClassVar[bool] = True
security_risk: ActionSecurityRisk | None = None
@property
def message(self) -> str:
return f'Browsing URL: {self.url}'
def __str__(self) -> str:
ret = '**BrowseURLAction**\n'
if self.thought:
ret += f'THOUGHT: {self.thought}\n'
ret += f'URL: {self.url}'
return ret
@dataclass
class BrowseInteractiveAction(Action):
browser_actions: str
thought: str = ''
browsergym_send_msg_to_user: str = ''
action: str = ActionType.BROWSE_INTERACTIVE
runnable: ClassVar[bool] = True
security_risk: ActionSecurityRisk | None = None
@property
def message(self) -> str:
return f'Executing browser actions: {self.browser_actions}'
def __str__(self) -> str:
ret = '**BrowseInteractiveAction**\n'
if self.thought:
ret += f'THOUGHT: {self.thought}\n'
ret += f'BROWSER_ACTIONS: {self.browser_actions}'
return ret