Fix groq initialization by using lazy loading

- Comment out global analyzer instance creation at import time
- Create BrandPresenceAnalyzer only when analyze_brand_presence() is called
- This prevents groq client initialization during Django import phase
- Resolves TypeError with proxies argument on module import

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
thecyberlearn 2025-09-05 08:51:50 +05:30
parent 332a61c060
commit 133b3f1d50

View File

@ -191,8 +191,8 @@ IMPORTANT:
} }
} }
# Global analyzer instance # Global analyzer instance - commented out to avoid import-time initialization
analyzer = BrandPresenceAnalyzer() # analyzer = BrandPresenceAnalyzer()
def analyze_brand_presence(brand_name: str, website_url: str) -> Dict[str, Any]: def analyze_brand_presence(brand_name: str, website_url: str) -> Dict[str, Any]:
""" """
@ -205,4 +205,6 @@ def analyze_brand_presence(brand_name: str, website_url: str) -> Dict[str, Any]:
Returns: Returns:
Analysis results dictionary Analysis results dictionary
""" """
# Create analyzer instance when needed to avoid import-time initialization
analyzer = BrandPresenceAnalyzer()
return analyzer.analyze_brand_presence(brand_name, website_url) return analyzer.analyze_brand_presence(brand_name, website_url)