mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-03-09 02:40:50 +00:00
We have a flag to signal we are shortening the embeddings of a model. Only used in Open AI's text-embedding-3-*, but we plan to use it for other services.
23 lines
635 B
Ruby
23 lines
635 B
Ruby
# frozen_string_literal: true
|
|
class MatryoshkaDimensionsSupport < ActiveRecord::Migration[7.2]
|
|
def change
|
|
add_column :embedding_definitions, :matryoshka_dimensions, :boolean, null: false, default: false
|
|
|
|
execute <<~SQL
|
|
UPDATE embedding_definitions
|
|
SET matryoshka_dimensions = TRUE
|
|
WHERE
|
|
provider = 'open_ai' AND
|
|
provider_params IS NOT NULL AND
|
|
(
|
|
(provider_params->>'model_name') = 'text-embedding-3-large' OR
|
|
(provider_params->>'model_name') = 'text-embedding-3-small'
|
|
)
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
raise ActiveRecord::IrreversibleMigration
|
|
end
|
|
end
|