Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| # Define Streamlit app | |
| st.set_page_config(page_title="EduNexus", page_icon=":book:", layout="wide") | |
| # Add custom styling using Streamlit | |
| st.markdown(""" | |
| <style> | |
| .css-1o7k8tt { | |
| background-color: #1e1e2f; | |
| color: #ffffff; | |
| } | |
| .css-1o7k8tt h1 { | |
| color: #ff9a8b; | |
| } | |
| .stButton { | |
| background-color: #ff9a8b; | |
| color: #000000; | |
| border-radius: 12px; | |
| padding: 10px 20px; | |
| font-size: 16px; | |
| } | |
| .stButton:hover { | |
| background-color: #ff6f6f; | |
| } | |
| .stTextInput, .stTextArea { | |
| border: 1px solid #ff9a8b; | |
| border-radius: 8px; | |
| background-color: #282c34; | |
| color: #ffffff; | |
| } | |
| .stTextInput::placeholder, .stTextArea::placeholder { | |
| color: #b0b0b0; | |
| } | |
| .stSidebar { | |
| background-color: #2e2e3e; | |
| } | |
| .stSidebar .stMarkdown { | |
| color: #ffffff; | |
| } | |
| .footer { | |
| background-color: #1e1e2f; | |
| padding: 10px; | |
| text-align: center; | |
| color: #ffffff; | |
| border-top: 1px solid #ff9a8b; | |
| } | |
| .footer a { | |
| color: #ff9a8b; | |
| margin: 0 10px; | |
| text-decoration: none; | |
| font-size: 18px; | |
| } | |
| .footer a:hover { | |
| color: #ffffff; | |
| } | |
| .footer i { | |
| font-size: 20px; | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| # Define function to clear all inputs | |
| def clear_chat(): | |
| st.session_state['personalized_learning_assistant'] = "" | |
| st.session_state['ai_coding_mentor'] = "" | |
| st.session_state['smart_document_summarizer'] = "" | |
| st.session_state['interactive_study_planner'] = "" | |
| st.session_state['real_time_qa_support'] = "" | |
| st.session_state['mental_health_check_in'] = "" | |
| st.session_state['responses'] = { | |
| "personalized_learning_assistant": "", | |
| "ai_coding_mentor": "", | |
| "smart_document_summarizer": "", | |
| "interactive_study_planner": "", | |
| "real_time_qa_support": "", | |
| "mental_health_check_in": "" | |
| } | |
| # Add Clear Chat button | |
| if st.sidebar.button("Clear All", key="clear_button"): | |
| clear_chat() | |
| # Navigation sidebar | |
| st.sidebar.title("EduNexus Tools") | |
| selected_tool = st.sidebar.radio( | |
| "Select a tool", | |
| ("Personalized Learning Assistant", "AI Coding Mentor", "Smart Document Summarizer", | |
| "Interactive Study Planner", "Real-Time Q&A Support", "Mental Health Check-In") | |
| ) | |
| # Display tool based on selection | |
| st.title("EduNexus :book:") | |
| # Common function to display response and download button | |
| def display_response(response_key, response): | |
| st.write(response) | |
| st.download_button( | |
| "Download Response", | |
| response, | |
| file_name=f"{response_key}.txt" | |
| ) | |
| if selected_tool == "Personalized Learning Assistant": | |
| st.header("Personalized Learning Assistant") | |
| with st.form(key="learning_form"): | |
| topic_input = st.text_input("Enter a topic you want to learn about", placeholder="e.g., Quantum Mechanics") | |
| submit_button = st.form_submit_button("Get Explanation") | |
| if submit_button: | |
| explanation = personalized_learning_assistant(topic_input) | |
| st.session_state['responses']['personalized_learning_assistant'] = explanation | |
| if st.session_state['responses']['personalized_learning_assistant']: | |
| display_response("personalized_learning_assistant", st.session_state['responses']['personalized_learning_assistant']) | |
| elif selected_tool == "AI Coding Mentor": | |
| st.header("AI Coding Mentor") | |
| with st.form(key="coding_form"): | |
| code_input = st.text_area("Enter your code snippet", placeholder="e.g., def add(a, b): return a + b") | |
| submit_button = st.form_submit_button("Review Code") | |
| if submit_button: | |
| review = ai_coding_mentor(code_input) | |
| st.session_state['responses']['ai_coding_mentor'] = review | |
| if st.session_state['responses']['ai_coding_mentor']: | |
| display_response("ai_coding_mentor", st.session_state['responses']['ai_coding_mentor']) | |
| elif selected_tool == "Smart Document Summarizer": | |
| st.header("Smart Document Summarizer") | |
| with st.form(key="document_form"): | |
| document_input = st.text_area("Enter your document text", placeholder="Paste your document text here") | |
| submit_button = st.form_submit_button("Summarize Document") | |
| if submit_button: | |
| summary = smart_document_summarizer(document_input) | |
| st.session_state['responses']['smart_document_summarizer'] = summary | |
| if st.session_state['responses']['smart_document_summarizer']: | |
| display_response("smart_document_summarizer", st.session_state['responses']['smart_document_summarizer']) | |
| elif selected_tool == "Interactive Study Planner": | |
| st.header("Interactive Study Planner") | |
| with st.form(key="study_form"): | |
| exam_schedule_input = st.text_area("Enter your exam schedule", placeholder="e.g., 3 exams in one week") | |
| submit_button = st.form_submit_button("Generate Study Plan") | |
| if submit_button: | |
| plan = interactive_study_planner(exam_schedule_input) | |
| st.session_state['responses']['interactive_study_planner'] = plan | |
| if st.session_state['responses']['interactive_study_planner']: | |
| display_response("interactive_study_planner", st.session_state['responses']['interactive_study_planner']) | |
| elif selected_tool == "Real-Time Q&A Support": | |
| st.header("Real-Time Q&A Support") | |
| with st.form(key="qa_form"): | |
| question_input = st.text_input("Enter your question", placeholder="e.g., What is Newton's third law of motion?") | |
| submit_button = st.form_submit_button("Get Answer") | |
| if submit_button: | |
| answer = real_time_qa_support(question_input) | |
| st.session_state['responses']['real_time_qa_support'] = answer | |
| if st.session_state['responses']['real_time_qa_support']: | |
| display_response("real_time_qa_support", st.session_state['responses']['real_time_qa_support']) | |
| elif selected_tool == "Mental Health Check-In": | |
| st.header("Mental Health Check-In") | |
| with st.form(key="mental_health_form"): | |
| feelings_input = st.text_area("How are you feeling?", placeholder="e.g., Stressed about exams") | |
| submit_button = st.form_submit_button("Get Advice") | |
| if submit_button: | |
| advice = mental_health_check_in(feelings_input) | |
| st.session_state['responses']['mental_health_check_in'] = advice | |
| if st.session_state['responses']['mental_health_check_in']: | |
| display_response("mental_health_check_in", st.session_state['responses']['mental_health_check_in']) | |
| # Footer with acknowledgments | |
| st.markdown(""" | |
| <div class="footer"> | |
| <p>Developed by MUHAMMD IBRAHIM ❤ </p> | |
| <a href="https://github.com/muhammadibrahim313"><i class="fab fa-github"></i></a> | |
| <a href="https://www.kaggle.com/muhammadibrahimqasmi"><i class="fab fa-kaggle"></i></a> | |
| <a href="https://www.linkedin.com/in/muhammad-ibrahim-qasmi-9876a1297/"><i class="fab fa-linkedin"></i></a> | |
| </div> | |
| """, unsafe_allow_html=True) | |