This commit is contained in:
Rafael dos Santos Silva 2023-03-08 17:52:17 -03:00
parent 4b938efa6e
commit 9e4a007a4a
No known key found for this signature in database
GPG Key ID: 5E50360227B34938
1 changed files with 9 additions and 13 deletions

View File

@ -3,9 +3,8 @@
module DiscourseAI module DiscourseAI
module Embeddings module Embeddings
class Topic class Topic
DISCOURSE_MODELS = %i[all-mpnet-base-v2 msmarco-distilbert-base-v4]
DISCOURSE_MODELS = %i{all-mpnet-base-v2 msmarco-distilbert-base-v4} OPENAI_MODELS = %i[text-embedding-ada-002]
OPENAI_MODELS = %i{text-embedding-ada-002}
def initialize(topic) def initialize(topic)
@topic = topic @topic = topic
@ -40,17 +39,15 @@ module DiscourseAI
def discourse_embeddings(model) def discourse_embeddings(model)
DiscourseAI::Inference::DiscourseClassifier.perform!( DiscourseAI::Inference::DiscourseClassifier.perform!(
"#{SiteSetting.ai_embeddings_discourse_service_api_endpoint}/api/v1/classify", "#{SiteSetting.ai_embeddings_discourse_service_api_endpoint}/api/v1/classify",
model.to_s, model.to_s,
@topic.first_post.raw, @topic.first_post.raw,
SiteSetting.ai_embeddings_discourse_service_api_key, SiteSetting.ai_embeddings_discourse_service_api_key,
) )
end end
def openai_embeddings def openai_embeddings
DiscourseAI::Inference::OpenAIEmbeddings.perform!( DiscourseAI::Inference::OpenAIEmbeddings.perform!(@topic.first_post.raw)
@topic.first_post.raw
)
end end
private private
@ -58,7 +55,6 @@ module DiscourseAI
def enabled_models def enabled_models
SiteSetting.ai_embeddings_models.split("|").map(&:to_sym) SiteSetting.ai_embeddings_models.split("|").map(&:to_sym)
end end
end end
end end
end end