From caecce6053cad4eecdeb84b71948d96efb3994d8 Mon Sep 17 00:00:00 2001 From: Kye Date: Wed, 4 Oct 2023 01:27:01 -0400 Subject: [PATCH] clean up Former-commit-id: a3b02564f43d92ecbf554d63435cb99f8a2f2313 --- omni_ui.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/omni_ui.py b/omni_ui.py index 31738c7d..4bc44913 100644 --- a/omni_ui.py +++ b/omni_ui.py @@ -18,31 +18,33 @@ def update_chat(user_input): # Get agent response agent_response = agent.run(user_input) - - # Let's assume agent_response is a dictionary containing type and content. chat_history.append(agent_response) return render_chat(chat_history) def render_chat(chat_history): - chat_str = "" + chat_str = '
' for message in chat_history: + timestamp = message.get('timestamp', 'N/A') if message['type'] == 'user': - chat_str += f"User: {message['content']}
" + chat_str += f'
{message["content"]}
{timestamp}
' elif message['type'] == 'text': - chat_str += f"Agent: {message['content']}
" + chat_str += f'
{message["content"]}
{timestamp}
' elif message['type'] == 'image': img_path = os.path.join("root_directory", message['content']) - chat_str += f"Agent: image
" + chat_str += f'
image
{timestamp}
' + chat_str += '
' return chat_str # Define Gradio interface iface = Interface( fn=update_chat, - inputs="text", + inputs=gr.inputs.Textbox(lines=2, placeholder="Type your message here..."), outputs=gr.outputs.HTML(label="Chat History"), - live=True + live=True, + title="Conversational AI Interface", + description="Chat with our AI agent!", + allow_flagging=False ) -# Launch the Gradio interface iface.launch()