Class: SpreeMenuChat::Embedding

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree_menu_chat/embedding.rb

Overview

One row per embedded source record — a Spree::Product (menu item) or a Spree::Policy (hours/delivery-area/allergen content, per the plan's decision to reuse Spree::Policy rather than build a bespoke FAQ model). content is a snapshot of exactly what was embedded, so SpreeMenuChat::Retriever can use it directly as generation context without a second lookup against the live product/policy.

Postgres+pgvector only — see EnablePgvectorExtension's migration comment. On a non-Postgres adapter this table doesn't exist at all, so this model is only ever touched from code paths that already assume Postgres (SpreeMenuChat::EmbeddingClient callers).

Class Method Summary collapse

Class Method Details

.content_hash_for(text) ⇒ Object

True when content no longer matches what's actually embedded — ReembedProductJob checks this before spending a Voyage API call.



26
27
28
# File 'app/models/spree_menu_chat/embedding.rb', line 26

def self.content_hash_for(text)
  Digest::SHA256.hexdigest(text)
end