diff --git a/Dockerfile b/Dockerfile
index 39c7b38..6b003b4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -47,6 +47,7 @@ RUN chmod +x /usr/local/bin/docker-entrypoint.sh && mkdir -p /data /models
ENV LOKI_CONTAINER=1 \
LOKI_HOME=/data \
LOKI_MODEL_DIRS=/models \
+ LOKI_ENGINE_BIN=/app/llama-server \
LD_LIBRARY_PATH=/app \
NVIDIA_VISIBLE_DEVICES=all \
NVIDIA_DRIVER_CAPABILITIES=compute,utility
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index 4b926d6..18cd143 100644
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -9,7 +9,7 @@ mkdir -p "$LOKI_HOME"
# Le chemin du moteur est imposé par l'image (llama-server précompilé de
# l'image officielle llama.cpp, dans /app) : on le (re)pose à chaque boot,
# une mise à jour de l'image ne doit pas laisser un BIN obsolète en base.
-loki config set "BIN=/app/llama-server"
+loki config set "BIN=${LOKI_ENGINE_BIN:-/app/llama-server}"
# Les autres clés ne sont semées QUE si absentes : ce que l'utilisateur règle
# ensuite dans l'UI (modèle, contexte…) est conservé d'un redémarrage à l'autre.
diff --git a/internal/loki/ui/index.html b/internal/loki/ui/index.html
index 9018665..5fd1a05 100644
--- a/internal/loki/ui/index.html
+++ b/internal/loki/ui/index.html
@@ -133,7 +133,12 @@ h1{margin:0;font-size:18px;color:var(--accent)}
#brand svg{height:10px;width:auto;display:block;shape-rendering:crispEdges;fill:currentColor}
#brand-word{display:inline-flex;color:var(--accent)}
#ver{font-size:10px;font-weight:400;color:var(--dim);margin-left:7px;letter-spacing:0;align-self:flex-end;line-height:1;position:relative;top:1px}
-.sidehead{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:18px}
+.sidehead{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
+/* Attribution : Loki est un fork d'AJEAN (MIT). Discrète mais permanente, et le
+ nom du projet d'origine renvoie à son dépôt. */
+.brand-fork{font-size:10px;color:var(--dim);margin:0 0 14px;line-height:1.3}
+.brand-fork a{color:var(--dim);text-decoration:underline;text-underline-offset:2px}
+.brand-fork a:hover{color:var(--accent)}
/* pastille d'état service, en haut à droite de la barre latérale */
.statuspill{display:inline-flex;align-items:center;gap:6px;font-size:11px;padding:3px 10px;border-radius:999px;border:1px solid var(--border);background:var(--panel);color:var(--dim);font-weight:600;white-space:nowrap;cursor:pointer}
.statuspill.ok{color:var(--ok);border-color:color-mix(in srgb,var(--ok) 45%,transparent);background:color-mix(in srgb,var(--ok) 12%,transparent)}
@@ -1207,6 +1212,7 @@ button:hover{border-color:var(--dim);color:var(--text)}
diff --git a/internal/loki/ui/src/js/07-models.js b/internal/loki/ui/src/js/07-models.js
index ca5aa97..56ef2c2 100644
--- a/internal/loki/ui/src/js/07-models.js
+++ b/internal/loki/ui/src/js/07-models.js
@@ -384,13 +384,21 @@ function underDir(p, dir){
const n = x => String(x||'').replace(/\\/g,'/').replace(/\/+$/,'').toLowerCase();
return !!p && !!dir && n(p).startsWith(n(dir)+'/');
}
-let beFastPath = '', beOptPath = '', beFastDir = '';
+let beFastPath = '', beOptPath = '', beFastDir = '', beImagePath = '';
async function populateBackend(){
// Chemins des deux moteurs gérés + liste des backends détectés (dossier loki).
let lc = {}; try{ lc = await jget('/api/llamacpp'); }catch(_){}
beFastPath = (lc.prebuilt && lc.prebuilt.bin) || '';
beFastDir = (lc.prebuilt && lc.prebuilt.dir) || '';
beOptPath = lc.bin || '';
+ // Conteneur : le moteur vient de l'image. « Précompilé » et « Compilé »
+ // désignent des installations que Loki ne fait pas ici — les proposer ne
+ // menait qu'à « installez d'abord… ». On les remplace par « Image ».
+ beImagePath = lc.provided ? (lc.provided_bin || '') : '';
+ document.getElementById('be-lab-image').style.display = beImagePath ? '' : 'none';
+ document.getElementById('be-lab-fast').style.display = beImagePath ? 'none' : '';
+ document.getElementById('be-lab-opt').style.display = beImagePath ? 'none' : '';
+ document.getElementById('be-image-note').textContent = beImagePath ? 'llama.cpp officiel' : '';
// Menu « backend détecté » du mode personnalisé : tout ce qu'on trouve dans
// le dossier backends de loki (l'utilisateur peut y déposer son propre build).
const detected = await jget('/api/backends');
@@ -403,7 +411,10 @@ async function populateBackend(){
// Sélectionne l'option correspondant au BIN actuel du preset.
const cur = currentBinInTextarea();
let mode = 'custom';
- if(sameBinPath(cur, beFastPath) || underDir(cur, beFastDir)) mode = 'fast';
+ // Un preset sans BIN hérite du moteur global : en conteneur c'est celui de
+ // l'image, qu'on affiche comme tel plutôt qu'en « personnalisé ».
+ if(beImagePath && (sameBinPath(cur, beImagePath) || !cur)) mode = 'image';
+ else if(sameBinPath(cur, beFastPath) || underDir(cur, beFastDir)) mode = 'fast';
else if(sameBinPath(cur, beOptPath)) mode = 'opt';
const radio = document.querySelector('input[name=m-be][value='+mode+']');
if(radio) radio.checked = true;
@@ -419,7 +430,11 @@ function toggleBackendCustom(mode){
}
function onBackendMode(mode){
toggleBackendCustom(mode);
- if(mode === 'fast'){
+ if(mode === 'image'){
+ if(!beImagePath){ toast('aucun moteur fourni par l\'image'); return; }
+ setBinInTextarea(beImagePath); toast('moteur : llama.cpp de l\'image');
+ loadGpuDevices();
+ } else if(mode === 'fast'){
if(!beFastPath){ toast('installez d\'abord llama.cpp précompilé (section MOTEUR)'); return; }
setBinInTextarea(beFastPath); toast('moteur : llama.cpp précompilé');
loadGpuDevices();
diff --git a/internal/loki/ui/src/styles.css b/internal/loki/ui/src/styles.css
index b409a9b..9eb328f 100644
--- a/internal/loki/ui/src/styles.css
+++ b/internal/loki/ui/src/styles.css
@@ -107,7 +107,12 @@ h1{margin:0;font-size:18px;color:var(--accent)}
#brand svg{height:10px;width:auto;display:block;shape-rendering:crispEdges;fill:currentColor}
#brand-word{display:inline-flex;color:var(--accent)}
#ver{font-size:10px;font-weight:400;color:var(--dim);margin-left:7px;letter-spacing:0;align-self:flex-end;line-height:1;position:relative;top:1px}
-.sidehead{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:18px}
+.sidehead{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
+/* Attribution : Loki est un fork d'AJEAN (MIT). Discrète mais permanente, et le
+ nom du projet d'origine renvoie à son dépôt. */
+.brand-fork{font-size:10px;color:var(--dim);margin:0 0 14px;line-height:1.3}
+.brand-fork a{color:var(--dim);text-decoration:underline;text-underline-offset:2px}
+.brand-fork a:hover{color:var(--accent)}
/* pastille d'état service, en haut à droite de la barre latérale */
.statuspill{display:inline-flex;align-items:center;gap:6px;font-size:11px;padding:3px 10px;border-radius:999px;border:1px solid var(--border);background:var(--panel);color:var(--dim);font-weight:600;white-space:nowrap;cursor:pointer}
.statuspill.ok{color:var(--ok);border-color:color-mix(in srgb,var(--ok) 45%,transparent);background:color-mix(in srgb,var(--ok) 12%,transparent)}
diff --git a/internal/loki/web_llamacpp.go b/internal/loki/web_llamacpp.go
index 29c5295..f1e9252 100644
--- a/internal/loki/web_llamacpp.go
+++ b/internal/loki/web_llamacpp.go
@@ -163,8 +163,11 @@ func handleLlamacpp(w http.ResponseWriter, r *http.Request) {
out["config_bin"] = cfgBin
out["in_use"] = bin != "" && samePath(bin, cfgBin)
// Moteur livré par l'image Docker : il n'y a rien à installer, et l'image
- // ne contient ni cmake ni compilateur. L'UI masque alors les trois modes.
- out["provided"] = engineProvided(cfgBin)
+ // ne contient ni cmake ni compilateur. L'UI masque alors les trois modes,
+ // et le sélecteur par modèle propose « Image » au lieu de « Précompilé /
+ // Compilé », qui ne désignent rien ici.
+ out["provided"] = engineProvided()
+ out["provided_bin"] = providedEngineBin()
plan := detectBuildPlan()
out["plan"] = map[string]any{
@@ -189,36 +192,39 @@ func handleLlamacpp(w http.ResponseWriter, r *http.Request) {
sendJSON(w, 200, out)
}
-// engineProvided : le moteur est-il fourni par l'image Docker ? Vrai quand on
-// tourne en conteneur et que BIN désigne un exécutable existant SITUÉ HORS de
-// LOKI_HOME — donc ni le dépôt cloné, ni les binaires précompilés, ni les
-// backends custom, qui vivent tous sous LOKI_HOME et sont gérés par Loki.
+// providedEngineBin renvoie le moteur livré par l'image Docker, ou "" hors
+// conteneur. L'image le déclare elle-même via LOKI_ENGINE_BIN (voir Dockerfile
+// et docker-entrypoint.sh) : pas de chemin en dur ici, et n'importe quelle image
+// de base convient tant qu'elle pose cette variable.
//
-// Sans cette distinction, l'UI proposait d'installer un moteur déjà présent, et
+// Sans cette notion, l'UI proposait d'installer un moteur déjà présent et
// l'utilisateur tombait sur « outils manquants : cmake » — l'image ne contient
// volontairement ni cmake ni compilateur, puisqu'elle part de l'image officielle
// llama.cpp où llama-server est déjà compilé.
-func engineProvided(cfgBin string) bool {
- if os.Getenv("LOKI_CONTAINER") != "1" || strings.TrimSpace(cfgBin) == "" {
- return false
+func providedEngineBin() string {
+ p := strings.TrimSpace(os.Getenv("LOKI_ENGINE_BIN"))
+ if p == "" {
+ return ""
}
- bin := prebuiltResolveBin(cfgBin)
- if st, err := os.Stat(bin); err != nil || st.IsDir() {
- return false
+ if st, err := os.Stat(prebuiltResolveBin(p)); err != nil || st.IsDir() {
+ return ""
}
- rel, err := filepath.Rel(LokiHome(), bin)
- return err != nil || strings.HasPrefix(rel, "..")
+ return p
}
+// engineProvided : le moteur vient-il de l'image ? (raccourci de lecture)
+func engineProvided() bool { return providedEngineBin() != "" }
+
// refuseIfProvided coupe court aux jobs d'installation/compilation quand le
// moteur vient de l'image : rien à installer, et aucun compilateur disponible.
// Renvoie true si la requête a été refusée (l'appelant doit sortir).
func refuseIfProvided(w http.ResponseWriter) bool {
- if !engineProvided(ReadConfig()["BIN"]) {
+ bin := providedEngineBin()
+ if bin == "" {
return false
}
- sendJSON(w, 409, map[string]any{"ok": false, "error": "Le moteur est fourni par l'image Docker (" +
- ReadConfig()["BIN"] + ") : il n'y a rien à installer ici, et l'image ne contient ni cmake ni compilateur. " +
+ sendJSON(w, 409, map[string]any{"ok": false, "error": "Le moteur est fourni par l'image Docker (" + bin +
+ ") : il n'y a rien à installer ici, et l'image ne contient ni cmake ni compilateur. " +
"Pour changer de moteur, reconstruis l'image avec un autre build-arg LLAMACPP_IMAGE."})
return true
}