mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-07-10 08:03:28 +00:00
This change moves all the personas code into its own module. We want to treat them as a building block features can built on top of, same as `Completions::Llm`. The code to title a message was moved from `Bot` to `Playground`.
29 lines
770 B
Ruby
29 lines
770 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ::Jobs
|
|
class CreateAiChatReply < ::Jobs::Base
|
|
sidekiq_options retry: false
|
|
|
|
def execute(args)
|
|
channel = ::Chat::Channel.find_by(id: args[:channel_id])
|
|
return if channel.blank?
|
|
|
|
message = ::Chat::Message.find_by(id: args[:message_id])
|
|
return if message.blank?
|
|
|
|
personaClass =
|
|
DiscourseAi::Personas::Persona.find_by(id: args[:persona_id], user: message.user)
|
|
return if personaClass.blank?
|
|
|
|
user = User.find_by(id: personaClass.user_id)
|
|
bot = DiscourseAi::Personas::Bot.as(user, persona: personaClass.new)
|
|
|
|
DiscourseAi::AiBot::Playground.new(bot).reply_to_chat_message(
|
|
message,
|
|
channel,
|
|
args[:context_post_ids],
|
|
)
|
|
end
|
|
end
|
|
end
|