FIX: Use correct variable and method for embeddings (#35)
This commit is contained in:
parent
4e05763a99
commit
7a54455cf6
|
@ -1,6 +1,5 @@
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import { translateResults, updateRecentSearches } from "discourse/lib/search";
|
import { translateResults, updateRecentSearches } from "discourse/lib/search";
|
||||||
import { setTransient } from "discourse/lib/page-tracker";
|
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
|
||||||
const SEMANTIC_SEARCH = "semantic_search";
|
const SEMANTIC_SEARCH = "semantic_search";
|
||||||
|
@ -9,7 +8,7 @@ function initializeSemanticSearch(api) {
|
||||||
api.addFullPageSearchType(
|
api.addFullPageSearchType(
|
||||||
"discourse_ai.embeddings.semantic_search",
|
"discourse_ai.embeddings.semantic_search",
|
||||||
SEMANTIC_SEARCH,
|
SEMANTIC_SEARCH,
|
||||||
(searchController, args, searchKey) => {
|
(searchController, args) => {
|
||||||
if (searchController.currentUser) {
|
if (searchController.currentUser) {
|
||||||
updateRecentSearches(searchController.currentUser, args.searchTerm);
|
updateRecentSearches(searchController.currentUser, args.searchTerm);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +31,6 @@ function initializeSemanticSearch(api) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setTransient("lastSearch", { searchKey, model }, 5);
|
|
||||||
model.grouped_search_result = results.grouped_search_result;
|
model.grouped_search_result = results.grouped_search_result;
|
||||||
searchController.set("model", model);
|
searchController.set("model", model);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ module Jobs
|
||||||
|
|
||||||
topic = Topic.find_by_id(topic_id)
|
topic = Topic.find_by_id(topic_id)
|
||||||
return if topic.nil? || topic.private_message? && !SiteSetting.ai_embeddings_generate_for_pms
|
return if topic.nil? || topic.private_message? && !SiteSetting.ai_embeddings_generate_for_pms
|
||||||
post = Topic.find_by_id(topic_id).first_post
|
post = topic.first_post
|
||||||
return if post.nil? || post.raw.blank?
|
return if post.nil? || post.raw.blank?
|
||||||
|
|
||||||
DiscourseAi::Embeddings::Topic.new(post.topic).perform!
|
DiscourseAi::Embeddings::Topic.new.generate_and_store_embeddings_for(topic)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,7 +46,7 @@ module DiscourseAi
|
||||||
end
|
end
|
||||||
|
|
||||||
def asymmetric_semantic_search(model, query, limit, offset)
|
def asymmetric_semantic_search(model, query, limit, offset)
|
||||||
query_embedding = model.generate_embedding(query)
|
embedding = model.generate_embedding(query)
|
||||||
|
|
||||||
candidate_ids =
|
candidate_ids =
|
||||||
DiscourseAi::Database::Connection
|
DiscourseAi::Database::Connection
|
||||||
|
|
Loading…
Reference in New Issue