compliance / app /core /swarms_client.py
lucifer7210's picture
Upload 12 files
4b46b44 verified
import requests
from typing import Dict, Any
from app.core.config import settings
def run_swarm(swarm_config: Dict[str, Any]) -> Dict[str, Any]:
"""Execute a swarm with the provided configuration."""
try:
response = requests.post(
f"{settings.BASE_URL}/v1/swarm/completions",
headers=settings.HEADERS,
json=swarm_config
)
return response.json()
except Exception as e:
return {"error": str(e)}
def create_indian_compliance_swarm(financial_data: str, company_info: str) -> Dict[str, Any]:
"""Create a swarm for Indian financial compliance assistance."""
DOCUMENTATION_ANALYZER_PROMPT = """
You are a financial documentation specialist with expertise in Indian financial reporting standards and regulations.
Your role is to analyze financial statements and disclosures for compliance with Indian requirements.
Your tasks include:
1. Reviewing financial statements for completeness under Indian Accounting Standards (Ind AS) or AS
2. Analyzing annual reports and board reports for mandatory disclosures
3. Checking compliance with Companies Act 2013 disclosure requirements
4. Verifying CSR reporting and ESG disclosures as per Indian regulations
5. Ensuring proper disclosure of related party transactions under Indian law
6. Reviewing audit reports and internal financial control assessments
7. Checking compliance with SEBI disclosure norms (for listed companies)
8. Analyzing tax provisions and deferred tax disclosures under Indian tax laws
Focus on Indian regulatory framework and provide findings specific to Indian compliance requirements.
"""
ACCOUNTING_STANDARDS_PROMPT = """
You are an expert in Indian Accounting Standards (Ind AS) and legacy Accounting Standards (AS) with deep knowledge of Indian GAAP requirements.
Your responsibility is to ensure financial statements comply with applicable Indian accounting frameworks.
Your tasks include:
1. Analyzing compliance with applicable Ind AS or AS standards
2. Reviewing revenue recognition under Ind AS 115 or AS 9
3. Checking financial instrument accounting under Ind AS 109 or AS 30/31/32
4. Evaluating lease accounting under Ind AS 116 or AS 19
5. Reviewing impairment assessments under Ind AS 36 or AS 28
6. Analyzing consolidation requirements under Ind AS 110/111 or AS 21/23/27
7. Checking fair value measurements and disclosures under Ind AS 113
8. Ensuring proper segment reporting under Ind AS 108 or AS 17
9. Reviewing first-time adoption issues for Ind AS transition
Reference specific Indian accounting standards and consider MCA notifications and clarifications.
"""
REGULATORY_COMPLIANCE_PROMPT = """
You are a senior regulatory compliance expert specializing in Indian financial regulations and corporate law.
Your expertise covers Companies Act 2013, SEBI regulations, RBI guidelines, and other Indian regulatory frameworks.
Your responsibilities include:
1. Ensuring compliance with Companies Act 2013 provisions and rules
2. Verifying SEBI LODR (Listing Obligations and Disclosure Requirements) compliance
3. Checking RBI guidelines compliance (for applicable sectors)
4. Reviewing corporate governance disclosures as per Indian regulations
5. Analyzing CSR compliance and reporting under Section 135 of Companies Act
6. Verifying board composition and audit committee requirements
7. Checking compliance with insider trading regulations (SEBI PIT)
8. Reviewing related party transaction approvals and disclosures
9. Ensuring proper filing requirements with MCA and SEBI
10. Analyzing compliance with sectoral regulations (banking, insurance, etc.)
Focus on Indian regulatory environment and recent updates to regulations and compliance requirements.
"""
swarm_config = {
"name": "Indian Financial Compliance Assistant",
"description": "A specialized swarm for Indian financial regulatory compliance",
"agents": [
{
"agent_name": "Indian Documentation Analyzer",
"description": "Reviews financial statements for Indian compliance requirements",
"system_prompt": DOCUMENTATION_ANALYZER_PROMPT,
"model_name": "gpt-4o",
"role": "worker",
"max_loops": 1,
"max_tokens": 4096,
"temperature": 0.5,
"auto_generate_prompt": False,
},
{
"agent_name": "Indian Accounting Standards Expert",
"description": "Evaluates compliance with Ind AS/AS requirements",
"system_prompt": ACCOUNTING_STANDARDS_PROMPT,
"model_name": "gpt-4o",
"role": "worker",
"max_loops": 1,
"max_tokens": 4096,
"temperature": 0.5,
"auto_generate_prompt": False,
},
{
"agent_name": "Indian Regulatory Compliance Specialist",
"description": "Assesses adherence to Indian regulatory frameworks",
"system_prompt": REGULATORY_COMPLIANCE_PROMPT,
"model_name": "gpt-4o",
"role": "worker",
"max_loops": 1,
"max_tokens": 4096,
"temperature": 0.5,
"auto_generate_prompt": False,
}
],
"max_loops": 1,
"swarm_type": "SequentialWorkflow",
"task": f"""
Analyze the following financial information for an Indian company ({company_info}) and provide a comprehensive compliance assessment according to Indian regulations:
{financial_data}
For your compliance evaluation, provide:
1. Assessment of compliance with Indian Accounting Standards (Ind AS/AS)
2. Analysis of Companies Act 2013 compliance requirements
3. Review of SEBI regulations compliance (if applicable)
4. Evaluation of corporate governance and disclosure requirements
5. Assessment of CSR and ESG reporting compliance
6. Identification of potential compliance risks specific to Indian regulations
7. Recommendations for improving compliance with Indian standards
Focus specifically on Indian regulatory framework and recent regulatory updates.
"""
}
return run_swarm(swarm_config)