arielleharris commited on
Commit
b133ade
·
verified ·
1 Parent(s): 8a23e3b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -15
app.py CHANGED
@@ -1,5 +1,5 @@
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")
@@ -13,7 +13,6 @@ faq_responses = {
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):
19
  # Check if the user's input matches any FAQ keywords
@@ -25,17 +24,14 @@ def faq_chatbot(user_input):
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
- label = gr.Text("**Academic Advisor**")
31
-
32
- # Combine the label with the chatbot interface (specifying the output type)
33
- interface = gr.Interface(fn=faq_chatbot, inputs=gr.Textbox(lines=2, placeholder="Ask me about studying tips or resources..."), outputs="text", # Define the output type
34
- title="**Academic Advisor**",
35
- description="Ask me for study tips, time management advice, or about resources to help with your studies!")
36
-
37
- # Stack the label on top of the interface vertically
38
- interface = gr.Interface(label, interface, layout="vertical")
39
-
40
- # Launch the chatbot
41
- interface.launch(share=True)
 
 
1
  from transformers import pipeline
2
+ import gradio as gr # Import Gradio for the interface
3
 
4
  # Load a text-generation model
5
  chatbot = pipeline("text-generation", model="microsoft/DialoGPT-medium")
 
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
  # Define the chatbot's response function
17
  def faq_chatbot(user_input):
18
  # Check if the user's input matches any FAQ keywords
 
24
  conversation = chatbot(user_input, max_length=50, num_return_sequences=1)
25
  return conversation[0]['generated_text']
26
 
 
27
  # Create the Gradio interface
28
+ interface = gr.Interface(
29
+ fn=faq_chatbot, # The function to handle user input
30
+ inputs=gr.Textbox(lines=2, placeholder="Ask me about studying tips or resources..."), # Input text box
31
+ outputs="text", # Output as text
32
+ title="Student FAQ Chatbot",
33
+ description="Ask me for study tips, time management advice, or about resources to help with your studies!"
34
+ )
35
+
36
+ # Launch the chatbot and make it public
37
+ interface.launch(share=True)