Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from transformers import pipeline, Conversational
|
| 5 |
+
|
| 6 |
+
# Load a conversational pipeline
|
| 7 |
+
generator = pipeline("conversational", model="microsoft/DialoGPT-medium")
|
| 8 |
+
|
| 9 |
+
# Define chatbot function
|
| 10 |
+
def chat_with_bot(user_input):
|
| 11 |
+
conversation = Conversational(user_input)
|
| 12 |
+
response = generator(conversation)
|
| 13 |
+
return response.generated_responses[-1]
|
| 14 |
+
|
| 15 |
+
# Create Gradio interface
|
| 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!"),
|
| 19 |
+
outputs="text",
|
| 20 |
+
title="🎓 Student Advisor Chatbot",
|
| 21 |
+
description="Get study advice, routine tips, university guidance, and motivational support.",
|
| 22 |
+
theme="compact"
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
# Run the app
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
iface.launch()
|