From a2d91ee3a809fec2516b17bf135f18ec3753fc56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AE=E0=AE=A9=E0=AF=8B=E0=AE=9C=E0=AF=8D=E0=AE=95?= =?UTF-8?q?=E0=AF=81=E0=AE=AE=E0=AE=BE=E0=AE=B0=E0=AF=8D=20=E0=AE=AA?= =?UTF-8?q?=E0=AE=B4=E0=AE=A9=E0=AE=BF=E0=AE=9A=E0=AF=8D=E0=AE=9A=E0=AE=BE?= =?UTF-8?q?=E0=AE=AE=E0=AE=BF?= Date: Thu, 20 Jun 2024 19:35:01 +0530 Subject: [PATCH] visual diff --- opendevin/core/logger.py | 7 +++++++ opendevin/events/observation/commands.py | 2 +- opendevin/server/session/session.py | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/opendevin/core/logger.py b/opendevin/core/logger.py index a92968b244..3408577a42 100644 --- a/opendevin/core/logger.py +++ b/opendevin/core/logger.py @@ -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]) diff --git a/opendevin/events/observation/commands.py b/opendevin/events/observation/commands.py index 1a199cec8f..089d8ae08c 100644 --- a/opendevin/events/observation/commands.py +++ b/opendevin/events/observation/commands.py @@ -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 diff --git a/opendevin/server/session/session.py b/opendevin/server/session/session.py index fcb18cd6d5..d1bddb47e2 100644 --- a/opendevin/server/session/session.py +++ b/opendevin/server/session/session.py @@ -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: