Threatthriver commited on
Commit
c72759d
·
verified ·
1 Parent(s): 654503a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -44,17 +44,23 @@ def chat_with_cerebras(user_input):
44
  # Gradio interface
45
  def gradio_ui():
46
  with gr.Blocks() as demo:
47
- gr.Markdown("""# Cerebras AI Chatbot\nChat with a state-of-the-art AI model.""")
48
 
49
  with gr.Row():
50
- user_input = gr.Textbox(label="Your Message", placeholder="Type your message here...")
51
- response = gr.Textbox(label="AI Response", interactive=False)
52
- compute_time = gr.Textbox(label="Compute Time", interactive=False)
 
53
 
54
- submit_button = gr.Button("Submit")
 
55
 
56
- # Define interaction logic
57
- submit_button.click(chat_with_cerebras, inputs=user_input, outputs=[response, compute_time])
 
 
 
 
58
 
59
  return demo
60
 
 
44
  # Gradio interface
45
  def gradio_ui():
46
  with gr.Blocks() as demo:
47
+ gr.Markdown("""# 🤖 Cerebras AI Chatbot\nChat with a state-of-the-art AI model!""")
48
 
49
  with gr.Row():
50
+ with gr.Column(scale=8):
51
+ chat_history = gr.Chatbot(label="Chat History")
52
+ with gr.Column(scale=2):
53
+ compute_time = gr.Textbox(label="Compute Time", interactive=False)
54
 
55
+ user_input = gr.Textbox(label="Type your message", placeholder="Ask me anything...", lines=2)
56
+ send_button = gr.Button("Send", variant="primary")
57
 
58
+ def handle_chat(chat_history, user_input):
59
+ ai_response, compute_info = chat_with_cerebras(user_input)
60
+ chat_history.append((user_input, ai_response))
61
+ return chat_history, compute_info
62
+
63
+ send_button.click(handle_chat, inputs=[chat_history, user_input], outputs=[chat_history, compute_time])
64
 
65
  return demo
66