added apis for executives sops

This commit is contained in:
2024-09-06 01:48:32 +00:00
parent 67d30fbc6a
commit 690f80bc6e
6 changed files with 571 additions and 375 deletions
+69 -25
View File
@@ -1,37 +1,81 @@
from src.services.sop_generator import SopGenerator
from src.services.sop_generator import SopGeneratorDocument, SopGeneratorExecutive
from src.utils.document_loader import load_document
from src.services.sop_generator import SopPersonalAssessment
file_path = "/root/ds_erp_ai/data/raw/document.doc"
docs = load_document(file_path)
from src.services.sop_generator import SopGeneratorDocument
sop = SopPersonalAssessment()
sop_doc = SopGeneratorDocument()
sop_executive = SopGeneratorExecutive()
if __name__ == "__main__":
# Assuming 'sop' is an instance of SopGenerator and 'docs' is the loaded document content.
# Step 1: Get the roles from the document
roles = [
{
"role": "Content Marketing Specialist",
"sop_types": ["will", "shall"],
"areas": ["communication", "development"]
# Test the generate_sops_from_questionnaire function
questionnaire_data = {
"organizational_vision": {
"question_1_answer": "Our vision is to lead the market in innovative product solutions.",
"question_2_answer": "We see our organization contributing by expanding into new regions and enhancing service quality.",
"question_3_answer": "The key elements of our vision focus on scalability, customer satisfaction, and technological advancement."
},
{
"role": "Digital Marketing Specialist",
"sop_types": ["must"],
"areas": ["finance", "project management"]
"organizational_strategic_goals": {
"question_1_answer": "The strategic direction is to increase market share and improve operational efficiency.",
"question_2_answer": "We aim to achieve a 20% reduction in operating costs by streamlining internal processes.",
"question_3_answer": "The process aligns with our goal to reduce costs while maintaining high product quality."
},
{
"role": "Information Technology Officer",
"sop_types": ["shall", "must"],
"areas": ["development", "communication", "operations"]
"departmental_strategic_goals": {
"sales_department_answer": "Increase sales by 15% in the next fiscal year through better lead generation and customer retention.",
"finance_department_answer": "Ensure a balanced budget by optimizing resource allocation and reducing overhead costs."
}
]
}
executives = ["CEO", "COO"]
managers = ["Sales Manager", "Finance Manager"]
sops_from_questionnaire = sop_executive.generate_sops_from_questionnaire(questionnaire_data, executives, managers)
if sops_from_questionnaire:
print("Generated SOPs from Questionnaire:")
# Print Executive SOPs
print("\nExecutive SOPs:")
for executive, sops in sops_from_questionnaire["executive_sops"].items():
print(f" {executive}:")
print(" Must SOPs:")
for sop in sops.must:
print(f" - {sop}")
print(" Shall SOPs:")
for sop in sops.shall:
print(f" - {sop}")
print(" Will SOPs:")
for sop in sops.will:
print(f" - {sop}")
# Print Department Manager SOPs
print("\nDepartment Manager SOPs:")
for department in sops_from_questionnaire["department_sops"].departments:
print(f" Department: {department.name}")
for manager in department.managers:
print(f" Manager: {manager.title}")
print(" Must SOPs:")
for sop in manager.sops.must:
print(f" - {sop}")
print(" Shall SOPs:")
for sop in manager.sops.shall:
print(f" - {sop}")
print(" Will SOPs:")
for sop in manager.sops.will:
print(f" - {sop}")
else:
print("Failed to generate SOPs from questionnaire.")
# You can keep the previous tests if you want
departments_and_roles = sop_doc.extract_departments_and_managers(docs)
if departments_and_roles:
print("\nExtracted Departments and Roles:")
for department in departments_and_roles.get('departments', []):
print(f"\nDepartment: {department['name']}")
for role in department.get('managerial_roles', []):
print(f" Role: {role['title']}")
print(f" Responsibilities: {', '.join(role['responsibilities'])}")
else:
print("Failed to extract departments and roles.")
sops = sop.generate_sops_by_role_and_area(roles)
print(f"sops:{sops}")
v_ms = sop_doc.extract_vision_mission(docs)
print(f"\nVision and Mission: {v_ms}")