Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 5a97752

Browse files
authored
FIX: Always raise the single exception/Open AI models migration (#1087)
1 parent d5cf53e commit 5a97752

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

db/migrate/20250110114305_embedding_config_data_migration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def creds_for(provider)
9090

9191
# Open AI
9292
elsif provider == "open_ai"
93-
endpoint = fetch_setting("ai_openai_embeddings_url")
93+
endpoint = fetch_setting("ai_openai_embeddings_url") || "https://api.openai.com/v1/embeddings"
9494
api_key = fetch_setting("ai_openai_api_key")
9595

9696
return if endpoint.blank? || api_key.blank?

lib/embeddings/semantic_related.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
module DiscourseAi
44
module Embeddings
55
class SemanticRelated
6-
MissingEmbeddingError = Class.new(StandardError)
7-
86
def self.clear_cache_for(topic)
97
Discourse.cache.delete("semantic-suggested-topic-#{topic.id}")
108
Discourse.redis.del("build-semantic-suggested-topic-#{topic.id}")
@@ -26,11 +24,12 @@ def related_topic_ids_for(topic)
2624
# Happens when the topic doesn't have any embeddings
2725
# I'd rather not use Exceptions to control the flow, so this should be refactored soon
2826
if candidate_ids.empty? || !candidate_ids.include?(topic.id)
29-
raise MissingEmbeddingError, "No embeddings found for topic #{topic.id}"
27+
raise ::DiscourseAi::Embeddings::Schema::MissingEmbeddingError,
28+
"No embeddings found for topic #{topic.id}"
3029
end
3130
end
3231
end
33-
rescue MissingEmbeddingError
32+
rescue ::DiscourseAi::Embeddings::Schema::MissingEmbeddingError
3433
# avoid a flood of jobs when visiting topic
3534
if Discourse.redis.set(
3635
build_semantic_suggested_key(topic.id),

0 commit comments

Comments
 (0)