Spaces:
Sleeping
Sleeping
| # Step 2: Import libraries | |
| import gradio as gr | |
| # Step 3: Define College Data | |
| college_about = """ | |
| The college was notified to work from 16th July 2003 on the directions of the then care-taker Minister for education Mr. Khan Muhammad Dahri. | |
| At the beginning, the college had no staff of its own, so it was borrowed from Government Degree College Sakrand. | |
| The college started its classes in the afternoon at Government High School Daulatpur as it had no specific building. | |
| With the help of the EDO Education, the possession of the Government Girls High School (Old) Daulatpur was given to the college. | |
| """ | |
| # Restructured Data | |
| data = { | |
| "Programs": [ | |
| "ADSE-I", "ADSE-II", "ADAA-I", "ADAA-II", "BS (Zoology) (Proposed for this year)" | |
| ], | |
| "Teachers": { | |
| "Islamiat": ["Prof Mahfooz Khan (Associate Prof)", "M. Essa Samego (Lecturer)"], | |
| "Physics": ["Muhammad Aslam Palli (Associate Prof)", "Asif Ali Rajput (Lecturer)"], | |
| "Botany": ["Abdul Rahman Gaincho (Lecturer)"], | |
| "Chemistry": ["Ali Aijaz Dahri (Lecturer)"], | |
| "Math": ["Fida Hussain (Lecturer)"], | |
| "Librarian": ["Zulfiqar Ali (Senior Librarian)"], | |
| "DPE": ["Naseer Ahmed (DPE)"], | |
| }, | |
| "Facilities": [ | |
| "Digital library with 20+ computers", | |
| "Parks: Alquran Park and Botany Park with 50+ plants", | |
| "Building: Two-floor building with 24 rooms", | |
| "Labs: Zoology, Botany, Physics, Chemistry", | |
| "Parking area", | |
| "Solar system", | |
| "RO Plant", | |
| ], | |
| "Location": "Bypass Daulatpur", | |
| "Principal": "Prof Irshad Ali Otho", | |
| "Established": "2003", | |
| "Contact": { | |
| "Location": "National Highway N6 bypass Daulatpur", | |
| "Phone": "+92 300 3003249", | |
| "Email": "othoirshad@gmail.com", | |
| "Facebook": "https://www.facebook.com/share/19j9Z1iEvz/" | |
| } | |
| } | |
| # Helper function to answer questions | |
| def get_answer(question): | |
| # Convert question to lowercase for easier matching | |
| question = question.lower() | |
| # Check for general categories | |
| if "program" in question or "course" in question: | |
| return f"Programs offered:\n- " + "\n- ".join(data["Programs"]) | |
| if "teacher" in question: | |
| if "islamiat" in question: | |
| return f"Islamiat Teachers:\n- " + "\n- ".join(data["Teachers"]["Islamiat"]) | |
| elif "physics" in question: | |
| return f"Physics Teachers:\n- " + "\n- ".join(data["Teachers"]["Physics"]) | |
| elif "botany" in question: | |
| return f"Botany Teacher:\n- " + "\n- ".join(data["Teachers"]["Botany"]) | |
| elif "chemistry" in question: | |
| return f"Chemistry Teacher:\n- " + "\n- ".join(data["Teachers"]["Chemistry"]) | |
| elif "math" in question: | |
| return f"Math Teacher:\n- " + "\n- ".join(data["Teachers"]["Math"]) | |
| elif "librarian" in question: | |
| return f"Librarian:\n- " + "\n- ".join(data["Teachers"]["Librarian"]) | |
| elif "dpe" in question: | |
| return f"DPE:\n- " + "\n- ".join(data["Teachers"]["DPE"]) | |
| else: | |
| # Return all teachers if no specific subject is mentioned | |
| all_teachers = "\n".join( | |
| [f"{subject}: " + ", ".join(teachers) for subject, teachers in data["Teachers"].items()] | |
| ) | |
| return f"All Teachers:\n{all_teachers}" | |
| if "facility" in question: | |
| return f"Facilities available:\n- " + "\n- ".join(data["Facilities"]) | |
| if "location" in question: | |
| return f"College Location: {data['Location']}" | |
| if "principal" in question: | |
| return f"Principal: {data['Principal']}" | |
| if "establish" in question or "founded" in question: | |
| return f"Established in: {data['Established']}" | |
| if "contact" in question: | |
| contact_info = data["Contact"] | |
| return ( | |
| f"Contact Details:\n" | |
| f"- Location: {contact_info['Location']}\n" | |
| f"- Phone: {contact_info['Phone']}\n" | |
| f"- Email: {contact_info['Email']}\n" | |
| f"- Facebook: {contact_info['Facebook']}" | |
| ) | |
| return "Sorry, I don't have an answer for that. Please ask something else." | |
| # Step 4: Create Gradio Interface | |
| with gr.Blocks(theme=gr.themes.Monochrome()) as app: | |
| gr.Markdown("## Government Boys Degree College Daulatpur") | |
| gr.Markdown("### Welcome to our College Information App") | |
| gr.Image("college_logo.png", label="College Logo") # Ensure "college_logo.png" exists | |
| with gr.Tabs(): | |
| with gr.Tab("About College"): | |
| gr.Markdown(college_about) | |
| with gr.Tab("Programs"): | |
| gr.Markdown("\n".join(data["Programs"])) | |
| with gr.Tab("Teachers"): | |
| all_teachers = "\n".join( | |
| [f"{subject}: " + ", ".join(teachers) for subject, teachers in data["Teachers"].items()] | |
| ) | |
| gr.Markdown(all_teachers) | |
| with gr.Tab("Facilities"): | |
| gr.Markdown("\n".join(data["Facilities"])) | |
| with gr.Tab("Ask a Question"): | |
| question = gr.Textbox(label="Ask a question about the college") | |
| answer = gr.Textbox(label="Answer") | |
| question.submit(get_answer, inputs=question, outputs=answer) | |
| with gr.Tab("Contact Us"): | |
| contact_info = data["Contact"] | |
| gr.Markdown( | |
| f"**Contact Details:**\n" | |
| f"- Location: {contact_info['Location']}\n" | |
| f"- Phone: {contact_info['Phone']}\n" | |
| f"- Email: {contact_info['Email']}\n" | |
| f"[Visit our Facebook Page]({contact_info['Facebook']})" | |
| ) | |
| gr.Markdown("### Made by Musawir Manzoor") | |
| # Step 5: Launch the App | |
| app.launch() | |