Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load a free chatbot model
|
| 5 |
+
chatbot = pipeline("text-generation", model="tiiuae/falcon-7b-instruct")
|
| 6 |
+
|
| 7 |
+
def chat(message, history=[]):
|
| 8 |
+
response = chatbot(message, max_length=200)[0]['generated_text']
|
| 9 |
+
history.append((message, response))
|
| 10 |
+
return history, history
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=chat,
|
| 14 |
+
inputs=["text", "state"],
|
| 15 |
+
outputs=["chatbot", "state"],
|
| 16 |
+
title="DevMegaBlack AI",
|
| 17 |
+
description="Chat with your AI"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
iface.launch()
|