Spaces:
Paused
Paused
Download scripts/diagnose_gemini_setup.py from 3SCError404/miracle: direct link, hf CLI and curl.
- Browser
- Download file 3.28 kB
-
https://huggingface.co/spaces/3SCError404/miracle/resolve/main/scripts/diagnose_gemini_setup.py
- Command line
-
hf download hf://spaces/3SCError404/miracle/scripts/diagnose_gemini_setup.py
-
curl -L -o diagnose_gemini_setup.py https://huggingface.co/spaces/3SCError404/miracle/resolve/main/scripts/diagnose_gemini_setup.py
3.28 kB
| #!/usr/bin/env python3 | |
| """ | |
| Diagnostic script for Gemini integration issues. | |
| Helps identify configuration and dependency problems. | |
| """ | |
| import sys | |
| import os | |
| # Add project root to path | |
| sys.path.insert(0, os.getcwd()) | |
| from core.config import get_settings | |
| import logging | |
| logging.basicConfig(level=logging.DEBUG, format='%(name)s - %(levelname)s - %(message)s') | |
| def diagnose_gemini(): | |
| """Run comprehensive Gemini diagnostics.""" | |
| settings = get_settings() | |
| print("\n" + "="*60) | |
| print("NEXUS AI - GEMINI INTEGRATION DIAGNOSTICS") | |
| print("="*60) | |
| # 1. Check Configuration | |
| print("\n[1/4] Configuration Check") | |
| print(f" Primary Provider: {settings.AI_PRIMARY_PROVIDER}") | |
| print(f" Primary Model: {settings.AI_MODEL}") | |
| print(f" Fast Model: {settings.AI_FAST_MODEL}") | |
| print(f" Secondary Provider: {settings.AI_SECONDARY_PROVIDER}") | |
| print(f" Backup Model: {settings.AI_BACKUP_PROVIDER_MODEL}") | |
| # 2. Check API Key | |
| print("\n[2/4] API Key Check") | |
| if not settings.GOOGLE_API_KEY: | |
| print(" β GOOGLE_API_KEY: NOT SET") | |
| print(" β Set GOOGLE_API_KEY environment variable") | |
| print(" β Get key from: https://aistudio.google.com/app/apikeys") | |
| else: | |
| key_preview = f"{settings.GOOGLE_API_KEY[:10]}...{settings.GOOGLE_API_KEY[-5:]}" | |
| print(f" β GOOGLE_API_KEY: SET ({key_preview}) [length={len(settings.GOOGLE_API_KEY)}]") | |
| # 3. Check Dependencies | |
| print("\n[3/4] Dependency Check") | |
| dependencies = { | |
| "langchain_google_genai": "LangChain Google AI integration", | |
| "langchain_core": "LangChain core", | |
| "google.generativeai": "Google Generative AI SDK", | |
| } | |
| for module_name, description in dependencies.items(): | |
| try: | |
| __import__(module_name) | |
| print(f" β {module_name}: installed ({description})") | |
| except ImportError as e: | |
| print(f" β {module_name}: NOT installed ({description})") | |
| print(f" β Install with: pip install {module_name.split('.')[0]}") | |
| # 4. Test Initialization | |
| print("\n[4/4] Initialization Test") | |
| try: | |
| from core.llm import get_llm | |
| print(" β³ Attempting to initialize Google Gemini...") | |
| llm = get_llm(provider="google", model="gemini-2.5-flash") | |
| print(f" β Initialization successful!") | |
| print(f" β Model: {getattr(llm, 'model', 'unknown')}") | |
| # Test a simple invocation | |
| print(" β³ Testing model invocation...") | |
| response = llm.invoke("Say 'Gemini is working!' in one sentence.") | |
| print(f" β Model response: {response.content[:100]}...") | |
| except ImportError as e: | |
| print(f" β Import Error: {e}") | |
| print(f" β Missing dependency. Check [3/4] above.") | |
| except ValueError as e: | |
| print(f" β Configuration Error: {e}") | |
| print(f" β Check API key and configuration") | |
| except Exception as e: | |
| print(f" β Initialization Failed: {type(e).__name__}: {e}") | |
| print(f" β Check logs for detailed error information") | |
| print("\n" + "="*60) | |
| print("Diagnostics Complete") | |
| print("="*60 + "\n") | |
| if __name__ == "__main__": | |
| diagnose_gemini() | |