mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-04-29 03:00:45 -04:00
visual diff
This commit is contained in:
@@ -33,7 +33,9 @@ ColorType = Literal[
|
||||
LOG_COLORS: Mapping[str, ColorType] = {
|
||||
'BACKGROUND LOG': 'blue',
|
||||
'ACTION': 'green',
|
||||
'USER_ACTION': 'light_red',
|
||||
'OBSERVATION': 'yellow',
|
||||
'USER_OBSERVATION': 'light_green',
|
||||
'DETAIL': 'cyan',
|
||||
'ERROR': 'red',
|
||||
'PLAN': 'light_magenta',
|
||||
@@ -43,6 +45,11 @@ LOG_COLORS: Mapping[str, ColorType] = {
|
||||
class ColoredFormatter(logging.Formatter):
|
||||
def format(self, record):
|
||||
msg_type = record.__dict__.get('msg_type')
|
||||
event_source = record.__dict__.get('event_source')
|
||||
if event_source:
|
||||
new_msg_type = f'{event_source.upper()}_{msg_type}'
|
||||
if new_msg_type in LOG_COLORS:
|
||||
msg_type = new_msg_type
|
||||
if msg_type in LOG_COLORS and not DISABLE_COLOR_PRINTING:
|
||||
msg_type_color = colored(msg_type, LOG_COLORS[msg_type])
|
||||
msg = colored(record.msg, LOG_COLORS[msg_type])
|
||||
|
||||
@@ -25,7 +25,7 @@ class CmdOutputObservation(Observation):
|
||||
return f'Command `{self.command}` executed with exit code {self.exit_code}.'
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f'**CmdOutputObservation (exit code={self.exit_code})**\n{self.content}'
|
||||
return f'**CmdOutputObservation (source={self.source}, exit code={self.exit_code})**\n{self.content}'
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -98,7 +98,9 @@ class Session:
|
||||
event = event_from_dict(data.copy())
|
||||
event._source = EventSource.USER # type: ignore[attr-defined]
|
||||
if isinstance(event, Action):
|
||||
logger.info(event, extra={'msg_type': 'ACTION'})
|
||||
logger.info(
|
||||
event, extra={'msg_type': 'ACTION', 'event_source': EventSource.USER}
|
||||
)
|
||||
await self.agent_session.event_stream.add_event(event, EventSource.USER)
|
||||
|
||||
async def send(self, data: dict[str, object]) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user