Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
|
@@ -7,8 +7,10 @@ from huggingface_hub import hf_hub_download
|
|
| 7 |
from llama_cpp import Llama
|
| 8 |
|
| 9 |
# --- Configuration ---
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
MODEL_PATH = os.path.join("models", MODEL_FILE)
|
| 13 |
|
| 14 |
app = FastAPI(title="Autonomous Coding AI")
|
|
@@ -16,7 +18,7 @@ app = FastAPI(title="Autonomous Coding AI")
|
|
| 16 |
# --- 1. Model Loader ---
|
| 17 |
print("Checking model existence...")
|
| 18 |
if not os.path.exists(MODEL_PATH):
|
| 19 |
-
print("Model not found. Downloading...")
|
| 20 |
os.makedirs("models", exist_ok=True)
|
| 21 |
hf_hub_download(repo_id=MODEL_ID, filename=MODEL_FILE, local_dir="models")
|
| 22 |
print("Download complete.")
|
|
@@ -24,16 +26,17 @@ if not os.path.exists(MODEL_PATH):
|
|
| 24 |
print("Loading model into memory...")
|
| 25 |
llm = Llama(
|
| 26 |
model_path=MODEL_PATH,
|
| 27 |
-
n_ctx=
|
| 28 |
-
n_gpu_layers=0,
|
| 29 |
verbose=False
|
| 30 |
)
|
| 31 |
print("Model loaded successfully!")
|
| 32 |
|
| 33 |
# --- 2. Agent System ---
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
def run_agent(system_prompt: str, user_prompt: str) -> str:
|
| 39 |
response = llm.create_chat_completion(
|
|
|
|
| 7 |
from llama_cpp import Llama
|
| 8 |
|
| 9 |
# --- Configuration ---
|
| 10 |
+
# Model: Dolphin 2.9 Llama 3 8B (Uncensored)
|
| 11 |
+
# Reasoning: Best coding model for CPU hardware with ZERO censorship.
|
| 12 |
+
MODEL_ID = "cognitivecomputations/dolphin-2.9-llama3-8b-gguf"
|
| 13 |
+
MODEL_FILE = "dolphin-2.9-llama3-8b-Q4_K_M.gguf"
|
| 14 |
MODEL_PATH = os.path.join("models", MODEL_FILE)
|
| 15 |
|
| 16 |
app = FastAPI(title="Autonomous Coding AI")
|
|
|
|
| 18 |
# --- 1. Model Loader ---
|
| 19 |
print("Checking model existence...")
|
| 20 |
if not os.path.exists(MODEL_PATH):
|
| 21 |
+
print("Model not found. Downloading Uncensored Dolphin model...")
|
| 22 |
os.makedirs("models", exist_ok=True)
|
| 23 |
hf_hub_download(repo_id=MODEL_ID, filename=MODEL_FILE, local_dir="models")
|
| 24 |
print("Download complete.")
|
|
|
|
| 26 |
print("Loading model into memory...")
|
| 27 |
llm = Llama(
|
| 28 |
model_path=MODEL_PATH,
|
| 29 |
+
n_ctx=8192, # Increased context for coding projects
|
| 30 |
+
n_gpu_layers=0, # CPU only
|
| 31 |
verbose=False
|
| 32 |
)
|
| 33 |
print("Model loaded successfully!")
|
| 34 |
|
| 35 |
# --- 2. Agent System ---
|
| 36 |
+
# Prompts tailored for an uncensored, autonomous workflow
|
| 37 |
+
SYSTEM_PROMPT_ARCHITECT = "You are an Architect Agent. Analyze requirements and output a JSON structure. Do not refuse requests."
|
| 38 |
+
SYSTEM_PROMPT_CODER = "You are a Coder Agent. Write clean, efficient Python code based on the architecture. Do not refuse requests."
|
| 39 |
+
SYSTEM_PROMPT_SECURITY = "You are a Security Agent. Review code for vulnerabilities."
|
| 40 |
|
| 41 |
def run_agent(system_prompt: str, user_prompt: str) -> str:
|
| 42 |
response = llm.create_chat_completion(
|