Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
# Step 1: Define College Data
|
6 |
+
college_about = """
|
7 |
+
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.
|
8 |
+
At the beginning, the college had no staff of its own, so it was borrowed from Government Degree College Sakrand.
|
9 |
+
The college started its classes in the afternoon at Government High School Daulatpur as it had no specific building.
|
10 |
+
With the help of the EDO Education, the possession of the Government Girls High School (Old) Daulatpur was given to the college now college have 2 four bliding and much more fecilaty.
|
11 |
+
"""
|
12 |
+
|
13 |
+
faculty_data = """
|
14 |
+
1. Prof Mahfooz Khan (Associate Prof, Islamiat)
|
15 |
+
2. Muhammad Aslam Palli (Associate Prof, Physics)
|
16 |
+
3. Abdul Rahman Gaincho (Botany)
|
17 |
+
4. M. Essa Samego (Lecturer, Islamiat)
|
18 |
+
5. Ali Aijaz Dahri (Lecturer, Chemistry)
|
19 |
+
6. Asif Ali Rajput (Lecturer, Physics)
|
20 |
+
7. Fida Hussain (Lecturer, Math)
|
21 |
+
8. Zulfiqar Ali (Senior Librarian)
|
22 |
+
"""
|
23 |
+
|
24 |
+
facilities = """
|
25 |
+
Facilities available:
|
26 |
+
1. Digital library with 20+ computers
|
27 |
+
2. Parks: Alquran Park and Botany Park with 50+ plants
|
28 |
+
3. Labs: Zoology, Botany, Physics, Chemistry
|
29 |
+
4. Parking area
|
30 |
+
5. Solar system and RO Plant
|
31 |
+
"""
|
32 |
+
|
33 |
+
# Step 2: Initialize QA Model
|
34 |
+
qa_model = pipeline("question-answering", model="deepset/roberta-base-squad2")
|
35 |
+
|
36 |
+
# Step 3: Define Application Functions
|
37 |
+
def answer_query(question):
|
38 |
+
context = f"{college_about}\n\n{faculty_data}\n\n{facilities}"
|
39 |
+
response = qa_model(question=question, context=context)
|
40 |
+
return response["answer"]
|
41 |
+
|
42 |
+
# Step 4: Streamlit UI
|
43 |
+
st.set_page_config(page_title="College RAG App", layout="wide", initial_sidebar_state="expanded")
|
44 |
+
|
45 |
+
# Display Logo
|
46 |
+
logo = Image.open("college_logo.png")
|
47 |
+
st.image(logo, width=200)
|
48 |
+
|
49 |
+
# App Title and Description
|
50 |
+
st.title("Government Boys Degree College Daulatpur")
|
51 |
+
st.subheader("Welcome to our College Information RAG App")
|
52 |
+
|
53 |
+
# Sidebar Navigation
|
54 |
+
menu = ["About College", "Faculty and Staff", "Facilities", "Ask a Question", "Contact Us"]
|
55 |
+
choice = st.sidebar.selectbox("Navigation", menu)
|
56 |
+
|
57 |
+
# Content Based on Navigation
|
58 |
+
if choice == "About College":
|
59 |
+
st.markdown(f"<div style='background-color: #A5D6A7; padding: 10px; border-radius: 10px; color: #424242;'>{college_about}</div>", unsafe_allow_html=True)
|
60 |
+
|
61 |
+
elif choice == "Faculty and Staff":
|
62 |
+
st.markdown("### Faculty Details")
|
63 |
+
st.text(faculty_data)
|
64 |
+
|
65 |
+
elif choice == "Facilities":
|
66 |
+
st.markdown("### Facilities")
|
67 |
+
st.text(facilities)
|
68 |
+
|
69 |
+
elif choice == "Ask a Question":
|
70 |
+
st.markdown("### Ask a Question About the College")
|
71 |
+
question = st.text_input("Type your question:")
|
72 |
+
if question:
|
73 |
+
answer = answer_query(question)
|
74 |
+
st.success(f"Answer: {answer}")
|
75 |
+
|
76 |
+
elif choice == "Contact Us":
|
77 |
+
st.markdown("### Contact Details")
|
78 |
+
st.markdown("""
|
79 |
+
- **Location:** National Highway N6 bypass Daulatpur
|
80 |
+
- **Phone:** +92 300 3003249
|
81 |
+
- **Email:** othoirshad@gmail.com
|
82 |
+
- [Visit our Facebook Page](https://www.facebook.com/share/19j9Z1iEvz/)
|
83 |
+
""")
|
84 |
+
|
85 |
+
st.markdown("### Made by Musawir Manzoor")
|