2023-09-05 10:08:23 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DiscourseAi
|
|
|
|
module Embeddings
|
|
|
|
module VectorRepresentations
|
|
|
|
class AllMpnetBaseV2 < Base
|
2024-02-01 14:54:09 -05:00
|
|
|
class << self
|
|
|
|
def name
|
|
|
|
"all-mpnet-base-v2"
|
|
|
|
end
|
|
|
|
|
|
|
|
def correctly_configured?
|
|
|
|
SiteSetting.ai_embeddings_discourse_service_api_endpoint_srv.present? ||
|
|
|
|
SiteSetting.ai_embeddings_discourse_service_api_endpoint.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def dependant_setting_names
|
|
|
|
%w[
|
|
|
|
ai_embeddings_discourse_service_api_key
|
|
|
|
ai_embeddings_discourse_service_api_endpoint_srv
|
|
|
|
ai_embeddings_discourse_service_api_endpoint
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-03-08 11:02:50 -05:00
|
|
|
def vector_from(text, asymetric: false)
|
2023-09-05 10:08:23 -04:00
|
|
|
DiscourseAi::Inference::DiscourseClassifier.perform!(
|
2024-01-10 17:23:07 -05:00
|
|
|
"#{discourse_embeddings_endpoint}/api/v1/classify",
|
2024-02-01 14:54:09 -05:00
|
|
|
self.class.name,
|
2023-09-05 10:08:23 -04:00
|
|
|
text,
|
|
|
|
SiteSetting.ai_embeddings_discourse_service_api_key,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def dimensions
|
|
|
|
768
|
|
|
|
end
|
|
|
|
|
|
|
|
def max_sequence_length
|
|
|
|
384
|
|
|
|
end
|
|
|
|
|
|
|
|
def id
|
|
|
|
1
|
|
|
|
end
|
|
|
|
|
|
|
|
def version
|
|
|
|
1
|
|
|
|
end
|
|
|
|
|
|
|
|
def pg_function
|
|
|
|
"<#>"
|
|
|
|
end
|
|
|
|
|
|
|
|
def pg_index_type
|
|
|
|
"vector_ip_ops"
|
|
|
|
end
|
|
|
|
|
|
|
|
def tokenizer
|
|
|
|
DiscourseAi::Tokenizer::AllMpnetBaseV2Tokenizer
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|