Spaces:
3SCError404
/
Paused

File size: 2,146 Bytes
5eb4857
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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()