Spaces:
Runtime error
Runtime error
Create app.py
#1
by
AThirumoorthi
- opened
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
with gr.Blocks() as iface:
|
7 |
+
|
8 |
+
gr.Markdown("# Mr AI")
|
9 |
+
gr.Markdown("Hi there! I'm your friendly assistant. Ask me anything, and I'll do my best to help! (By Thirumoorthi.A)")
|
10 |
+
|
11 |
+
chat_history_output = gr.Chatbot(label="Chat History", height=400)
|
12 |
+
|
13 |
+
|
14 |
+
with gr.Row():
|
15 |
+
message_input = gr.Textbox(label="Your Question", placeholder="Type your question here...", lines=2)
|
16 |
+
submit_btn = gr.Button("Submit")
|
17 |
+
clear_btn = gr.Button("Clear Chat")
|
18 |
+
|
19 |
+
def respond(message, chat_history):
|
20 |
+
chat_history.append(("USER", message))
|
21 |
+
response = llm_chain.run(input=message)
|
22 |
+
chat_history.append(("Assistant", response))
|
23 |
+
return "", chat_history
|
24 |
+
|
25 |
+
|
26 |
+
def clear_chat():
|
27 |
+
return []
|
28 |
+
|
29 |
+
|
30 |
+
submit_btn.click(respond, inputs=[message_input, chat_history_output], outputs=[message_input, chat_history_output])
|
31 |
+
clear_btn.click(clear_chat, outputs=chat_history_output)
|
32 |
+
|
33 |
+
|
34 |
+
iface.launch(inline=False)
|