MySafeCode commited on
Commit
be61cc3
·
verified ·
1 Parent(s): c139321

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -22
app.py CHANGED
@@ -9,7 +9,7 @@ from dotenv import load_dotenv
9
  load_dotenv()
10
 
11
  # API Configuration
12
- API_KEY = os.getenv('STABLECOG_API_KEY', '')
13
  if not API_KEY:
14
  API_KEY = "StableCogKey"
15
 
@@ -441,14 +441,9 @@ def get_recommendation(remaining_credits, percentage_used):
441
  else:
442
  return "🚀 **Plenty of credits!** Ready for extensive image generation work and experimentation."
443
 
444
- # Create Gradio interface with Gradio 6 theme
445
- # Note: Gradio 6 has a simplified theme system
446
  with gr.Blocks(
447
- theme=gr.themes.Soft(
448
- primary_hue="purple",
449
- secondary_hue="indigo",
450
- font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"]
451
- ),
452
  title="StableCog Dashboard",
453
  css="""
454
  footer {display: none !important;}
@@ -456,6 +451,17 @@ with gr.Blocks(
456
  .tab-nav {background: rgba(255,255,255,0.1) !important; border-radius: 10px !important; padding: 5px !important;}
457
  .stat-box input {font-weight: bold !important; font-size: 18px !important;}
458
  .recommendation-box textarea {font-size: 16px !important; line-height: 1.5 !important;}
 
 
 
 
 
 
 
 
 
 
 
459
  """
460
  ) as demo:
461
  gr.Markdown("""
@@ -483,14 +489,12 @@ with gr.Blocks(
483
  with gr.Column():
484
  credits_display = gr.Number(
485
  label="Remaining Credits",
486
- interactive=False,
487
- elem_classes="stat-box"
488
  )
489
  with gr.Column():
490
  usage_display = gr.Number(
491
  label="Usage Percentage",
492
- interactive=False,
493
- elem_classes="stat-box"
494
  )
495
 
496
  # Recommendation row
@@ -498,16 +502,14 @@ with gr.Blocks(
498
  recommendation_box = gr.Textbox(
499
  label="🎯 AI Recommendation",
500
  interactive=False,
501
- lines=3,
502
- elem_classes="recommendation-box"
503
  )
504
 
505
  # Control row
506
  with gr.Row():
507
  check_credits_btn = gr.Button(
508
  "🔄 Check Credits",
509
- variant="primary",
510
- scale=0
511
  )
512
 
513
  with gr.Tab("🤖 Available Models", id="models"):
@@ -525,8 +527,7 @@ with gr.Blocks(
525
  with gr.Row():
526
  check_models_btn = gr.Button(
527
  "🔄 Refresh Models",
528
- variant="primary",
529
- scale=0
530
  )
531
 
532
  # Instructions and info
@@ -570,10 +571,6 @@ with gr.Blocks(
570
  outputs=[models_html_output, models_raw_output]
571
  )
572
 
573
- # Update recommendation after credits load
574
- def update_recommendation_after_load():
575
- return get_recommendation(credits_display.value, usage_display.value)
576
-
577
  # Connect buttons
578
  def update_all_credits():
579
  html, raw, credits, usage = update_display()
 
9
  load_dotenv()
10
 
11
  # API Configuration
12
+ API_KEY = os.getenv('StableCogKey', '')
13
  if not API_KEY:
14
  API_KEY = "StableCogKey"
15
 
 
441
  else:
442
  return "🚀 **Plenty of credits!** Ready for extensive image generation work and experimentation."
443
 
444
+ # Create Gradio interface with simplified theme configuration for Gradio 6
445
+ # In Gradio 6, theme is set differently or uses default
446
  with gr.Blocks(
 
 
 
 
 
447
  title="StableCog Dashboard",
448
  css="""
449
  footer {display: none !important;}
 
451
  .tab-nav {background: rgba(255,255,255,0.1) !important; border-radius: 10px !important; padding: 5px !important;}
452
  .stat-box input {font-weight: bold !important; font-size: 18px !important;}
453
  .recommendation-box textarea {font-size: 16px !important; line-height: 1.5 !important;}
454
+ body {
455
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
456
+ min-height: 100vh;
457
+ padding: 20px;
458
+ }
459
+ .gradio-container {
460
+ background: rgba(255, 255, 255, 0.95);
461
+ border-radius: 20px;
462
+ padding: 20px;
463
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
464
+ }
465
  """
466
  ) as demo:
467
  gr.Markdown("""
 
489
  with gr.Column():
490
  credits_display = gr.Number(
491
  label="Remaining Credits",
492
+ interactive=False
 
493
  )
494
  with gr.Column():
495
  usage_display = gr.Number(
496
  label="Usage Percentage",
497
+ interactive=False
 
498
  )
499
 
500
  # Recommendation row
 
502
  recommendation_box = gr.Textbox(
503
  label="🎯 AI Recommendation",
504
  interactive=False,
505
+ lines=3
 
506
  )
507
 
508
  # Control row
509
  with gr.Row():
510
  check_credits_btn = gr.Button(
511
  "🔄 Check Credits",
512
+ variant="primary"
 
513
  )
514
 
515
  with gr.Tab("🤖 Available Models", id="models"):
 
527
  with gr.Row():
528
  check_models_btn = gr.Button(
529
  "🔄 Refresh Models",
530
+ variant="primary"
 
531
  )
532
 
533
  # Instructions and info
 
571
  outputs=[models_html_output, models_raw_output]
572
  )
573
 
 
 
 
 
574
  # Connect buttons
575
  def update_all_credits():
576
  html, raw, credits, usage = update_display()