mirror of
				https://github.com/discourse/discourse-ai.git
				synced 2025-10-31 14:38:37 +00:00 
			
		
		
		
	* FIX: guide GPT 3.5 better This limits search results to 10 cause we were blowing the whole token budget on search results, additionally it includes a quick exchange at the start of a session to try and guide GPT 3.5 to follow instructions Sadly GPT 3.5 drifts off very quickly but this does improve stuff a bit. It also attempts to correct some issues with anthropic, though it still is surprisingly hard to ground * add status:public, this is a bit of a hack but ensures that we can search for any filter provided * fix specs
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| #frozen_string_literal: true
 | |
| 
 | |
| require_relative "../../../../support/openai_completions_inference_stubs"
 | |
| 
 | |
| RSpec.describe DiscourseAi::AiBot::Commands::SearchCommand do
 | |
|   fab!(:bot_user) { User.find(DiscourseAi::AiBot::EntryPoint::GPT3_5_TURBO_ID) }
 | |
| 
 | |
|   before { SearchIndexer.enable }
 | |
|   after { SearchIndexer.disable }
 | |
| 
 | |
|   describe "#process" do
 | |
|     it "can handle no results" do
 | |
|       post1 = Fabricate(:post)
 | |
|       search = described_class.new(bot_user, post1)
 | |
| 
 | |
|       results = search.process("order:fake ABDDCDCEDGDG")
 | |
|       expect(results).to eq("No results found")
 | |
|     end
 | |
| 
 | |
|     it "can handle limits" do
 | |
|       post1 = Fabricate(:post)
 | |
|       _post2 = Fabricate(:post, user: post1.user)
 | |
|       _post3 = Fabricate(:post, user: post1.user)
 | |
| 
 | |
|       # search has no built in support for limit: so handle it from the outside
 | |
|       search = described_class.new(bot_user, post1)
 | |
| 
 | |
|       results = search.process("@#{post1.user.username} limit:2")
 | |
| 
 | |
|       # title + 2 rows
 | |
|       expect(results.split("\n").length).to eq(3)
 | |
| 
 | |
|       # just searching for everything
 | |
|       results = search.process("order:latest_topic")
 | |
|       expect(results.split("\n").length).to be > 1
 | |
|     end
 | |
|   end
 | |
| end
 |