File size: 3,115 Bytes
3e5f0a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# DocuVerse AI - Launcher Script for Unix/Linux/Mac
# © 2025 Justine & Krishna. All Rights Reserved.

echo "=================================================="
echo " DOCUVERSE AI - REVOLUTIONARY PDF ASSISTANT"
echo "=================================================="
echo ""

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color

# Check if Python is installed
if ! command -v python3 &> /dev/null && ! command -v python &> /dev/null; then
    echo -e "${RED}[ERROR] Python is not installed or not in PATH${NC}"
    echo -e "${YELLOW}[INFO] Please install Python 3.8+ and try again${NC}"
    exit 1
fi

# Use python3 if available, otherwise use python
if command -v python3 &> /dev/null; then
    PYTHON_CMD="python3"
else
    PYTHON_CMD="python"
fi

# Check Python version
PYTHON_VERSION=$($PYTHON_CMD -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
echo -e "${BLUE}[INFO] Using Python ${PYTHON_VERSION}${NC}"

# Check if app.py exists
if [ ! -f "app.py" ]; then
    echo -e "${RED}[ERROR] app.py not found!${NC}"
    echo -e "${YELLOW}[INFO] Please run this script from the project directory${NC}"
    exit 1
fi

# Check if requirements.txt exists
if [ ! -f "requirements.txt" ]; then
    echo -e "${YELLOW}[WARNING] requirements.txt not found${NC}"
else
    echo -e "${CYAN}[INFO] Checking dependencies...${NC}"

    # Check if streamlit is installed
    if ! $PYTHON_CMD -c "import streamlit" &> /dev/null; then
        echo -e "${YELLOW}[INFO] Installing missing dependencies...${NC}"
        $PYTHON_CMD -m pip install -r requirements.txt

        if [ $? -ne 0 ]; then
            echo -e "${RED}[ERROR] Error installing requirements${NC}"
            echo -e "${YELLOW}[INFO] Try running manually: pip install -r requirements.txt${NC}"
            exit 1
        fi
    fi
fi

# Verify all key dependencies
echo -e "${CYAN}[INFO] Verifying dependencies...${NC}"
$PYTHON_CMD -c "
try:
    import streamlit
    import PyPDF2
    import transformers
    import torch
    print('[SUCCESS] All key dependencies found!')
except ImportError as e:
    print(f'[ERROR] Missing dependency: {e}')
    print('[INFO] Please run: pip install -r requirements.txt')
    exit(1)
" || exit 1

echo ""
echo -e "${GREEN}[INFO] Starting DocuVerse AI...${NC}"
echo -e "${PURPLE}[INFO] The application will open in your default browser${NC}"
echo -e "${CYAN}[INFO] Local URL: http://localhost:8501${NC}"
echo ""
echo -e "${YELLOW}[INFO] To stop the application, press Ctrl+C${NC}"
echo "=================================================="
echo ""

# Make script executable
chmod +x "$0" 2>/dev/null

# Start the Streamlit application
trap 'echo -e "\n\n[INFO] Shutting down DocuVerse AI..."; echo -e "[INFO] Thank you for using DocuVerse AI!"; exit 0' INT

$PYTHON_CMD -m streamlit run app.py \
    --server.headless false \
    --server.port 8501 \
    --server.address localhost \
    --browser.gatherUsageStats false

echo ""
echo -e "${GREEN}[INFO] Thank you for using DocuVerse AI!${NC}"