from datetime import datetime from IPython.display import HTML, display from letta.local_llm.constants import ( ASSISTANT_MESSAGE_CLI_SYMBOL, INNER_THOUGHTS_CLI_SYMBOL, ) def pprint(messages): """Utility function for pretty-printing the output of client.send_message in notebooks""" css_styles = """ """ html_content = css_styles + "
" for message in messages: date_str = message["date"] date_formatted = datetime.fromisoformat(date_str.replace("Z", "+00:00")).strftime("%Y-%m-%d %H:%M:%S") if "function_return" in message: return_string = message["function_return"] return_status = message["status"] html_content += f"

🛠️ [{date_formatted}] Function Return ({return_status}):

" html_content += f"

{return_string}

" elif "internal_monologue" in message: html_content += f"

{INNER_THOUGHTS_CLI_SYMBOL} [{date_formatted}] Internal Monologue:

" html_content += f"

{message['internal_monologue']}

" elif "function_call" in message: html_content += f"

🛠️ [[{date_formatted}] Function Call:

" html_content += f"

{message['function_call']}

" elif "assistant_message" in message: html_content += f"

{ASSISTANT_MESSAGE_CLI_SYMBOL} [{date_formatted}] Assistant Message:

" html_content += f"

{message['assistant_message']}

" html_content += "
" html_content += "
" display(HTML(html_content))