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:
@@ -1,6 +1,6 @@
|
||||
require 'openai'
|
||||
|
||||
class Captain::Llm::AssistantChatService < Captain::Llm::BaseOpenAiService
|
||||
class Captain::Llm::AssistantChatService < Llm::BaseOpenAiService
|
||||
include Captain::ChatHelper
|
||||
|
||||
def initialize(assistant: nil)
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
class Captain::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
|
||||
@@ -1,4 +1,4 @@
|
||||
class Captain::Llm::ContactAttributesService < Captain::Llm::BaseOpenAiService
|
||||
class Captain::Llm::ContactAttributesService < Llm::BaseOpenAiService
|
||||
def initialize(assistant, conversation)
|
||||
super()
|
||||
@assistant = assistant
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Captain::Llm::ContactNotesService < Captain::Llm::BaseOpenAiService
|
||||
class Captain::Llm::ContactNotesService < Llm::BaseOpenAiService
|
||||
def initialize(assistant, conversation)
|
||||
super()
|
||||
@assistant = assistant
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Captain::Llm::ConversationFaqService < Captain::Llm::BaseOpenAiService
|
||||
class Captain::Llm::ConversationFaqService < Llm::BaseOpenAiService
|
||||
DISTANCE_THRESHOLD = 0.3
|
||||
|
||||
def initialize(assistant, conversation)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'openai'
|
||||
|
||||
class Captain::Llm::EmbeddingService < Captain::Llm::BaseOpenAiService
|
||||
class Captain::Llm::EmbeddingService < Llm::BaseOpenAiService
|
||||
class EmbeddingsError < StandardError; end
|
||||
|
||||
DEFAULT_MODEL = 'text-embedding-3-small'.freeze
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Captain::Llm::FaqGeneratorService < Captain::Llm::BaseOpenAiService
|
||||
class Captain::Llm::FaqGeneratorService < Llm::BaseOpenAiService
|
||||
def initialize(content)
|
||||
super()
|
||||
@content = content
|
||||
|
||||
Reference in New Issue
Block a user