Spaces:
Runtime error
Runtime error
File size: 2,348 Bytes
86042ad 35d653a 86042ad 48e767e 86042ad 35d653a 86042ad 48e767e 35d653a 86042ad 48e767e 35d653a 48e767e 86042ad 48e767e 86042ad 48e767e 86042ad 48e767e 86042ad 48e767e 35d653a |
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 |
#!/bin/bash
set -e
echo "π Starting LLM API Backend..."
echo "π Working directory: $(pwd)"
echo "π’ Node version: $(node --version)"
# Change to backend directory
cd /app/backend
# Verify Encore CLI is available
if ! command -v encore &> /dev/null; then
echo "β ERROR: Encore CLI not found in PATH"
echo "Available binaries:"
ls -la /usr/local/bin/ | grep encore || echo "No encore binary found"
ls -la /root/.encore/bin/ 2>/dev/null | grep encore || echo "No encore binary in home"
exit 1
fi
echo "β
Encore CLI found: $(which encore)"
echo "π¦ Encore version: $(encore version)"
# Configure secrets from environment variables
echo "π Configuring secrets from environment..."
if [ -z "$LLMProvider" ]; then
echo "β οΈ Warning: LLMProvider not set. Please configure in Space settings."
echo " Add: LLMProvider = 'huggingface' or 'ollama'"
else
echo "β
LLMProvider: $LLMProvider"
encore secret set --type=local LLMProvider "$LLMProvider" 2>/dev/null || echo " Note: Secret may already be set"
fi
if [ "$LLMProvider" = "huggingface" ]; then
if [ -z "$HuggingFaceAPIKey" ]; then
echo "β ERROR: HuggingFaceAPIKey required for Hugging Face provider"
exit 1
else
echo "β
HuggingFaceAPIKey configured"
encore secret set --type=local HuggingFaceAPIKey "$HuggingFaceAPIKey" 2>/dev/null || echo " Note: Secret may already be set"
fi
if [ -n "$DefaultModel" ]; then
echo "β
DefaultModel: $DefaultModel"
encore secret set --type=local DefaultModel "$DefaultModel" 2>/dev/null || echo " Note: Secret may already be set"
fi
fi
if [ "$LLMProvider" = "ollama" ]; then
if [ -z "$OllamaBaseURL" ]; then
echo "β οΈ Warning: OllamaBaseURL not set for Ollama provider"
echo " Add: OllamaBaseURL = 'http://localhost:11434'"
else
echo "β
OllamaBaseURL: $OllamaBaseURL"
encore secret set --type=local OllamaBaseURL "$OllamaBaseURL" 2>/dev/null || echo " Note: Secret may already be set"
fi
fi
# Start the application
echo ""
echo "β¨ Starting Encore application on port ${PORT:-7860}..."
echo "π‘ Health endpoint: http://localhost:${PORT:-7860}/health"
echo "π¬ Chat endpoint: http://localhost:${PORT:-7860}/chat"
echo ""
exec encore run --port="${PORT:-7860}" |