Files
OpenHands/openhands/events/observation/commands.py
Robert Brennan 01ae22ef57 Rename OpenDevin to OpenHands (#3472)
* 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>
2024-08-20 00:44:54 +08:00

46 lines
1.2 KiB
Python

from dataclasses import dataclass
from openhands.core.schema import ObservationType
from .observation import Observation
@dataclass
class CmdOutputObservation(Observation):
"""This data class represents the output of a command."""
command_id: int
command: str
exit_code: int = 0
observation: str = ObservationType.RUN
@property
def error(self) -> bool:
return self.exit_code != 0
@property
def message(self) -> str:
return f'Command `{self.command}` executed with exit code {self.exit_code}.'
def __str__(self) -> str:
return f'**CmdOutputObservation (source={self.source}, exit code={self.exit_code})**\n{self.content}'
@dataclass
class IPythonRunCellObservation(Observation):
"""This data class represents the output of a IPythonRunCellAction."""
code: str
observation: str = ObservationType.RUN_IPYTHON
@property
def error(self) -> bool:
return False # IPython cells do not return exit codes
@property
def message(self) -> str:
return 'Code executed in IPython cell.'
def __str__(self) -> str:
return f'**IPythonRunCellObservation**\n{self.content}'