Spaces:
Runtime error
Runtime error
Commit ·
dca816b
1
Parent(s): 2718c7b
Upd bash scripts
Browse files4 unmodified lines56789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354855561011575813145960166162636465181920212223246667686970717273747576772878793031328081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132341331341354 unmodified linesecho "🏗️ MedAI Processing Build Script"echo "=================================="
# Function to prompt user for yes/noprompt_yes_no() { local prompt="$1" local response while true; do read -p "$prompt (y/n): " response case $response in [Yy]* ) return 0;; [Nn]* ) return 1;; * ) echo "Please answer yes (y) or no (n).";; esac done}
# Function to get environment variablesget_env_vars() { local mode="$1" local env_vars="" if [ "$mode" = "local" ]; then echo "🔑 Please provide your Hugging Face token:" read -p "HF_TOKEN: " hf_token if [ -n "$hf_token" ]; then env_vars="-e HF_TOKEN=$hf_token" else echo "⚠️ Warning: No HF_TOKEN provided. Model download may fail." fi else echo "🔑 Please provide your API keys:" read -p "NVIDIA_API_1: " nvidia_key read -p "GEMINI_API_1: " gemini_key if [ -n "$nvidia_key" ]; then env_vars="$env_vars -e NVIDIA_API_1=$nvidia_key" fi if [ -n "$gemini_key" ]; then env_vars="$env_vars -e GEMINI_API_1=$gemini_key" fi if [ -z "$nvidia_key" ] && [ -z "$gemini_key" ]; then echo "⚠️ Warning: No API keys provided. Processing may fail." fi fi echo "$env_vars"}
# Check if mode is specified# Check if mode is specified as argumentif [ "$1" = "local" ]; then echo "🏠 Building in LOCAL mode (MedAlpaca-13b)" docker build --build-arg IS_LOCAL=true -t medai-processing:local . MODE="local"elif [ "$1" = "cloud" ]; then echo "☁️ Building in CLOUD mode (NVIDIA/Gemini APIs)" docker build --build-arg IS_LOCAL=false -t medai-processing:cloud . MODE="cloud"else echo "Usage: $0 [local|cloud]" # Interactive mode selection echo "Please select the runtime mode:" echo "1) Local mode (MedAlpaca-13b) - No API costs, complete privacy" echo "2) Cloud mode (NVIDIA/Gemini APIs) - Faster processing, requires API keys" echo "" echo " local - Build with MedAlpaca-13b model for local inference" echo " cloud - Build with NVIDIA/Gemini API integration" echo "" echo "Examples:" echo " $0 local # Build for local mode" echo " $0 cloud # Build for cloud mode" exit 1 while true; do read -p "Enter your choice (1 or 2): " choice case $choice in 1) MODE="local"; break;; 2) MODE="cloud"; break;; *) echo "Please enter 1 for local mode or 2 for cloud mode.";; esac donefi
echo ""echo "✅ Build completed successfully!"echo "Selected mode: $MODE"echo ""echo "To run the container:"if [ "$1" = "local" ]; then echo " docker run -p 7860:7860 -e HF_TOKEN=your_token_here medai-processing:local"
# Ask if user wants to build/rebuild Docker imageif prompt_yes_no "Would you like to build/rebuild the Docker image?"; then echo "" if [ "$MODE" = "local" ]; then echo "🏠 Building in LOCAL mode (MedAlpaca-13b)..." docker build --build-arg IS_LOCAL=true -t medai-processing:local . else echo "☁️ Building in CLOUD mode (NVIDIA/Gemini APIs)..." docker build --build-arg IS_LOCAL=false -t medai-processing:cloud . fi if [ $? -eq 0 ]; then echo "" echo "✅ Build completed successfully!" else echo "" echo "❌ Build failed! Please check the error messages above." exit 1 fielse echo "⏭️ Skipping Docker build..."fi
echo ""
# Ask if user wants to run the containerif prompt_yes_no "Would you like to run the Docker container now?"; then echo "" echo "🚀 Starting Docker container..." # Get environment variables ENV_VARS=$(get_env_vars "$MODE") # Set the image name based on mode if [ "$MODE" = "local" ]; then IMAGE_NAME="medai-processing:local" IS_LOCAL_FLAG="-e IS_LOCAL=true" else IMAGE_NAME="medai-processing:cloud" IS_LOCAL_FLAG="-e IS_LOCAL=false" fi # Run the container echo "Running: docker run -p 7860:7860 $IS_LOCAL_FLAG $ENV_VARS $IMAGE_NAME" echo "" docker run -p 7860:7860 $IS_LOCAL_FLAG $ENV_VARS $IMAGE_NAMEelse echo "" echo "📋 Manual run command:" if [ "$MODE" = "local" ]; then echo " docker run -p 7860:7860 -e IS_LOCAL=true -e HF_TOKEN=your_token_here medai-processing:local" else echo " docker run -p 7860:7860 -e NVIDIA_API_1=your_key -e GEMINI_API_1=your_key medai-processing:cloud" echo " docker run -p 7860:7860 -e IS_LOCAL=false -e NVIDIA_API_1=your_key -e GEMINI_API_1=your_key medai-processing:cloud" fifibuild.sh+118-18