Spaces:
Sleeping
Sleeping
File size: 1,761 Bytes
61c2fdb 495bec1 61c2fdb a24a1af 495bec1 561b816 8845183 e784559 537642c 561b816 a24a1af 561b816 fc1af95 561b816 537642c 4351033 561b816 a24a1af 561b816 61c2fdb a24a1af 08c7eb4 8845183 08c7eb4 61c2fdb 4351033 561b816 a24a1af 08c7eb4 561b816 fc1af95 4351033 61c2fdb 8845183 a24a1af 561b816 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import gradio as gr
from llama_cpp import Llama
from huggingface_hub import hf_hub_download
import os
# 1. Config - Verified Filename
REPO_ID = "erdemozkan/YOLO-7B-Qwen-Coder"
GGUF_FILE = "YOLO-7B-Qwen-q4.gguf"
print(f"π YOLO CODER: Pulling {GGUF_FILE}...")
try:
model_path = hf_hub_download(repo_id=REPO_ID, filename=GGUF_FILE)
print(f"β
Model found: {model_path}")
except Exception as e:
print(f"β Download failed: {e}")
model_path = None
# 2. Engine Initialization
if model_path:
llm = Llama(
model_path=model_path,
n_ctx=1024,
n_threads=2, # Optimized for HF Free Tier
verbose=False
)
else:
llm = None
def yoco_heal(broken_code):
if not llm: return "β Engine Offline. Model file not found."
if not broken_code.strip(): return "β οΈ Paste code."
prompt = f"<|im_start|>system\nYou are YOLO CODER. Fix the code perfectly.<|im_end|>\n<|im_start|>user\n{broken_code}<|im_end|>\n<|im_start|>assistant\n"
response = llm(prompt, max_tokens=1024, stop=["<|im_end|>"], echo=False)
return response["choices"][0]["text"].strip()
# 3. UI logic
css = ".gradio-container {background:#000; color:#ffff00; font-family:monospace;} #header {text-align:center; text-shadow: 0 0 10px #ffff00;}"
with gr.Blocks(css=css) as demo:
gr.Markdown("# YOLO CODER [DOCKER CPU]", elem_id="header")
with gr.Row():
in_code = gr.Code(label="INPUT", language="python", lines=12)
out_code = gr.Code(label="HEALED", language="python", lines=12)
btn = gr.Button("YOLO IT!")
btn.click(fn=yoco_heal, inputs=in_code, outputs=out_code)
if __name__ == "__main__":
# REQUIRED: Port 7860 for Docker on HF
demo.launch(server_name="0.0.0.0", server_port=7860) |