Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,25 +3,25 @@
|
|
| 3 |
import gradio as gr
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
generator = pipeline("
|
| 8 |
|
| 9 |
-
#
|
| 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
|
| 18 |
outputs="text",
|
| 19 |
title="🎓 Student Advisor Chatbot",
|
| 20 |
-
description="Get study advice,
|
| 21 |
theme="compact"
|
| 22 |
)
|
| 23 |
|
| 24 |
-
# Run the app
|
| 25 |
if __name__ == "__main__":
|
| 26 |
iface.launch()
|
| 27 |
|
|
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
+
# Use a text-generation model instead of conversational for simplicity
|
| 7 |
+
generator = pipeline("text-generation", model="gpt2")
|
| 8 |
|
| 9 |
+
# Chatbot function
|
| 10 |
def chat_with_bot(user_input):
|
| 11 |
+
response = generator(user_input, max_length=100, num_return_sequences=1)
|
| 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 about study tips, scholarships, university selection, motivation!"),
|
| 18 |
outputs="text",
|
| 19 |
title="🎓 Student Advisor Chatbot",
|
| 20 |
+
description="Get helpful study advice, routines, university guidance, and motivation!",
|
| 21 |
theme="compact"
|
| 22 |
)
|
| 23 |
|
|
|
|
| 24 |
if __name__ == "__main__":
|
| 25 |
iface.launch()
|
| 26 |
|
| 27 |
+
|