erdemozkan commited on
Commit
e784559
Β·
verified Β·
1 Parent(s): 5f98e7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -3,22 +3,22 @@ from llama_cpp import Llama
3
  from huggingface_hub import hf_hub_download
4
  import os
5
 
6
- # 1. Config - Filename: YOLO-7B-Qwen-q4.gguf
7
  REPO_ID = "erdemozkan/YOLO-7B-Qwen-Coder"
8
  GGUF_FILE = "YOLO-7B-Qwen-q4.gguf"
9
 
10
- print(f"πŸš€ YOLO CODER: Pulling the engine ({GGUF_FILE})...")
11
 
12
  try:
13
  # Downloads the GGUF file from your HF repo
14
  model_path = hf_hub_download(repo_id=REPO_ID, filename=GGUF_FILE)
15
  print(f"βœ… Model found: {model_path}")
16
  except Exception as e:
17
- print(f"❌ Download failed: {e}")
18
  model_path = None
19
 
20
  # 2. Engine Initialization
21
- # n_threads=2 is the hardware limit for the HF Free Tier
22
  if model_path:
23
  llm = Llama(
24
  model_path=model_path,
@@ -30,26 +30,25 @@ else:
30
  llm = None
31
 
32
  def yoco_heal(broken_code):
33
- if not llm: return "❌ Engine Offline. Check model filename in repo."
34
  if not broken_code.strip(): return "⚠️ Paste code."
35
 
36
- # Qwen-Coder prompt format
37
  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"
38
 
39
  response = llm(prompt, max_tokens=1024, stop=["<|im_end|>"], echo=False)
40
  return response["choices"][0]["text"].strip()
41
 
42
- # 3. UI
43
  css = ".gradio-container {background:#000; color:#ffff00; font-family:monospace;} #header {text-align:center; text-shadow: 0 0 10px #ffff00;}"
44
 
45
  with gr.Blocks(css=css) as demo:
46
  gr.Markdown("# YOLO CODER [DOCKER CPU]", elem_id="header")
47
  with gr.Row():
48
- in_code = gr.Code(label="INPUT", language="python", lines=12)
49
- out_code = gr.Code(label="HEALED", language="python", lines=12)
50
  btn = gr.Button("YOLO IT!")
51
  btn.click(fn=yoco_heal, inputs=in_code, outputs=out_code)
52
 
53
  if __name__ == "__main__":
54
- # REQUIRED: Port 7860 for Docker on HF
55
  demo.launch(server_name="0.0.0.0", server_port=7860)
 
3
  from huggingface_hub import hf_hub_download
4
  import os
5
 
6
+ # 1. Configuration - Verified Filename
7
  REPO_ID = "erdemozkan/YOLO-7B-Qwen-Coder"
8
  GGUF_FILE = "YOLO-7B-Qwen-q4.gguf"
9
 
10
+ print(f"πŸš€ YOLO CODER: Pulling {GGUF_FILE}...")
11
 
12
  try:
13
  # Downloads the GGUF file from your HF repo
14
  model_path = hf_hub_download(repo_id=REPO_ID, filename=GGUF_FILE)
15
  print(f"βœ… Model found: {model_path}")
16
  except Exception as e:
17
+ print(f"❌ Error downloading model: {e}")
18
  model_path = None
19
 
20
  # 2. Engine Initialization
21
+ # n_threads=2: Hardware limit for HF Free Tier
22
  if model_path:
23
  llm = Llama(
24
  model_path=model_path,
 
30
  llm = None
31
 
32
  def yoco_heal(broken_code):
33
+ if not llm: return "❌ Engine Offline. Model file not found in repo."
34
  if not broken_code.strip(): return "⚠️ Paste code."
35
 
36
+ # Qwen-Coder specific prompt format
37
  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"
38
 
39
  response = llm(prompt, max_tokens=1024, stop=["<|im_end|>"], echo=False)
40
  return response["choices"][0]["text"].strip()
41
 
42
+ # 3. The "YOLO" Aesthetic
43
  css = ".gradio-container {background:#000; color:#ffff00; font-family:monospace;} #header {text-align:center; text-shadow: 0 0 10px #ffff00;}"
44
 
45
  with gr.Blocks(css=css) as demo:
46
  gr.Markdown("# YOLO CODER [DOCKER CPU]", elem_id="header")
47
  with gr.Row():
48
+ in_code = gr.Code(label="FAILED SCRIPT", language="python", lines=12)
49
+ out_code = gr.Code(label="HEALED VERSION", language="python", lines=12)
50
  btn = gr.Button("YOLO IT!")
51
  btn.click(fn=yoco_heal, inputs=in_code, outputs=out_code)
52
 
53
  if __name__ == "__main__":
 
54
  demo.launch(server_name="0.0.0.0", server_port=7860)