Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
51 |
-
|
52 |
-
|
|
|
53 |
|
54 |
-
|
|
|
55 |
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
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 |
|