Spaces:
Configuration error
Configuration error
Download openhands/events/action/commands.py from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 2.03 kB
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/openhands/events/action/commands.py
- Command line
-
hf download hf://spaces/flyingdarkdev/README/openhands/events/action/commands.py
-
curl -L -o commands.py https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/openhands/events/action/commands.py
2.03 kB
| from dataclasses import dataclass | |
| from typing import ClassVar | |
| from openhands.core.schema import ActionType | |
| from openhands.events.action.action import ( | |
| Action, | |
| ActionConfirmationStatus, | |
| ActionSecurityRisk, | |
| ) | |
| class CmdRunAction(Action): | |
| command: ( | |
| str # When `command` is empty, it will be used to print the current tmux window | |
| ) | |
| is_input: bool = False # if True, the command is an input to the running process | |
| thought: str = '' | |
| blocking: bool = False | |
| # If blocking is True, the command will be run in a blocking manner. | |
| # e.g., it will NOT return early due to soft timeout. | |
| hidden: bool = False | |
| action: str = ActionType.RUN | |
| runnable: ClassVar[bool] = True | |
| confirmation_state: ActionConfirmationStatus = ActionConfirmationStatus.CONFIRMED | |
| security_risk: ActionSecurityRisk | None = None | |
| def message(self) -> str: | |
| return f'Running command: {self.command}' | |
| def __str__(self) -> str: | |
| ret = f'**CmdRunAction (source={self.source}, is_input={self.is_input})**\n' | |
| if self.thought: | |
| ret += f'THOUGHT: {self.thought}\n' | |
| ret += f'COMMAND:\n{self.command}' | |
| return ret | |
| class IPythonRunCellAction(Action): | |
| code: str | |
| thought: str = '' | |
| include_extra: bool = ( | |
| True # whether to include CWD & Python interpreter in the output | |
| ) | |
| action: str = ActionType.RUN_IPYTHON | |
| runnable: ClassVar[bool] = True | |
| confirmation_state: ActionConfirmationStatus = ActionConfirmationStatus.CONFIRMED | |
| security_risk: ActionSecurityRisk | None = None | |
| kernel_init_code: str = '' # code to run in the kernel (if the kernel is restarted) | |
| def __str__(self) -> str: | |
| ret = '**IPythonRunCellAction**\n' | |
| if self.thought: | |
| ret += f'THOUGHT: {self.thought}\n' | |
| ret += f'CODE:\n{self.code}' | |
| return ret | |
| def message(self) -> str: | |
| return f'Running Python code interactively: {self.code}' | |