mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-04-29 03:00:45 -04:00
* Refactor monologue to use the messages in state history * add messages, clean up * fix monologue * update integration tests * move private method * update SWE agent to use the history from State * integration tests for SWE agent * rename monologue to initial_thoughts, since that is what it is
42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
import datetime
|
|
from dataclasses import dataclass
|
|
from enum import Enum
|
|
|
|
|
|
class EventSource(str, Enum):
|
|
AGENT = 'agent'
|
|
USER = 'user'
|
|
|
|
|
|
@dataclass
|
|
class Event:
|
|
@property
|
|
def message(self) -> str | None:
|
|
if hasattr(self, '_message'):
|
|
return self._message # type: ignore [attr-defined]
|
|
return ''
|
|
|
|
@property
|
|
def id(self) -> int | None:
|
|
if hasattr(self, '_id'):
|
|
return self._id # type: ignore [attr-defined]
|
|
return -1
|
|
|
|
@property
|
|
def timestamp(self) -> datetime.datetime | None:
|
|
if hasattr(self, '_timestamp'):
|
|
return self._timestamp # type: ignore [attr-defined]
|
|
return None
|
|
|
|
@property
|
|
def source(self) -> EventSource | None:
|
|
if hasattr(self, '_source'):
|
|
return self._source # type: ignore [attr-defined]
|
|
return None
|
|
|
|
@property
|
|
def cause(self) -> int | None:
|
|
if hasattr(self, '_cause'):
|
|
return self._cause # type: ignore [attr-defined]
|
|
return None
|