mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-08-03 03:43:26 +00:00
Previous to this change we reused channels for proofreading progress and ai helper progress The new changeset ensures each POST to stream progress gets a dedicated message bus channel This fixes a class of issues where the wrong information could be displayed to end users on subsequent proofreading or helper calls * fix tests * fix implementation (got to subscribe at 0)
28 lines
700 B
Ruby
28 lines
700 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class StreamComposerHelper < ::Jobs::Base
|
|
sidekiq_options retry: false
|
|
|
|
def execute(args)
|
|
return unless args[:prompt]
|
|
return unless user = User.find_by(id: args[:user_id])
|
|
return unless args[:text]
|
|
return unless args[:client_id]
|
|
return unless args[:progress_channel]
|
|
|
|
helper_mode = args[:prompt]
|
|
|
|
DiscourseAi::AiHelper::Assistant.new.stream_prompt(
|
|
helper_mode,
|
|
args[:text],
|
|
user,
|
|
args[:progress_channel],
|
|
force_default_locale: args[:force_default_locale],
|
|
client_id: args[:client_id],
|
|
custom_prompt: args[:custom_prompt],
|
|
)
|
|
end
|
|
end
|
|
end
|