From c089997b38cf80e06bd7ace89abb642c31ad0445 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 27 Feb 2023 18:57:10 -0800 Subject: [PATCH] add default field weight multipliers --- app/controllers/basil_controller.rb | 11 +++++++++-- app/views/basil/character.html.erb | 8 +++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/controllers/basil_controller.rb b/app/controllers/basil_controller.rb index 602f5950..56a3298d 100644 --- a/app/controllers/basil_controller.rb +++ b/app/controllers/basil_controller.rb @@ -106,6 +106,12 @@ class BasilController < ApplicationController end end + field_importance_multipliers = { + 'hair color': 1.4, + 'hair style': 1.2, + 'skin tone': 1.3 + } + # Step 3. Do it all again for every other field, too formatted_field_values = appearance_fields.map do |field| value = attributes.detect { |a| a.attribute_field_id == field.id }.try(:value) @@ -123,8 +129,9 @@ class BasilController < ApplicationController value = value.gsub('(', '').gsub(')', '') # Get the importance of this field and add 1 to get back to our SD version - importance = params.dig(:field, field.id.to_s) - importance = importance.to_f if importance.present? + importance = params.dig(:field, field.id.to_s) || 1.0 + importance = importance.to_f * field_importance_multipliers.fetch(field.label.downcase.to_sym, 1.0) + importance = importance.round(2) # If the importance is exactly 1, we can omit the parentheses and save a few tokens, since the # default attention importance is 1. diff --git a/app/views/basil/character.html.erb b/app/views/basil/character.html.erb index 13ce6a88..e97d6d53 100644 --- a/app/views/basil/character.html.erb +++ b/app/views/basil/character.html.erb @@ -11,7 +11,7 @@