37 lines
1.2 KiB
Bash
37 lines
1.2 KiB
Bash
#!/bin/bash
|
|
|
|
echo "Starting LocalAI P2P Master"
|
|
|
|
# Lire la configuration Home Assistant
|
|
if [ -f /data/options.json ]; then
|
|
MODELS_PATH="$(bashio::config 'models_path' 2>/dev/null || echo '/share/localai/models')"
|
|
THREADS="$(bashio::config 'threads' 2>/dev/null || echo '8')"
|
|
|
|
echo "Models Path: $MODELS_PATH"
|
|
echo "Threads: $THREADS"
|
|
else
|
|
echo "No Home Assistant config found, using defaults"
|
|
MODELS_PATH="/share/localai/models"
|
|
THREADS="8"
|
|
fi
|
|
|
|
# Créer le répertoire des modèles
|
|
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 variables d'environnement
|
|
export THREADS="$THREADS"
|
|
export OMP_NUM_THREADS="$THREADS"
|
|
|
|
# Lancer LocalAI (master génère automatiquement un token)
|
|
echo "Starting LocalAI Master with models path: $MODELS_PATH"
|
|
echo "P2P Token will be generated automatically"
|
|
exec /build/local-ai run \
|
|
--models-path="$MODELS_PATH" \
|
|
--threads="$THREADS" \
|
|
--address="0.0.0.0:8080" \
|
|
--cors \
|
|
--cors-allow-origins="*"
|