diff --git a/db/migrate/20250110114305_embedding_config_data_migration.rb b/db/migrate/20250110114305_embedding_config_data_migration.rb index 98fc3864..acab9a57 100644 --- a/db/migrate/20250110114305_embedding_config_data_migration.rb +++ b/db/migrate/20250110114305_embedding_config_data_migration.rb @@ -90,7 +90,7 @@ class EmbeddingConfigDataMigration < ActiveRecord::Migration[7.0] # Open AI elsif provider == "open_ai" - endpoint = fetch_setting("ai_openai_embeddings_url") + endpoint = fetch_setting("ai_openai_embeddings_url") || "https://api.openai.com/v1/embeddings" api_key = fetch_setting("ai_openai_api_key") return if endpoint.blank? || api_key.blank? diff --git a/lib/embeddings/semantic_related.rb b/lib/embeddings/semantic_related.rb index 54c8e572..76562fa4 100644 --- a/lib/embeddings/semantic_related.rb +++ b/lib/embeddings/semantic_related.rb @@ -3,8 +3,6 @@ module DiscourseAi module Embeddings class SemanticRelated - MissingEmbeddingError = Class.new(StandardError) - def self.clear_cache_for(topic) Discourse.cache.delete("semantic-suggested-topic-#{topic.id}") Discourse.redis.del("build-semantic-suggested-topic-#{topic.id}") @@ -26,11 +24,12 @@ module DiscourseAi # Happens when the topic doesn't have any embeddings # I'd rather not use Exceptions to control the flow, so this should be refactored soon if candidate_ids.empty? || !candidate_ids.include?(topic.id) - raise MissingEmbeddingError, "No embeddings found for topic #{topic.id}" + raise ::DiscourseAi::Embeddings::Schema::MissingEmbeddingError, + "No embeddings found for topic #{topic.id}" end end end - rescue MissingEmbeddingError + rescue ::DiscourseAi::Embeddings::Schema::MissingEmbeddingError # avoid a flood of jobs when visiting topic if Discourse.redis.set( build_semantic_suggested_key(topic.id),