Files
OpenHands/opendevin/events/event.py
Engel Nyst 0eccf31604 Refactor monologue and SWE agent to use the messages in state history (#1863)
* 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
2024-05-23 07:29:12 +00:00

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