Skip to content

Commit fe28e1d

Browse files
committed
final touches on basil v2
1 parent 30099a8 commit fe28e1d

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

app/controllers/basil_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,10 @@ def stats
353353

354354
def page_stats
355355
@page_type = params[:page_type]
356+
@version = params[:v] || 2
356357
# TODO verify page_type is valid
357358

358-
@commissions = BasilCommission.where(entity_type: @page_type)
359+
@commissions = BasilCommission.where(entity_type: @page_type).where(basil_version: @version)
359360

360361
# Feedback today
361362
@feedback_today = BasilFeedback.where('updated_at > ?', 24.hours.ago)
@@ -381,6 +382,7 @@ def page_stats
381382
.where(basil_commission_id: @commissions.pluck(:id))
382383
.order(:score_adjustment)
383384
.group(:score_adjustment)
385+
.where(basil_version: @version)
384386
.count
385387
days_since_start = (Date.current - BasilFeedback.minimum(:updated_at).to_date)
386388
days_since_start = 1 if days_since_start.zero? # no dividing by 0 lol

app/jobs/generate_basil_image_job.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
require 'aws-sdk-s3'
77

88
class GenerateBasilImageJob < ApplicationJob
9-
queue_as :default
9+
queue_as :basil
1010

1111
# Define potential errors for rescue
1212
class ApiError < StandardError; end
@@ -18,13 +18,16 @@ def perform(basil_commission_id)
1818
# Skip if already completed (image attached)
1919
return if commission.image.attached?
2020

21+
# Filter out specific words from the prompt that we don't want to include in image generation
22+
sanitized_commmission_prompt = commission.prompt.gsub(/(nudity|nsfw|nude|xxx|porn|pornographic|naked|sex|blowjob|undressed|stripped|stripping|stripper)/i, '')
23+
2124
# Details we can use:
2225
# commission.prompt - the prompt for the image
2326
# commission.style - the style of the image
2427
# commission.entity_type - the type of entity the image is for (e.g. Character, Location, etc)
25-
prompt_to_send = "(#{commission.style} style), #{commission.entity_type}, #{commission.prompt}"
28+
prompt_to_send = "(#{commission.style} style), #{commission.entity_type}, #{sanitized_commmission_prompt}"
2629

27-
# Make the API request to generate the image
30+
# Make the API request to generate the imagex
2831
endpoint_url = ENV.fetch("BASIL_ENDPOINT")
2932
api_url = URI.join(endpoint_url, '/sdapi/v1/txt2img')
3033

app/models/basil_commission.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def submit_to_job_queue!
3434
# )
3535

3636
# Enqueue the background job to generate the image
37-
GenerateBasilImageJob.perform_now(self.id)
37+
GenerateBasilImageJob.perform_later(self.id)
3838
end
3939

4040
def cache_after_complete!

config/sidekiq.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- paypal
44
- analysis
55
- mentions
6+
- basil
67
- default
78
- cache
89
- notifications

0 commit comments

Comments
 (0)