Spaces:
Sleeping
Sleeping
feat(ui):added new UI
Browse files1234564 unmodified lines11121314151617181920212223242526272829303132import gradio as grdef chatbot_response(user_input):# Handle different questionsif user_input.lower() in ['hello', 'hi', 'hey']:return "Hi there! How can I help you with your studies today?"4 unmodified lineselse:return "I'm here to assist with academic questions. Please specify if you'd like help with any specific subject or topic."with gr.Blocks() as demo:gr.Markdown("# Study Assistance Chatbot")gr.Markdown("Welcome! Ask me anything related to your academic studies.")with gr.Row():with gr.Column():user_input = gr.Textbox(label="Enter your question here:")submit_button = gr.Button("Submit")with gr.Column():chatbot_output = gr.Textbox(label="Chatbot Response", interactive=False)submit_button.click(chatbot_response, inputs=user_input, outputs=chatbot_output)demo.launch()from datasets import load_dataset1234567891011121314154 unmodified lines202122232425262728293031323334353637import gradio as grimport time#Provides streaming chatbot responsedef streaming_response(user_input, history):response = chatbot_response(user_input, history)for i in range(len(response)):time.sleep(0.3)yield response[:i+1]#Responsedef chatbot_response(user_input, history):# Handle different questionsif user_input.lower() in ['hello', 'hi', 'hey']:return "Hi there! How can I help you with your studies today?"4 unmodified lineselse:return "I'm here to assist with academic questions. Please specify if you'd like help with any specific subject or topic."#Block for defining layout of the Chatbot Interfacewith gr.Blocks() as app:chatbot = gr.ChatInterface(streaming_response,type="messages",title="Study Assistance Chatbot",description="Welcome! Ask me anything related to your academic studies.",examples=["Hello","Hi", "Hey", "Help"])app.launch()
app.py+20-15