Spaces:
Build error
Build error
Merge branch 'main' of https://huggingface.co/spaces/Jamal811/Test-Chatbot
Browse files
app.py
CHANGED
|
@@ -1,17 +1,19 @@
|
|
| 1 |
-
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
message_list = []
|
| 7 |
-
response_list = []
|
| 8 |
|
|
|
|
| 9 |
def vanilla_chatbot(message, history):
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
-
|
|
|
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
# Use the BlenderBot model with the 'text2text-generation' task
|
| 5 |
+
chatbot = pipeline("text2text-generation", model="facebook/blenderbot-400M-distill")
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Function to handle conversation
|
| 8 |
def vanilla_chatbot(message, history):
|
| 9 |
+
# Generate a response using the chatbot model
|
| 10 |
+
response = chatbot(message)
|
| 11 |
+
|
| 12 |
+
# Return the generated response
|
| 13 |
+
return response[0]['generated_text']
|
| 14 |
|
| 15 |
+
# Initialize the Gradio ChatInterface with 'messages' format
|
| 16 |
+
demo_chatbot = gr.ChatInterface(vanilla_chatbot, title="Vanilla Chatbot", description="Enter text to start chatting.", type="messages")
|
| 17 |
|
| 18 |
+
# Launch the Gradio interface with a public link
|
| 19 |
+
demo_chatbot.launch(share=True)
|