Spaces:
Runtime error
Runtime error
File size: 712 Bytes
8dc302c 7997e4f 6c8dd0a 7997e4f 8dc302c 97fb81b 7997e4f 97fb81b 8dc302c 7997e4f ac48f13 7997e4f 97fb81b 8dc302c ac48f13 8dc302c 97fb81b 7997e4f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
from transformers import pipeline
# Tiny, CPU-friendly model
chatbot_pipeline = pipeline("text-generation", model="sshleifer/tiny-gpt2")
def chat(message, history=[]):
result = chatbot_pipeline(message, max_new_tokens=50)
reply = result[0]['generated_text'].replace(message, "").strip()
history.append((message, reply))
return history, history
with gr.Blocks() as demo:
gr.Markdown("## 🤖 Permanent Tiny AI Chatbot")
chat_ui = gr.Chatbot()
msg = gr.Textbox(label="Type your message here")
clear = gr.Button("Clear Chat")
msg.submit(chat, [msg, chat_ui], [chat_ui, chat_ui])
clear.click(lambda: None, None, chat_ui, queue=False)
demo.launch()
|