diff --git a/openai_server/chat_history_render.py b/openai_server/chat_history_render.py index 371158de0..6eef33703 100644 --- a/openai_server/chat_history_render.py +++ b/openai_server/chat_history_render.py @@ -37,12 +37,30 @@ def chat_to_pretty_markdown( else "ℹī¸" ) real_role = ( - assistant_name - if role.lower() == "assistant" - else user_name - if role.lower() == "user" - else dummy_name - ) + assistant_name + if role.lower() == "assistant" + else user_name + if role.lower() == "user" + else dummy_name + ) + # If there is agent name mentioned, update the role and the emoji + if 'name' in message and message['name']: + # turns 'chat_agent' to 'Chat Agent' + real_role = message['name'] + real_role = ' '.join(word.capitalize() for word in real_role.split('_')) + + if message['name'] == 'chat_agent': + # put bubble emoji for chat agent + emoji = "đŸ’Ŧ" + if message['name'] == 'human_proxy_agent': + # put human emoji for human proxy agent + emoji = "👤" + if message['name'] == 'code_writer_agent': + # put code emoji for code writer agent + emoji = "🤖" + if message['name'] == 'code_executor_agent': + # put code emoji for code executor agent + emoji = "🧠" # Format the role if cute: @@ -125,12 +143,30 @@ def chat_to_pretty_markdown_simple( else "ℹī¸" ) real_role = ( - assistant_name - if role.lower() == "assistant" - else user_name - if role.lower() == "user" - else dummy_name - ) + assistant_name + if role.lower() == "assistant" + else user_name + if role.lower() == "user" + else dummy_name + ) + # If there is agent name mentioned, update the role and the emoji + if 'name' in message and message['name']: + # turns 'chat_agent' to 'Chat Agent' + real_role = message['name'] + real_role = ' '.join(word.capitalize() for word in real_role.split('_')) + + if message['name'] == 'chat_agent': + # put bubble emoji for chat agent + emoji = "đŸ’Ŧ" + if message['name'] == 'human_proxy_agent': + # put human emoji for human proxy agent + emoji = "👤" + if message['name'] == 'code_writer_agent': + # put code emoji for code writer agent + emoji = "🤖" + if message['name'] == 'code_executor_agent': + # put code emoji for code executor agent + emoji = "🧠" # Format the role if cute: