Spaces:
Sleeping
Sleeping
added chatbot block and bart spa guc model
Browse files
README.md
CHANGED
|
@@ -8,6 +8,8 @@ sdk_version: 4.8.0
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
+
models:
|
| 12 |
+
- Broomva/bart-large-translation-spa-guc
|
| 13 |
---
|
| 14 |
|
| 15 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
import time
|
| 3 |
+
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
+
with gr.Blocks() as demo:
|
| 7 |
+
chatbot = gr.Chatbot()
|
| 8 |
+
msg = gr.Textbox()
|
| 9 |
+
clear = gr.Button("Clear")
|
| 10 |
+
|
| 11 |
+
def user(user_message, history):
|
| 12 |
+
return "", history + [[user_message, None]]
|
| 13 |
|
| 14 |
+
def bot(history):
|
| 15 |
+
bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
|
| 16 |
+
history[-1][1] = ""
|
| 17 |
+
for character in bot_message:
|
| 18 |
+
history[-1][1] += character
|
| 19 |
+
time.sleep(0.05)
|
| 20 |
+
yield history
|
| 21 |
|
| 22 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
| 23 |
+
bot, chatbot, chatbot
|
| 24 |
+
)
|
| 25 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
| 26 |
+
|
| 27 |
+
demo.queue()
|
| 28 |
+
demo.launch()
|