Spaces:
Runtime error
Runtime error
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| from typing import List, Dict, Optional | |
| import uvicorn | |
| app = FastAPI() | |
| class DescriptionRequest(BaseModel): | |
| query_type: str | |
| query_name: str | |
| class PeakPeriodRequest(BaseModel): | |
| department: str | |
| process_name: str | |
| sector: str | |
| class ImpactMatrixRequest(BaseModel): | |
| process_name: str | |
| impact_name: str | |
| class BCMPolicyRequest(BaseModel): | |
| organization_name: str | |
| standards: List[str] | |
| custom_notes: str | |
| qa_pairs: Optional[List[Dict]] = [] | |
| def root(): | |
| return {"message": "Procedures LLM Endpoints API", "status": "running"} | |
| def get_description(request: DescriptionRequest): | |
| descriptions = { | |
| "BIA Procedure": "The Business Impact Analysis (BIA) Procedure is a systematic process used to identify, assess, and prioritize an organization's critical business functions and assets, evaluating the potential impact of disruptions to these functions.", | |
| "Business Impact Analysis Scope": "A Business Impact Analysis (BIA) Scope is a process used to identify, prioritize, and define the objectives and boundaries of a BIA, ensuring it is comprehensive and focused on critical business processes.", | |
| "BIA Objective": "The BIA Objective is to quantify the potential business risks and consequences resulting from disruptions or losses of critical business functions, systems, or resources.", | |
| "BIA Methodology": "The BIA Methodology is a framework used to assess potential disruption to business operations in the event of a disruption or disaster.", | |
| "Risk Assessment Procedure": "Risk Assessment Procedure is a systematic approach to identifying, analyzing, and evaluating potential risks that could impact business operations.", | |
| "BCM Plan Development": "BCM Plan Development is the process of creating comprehensive business continuity plans that ensure organizational resilience." | |
| } | |
| description = descriptions.get(request.query_name, f"Comprehensive procedure for {request.query_name} management.") | |
| return {"description": description} | |
| def get_peak_period(request: PeakPeriodRequest): | |
| peak_periods = { | |
| "Human Resources": "9am-5pm, Monday to Friday", | |
| "IT": "24/7 operations with peak during business hours", | |
| "Finance": "Month-end and quarter-end periods", | |
| "Operations": "Business hours with seasonal variations" | |
| } | |
| period = peak_periods.get(request.department, "Business hours with periodic peaks") | |
| return {"peak_period": period} | |
| def get_impact_scale_matrix(request: ImpactMatrixRequest): | |
| matrices = { | |
| "Financial": { | |
| "1 Hour": {"impact_severity": "1", "reason": "Minimal financial impact"}, | |
| "4 Hours": {"impact_severity": "2", "reason": "Minor financial losses"}, | |
| "8 Hours": {"impact_severity": "3", "reason": "Moderate financial impact"}, | |
| "24 Hours": {"impact_severity": "4", "reason": "Significant financial losses"}, | |
| "72 Hours": {"impact_severity": "5", "reason": "Critical financial impact"} | |
| }, | |
| "Operational": { | |
| "1 Hour": {"impact_severity": "1", "reason": "Minimal operational disruption"}, | |
| "4 Hours": {"impact_severity": "2", "reason": "Minor operational delays"}, | |
| "8 Hours": {"impact_severity": "3", "reason": "Moderate operational impact"}, | |
| "24 Hours": {"impact_severity": "4", "reason": "Significant operational disruption"}, | |
| "72 Hours": {"impact_severity": "5", "reason": "Critical operational failure"} | |
| }, | |
| "Reputational": { | |
| "1 Hour": {"impact_severity": "1", "reason": "No reputational impact"}, | |
| "4 Hours": {"impact_severity": "2", "reason": "Minor customer dissatisfaction"}, | |
| "8 Hours": {"impact_severity": "3", "reason": "Moderate reputational concerns"}, | |
| "24 Hours": {"impact_severity": "4", "reason": "Significant reputation damage"}, | |
| "72 Hours": {"impact_severity": "5", "reason": "Critical reputational damage"} | |
| }, | |
| "Legal and Regulatory": { | |
| "1 Hour": {"impact_severity": "1", "reason": "No regulatory compliance issues"}, | |
| "4 Hours": {"impact_severity": "2", "reason": "Minor compliance reporting delays"}, | |
| "8 Hours": {"impact_severity": "3", "reason": "Moderate regulatory compliance concerns"}, | |
| "24 Hours": {"impact_severity": "4", "reason": "Significant regulatory violations possible"}, | |
| "72 Hours": {"impact_severity": "5", "reason": "Critical regulatory non-compliance"} | |
| }, | |
| "Customer": { | |
| "1 Hour": {"impact_severity": "1", "reason": "Minimal customer service impact"}, | |
| "4 Hours": {"impact_severity": "2", "reason": "Minor customer inconvenience"}, | |
| "8 Hours": {"impact_severity": "3", "reason": "Moderate customer dissatisfaction"}, | |
| "24 Hours": {"impact_severity": "4", "reason": "Significant customer impact and complaints"}, | |
| "72 Hours": {"impact_severity": "5", "reason": "Critical customer service failure"} | |
| }, | |
| "Wellbeing": { | |
| "1 Hour": {"impact_severity": "1", "reason": "No health and safety concerns"}, | |
| "4 Hours": {"impact_severity": "2", "reason": "Minor employee inconvenience"}, | |
| "8 Hours": {"impact_severity": "3", "reason": "Moderate impact on employee wellbeing"}, | |
| "24 Hours": {"impact_severity": "4", "reason": "Significant health and safety concerns"}, | |
| "72 Hours": {"impact_severity": "5", "reason": "Critical health and safety risks"} | |
| } | |
| } | |
| matrix = matrices.get(request.impact_name, matrices["Operational"]) | |
| return {"impact_scale_matrix": matrix} | |
| def generate_bcm_policy(request: BCMPolicyRequest): | |
| standards_text = ", ".join(request.standards) if request.standards else "ISO 22301:2019" | |
| policy = f"{request.organization_name} is committed to maintaining business continuity and ensuring the resilience of critical business operations. This policy is established in accordance with {standards_text}." | |
| return {"policy": policy} | |
| def generate_bcm_questions(): | |
| questions = [ | |
| "What are the critical business processes that must be maintained during a disruption?", | |
| "What are the maximum acceptable downtime periods for each critical process?", | |
| "What resources are required to maintain critical operations during a disruption?", | |
| "How will communication be maintained with stakeholders during an incident?", | |
| "What are the recovery strategies for each critical business function?" | |
| ] | |
| return {"questions": questions} | |
| if __name__ == "__main__": | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |