feat: Add support for account abuse detection (#11001)
This PR adds service to automate account abuse detection. Currently based on the signup name and URL, could potentially add more context such as usage analysis, message metadata etc.
This commit is contained in:
20
enterprise/app/services/llm/base_open_ai_service.rb
Normal file
20
enterprise/app/services/llm/base_open_ai_service.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class Llm::BaseOpenAiService
|
||||
DEFAULT_MODEL = 'gpt-4o-mini'.freeze
|
||||
|
||||
def initialize
|
||||
@client = OpenAI::Client.new(
|
||||
access_token: InstallationConfig.find_by!(name: 'CAPTAIN_OPEN_AI_API_KEY').value,
|
||||
log_errors: Rails.env.development?
|
||||
)
|
||||
setup_model
|
||||
rescue StandardError => e
|
||||
raise "Failed to initialize OpenAI client: #{e.message}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def setup_model
|
||||
config_value = InstallationConfig.find_by(name: 'CAPTAIN_OPEN_AI_MODEL')&.value
|
||||
@model = (config_value.presence || DEFAULT_MODEL)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user