Spaces:
Running
Running
Commit
·
63e6606
1
Parent(s):
8705f74
Refactor model path handling in main.py; define BASE_DIR and MODEL_DIR, ensure model directory exists, and set model download URL
Browse files
main.py
CHANGED
|
@@ -4,7 +4,15 @@ from pathlib import Path
|
|
| 4 |
import logging
|
| 5 |
import sys
|
| 6 |
from ctransformers import AutoModelForCausalLM
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def download_model():
|
| 9 |
"""Download the model if it doesn't exist"""
|
| 10 |
import requests
|
|
|
|
| 4 |
import logging
|
| 5 |
import sys
|
| 6 |
from ctransformers import AutoModelForCausalLM
|
| 7 |
+
BASE_DIR = Path("/app")
|
| 8 |
+
MODEL_DIR = BASE_DIR / "models"
|
| 9 |
+
MODEL_NAME = "llama-2-7b-chat.q4_K_M.gguf"
|
| 10 |
+
MODEL_PATH = MODEL_DIR / MODEL_NAME
|
| 11 |
+
|
| 12 |
+
# Ensure model directory exists
|
| 13 |
+
MODEL_DIR.mkdir(parents=True, exist_ok=True)
|
| 14 |
+
# Model download URL
|
| 15 |
+
MODEL_URL = "https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q4_K_M.gguf"
|
| 16 |
def download_model():
|
| 17 |
"""Download the model if it doesn't exist"""
|
| 18 |
import requests
|