CoolFace
Apppublic

kussssh/IPO-Analyzer

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
m7_risks.py85 linesDownload Raw Back to modules
1"""Module 7 — Risk Factor Severity Analysis"""2from backend.schemas import RiskAnalysis3from backend.modules.base import run_module4 5 6def analyze_risks(7    ensemble_retriever=None,8    reranker=None,9    doc_type: str = "drhp",10    analysis_context=None,11):12    return run_module(13        module_name="7. Risk Factor Severity Analysis",14        retrieval_queries=[15            "risk factors",16            "internal risk factors external risk factors",17            "material risks business risks regulatory risks",18            "litigation legal proceedings outstanding court cases penalties",19            "customer concentration revenue dependence single customer top clients",20            "regulatory approvals licenses government dependency non-compliance",21            "debt leverage financial risk cash burn negative cash flow net losses",22            "operational risks technology risks supply chain disruption",23            "related party transactions conflict of interest promoter loans",24            "industry risks competitive market external macroeconomic",25            "we have incurred losses in the past and may continue to incur losses",26            "government regulations licensing approvals renewal required",27            "our revenue is dependent on limited number of customers",28            "we are subject to extensive government regulations",29            "our indebtedness and the conditions and restrictions imposed",30            "risk related to our business risk related to india",31        ],32        extraction_prompt=f"""33        Perform a comprehensive risk factor analysis from the {doc_type.upper()}.34 35        IMPORTANT: The "Risk Factors" section of an Indian IPO document is long (often 30-60 pages).36        Scan ALL provided chunks thoroughly. Extract the TOP risks — do not stop at the first few.37 38        For EACH identified risk, provide:39        - risk_title: Clear, specific title (not generic). Use the exact heading from the document if present.40        - severity: HIGH / MEDIUM / LOW based on:41          HIGH: ongoing material litigation (>5% of revenue), regulatory non-compliance, single customer >30%,42                past losses with no clear profitability path, debt/equity >2x, pending government approvals43                critical to operations, promoter disputes or fraud history44          MEDIUM: customer concentration (top 5 clients = 50%+), competitive threats, regulatory changes pending,45                  technology obsolescence risk, working capital stress, dependence on key personnel46          LOW: generic industry risks, macro/cyclical risks, general competition, standard market risks47        - category: business / regulatory / financial / legal / operational48        - description: Write a SPECIFIC 2-sentence description citing actual numbers/names from the {doc_type.upper()}.49          Bad: "The company has customer concentration risk."50          Good: "Top 3 clients contribute 65% of revenue (₹450 Cr of ₹690 Cr total). Loss of any single major client would materially impact profitability."51 52        Extract at minimum:53        - All HIGH severity risks (these are the most critical — do not miss any)54        - Top 3-5 MEDIUM severity risks55        - Up to 3 representative LOW risks56 57        Identify the single most_material_risk with a detailed 2-sentence explanation.58 59        signal_reasoning: Write 2-3 sentences summarizing the overall risk profile with specific evidence.60 61        Signal Rules:62        POSITIVE if: only low/generic risks, no material litigation, diversified customer base63        NEUTRAL if: some medium risks but manageable, typical industry risks64        NEGATIVE if: any HIGH severity risks present, especially ongoing litigation or regulatory issues65        """,66        output_schema=RiskAnalysis,67        ensemble_retriever=ensemble_retriever,68        reranker=reranker,69        analysis_context=analysis_context,70        section_hint=None,71        final_top_k=30,72        forced_keyword_patterns=[73            "risk factor",74            "we are subject to",75            "we have incurred",76            "we depend on",77            "our business is subject",78            "litigation",79            "legal proceedings",80            "regulatory",81            "concentration",82        ],83        doc_type=doc_type,84    )85