keeperballon commited on
Commit
4559ffe
·
verified ·
1 Parent(s): 619c730

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -38
app.py CHANGED
@@ -85,6 +85,15 @@ def respond(
85
 
86
  # Model categories for better organization
87
  MODEL_CATEGORIES = {
 
 
 
 
 
 
 
 
 
88
  "Meta LLaMa": [
89
  "meta-llama/Llama-3.3-70B-Instruct",
90
  "meta-llama/Llama-3.1-70B-Instruct",
@@ -99,15 +108,6 @@ MODEL_CATEGORIES = {
99
  "mistralai/Mistral-7B-Instruct-v0.3",
100
  "mistralai/Mistral-7B-Instruct-v0.2",
101
  ],
102
- "Qwen": [
103
- "Qwen/Qwen3-235B-A22B",
104
- "Qwen/Qwen3-32B",
105
- "Qwen/Qwen2.5-72B-Instruct",
106
- "Qwen/Qwen2.5-3B-Instruct",
107
- "Qwen/Qwen2.5-0.5B-Instruct",
108
- "Qwen/QwQ-32B",
109
- "Qwen/Qwen2.5-Coder-32B-Instruct",
110
- ],
111
  "Microsoft Phi": [
112
  "microsoft/Phi-3.5-mini-instruct",
113
  "microsoft/Phi-3-mini-128k-instruct",
@@ -173,7 +173,7 @@ def update_model_display(search_term=""):
173
  for model in models:
174
  model_short = model.split('/')[-1]
175
  html += f"""
176
- <div class='model-card' onclick='selectModel("{model}")'
177
  style='border: 1px solid #ddd; border-radius: 8px; padding: 12px; cursor: pointer; transition: all 0.2s;
178
  background: linear-gradient(145deg, #f0f0f0, #ffffff); box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
179
  <div style='font-weight: bold; margin-bottom: 6px; color: #1a73e8;'>{model_short}</div>
@@ -185,7 +185,25 @@ def update_model_display(search_term=""):
185
  if not filtered_categories:
186
  html += "<p>No models found matching your search.</p>"
187
 
188
- html += "</div><script>function selectModel(model) { document.getElementById('custom-model-input').value = model; }</script>"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  return html
190
 
191
 
@@ -283,6 +301,33 @@ with gr.Blocks(css=custom_css, title=APP_TITLE, theme=gr.themes.Soft()) as demo:
283
  """)
284
 
285
  with gr.Row():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  with gr.Column(scale=3):
287
  # Main chat interface
288
  chatbot = gr.Chatbot(
@@ -358,33 +403,6 @@ with gr.Blocks(css=custom_css, title=APP_TITLE, theme=gr.themes.Soft()) as demo:
358
  step=1,
359
  label="Seed (-1 for random)"
360
  )
361
-
362
- with gr.Column(scale=2):
363
- # Model selection panel
364
- gr.HTML("<div style='border: 1px solid #e0e0e0; border-radius: 10px; padding: 15px;'>")
365
- gr.HTML("<h3 style='margin-top: 0;'>Model Selection</h3>")
366
-
367
- # Custom model input (this is what the respond function sees)
368
- custom_model_box = gr.Textbox(
369
- value="meta-llama/Llama-3.3-70B-Instruct",
370
- label="Selected Model",
371
- elem_id="custom-model-input"
372
- )
373
-
374
- # Search box
375
- model_search_box = gr.Textbox(
376
- label="Search Models",
377
- placeholder="Type to filter models...",
378
- lines=1
379
- )
380
-
381
- # Dynamic model display area
382
- model_display = gr.HTML(update_model_display())
383
-
384
- # Model information display
385
- gr.HTML("<h4>Current Model Info</h4>")
386
- model_info_display = gr.Markdown(get_model_info("meta-llama/Llama-3.3-70B-Instruct"))
387
- gr.HTML("</div>")
388
 
389
  # Footer
390
  gr.HTML("""
 
85
 
86
  # Model categories for better organization
87
  MODEL_CATEGORIES = {
88
+ "Qwen": [
89
+ "Qwen/Qwen3-235B-A22B",
90
+ "Qwen/Qwen3-32B",
91
+ "Qwen/Qwen2.5-72B-Instruct",
92
+ "Qwen/Qwen2.5-3B-Instruct",
93
+ "Qwen/Qwen2.5-0.5B-Instruct",
94
+ "Qwen/QwQ-32B",
95
+ "Qwen/Qwen2.5-Coder-32B-Instruct",
96
+ ],
97
  "Meta LLaMa": [
98
  "meta-llama/Llama-3.3-70B-Instruct",
99
  "meta-llama/Llama-3.1-70B-Instruct",
 
108
  "mistralai/Mistral-7B-Instruct-v0.3",
109
  "mistralai/Mistral-7B-Instruct-v0.2",
110
  ],
 
 
 
 
 
 
 
 
 
111
  "Microsoft Phi": [
112
  "microsoft/Phi-3.5-mini-instruct",
113
  "microsoft/Phi-3-mini-128k-instruct",
 
173
  for model in models:
174
  model_short = model.split('/')[-1]
175
  html += f"""
176
+ <div class='model-card' onclick='selectAndUpdateModel("{model}")'
177
  style='border: 1px solid #ddd; border-radius: 8px; padding: 12px; cursor: pointer; transition: all 0.2s;
178
  background: linear-gradient(145deg, #f0f0f0, #ffffff); box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
179
  <div style='font-weight: bold; margin-bottom: 6px; color: #1a73e8;'>{model_short}</div>
 
185
  if not filtered_categories:
186
  html += "<p>No models found matching your search.</p>"
187
 
188
+ html += """</div>
189
+ <script>
190
+ function selectAndUpdateModel(model) {
191
+ // Set the value in the input field
192
+ const input = document.getElementById('custom-model-input');
193
+ input.value = model;
194
+
195
+ // Create and dispatch a change event to trigger Gradio's handlers
196
+ const event = new Event('change', { bubbles: true });
197
+ input.dispatchEvent(event);
198
+
199
+ // Also trigger the input event for good measure
200
+ const inputEvent = new Event('input', { bubbles: true });
201
+ input.dispatchEvent(inputEvent);
202
+
203
+ console.log('Model selected:', model);
204
+ }
205
+ </script>"""
206
+
207
  return html
208
 
209
 
 
301
  """)
302
 
303
  with gr.Row():
304
+ with gr.Column(scale=2):
305
+ # Model selection panel - MOVED TO THE LEFT SIDE
306
+ gr.HTML("<div style='border: 1px solid #e0e0e0; border-radius: 10px; padding: 15px;'>")
307
+ gr.HTML("<h3 style='margin-top: 0;'>Model Selection</h3>")
308
+
309
+ # Custom model input (this is what the respond function sees)
310
+ custom_model_box = gr.Textbox(
311
+ value="Qwen/Qwen3-32B", # Changed default model to Qwen
312
+ label="Selected Model",
313
+ elem_id="custom-model-input"
314
+ )
315
+
316
+ # Search box
317
+ model_search_box = gr.Textbox(
318
+ label="Search Models",
319
+ placeholder="Type to filter models...",
320
+ lines=1
321
+ )
322
+
323
+ # Dynamic model display area
324
+ model_display = gr.HTML(update_model_display())
325
+
326
+ # Model information display
327
+ gr.HTML("<h4>Current Model Info</h4>")
328
+ model_info_display = gr.Markdown(get_model_info("Qwen/Qwen3-32B")) # Updated to match default
329
+ gr.HTML("</div>")
330
+
331
  with gr.Column(scale=3):
332
  # Main chat interface
333
  chatbot = gr.Chatbot(
 
403
  step=1,
404
  label="Seed (-1 for random)"
405
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
 
407
  # Footer
408
  gr.HTML("""