AIencoder commited on
Commit
2a955ef
·
verified ·
1 Parent(s): 3ed108f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -10
app.py CHANGED
@@ -12,15 +12,25 @@ MAX_TOKENS = 2048
12
  CONTEXT_SIZE = 4096
13
 
14
  MODELS = {
15
- "⭐ Qwen2.5 Coder 7B (Best)": "qwen2.5-coder-7b-instruct-q4_k_m.gguf",
16
- "Qwen2.5 Coder 3B (Fast)": "qwen2.5-coder-3b-instruct-q4_k_m.gguf",
17
- "Qwen2.5 Coder 1.5B (Fastest)": "qwen2.5-coder-1.5b-instruct-q4_k_m.gguf",
 
 
 
 
 
18
  }
19
 
20
  MODEL_INFO = {
21
- "⭐ Qwen2.5 Coder 7B (Best)": "🏆 Best quality • ~4.5GB",
22
- "Qwen2.5 Coder 3B (Fast)": "⚖️ Balanced • ~2GBRecommended",
23
- "Qwen2.5 Coder 1.5B (Fastest)": " Fastest • ~1GB",
 
 
 
 
 
24
  }
25
 
26
  LANGUAGES = [
@@ -118,10 +128,16 @@ def transcribe_audio(audio):
118
  def generate_response(model_name, prompt, temperature=0.7, max_tokens=2048):
119
  llm = load_model(model_name)
120
  if not llm:
121
- return "❌ **Model not available.** Check if downloaded."
122
 
123
  try:
124
- formatted = f"<|im_start|>system\nYou are an expert coding assistant.<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
 
 
 
 
 
 
125
 
126
  output = llm(
127
  formatted,
@@ -130,7 +146,7 @@ def generate_response(model_name, prompt, temperature=0.7, max_tokens=2048):
130
  top_p=0.9,
131
  top_k=40,
132
  repeat_penalty=1.1,
133
- stop=["<|im_end|>", "<|im_start|>"],
134
  echo=False
135
  )
136
 
@@ -138,7 +154,6 @@ def generate_response(model_name, prompt, temperature=0.7, max_tokens=2048):
138
  return response if response else "⚠️ Empty response."
139
  except Exception as e:
140
  return f"❌ **Error:** {str(e)[:100]}"
141
-
142
  def extract_code(text):
143
  if not text or "```" not in text:
144
  return text
 
12
  CONTEXT_SIZE = 4096
13
 
14
  MODELS = {
15
+ "⭐ Qwen3 Coder 30B-A3B (Best)": "Qwen3-Coder-30B-A3B-Instruct-Q4_K_M.gguf",
16
+ "🏆 Qwen2.5 Coder 14B (Premium)": "qwen2.5-coder-14b-instruct-q4_k_m.gguf",
17
+ "🧠 DeepSeek V2 Lite (Logic)": "DeepSeek-Coder-V2-Lite-Instruct-Q4_K_M.gguf",
18
+ "⚖️ Qwen2.5 Coder 7B (Balanced)": "qwen2.5-coder-7b-instruct-q4_k_m.gguf",
19
+ "🚀 Qwen2.5 Coder 3B (Fast)": "qwen2.5-coder-3b-instruct-q4_k_m.gguf",
20
+ "⚡ DeepSeek Coder 6.7B": "deepseek-coder-6.7b-instruct.Q4_K_M.gguf",
21
+ "💨 Qwen2.5 Coder 1.5B (Quick)": "qwen2.5-coder-1.5b-instruct-q4_k_m.gguf",
22
+ "🔬 Qwen2.5 Coder 0.5B (Instant)": "qwen2.5-coder-0.5b-instruct-q4_k_m.gguf",
23
  }
24
 
25
  MODEL_INFO = {
26
+ "⭐ Qwen3 Coder 30B-A3B (Best)": "🏆 Best quality • MoE 30B/3B • ~10GB",
27
+ "🏆 Qwen2.5 Coder 14B (Premium)": "💎 Premium • ~8GBComplex tasks",
28
+ "🧠 DeepSeek V2 Lite (Logic)": "🧠 MoE 16B • ~9GB • Algorithms",
29
+ "⚖️ Qwen2.5 Coder 7B (Balanced)": "⚖️ Balanced • ~4.5GB • Recommended",
30
+ "🚀 Qwen2.5 Coder 3B (Fast)": "🚀 Fast • ~2GB • Great all-rounder",
31
+ "⚡ DeepSeek Coder 6.7B": "⚡ Logic focused • ~4GB",
32
+ "💨 Qwen2.5 Coder 1.5B (Quick)": "💨 Quick • ~1GB • Simple tasks",
33
+ "🔬 Qwen2.5 Coder 0.5B (Instant)": "🔬 Instant • ~0.3GB • Lightning fast",
34
  }
35
 
36
  LANGUAGES = [
 
128
  def generate_response(model_name, prompt, temperature=0.7, max_tokens=2048):
129
  llm = load_model(model_name)
130
  if not llm:
131
+ return "❌ **Model not available.**"
132
 
133
  try:
134
+ # Different formats for different models
135
+ if "deepseek" in model_name.lower():
136
+ formatted = f"### Instruction:\n{prompt}\n\n### Response:\n"
137
+ stop_tokens = ["### Instruction:", "### Response:"]
138
+ else: # Qwen format
139
+ formatted = f"<|im_start|>system\nYou are an expert coding assistant.<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
140
+ stop_tokens = ["<|im_end|>", "<|im_start|>"]
141
 
142
  output = llm(
143
  formatted,
 
146
  top_p=0.9,
147
  top_k=40,
148
  repeat_penalty=1.1,
149
+ stop=stop_tokens,
150
  echo=False
151
  )
152
 
 
154
  return response if response else "⚠️ Empty response."
155
  except Exception as e:
156
  return f"❌ **Error:** {str(e)[:100]}"
 
157
  def extract_code(text):
158
  if not text or "```" not in text:
159
  return text