2023-07-19 18:19:38 -04:00
|
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "discourse-ai-related-topics",
|
|
|
|
|
|
|
|
initialize(container) {
|
|
|
|
const settings = container.lookup("service:site-settings");
|
|
|
|
|
2024-02-05 09:45:24 -05:00
|
|
|
if (
|
|
|
|
settings.ai_embeddings_enabled &&
|
|
|
|
settings.ai_embeddings_semantic_related_topics_enabled
|
|
|
|
) {
|
2023-07-19 18:19:38 -04:00
|
|
|
withPluginApi("1.1.0", (api) => {
|
|
|
|
api.modifyClass("model:post-stream", {
|
|
|
|
pluginId: "discourse-ai",
|
|
|
|
|
|
|
|
_setSuggestedTopics(result) {
|
|
|
|
this._super(...arguments);
|
|
|
|
|
|
|
|
if (!result.related_topics) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.topic.setProperties({
|
|
|
|
related_topics: result.related_topics,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|