File size: 2,875 Bytes
a54266b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python3
"""
Quick setup script for ColPali-Vespa Visual Retrieval System
"""

import os
import sys
from pathlib import Path


def create_env_file():
    """Create a sample .env file if it doesn't exist"""
    env_path = Path(".env")
    if env_path.exists():
        print("βœ… .env file already exists")
        return

    env_content = """# Vespa Configuration
# Choose one authentication method:

# Option 1: Token Authentication (Recommended)
VESPA_APP_TOKEN_URL=https://your-app.your-tenant.vespa-cloud.com
VESPA_CLOUD_SECRET_TOKEN=your_vespa_secret_token_here

# Option 2: mTLS Authentication
# USE_MTLS=true
# VESPA_APP_MTLS_URL=https://your-app.your-tenant.vespa-cloud.com
# VESPA_CLOUD_MTLS_KEY="-----BEGIN PRIVATE KEY-----
# Your private key content here
# -----END PRIVATE KEY-----"
# VESPA_CLOUD_MTLS_CERT="-----BEGIN CERTIFICATE-----
# Your certificate content here
# -----END CERTIFICATE-----"

# Google Gemini Configuration (Optional - for AI chat features)
GEMINI_API_KEY=your_gemini_api_key_here

# Application Configuration
LOG_LEVEL=INFO
HOT_RELOAD=false

# Development Configuration
# Uncomment for development mode
# HOT_RELOAD=true
# LOG_LEVEL=DEBUG
"""

    with open(env_path, "w") as f:
        f.write(env_content)

    print("βœ… Created .env file with sample configuration")
    print("   Please edit .env with your actual credentials")


def create_directories():
    """Create necessary directories"""
    directories = ["static", "static/full_images", "static/sim_maps"]

    for directory in directories:
        Path(directory).mkdir(parents=True, exist_ok=True)

    print("βœ… Created necessary directories")


def check_python_version():
    """Check if Python version is compatible"""
    version = sys.version_info
    if version.major != 3 or version.minor < 10 or version.minor >= 13:
        print("❌ Python 3.10, 3.11, or 3.12 is required")
        print(f"   Current version: {version.major}.{version.minor}.{version.micro}")
        return False

    print(
        f"βœ… Python version {version.major}.{version.minor}.{version.micro} is compatible"
    )
    return True


def main():
    """Main setup function"""
    print("πŸš€ ColPali-Vespa Visual Retrieval Setup")
    print("=" * 40)

    # Check Python version
    if not check_python_version():
        sys.exit(1)

    # Create directories
    create_directories()

    # Create .env file
    create_env_file()

    print("\nπŸ“‹ Next steps:")
    print("1. Edit .env file with your Vespa and Gemini credentials")
    print("2. Install dependencies: pip install -e .")
    print("3. Deploy Vespa application: python deploy_vespa_app.py ...")
    print("4. Upload documents: python feed_vespa.py ...")
    print("5. Run the application: python main.py")
    print("\nπŸ“– See README.md for detailed instructions")


if __name__ == "__main__":
    main()