38 lines
1.3 KiB
Bash
38 lines
1.3 KiB
Bash
#!/usr/bin/with-contenv bashio
|
|
|
|
# Les variables d'environnement sont automatiquement disponibles depuis les options
|
|
echo "Starting LocalAI P2P Worker"
|
|
echo "Master Token: $(bashio::config 'master_token')"
|
|
echo "GPU Layers: $(bashio::config 'gpu_layers')"
|
|
echo "Models Path: $(bashio::config 'models_path')"
|
|
|
|
# Configurer le token P2P si fourni
|
|
TOKEN="$(bashio::config 'master_token')"
|
|
if [ -n "$TOKEN" ] && [ "$TOKEN" != "null" ]; then
|
|
export LOCALAI_P2P_TOKEN="$TOKEN"
|
|
export P2P_TOKEN="$TOKEN"
|
|
echo "P2P Token configured"
|
|
else
|
|
echo "No P2P token provided - will generate one"
|
|
fi
|
|
|
|
# Créer le répertoire des modèles
|
|
MODELS_PATH="$(bashio::config 'models_path')"
|
|
mkdir -p "$MODELS_PATH"
|
|
|
|
# Nettoyer les fichiers corrompus
|
|
find "$MODELS_PATH" -name "*.yaml" -exec grep -l "#!/usr/bin/with-contenv bashio\|mapping values are not allowed in this context" {} \; 2>/dev/null | xargs rm -f 2>/dev/null || true
|
|
|
|
# Configurer les threads
|
|
export THREADS="$(bashio::config 'threads' || echo '8')"
|
|
export OMP_NUM_THREADS="$THREADS"
|
|
|
|
# Lancer LocalAI
|
|
echo "Starting LocalAI with models path: $MODELS_PATH"
|
|
exec /usr/local/bin/local-ai run \
|
|
--models-path="$MODELS_PATH" \
|
|
--threads="$THREADS" \
|
|
--address="0.0.0.0:8080" \
|
|
--cors \
|
|
--cors-allow-origins="*"
|