mirror of
				https://github.com/discourse/discourse-ai.git
				synced 2025-10-31 14:38:37 +00:00 
			
		
		
		
	* FEATURE: HyDE-powered semantic search. It relies on the new outlet added on discourse/discourse#23390 to display semantic search results in an unobtrusive way. We'll use a HyDE-backed approach for semantic search, which consists on generating an hypothetical document from a given keywords, which gets transformed into a vector and used in a asymmetric similarity topic search. This PR also reorganizes the internals to have less moving parts, maintaining one hierarchy of DAOish classes for vector-related operations like transformations and querying. Completions and vectors created by HyDE will remain cached on Redis for now, but we could later use Postgres instead. * Missing translation and rate limiting --------- Co-authored-by: Roman Rizzi <rizziromanalejandro@gmail.com>
		
			
				
	
	
		
			32 lines
		
	
	
		
			846 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			846 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| # frozen_string_literal: true
 | |
| 
 | |
| require "rails_helper"
 | |
| 
 | |
| describe DiscourseAi::Embeddings::EntryPoint do
 | |
|   fab!(:user) { Fabricate(:user) }
 | |
| 
 | |
|   describe "registering event callbacks" do
 | |
|     context "when creating a topic" do
 | |
|       let(:creator) do
 | |
|         PostCreator.new(
 | |
|           user,
 | |
|           raw: "this is the new content for my topic",
 | |
|           title: "this is my new topic title",
 | |
|         )
 | |
|       end
 | |
| 
 | |
|       it "queues a job on create if embeddings is enabled" do
 | |
|         SiteSetting.ai_embeddings_enabled = true
 | |
| 
 | |
|         expect { creator.create }.to change(Jobs::GenerateEmbeddings.jobs, :size).by(1)
 | |
|       end
 | |
| 
 | |
|       it "does nothing if sentiment analysis is disabled" do
 | |
|         SiteSetting.ai_embeddings_enabled = false
 | |
| 
 | |
|         expect { creator.create }.not_to change(Jobs::GenerateEmbeddings.jobs, :size)
 | |
|       end
 | |
|     end
 | |
|   end
 | |
| end
 |