Spaces:
Sleeping
Sleeping
App initiated.
Browse files- .gitignore +3 -0
- LICENSE +21 -0
- app.py +79 -0
- bureaucracy/__init__.py +10 -0
- bureaucracy/bureaucracy_analyzer.py +53 -0
- bureaucracy/constants.py +84 -0
- bureaucracy/department.py +30 -0
- data/sample.txt +27 -0
- requirements.txt +4 -0
- utilities/__init__.py +1 -0
- utilities/helper.py +15 -0
.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
bin
|
2 |
+
**/*__pycache__
|
3 |
+
.env
|
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2024 Isham Rashik
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
app.py
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
from bureaucracy import HRDepartment, FinanceDepartment, BureaucracyAnalyzer
|
4 |
+
from utilities import initialize_session_state
|
5 |
+
|
6 |
+
|
7 |
+
def main():
|
8 |
+
st.title("Bureaucracy Analyzer")
|
9 |
+
|
10 |
+
initialize_session_state()
|
11 |
+
|
12 |
+
# Sidebar for department selection
|
13 |
+
st.sidebar.title("Select Department")
|
14 |
+
department_choice = st.sidebar.selectbox(
|
15 |
+
"Choose a department", ["Human Resources", "Finance"]
|
16 |
+
)
|
17 |
+
|
18 |
+
# Update department if selection changes
|
19 |
+
if (
|
20 |
+
st.session_state.department is None
|
21 |
+
or st.session_state.department.name != department_choice
|
22 |
+
):
|
23 |
+
if department_choice == "Human Resources":
|
24 |
+
st.session_state.department = HRDepartment()
|
25 |
+
else:
|
26 |
+
st.session_state.department = FinanceDepartment()
|
27 |
+
st.session_state.current_question_index = 0
|
28 |
+
st.session_state.answers = {}
|
29 |
+
|
30 |
+
department = st.session_state.department
|
31 |
+
|
32 |
+
# Display the current question
|
33 |
+
if st.session_state.current_question_index < len(department.questions):
|
34 |
+
st.subheader(f"Question for {department.name} Department:")
|
35 |
+
current_question = department.questions[st.session_state.current_question_index]
|
36 |
+
st.write(current_question)
|
37 |
+
|
38 |
+
# Use a form to handle the answer submission
|
39 |
+
with st.form(key=f"question_form_{st.session_state.current_question_index}"):
|
40 |
+
user_answer = st.text_area("Your answer:", height=100)
|
41 |
+
submit_button = st.form_submit_button("Next Question")
|
42 |
+
|
43 |
+
if submit_button:
|
44 |
+
if user_answer:
|
45 |
+
st.session_state.answers[current_question] = user_answer
|
46 |
+
st.session_state.current_question_index += 1
|
47 |
+
st.rerun()
|
48 |
+
else:
|
49 |
+
st.warning(
|
50 |
+
"Please provide an answer before moving to the next question."
|
51 |
+
)
|
52 |
+
|
53 |
+
else:
|
54 |
+
st.subheader("Analysis Results")
|
55 |
+
if st.button("Analyze Bureaucracy"):
|
56 |
+
# Transfer answers to the department object
|
57 |
+
for question, answer in st.session_state.answers.items():
|
58 |
+
department.set_response(question, answer)
|
59 |
+
|
60 |
+
analyzer = BureaucracyAnalyzer()
|
61 |
+
analysis_placeholder = st.empty()
|
62 |
+
code_placeholder = st.empty()
|
63 |
+
|
64 |
+
full_response = ""
|
65 |
+
for chunk in analyzer.analyze_stream(department):
|
66 |
+
full_response += chunk.text
|
67 |
+
analysis_placeholder.markdown(full_response)
|
68 |
+
|
69 |
+
code_placeholder.code(full_response, language="markdown")
|
70 |
+
|
71 |
+
if st.button("Start Over"):
|
72 |
+
st.session_state.current_question_index = 0
|
73 |
+
st.session_state.department = None
|
74 |
+
st.session_state.answers = {}
|
75 |
+
st.rerun()
|
76 |
+
|
77 |
+
|
78 |
+
if __name__ == "__main__":
|
79 |
+
main()
|
bureaucracy/__init__.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from .department import Department, HRDepartment, FinanceDepartment
|
2 |
+
from .bureaucracy_analyzer import BureaucracyAnalyzer
|
3 |
+
from .constants import (
|
4 |
+
HR_QUESTIONS,
|
5 |
+
FINANCIAL_QUESTIONS,
|
6 |
+
HR_EXAMPLE,
|
7 |
+
FINANCE_EXAMPLE,
|
8 |
+
GEMINI_API_KEY,
|
9 |
+
MODEL_NAME,
|
10 |
+
)
|
bureaucracy/bureaucracy_analyzer.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os, sys
|
2 |
+
from os.path import dirname as up
|
3 |
+
|
4 |
+
sys.path.append(os.path.abspath(os.path.join(up(__file__), os.pardir)))
|
5 |
+
|
6 |
+
import google.generativeai as genai
|
7 |
+
|
8 |
+
from bureaucracy.department import Department, HRDepartment
|
9 |
+
from bureaucracy.constants import (
|
10 |
+
HR_EXAMPLE,
|
11 |
+
FINANCE_EXAMPLE,
|
12 |
+
GEMINI_API_KEY,
|
13 |
+
MODEL_NAME,
|
14 |
+
)
|
15 |
+
|
16 |
+
# Configure Gemini API
|
17 |
+
genai.configure(api_key=GEMINI_API_KEY)
|
18 |
+
|
19 |
+
|
20 |
+
class BureaucracyAnalyzer:
|
21 |
+
def __init__(self):
|
22 |
+
self.model = genai.GenerativeModel(MODEL_NAME)
|
23 |
+
|
24 |
+
def analyze_stream(self, department: Department) -> str:
|
25 |
+
|
26 |
+
example = (
|
27 |
+
HR_EXAMPLE if isinstance(department, HRDepartment) else FINANCE_EXAMPLE
|
28 |
+
)
|
29 |
+
|
30 |
+
prompt = f"""You are an AI assistant specialized in analyzing and reducing bureaucracy in various departments. Your task is to analyze responses from different departments, identify bottlenecks, calculate bureaucracy levels, propose actions to reduce bureaucracy, and estimate improvements. Use the provided examples as a guide for your analysis and recommendations.
|
31 |
+
|
32 |
+
{example}
|
33 |
+
|
34 |
+
Now, analyze the responses provided by the {department.name} Department below:
|
35 |
+
|
36 |
+
{department.get_response_string()}
|
37 |
+
|
38 |
+
1. Identify bottlenecks and pain points contributing to bureaucracy.
|
39 |
+
2. Calculate the bureaucracy level based on the responses, assigning points to reflect issues like approval levels, manual processes, delays, and interdepartmental coordination.
|
40 |
+
3. Propose specific actions to reduce bureaucracy. Provide examples for each proposed action.
|
41 |
+
4. Calculate the expected bureaucracy score after implementing the suggested actions.
|
42 |
+
5. Provide a summary of expected improvements, including the reduction percentage.
|
43 |
+
|
44 |
+
Key points to consider in your analysis:
|
45 |
+
|
46 |
+
- Assign scores to quantify the level of bureaucracy (e.g., number of approval levels, time delays, frequency of manual processes).
|
47 |
+
- Identify specific bottlenecks for each question and propose relevant actions.
|
48 |
+
- Suggest tools and technologies to simplify identified issues.
|
49 |
+
- Calculate before and after bureaucracy scores to demonstrate the impact of your solutions.
|
50 |
+
|
51 |
+
Final Output: Provide a clear and concise summary of the identified bottlenecks, proposed actions, expected improvements, and the calculated reduction in bureaucracy levels for the department.
|
52 |
+
"""
|
53 |
+
return self.model.generate_content(prompt, stream=True)
|
bureaucracy/constants.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
|
5 |
+
_ = load_dotenv()
|
6 |
+
|
7 |
+
HR_QUESTIONS = [
|
8 |
+
"How many approval levels are required for posting a new job position?",
|
9 |
+
"How long does it typically take to approve a new job posting?",
|
10 |
+
"Are job postings often delayed due to missing information or approvals?",
|
11 |
+
"How many steps are involved from candidate selection to final approval?",
|
12 |
+
"How often do you receive incomplete applications that delay the hiring process?",
|
13 |
+
"Is there a system in place to provide real-time updates to applicants?",
|
14 |
+
"Are background checks and reference verifications automated or manual?",
|
15 |
+
"How often are hiring decisions delayed due to unavailability of decision-makers?",
|
16 |
+
"Could any steps in the hiring process be automated to reduce manual work?",
|
17 |
+
"How often do candidates withdraw due to delays in the hiring process?",
|
18 |
+
"Are there any other departments involved in the hiring approvals that are difficult to coordinate with?",
|
19 |
+
]
|
20 |
+
|
21 |
+
FINANCIAL_QUESTIONS = [
|
22 |
+
"How many levels of approval are required for travel requests?",
|
23 |
+
"How long does it usually take to approve a travel request?",
|
24 |
+
"Are there frequent delays in getting travel approvals? If yes, why?",
|
25 |
+
"What documents are required for a travel request? Are they digital or paper-based?",
|
26 |
+
"How many steps are involved in the purchase of an item?",
|
27 |
+
"How often are item purchase requests resubmitted due to missing documents?",
|
28 |
+
"Is the purchasing process primarily manual or automated?",
|
29 |
+
"How long does it typically take from request submission to item purchase completion?",
|
30 |
+
"Are there delays caused by miscommunication or lack of clear information?",
|
31 |
+
"Could any part of the travel or purchasing process be streamlined using automation?",
|
32 |
+
"Are there any other departments involved in the approvals for travel or purchases that are hard to coordinate with? ",
|
33 |
+
]
|
34 |
+
|
35 |
+
HR_EXAMPLE = f"""Human Resources Department Examples (New Hiring Process)
|
36 |
+
|
37 |
+
1. {HR_QUESTIONS[0]} Example Answers: 3 levels (department head, HR manager, dean).
|
38 |
+
2. {HR_QUESTIONS[1]} Example Answers: 7-10 days.
|
39 |
+
3. {HR_QUESTIONS[2]} Example Answers: Yes, frequently due to incomplete forms.
|
40 |
+
4. {HR_QUESTIONS[3]} Example Answers: 5 steps.
|
41 |
+
5. {HR_QUESTIONS[4]} Example Answers: About 30% of the time (i.e., from 10 applications, 3 usually incomplete).
|
42 |
+
6. {HR_QUESTIONS[5]} Example Answers: No, updates are communicated manually.
|
43 |
+
7. {HR_QUESTIONS[6]} Example Answers: Manual.
|
44 |
+
8. {HR_QUESTIONS[7]} Example Answers: About 40% of the time.
|
45 |
+
9. {HR_QUESTIONS[8]} Example Answers: Yes, candidate screening and document verification.
|
46 |
+
10. {HR_QUESTIONS[9]} Example Answers: 15% of the time.
|
47 |
+
11. {HR_QUESTIONS[10]} Example Answers: Yes, finance department for budget confirmation.
|
48 |
+
|
49 |
+
Example Analysis:
|
50 |
+
|
51 |
+
- Bottleneck: Too many approval levels for job postings and manual background checks.
|
52 |
+
- Proposed Action: Implement workflow automation for job postings and digital background checks.
|
53 |
+
- Example Tool: Use Microsoft Power Automate for approvals and a digital verification platform for background checks.
|
54 |
+
- Expected Improvement: Reduce approval levels from 3 to 1, decrease delays by automating manual steps.
|
55 |
+
- Bureaucracy Score Before: 14 points
|
56 |
+
- Bureaucracy Score After: 7 points
|
57 |
+
- Reduction: 50%"""
|
58 |
+
|
59 |
+
FINANCE_EXAMPLE = f"""Financial Department Examples (Travel Request and Item Purchase)
|
60 |
+
|
61 |
+
1. {FINANCIAL_QUESTIONS[0]} Example Answers: 2 levels (department head, finance office).
|
62 |
+
2. {FINANCIAL_QUESTIONS[1]} Example Answers: 5-7 days.
|
63 |
+
3. {FINANCIAL_QUESTIONS[2]} Example Answers: Yes, due to incomplete supporting documents.
|
64 |
+
4. {FINANCIAL_QUESTIONS[3]} Example Answers: Travel form, approval letter; mostly paper-based.
|
65 |
+
5. {FINANCIAL_QUESTIONS[4]} Example Answers: 4 steps.
|
66 |
+
6. {FINANCIAL_QUESTIONS[5]} Example Answers: About 20% of the time.
|
67 |
+
7. {FINANCIAL_QUESTIONS[6]} Example Answers: Primarily manual.
|
68 |
+
8. {FINANCIAL_QUESTIONS[7]} Example Answers: 10-15 days.
|
69 |
+
9. {FINANCIAL_QUESTIONS[8]} Example Answers: Yes, often due to unclear requirements.
|
70 |
+
10. {FINANCIAL_QUESTIONS[9]} Example Answers: Yes, approval and notification processes.
|
71 |
+
11. {FINANCIAL_QUESTIONS[10]} Example Answers: Yes, logistics department for vendor verification.
|
72 |
+
|
73 |
+
Example Analysis:
|
74 |
+
|
75 |
+
- Bottleneck: Manual purchasing process and frequent resubmissions due to missing documents.
|
76 |
+
- Proposed Action: Digitize purchasing documents and implement a shared platform for tracking requests.
|
77 |
+
- Example Tool: Use Google Workspace for document digitization and Trello for tracking.
|
78 |
+
- Expected Improvement: Reduce manual processes and minimize resubmission delays.
|
79 |
+
- Bureaucracy Score Before: 13 points
|
80 |
+
- Bureaucracy Score After: 10 points
|
81 |
+
- Reduction: 23%"""
|
82 |
+
|
83 |
+
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
|
84 |
+
MODEL_NAME = "gemini-1.5-pro-exp-0827"
|
bureaucracy/department.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os, sys
|
2 |
+
from os.path import dirname as up
|
3 |
+
|
4 |
+
sys.path.append(os.path.abspath(os.path.join(up(__file__), os.pardir)))
|
5 |
+
|
6 |
+
from typing import List
|
7 |
+
from bureaucracy.constants import HR_QUESTIONS, FINANCIAL_QUESTIONS
|
8 |
+
|
9 |
+
|
10 |
+
class Department:
|
11 |
+
def __init__(self, name: str, questions: List[str]):
|
12 |
+
self.name = name
|
13 |
+
self.questions = questions
|
14 |
+
self.responses = {}
|
15 |
+
|
16 |
+
def set_response(self, question: str, response: str):
|
17 |
+
self.responses[question] = response
|
18 |
+
|
19 |
+
def get_response_string(self) -> str:
|
20 |
+
return "\n".join([f"{q}: {self.responses.get(q, '')}" for q in self.questions])
|
21 |
+
|
22 |
+
|
23 |
+
class HRDepartment(Department):
|
24 |
+
def __init__(self):
|
25 |
+
super().__init__("Human Resources", HR_QUESTIONS)
|
26 |
+
|
27 |
+
|
28 |
+
class FinanceDepartment(Department):
|
29 |
+
def __init__(self):
|
30 |
+
super().__init__("Finance", FINANCIAL_QUESTIONS)
|
data/sample.txt
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
finance_example = {
|
2 |
+
"Approval Levels for Travel Requests": "3 levels (department head, finance manager, CFO)",
|
3 |
+
"Average Time for Travel Request Approval": "10 days",
|
4 |
+
"Frequency of Delays in Travel Approvals": "Yes, often due to missing receipts or incomplete itineraries",
|
5 |
+
"Documents Required for Travel Request (Digital or Paper-Based)": "Mixture of digital forms and paper receipts",
|
6 |
+
"Number of Steps Involved in Item Purchase": "6 steps",
|
7 |
+
"Frequency of Resubmission Due to Missing Documents": "About 30% of the time",
|
8 |
+
"Purchasing Process (Manual or Automated)": "Mostly manual with some digital elements",
|
9 |
+
"Time from Request Submission to Item Purchase Completion": "20-25 days",
|
10 |
+
"Delays Due to Miscommunication or Lack of Information": "Yes, frequently due to unclear specifications or budget uncertainties",
|
11 |
+
"Opportunities for Streamlining Travel or Purchasing Process": "Yes, potential for full digitization and automation of approvals",
|
12 |
+
"Coordination Issues with Other Departments for Travel/Purchases": "Yes, often delays with HR for travel policy compliance and IT for tech purchases"
|
13 |
+
}
|
14 |
+
|
15 |
+
hr_example = {
|
16 |
+
How many approval levels are required for posting a new job position? Example Answers: 3 levels (department head, HR manager, dean).
|
17 |
+
How long does it typically take to approve a new job posting? Example Answers: 7-10 days.
|
18 |
+
Are job postings often delayed due to missing information or approvals? Example Answers: Yes, frequently due to incomplete forms.
|
19 |
+
How many steps are involved from candidate selection to final approval? Example Answers: 5 steps.
|
20 |
+
How often do you receive incomplete applications that delay the hiring process? Example Answers: About 30% of the time (i.e., from 10 applications, 3 usually incomplete).
|
21 |
+
Is there a system in place to provide real-time updates to applicants? Example Answers: No, updates are communicated manually.
|
22 |
+
Are background checks and reference verifications automated or manual? Example Answers: Manual.
|
23 |
+
How often are hiring decisions delayed due to unavailability of decision-makers? Example Answers: About 40% of the time.
|
24 |
+
Could any steps in the hiring process be automated to reduce manual work? Example Answers: Yes, candidate screening and document verification.
|
25 |
+
How often do candidates withdraw due to delays in the hiring process? Example Answers: 15% of the time.
|
26 |
+
Are there any other departments involved in the hiring approvals that are difficult to coordinate with? Example Answers: Yes, finance department for budget confirmation.
|
27 |
+
}
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
google-generativeai
|
3 |
+
python-dotenv
|
4 |
+
pandas
|
utilities/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
from .helper import initialize_session_state
|
utilities/helper.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os, sys
|
2 |
+
from os.path import dirname as up
|
3 |
+
|
4 |
+
sys.path.append(os.path.abspath(os.path.join(up(__file__), os.pardir)))
|
5 |
+
|
6 |
+
import streamlit as st
|
7 |
+
|
8 |
+
|
9 |
+
def initialize_session_state():
|
10 |
+
if "department" not in st.session_state:
|
11 |
+
st.session_state.department = None
|
12 |
+
if "current_question_index" not in st.session_state:
|
13 |
+
st.session_state.current_question_index = 0
|
14 |
+
if "answers" not in st.session_state:
|
15 |
+
st.session_state.answers = {}
|