Spaces:
Build error
Build error
Update app.py
Browse files1234567896 unmodified lines16171819202122233 unmodified lines27282930313233343536373839404142from transformers import pipelineimport gradio as gr # Import Gradio for the interface"""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"""# Load a text-generation modelchatbot = pipeline("text-generation", model="microsoft/DialoGPT-medium")6 unmodified lines"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."}# Define the chatbot's response functiondef faq_chatbot(The Academic Advisor):# Check if the user's input matches any FAQ keywordsfor key, response in faq_responses.items():if key in user_input.lower():3 unmodified linesconversation = chatbot(user_input, max_length=50, num_return_sequences=1)return conversation[0]['generated_text']# Create the Gradio interfaceinterface = gr.Interface(fn=faq_chatbot, # The function to handle user inputinputs=gr.Textbox(lines=2, placeholder="Ask me about studying tips or resources..."), # Input text boxoutputs="text", # Output as texttitle="Student FAQ Chatbot",description="Ask me for study tips, time management advice, or about resources to help with your studies!")# Launch the chatbotinterface.launch(share=True)1234566 unmodified lines1314151617181920213 unmodified lines252627282930313233343536373839import gradio as grfrom transformers import pipeline# Load a text-generation modelchatbot = pipeline("text-generation", model="microsoft/DialoGPT-medium")6 unmodified lines"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."}# Define the chatbot's response functiondef faq_chatbot(user_input): # Removed "The Academic Advisor" argument# Check if the user's input matches any FAQ keywordsfor key, response in faq_responses.items():if key in user_input.lower():3 unmodified linesconversation = chatbot(user_input, max_length=50, num_return_sequences=1)return conversation[0]['generated_text']# Create the Gradio interfaceinterface = gr.Interface(fn=faq_chatbot, # The function to handle user inputinputs=gr.Textbox(lines=2, placeholder="Ask me about studying tips or resources..."), # Input text boxoutputs="text", # Output as texttitle="**Academic Advisor**", # Updated titledescription="Ask me for study tips, time management advice, or about resources to help with your studies!")# Launch the chatbotinterface.launch(share=True)
app.py+6-9