File size: 2,168 Bytes
8bab08d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
Quick diagnostic to check if API keys are accessible
"""
import os
from dotenv import load_dotenv

# Load .env file
load_dotenv()

print("=" * 80)
print("API KEY DIAGNOSTIC CHECK")
print("=" * 80)
print()

# Check SERPER_API_KEY
serper_key = os.getenv('SERPER_API_KEY')
print(f"SERPER_API_KEY: {'βœ“ FOUND' if serper_key else 'βœ— NOT FOUND'}")
if serper_key:
    print(f"  Value: {serper_key[:10]}..." if len(serper_key) > 10 else f"  Value: {serper_key}")
    print(f"  Length: {len(serper_key)} characters")
else:
    print("  ⚠ This key is REQUIRED for real contact discovery!")
    print("  Get it from: https://serper.dev")

print()

# Check HF_API_TOKEN
hf_token = os.getenv('HF_API_TOKEN')
print(f"HF_API_TOKEN: {'βœ“ FOUND' if hf_token else 'βœ— NOT FOUND'}")
if hf_token:
    print(f"  Value: {hf_token[:10]}..." if len(hf_token) > 10 else f"  Value: {hf_token}")
    print(f"  Length: {len(hf_token)} characters")
else:
    print("  ⚠ This key is needed for AI email generation")

print()

# Check if running in HF Space
space_id = os.getenv('SPACE_ID')
space_author = os.getenv('SPACE_AUTHOR_NAME')
if space_id or space_author:
    print(f"πŸš€ Running in HuggingFace Space")
    print(f"   Space ID: {space_id}")
    print(f"   Author: {space_author}")
    print()
    print("NOTE: In HF Spaces, secrets should be set in:")
    print("  Settings β†’ Repository secrets")
    print("  Then restart the Space for changes to take effect")
else:
    print("πŸ’» Running locally")
    print()
    print("For local development, create a .env file with:")
    print("  SERPER_API_KEY=your-key-here")
    print("  HF_API_TOKEN=your-token-here")

print()
print("=" * 80)

# Test web search service
print("\nTesting WebSearchService initialization...")
try:
    from services.web_search import get_search_service
    search = get_search_service()
    if search.api_key:
        print("βœ“ WebSearchService initialized with API key")
    else:
        print("βœ— WebSearchService initialized WITHOUT API key")
        print("  Web search will fail!")
except Exception as e:
    print(f"βœ— Error initializing WebSearchService: {e}")

print()
print("=" * 80)