Spaces:
Runtime error
Runtime error
Commit ·
dca816b
1
Parent(s): 2718c7b
Upd bash scripts
Browse files4 unmodified lines5678910111213141516171819202122232425262728293031323334354 unmodified linesecho "🏗️ MedAI Processing Build Script"echo "=================================="# Check if mode is specifiedif [ "$1" = "local" ]; thenecho "🏠 Building in LOCAL mode (MedAlpaca-13b)"docker build --build-arg IS_LOCAL=true -t medai-processing:local .elif [ "$1" = "cloud" ]; thenecho "☁️ Building in CLOUD mode (NVIDIA/Gemini APIs)"docker build --build-arg IS_LOCAL=false -t medai-processing:cloud .elseecho "Usage: $0 [local|cloud]"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 1fiecho ""echo "✅ Build completed successfully!"echo ""echo "To run the container:"if [ "$1" = "local" ]; thenecho " docker run -p 7860:7860 -e HF_TOKEN=your_token_here medai-processing:local"elseecho " docker run -p 7860:7860 -e NVIDIA_API_1=your_key -e GEMINI_API_1=your_key medai-processing:cloud"fi4 unmodified lines567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341354 unmodified linesecho "🏗️ MedAI Processing Build Script"echo "=================================="# Function to prompt user for yes/noprompt_yes_no() {local prompt="$1"local responsewhile true; doread -p "$prompt (y/n): " responsecase $response in[Yy]* ) return 0;;[Nn]* ) return 1;;* ) echo "Please answer yes (y) or no (n).";;esacdone}# Function to get environment variablesget_env_vars() {local mode="$1"local env_vars=""if [ "$mode" = "local" ]; thenecho "🔑 Please provide your Hugging Face token:"read -p "HF_TOKEN: " hf_tokenif [ -n "$hf_token" ]; thenenv_vars="-e HF_TOKEN=$hf_token"elseecho "⚠️ Warning: No HF_TOKEN provided. Model download may fail."fielseecho "🔑 Please provide your API keys:"read -p "NVIDIA_API_1: " nvidia_keyread -p "GEMINI_API_1: " gemini_keyif [ -n "$nvidia_key" ]; thenenv_vars="$env_vars -e NVIDIA_API_1=$nvidia_key"fiif [ -n "$gemini_key" ]; thenenv_vars="$env_vars -e GEMINI_API_1=$gemini_key"fiif [ -z "$nvidia_key" ] && [ -z "$gemini_key" ]; thenecho "⚠️ Warning: No API keys provided. Processing may fail."fifiecho "$env_vars"}# Check if mode is specified as argumentif [ "$1" = "local" ]; thenMODE="local"elif [ "$1" = "cloud" ]; thenMODE="cloud"else# Interactive mode selectionecho "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 ""while true; doread -p "Enter your choice (1 or 2): " choicecase $choice in1) MODE="local"; break;;2) MODE="cloud"; break;;*) echo "Please enter 1 for local mode or 2 for cloud mode.";;esacdonefiecho ""echo "Selected mode: $MODE"echo ""# Ask if user wants to build/rebuild Docker imageif prompt_yes_no "Would you like to build/rebuild the Docker image?"; thenecho ""if [ "$MODE" = "local" ]; thenecho "🏠 Building in LOCAL mode (MedAlpaca-13b)..."docker build --build-arg IS_LOCAL=true -t medai-processing:local .elseecho "☁️ Building in CLOUD mode (NVIDIA/Gemini APIs)..."docker build --build-arg IS_LOCAL=false -t medai-processing:cloud .fiif [ $? -eq 0 ]; thenecho ""echo "✅ Build completed successfully!"elseecho ""echo "❌ Build failed! Please check the error messages above."exit 1fielseecho "⏭️ Skipping Docker build..."fiecho ""# Ask if user wants to run the containerif prompt_yes_no "Would you like to run the Docker container now?"; thenecho ""echo "🚀 Starting Docker container..."# Get environment variablesENV_VARS=$(get_env_vars "$MODE")# Set the image name based on modeif [ "$MODE" = "local" ]; thenIMAGE_NAME="medai-processing:local"IS_LOCAL_FLAG="-e IS_LOCAL=true"elseIMAGE_NAME="medai-processing:cloud"IS_LOCAL_FLAG="-e IS_LOCAL=false"fi# Run the containerecho "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_NAMEelseecho ""echo "📋 Manual run command:"if [ "$MODE" = "local" ]; thenecho " docker run -p 7860:7860 -e IS_LOCAL=true -e HF_TOKEN=your_token_here medai-processing:local"elseecho " docker run -p 7860:7860 -e IS_LOCAL=false -e NVIDIA_API_1=your_key -e GEMINI_API_1=your_key medai-processing:cloud"fifi
build.sh+118-18