Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def creds_for(provider)

# 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?
Expand Down
7 changes: 3 additions & 4 deletions lib/embeddings/semantic_related.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -26,11 +24,12 @@ def related_topic_ids_for(topic)
# 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),
Expand Down
Loading