Spaces:
Paused
Paused
Download scripts/test_gemini.py from 3SCError404/nexus: direct link, hf CLI and curl.
- Browser
- Download file 2.15 kB
-
https://huggingface.co/spaces/3SCError404/nexus/resolve/main/scripts/test_gemini.py
- Command line
-
hf download hf://spaces/3SCError404/nexus/scripts/test_gemini.py
-
curl -L -o test_gemini.py https://huggingface.co/spaces/3SCError404/nexus/resolve/main/scripts/test_gemini.py
2.15 kB
| import sys | |
| import os | |
| # Add the project root to sys.path to allow core imports | |
| sys.path.append(os.getcwd()) | |
| from core.config import get_settings | |
| from core.llm import get_llm, get_text_embeddings | |
| def test_gemini_integration(): | |
| """ | |
| Diagnostic script to verify Google Gemini LLM and Embedding configuration. | |
| Specifically checks for the 768-dimension requirement for text embeddings. | |
| """ | |
| settings = get_settings() | |
| print("\n--- NEXUS AI: GEMINI DIAGNOSTIC ---") | |
| print(f"Project: {settings.APP_NAME}") | |
| print(f"Provider: {settings.AI_PROVIDER}") | |
| print(f"LLM Model: {settings.AI_MODEL}") | |
| print(f"Embedding: {settings.AI_TEXT_EMBEDDING_MODEL}") | |
| if not settings.GOOGLE_API_KEY: | |
| print("\n[!] ERROR: GOOGLE_API_KEY is missing from your .env file.") | |
| return | |
| # 1. Test LLM Reasoning | |
| print("\n[1/2] Testing LLM Reasoning (gemini-3-flash-preview)...") | |
| try: | |
| llm = get_llm() | |
| response = llm.invoke("Hello Nexus. Briefly state your purpose for this hackathon.") | |
| print(f"Response: {response.content}") | |
| print("✅ LLM Connectivity: SUCCESS") | |
| except Exception as e: | |
| print(f"❌ LLM Connectivity: FAILED\nDetail: {str(e)}") | |
| # 2. Test Text Embeddings (MRL 768) | |
| print("\n[2/2] Testing Text Embeddings (MRL 768 Dimensions)...") | |
| try: | |
| embed_model = get_text_embeddings() | |
| sample_text = "Optimizing hybrid embedding infrastructure for free-tier deployment." | |
| vector = embed_model.embed_query(sample_text) | |
| dim = len(vector) | |
| print(f"Vector Dimensions: {dim}") | |
| if dim == 768: | |
| print("✅ Embedding Compatibility: SUCCESS (768-D Match)") | |
| else: | |
| print(f"⚠️ Embedding Compatibility: WARNING (Got {dim}-D, Expected 768-D)") | |
| print("Check if models/gemini-embedding-001 supports output_dimensionality in your region.") | |
| except Exception as e: | |
| print(f"❌ Embedding Connectivity: FAILED\nDetail: {str(e)}") | |
| print("\n--- DIAGNOSTIC COMPLETE ---\n") | |
| if __name__ == "__main__": | |
| test_gemini_integration() | |