Spaces:
Runtime error
Runtime error
| 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}" |