Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,6 @@
|
|
|
|
1 |
from transformers import pipeline
|
2 |
-
import gradio as gr # Import Gradio for the interface
|
3 |
|
4 |
-
"""
|
5 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
6 |
-
"""
|
7 |
# Load a text-generation model
|
8 |
chatbot = pipeline("text-generation", model="microsoft/DialoGPT-medium")
|
9 |
|
@@ -16,8 +13,9 @@ faq_responses = {
|
|
16 |
"how to avoid procrastination": "Break tasks into smaller steps, set deadlines, and reward yourself after completing milestones. Tools like Trello can help you stay organized."
|
17 |
}
|
18 |
|
|
|
19 |
# Define the chatbot's response function
|
20 |
-
def faq_chatbot(The Academic Advisor
|
21 |
# Check if the user's input matches any FAQ keywords
|
22 |
for key, response in faq_responses.items():
|
23 |
if key in user_input.lower():
|
@@ -27,16 +25,15 @@ def faq_chatbot(The Academic Advisor):
|
|
27 |
conversation = chatbot(user_input, max_length=50, num_return_sequences=1)
|
28 |
return conversation[0]['generated_text']
|
29 |
|
|
|
30 |
# Create the Gradio interface
|
31 |
interface = gr.Interface(
|
32 |
fn=faq_chatbot, # The function to handle user input
|
33 |
inputs=gr.Textbox(lines=2, placeholder="Ask me about studying tips or resources..."), # Input text box
|
34 |
outputs="text", # Output as text
|
35 |
-
title="
|
36 |
description="Ask me for study tips, time management advice, or about resources to help with your studies!"
|
37 |
)
|
38 |
|
39 |
# Launch the chatbot
|
40 |
-
interface.launch(share=True)
|
41 |
-
|
42 |
-
|
|
|
1 |
+
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
3 |
|
|
|
|
|
|
|
4 |
# Load a text-generation model
|
5 |
chatbot = pipeline("text-generation", model="microsoft/DialoGPT-medium")
|
6 |
|
|
|
13 |
"how to avoid procrastination": "Break tasks into smaller steps, set deadlines, and reward yourself after completing milestones. Tools like Trello can help you stay organized."
|
14 |
}
|
15 |
|
16 |
+
|
17 |
# Define the chatbot's response function
|
18 |
+
def faq_chatbot(user_input): # Removed "The Academic Advisor" argument
|
19 |
# Check if the user's input matches any FAQ keywords
|
20 |
for key, response in faq_responses.items():
|
21 |
if key in user_input.lower():
|
|
|
25 |
conversation = chatbot(user_input, max_length=50, num_return_sequences=1)
|
26 |
return conversation[0]['generated_text']
|
27 |
|
28 |
+
|
29 |
# Create the Gradio interface
|
30 |
interface = gr.Interface(
|
31 |
fn=faq_chatbot, # The function to handle user input
|
32 |
inputs=gr.Textbox(lines=2, placeholder="Ask me about studying tips or resources..."), # Input text box
|
33 |
outputs="text", # Output as text
|
34 |
+
title="**Academic Advisor**", # Updated title
|
35 |
description="Ask me for study tips, time management advice, or about resources to help with your studies!"
|
36 |
)
|
37 |
|
38 |
# Launch the chatbot
|
39 |
+
interface.launch(share=True)
|
|
|
|