Musawir19 commited on
Commit
46c58c4
1 Parent(s): 6b39a0f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -74
app.py CHANGED
@@ -1,74 +1,2 @@
1
- import gradio as gr
2
- from transformers import pipeline
3
-
4
- # Define data
5
- college_about = """
6
- 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.
7
- At the beginning, the college had no staff of its own, so it was borrowed from Government Degree College Sakrand.
8
- The college started its classes in the afternoon at Government High School Daulatpur as it had no specific building.
9
- With the help of the EDO Education, the possession of the Government Girls High School (Old) Daulatpur was given to the college.
10
- """
11
-
12
- faculty_data = """
13
- 1. Prof Mahfooz Khan (Associate Prof, Islamiat)
14
- 2. Muhammad Aslam Palli (Associate Prof, Physics)
15
- 3. Abdul Rahman Gaincho (Botany)
16
- 4. M. Essa Samego (Lecturer, Islamiat)
17
- 5. Ali Aijaz Dahri (Lecturer, Chemistry)
18
- 6. Asif Ali Rajput (Lecturer, Physics)
19
- 7. Fida Hussain (Lecturer, Math)
20
- 8. Zulfiqar Ali (Senior Librarian)
21
- """
22
-
23
- facilities = """
24
- Facilities available:
25
- 1. Digital library with 20+ computers
26
- 2. Parks: Alquran Park and Botany Park with 50+ plants
27
- 3. Labs: Zoology, Botany, Physics, Chemistry
28
- 4. Parking area
29
- 5. Solar system and RO Plant
30
- """
31
-
32
- # Define the QA model
33
- qa_model = pipeline("question-answering", model="deepset/roberta-base-squad2")
34
-
35
- # Define functions for Gradio app
36
- def about_college():
37
- return college_about
38
-
39
- def faculty_details():
40
- return faculty_data
41
-
42
- def facilities_details():
43
- return facilities
44
-
45
- def answer_query(question):
46
- context = f"{college_about}\n\n{faculty_data}\n\n{facilities}"
47
- response = qa_model(question=question, context=context)
48
- return response['answer']
49
-
50
- # Gradio Blocks app
51
- with gr.Blocks(theme=gr.themes.Default()) as app:
52
- gr.HTML("<h2 style='color: #1976D2;'>Government Boys Degree College Daulatpur</h2>")
53
- gr.HTML("<h3 style='color: #1976D2;'>Welcome to our College Information RAG App</h3>")
54
- gr.Image("college_logo.png", label="College Logo")
55
-
56
- with gr.Tabs():
57
- with gr.Tab("About College"):
58
- gr.HTML(f"<div style='background-color: #A5D6A7; padding: 10px; border-radius: 10px; color: #424242;'>{college_about}</div>")
59
- with gr.Tab("Faculty and Staff"):
60
- gr.Markdown(faculty_data)
61
- with gr.Tab("Facilities"):
62
- gr.Markdown(facilities)
63
- with gr.Tab("Ask a Question"):
64
- question = gr.Textbox(label="Ask about the college")
65
- answer = gr.Textbox(label="Answer")
66
- question.submit(answer_query, inputs=question, outputs=answer)
67
- with gr.Tab("Contact Us"):
68
- gr.Markdown("**Contact Details:**\n- Location: National Highway N6 bypass Daulatpur\n- Phone: +92 300 3003249\n- Email: othoirshad@gmail.com")
69
- gr.Markdown("[Visit our Facebook Page](https://www.facebook.com/share/19j9Z1iEvz/)")
70
-
71
- gr.Markdown("### Made by Musawir Manzoor")
72
-
73
- # Launch the app
74
- app.launch()
 
1
+ if __name__ == "__main__":
2
+ app.launch(share=True)