feat: Use embeddings in help center search (#9227)

This commit is contained in:
Sojan Jose
2024-04-15 16:35:23 -07:00
committed by GitHub
parent ade658ad86
commit 42a457ff5d
12 changed files with 190 additions and 12 deletions

View File

@@ -0,0 +1,23 @@
# == Schema Information
#
# Table name: article_embeddings
#
# id :bigint not null, primary key
# embedding :vector(1536)
# term :text not null
# created_at :datetime not null
# updated_at :datetime not null
# article_id :bigint not null
#
class ArticleEmbedding < ApplicationRecord
belongs_to :article
has_neighbors :embedding, normalize: true
before_save :update_response_embedding
private
def update_response_embedding
self.embedding = Openai::EmbeddingsService.new.get_embedding(term, 'text-embedding-3-small')
end
end