Spaces:
Build error
Build error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -6,11 +6,22 @@ import os
|
|
| 6 |
import uuid
|
| 7 |
import requests
|
| 8 |
import logging
|
| 9 |
-
|
| 10 |
|
| 11 |
# Configure logging
|
| 12 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# Create the directory if it doesn't exist
|
| 15 |
local_dir = "models"
|
| 16 |
os.makedirs(local_dir, exist_ok=True)
|
|
@@ -35,7 +46,7 @@ def download_model(repo_id, filename, save_path):
|
|
| 35 |
|
| 36 |
# Download the model if it doesn't exist
|
| 37 |
if not os.path.exists(model_path):
|
| 38 |
-
download_model("PurpleAILAB/Llama3.2-3B-uncensored-SQLi-Q4_K_M-GGUF", filename
|
| 39 |
|
| 40 |
def respond(
|
| 41 |
message,
|
|
@@ -55,7 +66,7 @@ def respond(
|
|
| 55 |
# Load the model with the maximum context length and control the maximum tokens in the response
|
| 56 |
llm = Llama(
|
| 57 |
model_path=model_path,
|
| 58 |
-
n_ctx=
|
| 59 |
max_tokens=512 # Control the maximum number of tokens generated in the response
|
| 60 |
)
|
| 61 |
|
|
|
|
| 6 |
import uuid
|
| 7 |
import requests
|
| 8 |
import logging
|
| 9 |
+
import subprocess
|
| 10 |
|
| 11 |
# Configure logging
|
| 12 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 13 |
|
| 14 |
+
# Function to install requirements
|
| 15 |
+
def install_requirements():
|
| 16 |
+
try:
|
| 17 |
+
subprocess.check_call([os.sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'])
|
| 18 |
+
logging.info("Requirements installed successfully.")
|
| 19 |
+
except subprocess.CalledProcessError as e:
|
| 20 |
+
logging.error(f"Failed to install requirements: {e}")
|
| 21 |
+
|
| 22 |
+
# Install requirements
|
| 23 |
+
install_requirements()
|
| 24 |
+
|
| 25 |
# Create the directory if it doesn't exist
|
| 26 |
local_dir = "models"
|
| 27 |
os.makedirs(local_dir, exist_ok=True)
|
|
|
|
| 46 |
|
| 47 |
# Download the model if it doesn't exist
|
| 48 |
if not os.path.exists(model_path):
|
| 49 |
+
download_model("PurpleAILAB/Llama3.2-3B-uncensored-SQLi-Q4_K_M-GGUF", filename)
|
| 50 |
|
| 51 |
def respond(
|
| 52 |
message,
|
|
|
|
| 66 |
# Load the model with the maximum context length and control the maximum tokens in the response
|
| 67 |
llm = Llama(
|
| 68 |
model_path=model_path,
|
| 69 |
+
n_ctx=5000, # Set the maximum context length
|
| 70 |
max_tokens=512 # Control the maximum number of tokens generated in the response
|
| 71 |
)
|
| 72 |
|