ramedde commited on
Commit
33a2e6b
·
verified ·
1 Parent(s): e83df75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -14
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 _LLAMA_OK:
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
- model_path = download_model()
74
- if not model_path or not os.path.exists(model_path):
75
- print("[law-app] Modèle introuvable.")
76
  return None
77
- print(f"[law-app] Chargement : {model_path}")
78
- _llm = Llama(
79
- model_path=model_path,
80
- n_ctx=1024,
81
- n_threads=int(os.getenv("N_THREADS", "2")),
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 ────────────────────────────────────────────────────────────────────