Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import json
|
|
|
|
| 4 |
from pathlib import Path
|
| 5 |
from typing import Optional
|
| 6 |
|
| 7 |
MODEL_REPO = os.environ.get("MODEL_REPO", "DavidAU/Qwen3.6-27B-Heretic-Uncensored-FINETUNE-NEO-CODE-Di-IMatrix-MAX-GGUF")
|
| 8 |
MODEL_FILE = os.environ.get("MODEL_FILE", "Qwen3.6-27B-NEO-CODE-HERE-2T-OT-Q4_K_M.gguf")
|
| 9 |
N_CTX = int(os.environ.get("N_CTX", "4096"))
|
| 10 |
-
N_GPU = int(os.environ.get("N_GPU_LAYERS", "-1"))
|
| 11 |
|
| 12 |
SYSTEM_PROMPT = """You are codeMax, an uncensored 27B coding assistant. You excel at:
|
| 13 |
- Writing production code in Python, TypeScript, JavaScript, Rust, Go, C/C++, SQL, shell
|
|
@@ -24,9 +27,9 @@ def _download():
|
|
| 24 |
if _model_path is not None:
|
| 25 |
return _model_path
|
| 26 |
from huggingface_hub import hf_hub_download
|
| 27 |
-
print(f"[MODEL] Downloading {MODEL_FILE}...")
|
| 28 |
_model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)
|
| 29 |
-
print(f"[MODEL] Cached -> {_model_path}")
|
| 30 |
return _model_path
|
| 31 |
|
| 32 |
def _load():
|
|
@@ -35,7 +38,7 @@ def _load():
|
|
| 35 |
return _llm
|
| 36 |
from llama_cpp import Llama
|
| 37 |
path = _download()
|
| 38 |
-
print(f"[MODEL] Loading (n_gpu_layers={N_GPU}, n_ctx={N_CTX})...")
|
| 39 |
_llm = Llama(
|
| 40 |
model_path=path,
|
| 41 |
n_ctx=N_CTX,
|
|
@@ -44,10 +47,10 @@ def _load():
|
|
| 44 |
verbose=False,
|
| 45 |
seed=-1,
|
| 46 |
)
|
| 47 |
-
print("[MODEL] Ready.")
|
| 48 |
return _llm
|
| 49 |
|
| 50 |
-
print("[BOOT] Loading model at startup...")
|
| 51 |
_load()
|
| 52 |
|
| 53 |
def _read_text(path, enc="utf-8"):
|
|
@@ -160,7 +163,7 @@ def respond(message, history, uploaded_files):
|
|
| 160 |
|
| 161 |
if file_context:
|
| 162 |
messages.append({"role": "user", "content": "[Uploaded files]\n\n" + file_context})
|
| 163 |
-
messages.append({"role": "assistant", "content": "Got it! I
|
| 164 |
|
| 165 |
for entry in history:
|
| 166 |
role = entry.get("role", "user")
|
|
|
|
| 1 |
+
import llama_bootstrap # noqa: F401 — MUST be first
|
| 2 |
+
|
| 3 |
import gradio as gr
|
| 4 |
import os
|
| 5 |
import json
|
| 6 |
+
import sys
|
| 7 |
from pathlib import Path
|
| 8 |
from typing import Optional
|
| 9 |
|
| 10 |
MODEL_REPO = os.environ.get("MODEL_REPO", "DavidAU/Qwen3.6-27B-Heretic-Uncensored-FINETUNE-NEO-CODE-Di-IMatrix-MAX-GGUF")
|
| 11 |
MODEL_FILE = os.environ.get("MODEL_FILE", "Qwen3.6-27B-NEO-CODE-HERE-2T-OT-Q4_K_M.gguf")
|
| 12 |
N_CTX = int(os.environ.get("N_CTX", "4096"))
|
| 13 |
+
N_GPU = int(os.environ.get("N_GPU_LAYERS", os.environ.get("DAVIDAU_N_GPU_LAYERS", "-1")))
|
| 14 |
|
| 15 |
SYSTEM_PROMPT = """You are codeMax, an uncensored 27B coding assistant. You excel at:
|
| 16 |
- Writing production code in Python, TypeScript, JavaScript, Rust, Go, C/C++, SQL, shell
|
|
|
|
| 27 |
if _model_path is not None:
|
| 28 |
return _model_path
|
| 29 |
from huggingface_hub import hf_hub_download
|
| 30 |
+
print(f"[MODEL] Downloading {MODEL_FILE}...", file=sys.stderr)
|
| 31 |
_model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)
|
| 32 |
+
print(f"[MODEL] Cached -> {_model_path}", file=sys.stderr)
|
| 33 |
return _model_path
|
| 34 |
|
| 35 |
def _load():
|
|
|
|
| 38 |
return _llm
|
| 39 |
from llama_cpp import Llama
|
| 40 |
path = _download()
|
| 41 |
+
print(f"[MODEL] Loading (n_gpu_layers={N_GPU}, n_ctx={N_CTX})...", file=sys.stderr)
|
| 42 |
_llm = Llama(
|
| 43 |
model_path=path,
|
| 44 |
n_ctx=N_CTX,
|
|
|
|
| 47 |
verbose=False,
|
| 48 |
seed=-1,
|
| 49 |
)
|
| 50 |
+
print("[MODEL] Ready.", file=sys.stderr)
|
| 51 |
return _llm
|
| 52 |
|
| 53 |
+
print("[BOOT] Loading model at startup...", file=sys.stderr)
|
| 54 |
_load()
|
| 55 |
|
| 56 |
def _read_text(path, enc="utf-8"):
|
|
|
|
| 163 |
|
| 164 |
if file_context:
|
| 165 |
messages.append({"role": "user", "content": "[Uploaded files]\n\n" + file_context})
|
| 166 |
+
messages.append({"role": "assistant", "content": "Got it! I’ve read through all the uploaded files."})
|
| 167 |
|
| 168 |
for entry in history:
|
| 169 |
role = entry.get("role", "user")
|