Skip to content

Commit b1eb8b4

Browse files
committed
make console ui better
1 parent 109571b commit b1eb8b4

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

AgentCrew/modules/chat/console_ui.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ def listen(self, event: str, data: Any = None):
8888
self.display_thinking_started(data) # data is agent_name
8989
elif event == "thinking_chunk":
9090
self.display_thinking_chunk(data) # data is the thinking chunk
91+
elif event == "user_message_created":
92+
self.console.print("\n")
9193
elif event == "response_chunk":
9294
self.stop_loading_animation() # Stop loading on first chunk
9395
_, assistant_response = data
@@ -965,20 +967,20 @@ def get_user_input(self):
965967
Returns:
966968
The user input as a string.
967969
"""
968-
title = Text(f"\n[{self.message_handler.agent.name}", style=RICH_STYLE_RED)
969-
title.append(":")
970-
title.append(
971-
f"{self.message_handler.agent.get_model()}]",
972-
style=RICH_STYLE_BLUE,
973-
)
974-
title.append(
975-
"\n(Press Enter for new line, Ctrl+S/Alt+Enter to submit, Up/Down for history)\n",
976-
style=RICH_STYLE_YELLOW,
977-
)
978-
self.console.print(title)
979970

980971
# Start input thread if not already running
981972
if self._input_thread is None or not self._input_thread.is_alive():
973+
title = Text(f"\n[{self.message_handler.agent.name}", style=RICH_STYLE_RED)
974+
title.append(":")
975+
title.append(
976+
f"{self.message_handler.agent.get_model()}]",
977+
style=RICH_STYLE_BLUE,
978+
)
979+
title.append(
980+
"\n(Press Enter for new line, Ctrl+S/Alt+Enter to submit, Up/Down for history)\n",
981+
style=RICH_STYLE_YELLOW,
982+
)
983+
self.console.print(title)
982984
self._start_input_thread()
983985
else:
984986
self._print_prompt_prefix()
@@ -1049,6 +1051,17 @@ def start_streaming_response(self, agent_name: str):
10491051
self.live.start()
10501052

10511053
def _print_prompt_prefix(self):
1054+
title = Text(f"\n[{self.message_handler.agent.name}", style=RICH_STYLE_RED)
1055+
title.append(":")
1056+
title.append(
1057+
f"{self.message_handler.agent.get_model()}]",
1058+
style=RICH_STYLE_BLUE,
1059+
)
1060+
title.append(
1061+
"\n(Press Enter for new line, Ctrl+S/Alt+Enter to submit, Up/Down for history)\n",
1062+
style=RICH_STYLE_YELLOW,
1063+
)
1064+
self.console.print(title)
10521065
prompt = Text("👤 YOU: ", style=RICH_STYLE_BLUE_BOLD)
10531066
self.console.print(prompt, end="")
10541067

0 commit comments

Comments
 (0)