Update app.py
Browse files
app.py
CHANGED
|
@@ -64,25 +64,20 @@ def get_llm():
|
|
| 64 |
global _llm
|
| 65 |
if _llm is not None:
|
| 66 |
return _llm
|
| 67 |
-
if not
|
| 68 |
-
print("[law-app] llama_cpp non disponible.")
|
| 69 |
return None
|
| 70 |
with _llm_lock:
|
| 71 |
if _llm is not None:
|
| 72 |
return _llm
|
| 73 |
-
|
| 74 |
-
if not
|
| 75 |
-
print("[
|
| 76 |
return None
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
n_gpu_layers=int(os.getenv("N_GPU_LAYERS", "0")),
|
| 83 |
-
verbose=False,
|
| 84 |
-
)
|
| 85 |
-
print("[law-app] Modèle prêt.")
|
| 86 |
return _llm
|
| 87 |
|
| 88 |
# ── Leçons ────────────────────────────────────────────────────────────────────
|
|
|
|
| 64 |
global _llm
|
| 65 |
if _llm is not None:
|
| 66 |
return _llm
|
| 67 |
+
if not _LLAMA_AVAILABLE:
|
|
|
|
| 68 |
return None
|
| 69 |
with _llm_lock:
|
| 70 |
if _llm is not None:
|
| 71 |
return _llm
|
| 72 |
+
gguf_files = glob.glob("/app/*.gguf") + glob.glob("*.gguf")
|
| 73 |
+
if not gguf_files:
|
| 74 |
+
print("[spelling-app] No .gguf file found – AI tips disabled.")
|
| 75 |
return None
|
| 76 |
+
model_path = gguf_files[0]
|
| 77 |
+
print(f"[spelling-app] Loading model: {model_path}")
|
| 78 |
+
_llm = Llama(model_path=model_path, n_ctx=512, n_threads=2,
|
| 79 |
+
n_gpu_layers=int(os.getenv("N_GPU_LAYERS", "-1")), verbose=False)
|
| 80 |
+
print("[spelling-app] Model ready.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
return _llm
|
| 82 |
|
| 83 |
# ── Leçons ────────────────────────────────────────────────────────────────────
|