Jae-Won Chung commited on
Commit
9f1c84b
1 Parent(s): 968b189

Show raw energy numbers, too

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -378,11 +378,8 @@ def consumed_less_energy_message(energy_a, energy_b):
378
  less_energy = min(energy_a, energy_b)
379
  more_energy = max(energy_a, energy_b)
380
  factor = less_energy / more_energy
381
- if factor <= 0.5:
382
- message = f"<h2>That response also <span class='green-text'>consumed {1/factor:.1f}X less energy</span>!</h2>"
383
- else:
384
- message = f"<h2>That response also <span class='green-text'>consumed {100 - factor * 100:.1f}% less energy</span>!</h2>"
385
- return message
386
 
387
  def consumed_more_energy_message(energy_a, energy_b):
388
  """Return a message that indicates that the user chose the model that consumed more energy.
@@ -392,11 +389,8 @@ def consumed_more_energy_message(energy_a, energy_b):
392
  less_energy = min(energy_a, energy_b)
393
  more_energy = max(energy_a, energy_b)
394
  factor = more_energy / less_energy
395
- if factor >= 2.0:
396
- message = f"<h2>That response <span class='red-text'>consumed {factor:.1f}x more energy</span>.</h2>"
397
- else:
398
- message = f"<h2>That response <span class='red-text'>consumed {factor * 100 - 100:.1f}% more energy</span>.</h2>"
399
- return message
400
 
401
  # Colosseum event handlers
402
  def add_prompt_disable_submit(prompt, history_a, history_b):
 
378
  less_energy = min(energy_a, energy_b)
379
  more_energy = max(energy_a, energy_b)
380
  factor = less_energy / more_energy
381
+ how_much = f"{1 / factor:.1f}x" if factor <= 0.5 else f"{100 - factor * 100:.1f}%"
382
+ return f"<h2>That response also <span class='green-text'>consumed {how_much} less energy</span> ({energy_a:,.0f} J vs. {energy_b:,.0f} J)!</h2>"
 
 
 
383
 
384
  def consumed_more_energy_message(energy_a, energy_b):
385
  """Return a message that indicates that the user chose the model that consumed more energy.
 
389
  less_energy = min(energy_a, energy_b)
390
  more_energy = max(energy_a, energy_b)
391
  factor = more_energy / less_energy
392
+ how_much = f"{factor:.1f}x" if factor >= 2.0 else f"{factor * 100 - 100:.1f}%"
393
+ return f"<h2>That response <span class='red-text'>consumed {how_much} more energy</span> ({energy_a:,.0f} J vs. {energy_b:,.0f} J).</h2>"
 
 
 
394
 
395
  # Colosseum event handlers
396
  def add_prompt_disable_submit(prompt, history_a, history_b):