Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,17 @@
|
|
| 1 |
# app.py
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
-
from transformers import pipeline
|
| 5 |
|
| 6 |
-
# Load
|
| 7 |
generator = pipeline("conversational", model="microsoft/DialoGPT-medium")
|
| 8 |
|
| 9 |
# Define chatbot function
|
| 10 |
def chat_with_bot(user_input):
|
| 11 |
-
|
| 12 |
-
response
|
| 13 |
-
return response.generated_responses[-1]
|
| 14 |
|
| 15 |
-
#
|
| 16 |
iface = gr.Interface(
|
| 17 |
fn=chat_with_bot,
|
| 18 |
inputs=gr.Textbox(lines=2, placeholder="Ask me anything about study tips, university selection, scholarships, or motivation!"),
|
|
@@ -25,3 +24,4 @@ iface = gr.Interface(
|
|
| 25 |
# Run the app
|
| 26 |
if __name__ == "__main__":
|
| 27 |
iface.launch()
|
|
|
|
|
|
| 1 |
# app.py
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
+
from transformers import pipeline
|
| 5 |
|
| 6 |
+
# Load conversational pipeline
|
| 7 |
generator = pipeline("conversational", model="microsoft/DialoGPT-medium")
|
| 8 |
|
| 9 |
# Define chatbot function
|
| 10 |
def chat_with_bot(user_input):
|
| 11 |
+
response = generator(user_input)
|
| 12 |
+
return response[0]['generated_text']
|
|
|
|
| 13 |
|
| 14 |
+
# Gradio interface
|
| 15 |
iface = gr.Interface(
|
| 16 |
fn=chat_with_bot,
|
| 17 |
inputs=gr.Textbox(lines=2, placeholder="Ask me anything about study tips, university selection, scholarships, or motivation!"),
|
|
|
|
| 24 |
# Run the app
|
| 25 |
if __name__ == "__main__":
|
| 26 |
iface.launch()
|
| 27 |
+
|