chrissoria Claude commited on
Commit
41896b8
·
1 Parent(s): 7779e40

Restrict free tier: disable custom model input and hide model_source

Browse files

- Set allow_custom_value=False for free tier model dropdown
- Hide model_source dropdown for free tier (only BYOK needs it)
- Toggle both settings correctly when switching between tiers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -1373,12 +1373,14 @@ Soria, C. (2025). CatLLM: A Python package for LLM-based text classification. DO
1373
  choices=FREE_MODEL_CHOICES,
1374
  value="Qwen/Qwen3-VL-235B-A22B-Instruct:novita",
1375
  label="Model",
1376
- allow_custom_value=True
 
1377
  )
1378
  model_source = gr.Dropdown(
1379
  choices=["auto", "openai", "anthropic", "google", "mistral", "xai", "huggingface", "perplexity"],
1380
  value="auto",
1381
- label="Model Source"
 
1382
  )
1383
  api_key = gr.Textbox(
1384
  label="API Key",
@@ -1431,21 +1433,23 @@ Soria, C. (2025). CatLLM: A Python package for LLM-based text classification. DO
1431
  def update_model_tier(tier):
1432
  if tier == "Free Models":
1433
  return (
1434
- gr.update(choices=FREE_MODEL_CHOICES, value=FREE_MODEL_CHOICES[0]),
1435
- gr.update(visible=False),
 
1436
  "**Free tier** - no API key required!"
1437
  )
1438
  else:
1439
  return (
1440
- gr.update(choices=PAID_MODEL_CHOICES, value=PAID_MODEL_CHOICES[0]),
1441
- gr.update(visible=True),
 
1442
  "**Bring Your Own Key** - enter your API key below."
1443
  )
1444
 
1445
  model_tier.change(
1446
  fn=update_model_tier,
1447
  inputs=[model_tier],
1448
- outputs=[model, api_key, api_key_status]
1449
  )
1450
 
1451
  spreadsheet_file.change(
 
1373
  choices=FREE_MODEL_CHOICES,
1374
  value="Qwen/Qwen3-VL-235B-A22B-Instruct:novita",
1375
  label="Model",
1376
+ allow_custom_value=False, # Only allow custom for "Bring Your Own Key"
1377
+ interactive=True
1378
  )
1379
  model_source = gr.Dropdown(
1380
  choices=["auto", "openai", "anthropic", "google", "mistral", "xai", "huggingface", "perplexity"],
1381
  value="auto",
1382
+ label="Model Source",
1383
+ visible=False # Hide for free tier, show for BYOK
1384
  )
1385
  api_key = gr.Textbox(
1386
  label="API Key",
 
1433
  def update_model_tier(tier):
1434
  if tier == "Free Models":
1435
  return (
1436
+ gr.update(choices=FREE_MODEL_CHOICES, value=FREE_MODEL_CHOICES[0], allow_custom_value=False),
1437
+ gr.update(visible=False), # model_source hidden for free
1438
+ gr.update(visible=False), # api_key hidden for free
1439
  "**Free tier** - no API key required!"
1440
  )
1441
  else:
1442
  return (
1443
+ gr.update(choices=PAID_MODEL_CHOICES, value=PAID_MODEL_CHOICES[0], allow_custom_value=True),
1444
+ gr.update(visible=True), # model_source shown for BYOK
1445
+ gr.update(visible=True), # api_key shown for BYOK
1446
  "**Bring Your Own Key** - enter your API key below."
1447
  )
1448
 
1449
  model_tier.change(
1450
  fn=update_model_tier,
1451
  inputs=[model_tier],
1452
+ outputs=[model, model_source, api_key, api_key_status]
1453
  )
1454
 
1455
  spreadsheet_file.change(