mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
* Replace OpenDevin with OpenHands * Update CONTRIBUTING.md * Update README.md * Update README.md * update poetry lock; move opendevin folder to openhands * fix env var * revert image references in docs * revert permissions * revert permissions --------- Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
43 lines
971 B
Python
43 lines
971 B
Python
from dataclasses import dataclass
|
|
from typing import ClassVar
|
|
|
|
from openhands.core.schema import ActionType
|
|
|
|
from .action import Action, ActionSecurityRisk
|
|
|
|
|
|
@dataclass
|
|
class FileReadAction(Action):
|
|
"""Reads a file from a given path.
|
|
Can be set to read specific lines using start and end
|
|
Default lines 0:-1 (whole file)
|
|
"""
|
|
|
|
path: str
|
|
start: int = 0
|
|
end: int = -1
|
|
thought: str = ''
|
|
action: str = ActionType.READ
|
|
runnable: ClassVar[bool] = True
|
|
security_risk: ActionSecurityRisk | None = None
|
|
|
|
@property
|
|
def message(self) -> str:
|
|
return f'Reading file: {self.path}'
|
|
|
|
|
|
@dataclass
|
|
class FileWriteAction(Action):
|
|
path: str
|
|
content: str
|
|
start: int = 0
|
|
end: int = -1
|
|
thought: str = ''
|
|
action: str = ActionType.WRITE
|
|
runnable: ClassVar[bool] = True
|
|
security_risk: ActionSecurityRisk | None = None
|
|
|
|
@property
|
|
def message(self) -> str:
|
|
return f'Writing file: {self.path}'
|