Basic interface for dumping agent events to the command-line
| 61 | |
| 62 | |
| 63 | class CLIInterface(AgentInterface): |
| 64 | """Basic interface for dumping agent events to the command-line""" |
| 65 | |
| 66 | @staticmethod |
| 67 | def important_message(msg: str): |
| 68 | fstr = f"{Fore.MAGENTA}{Style.BRIGHT}{{msg}}{Style.RESET_ALL}" |
| 69 | if STRIP_UI: |
| 70 | fstr = "{msg}" |
| 71 | print(fstr.format(msg=msg)) |
| 72 | |
| 73 | @staticmethod |
| 74 | def warning_message(msg: str): |
| 75 | fstr = f"{Fore.RED}{Style.BRIGHT}{{msg}}{Style.RESET_ALL}" |
| 76 | if STRIP_UI: |
| 77 | fstr = "{msg}" |
| 78 | else: |
| 79 | print(fstr.format(msg=msg)) |
| 80 | |
| 81 | @staticmethod |
| 82 | def internal_monologue(msg: str, msg_obj: Optional[Message] = None, chunk_index: Optional[int] = None): |
| 83 | # ANSI escape code for italic is '\x1B[3m' |
| 84 | fstr = f"\x1B[3m{Fore.LIGHTBLACK_EX}{INNER_THOUGHTS_CLI_SYMBOL} {{msg}}{Style.RESET_ALL}" |
| 85 | if STRIP_UI: |
| 86 | fstr = "{msg}" |
| 87 | print(fstr.format(msg=msg)) |
| 88 | |
| 89 | @staticmethod |
| 90 | def assistant_message(msg: str, msg_obj: Optional[Message] = None): |
| 91 | fstr = f"{Fore.YELLOW}{Style.BRIGHT}{ASSISTANT_MESSAGE_CLI_SYMBOL} {Fore.YELLOW}{{msg}}{Style.RESET_ALL}" |
| 92 | if STRIP_UI: |
| 93 | fstr = "{msg}" |
| 94 | print(fstr.format(msg=msg)) |
| 95 | |
| 96 | @staticmethod |
| 97 | def memory_message(msg: str, msg_obj: Optional[Message] = None): |
| 98 | fstr = f"{Fore.LIGHTMAGENTA_EX}{Style.BRIGHT}🧠 {Fore.LIGHTMAGENTA_EX}{{msg}}{Style.RESET_ALL}" |
| 99 | if STRIP_UI: |
| 100 | fstr = "{msg}" |
| 101 | print(fstr.format(msg=msg)) |
| 102 | |
| 103 | @staticmethod |
| 104 | def system_message(msg: str, msg_obj: Optional[Message] = None): |
| 105 | fstr = f"{Fore.MAGENTA}{Style.BRIGHT}🖥️ [system] {Fore.MAGENTA}{msg}{Style.RESET_ALL}" |
| 106 | if STRIP_UI: |
| 107 | fstr = "{msg}" |
| 108 | print(fstr.format(msg=msg)) |
| 109 | |
| 110 | @staticmethod |
| 111 | def user_message( |
| 112 | msg: str, |
| 113 | msg_obj: Optional[Message] = None, |
| 114 | raw: bool = False, |
| 115 | dump: bool = False, |
| 116 | debug: bool = DEBUG, |
| 117 | chunk_index: Optional[int] = None, |
| 118 | ): |
| 119 | def print_user_message(icon, msg, printf=print): |
| 120 | if STRIP_UI: |
no outgoing calls
no test coverage detected