Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import traceback
|
|
3 |
from fastapi import FastAPI, HTTPException
|
4 |
from pydantic import BaseModel
|
5 |
from huggingface_hub import hf_hub_download
|
6 |
-
from ctransformers import
|
7 |
|
8 |
# --- Config ---
|
9 |
REPO_ID = "bartowski/Llama-3.2-3B-Instruct-GGUF"
|
@@ -24,25 +24,19 @@ def get_model():
|
|
24 |
if _model is not None:
|
25 |
return _model
|
26 |
|
27 |
-
print("📥 Downloading model...")
|
28 |
local_file = hf_hub_download(
|
29 |
repo_id=REPO_ID,
|
30 |
filename=FILENAME,
|
31 |
cache_dir=CACHE_DIR,
|
32 |
local_dir_use_symlinks=False,
|
33 |
)
|
34 |
-
local_dir = os.path.dirname(local_file)
|
35 |
-
print("✅ Model downloaded at", local_file)
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
local_dir,
|
40 |
-
model_file=FILENAME,
|
41 |
model_type=MODEL_TYPE,
|
42 |
-
gpu_layers=0,
|
43 |
threads=os.cpu_count() or 2
|
44 |
)
|
45 |
-
print("✅ Model loaded")
|
46 |
return _model
|
47 |
|
48 |
# --- Request Schema ---
|
|
|
3 |
from fastapi import FastAPI, HTTPException
|
4 |
from pydantic import BaseModel
|
5 |
from huggingface_hub import hf_hub_download
|
6 |
+
from ctransformers import LLM
|
7 |
|
8 |
# --- Config ---
|
9 |
REPO_ID = "bartowski/Llama-3.2-3B-Instruct-GGUF"
|
|
|
24 |
if _model is not None:
|
25 |
return _model
|
26 |
|
|
|
27 |
local_file = hf_hub_download(
|
28 |
repo_id=REPO_ID,
|
29 |
filename=FILENAME,
|
30 |
cache_dir=CACHE_DIR,
|
31 |
local_dir_use_symlinks=False,
|
32 |
)
|
|
|
|
|
33 |
|
34 |
+
_model = LLM(
|
35 |
+
model=local_file, # direct file path
|
|
|
|
|
36 |
model_type=MODEL_TYPE,
|
37 |
+
gpu_layers=0,
|
38 |
threads=os.cpu_count() or 2
|
39 |
)
|
|
|
40 |
return _model
|
41 |
|
42 |
# --- Request Schema ---
|