2023-05-05 14:28:31 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DiscourseAi
|
|
|
|
module AiBot
|
|
|
|
class BotController < ::ApplicationController
|
|
|
|
requires_plugin ::DiscourseAi::PLUGIN_NAME
|
|
|
|
requires_login
|
|
|
|
|
|
|
|
def stop_streaming_response
|
|
|
|
post = Post.find(params[:post_id])
|
|
|
|
guardian.ensure_can_see!(post)
|
|
|
|
|
|
|
|
Discourse.redis.del("gpt_cancel:#{post.id}")
|
|
|
|
|
|
|
|
render json: {}, status: 200
|
|
|
|
end
|
2023-05-16 13:38:21 -04:00
|
|
|
|
|
|
|
def show_bot_username
|
|
|
|
bot_user_id = DiscourseAi::AiBot::EntryPoint.map_bot_model_to_user_id(params[:username])
|
|
|
|
raise Discourse::InvalidParameters.new(:username) if !bot_user_id
|
|
|
|
|
|
|
|
bot_username_lower = User.find(bot_user_id).username_lower
|
|
|
|
|
|
|
|
render json: { bot_username: bot_username_lower }, status: 200
|
|
|
|
end
|
2023-05-05 14:28:31 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|