mirror of
				https://github.com/discourse/discourse-ai.git
				synced 2025-10-31 14:38:37 +00:00 
			
		
		
		
	previously you would have to wait quite a while to see the prompt this implements a very basic implementation of progress so you can see the API is working. Also: - Fix google progress. - Handle the incredibly rare, zero results from google. - Simplify command so it is less error prone - replace invoke and attache results with a invoke - ensure invoke can only ever be run once - pass in all the information a command needs in constructor - use new pattern throughout - test invocation in isolation
		
			
				
	
	
		
			22 lines
		
	
	
		
			748 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			748 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| #frozen_string_literal: true
 | |
| 
 | |
| RSpec.describe DiscourseAi::AiBot::Commands::ReadCommand do
 | |
|   fab!(:bot_user) { User.find(DiscourseAi::AiBot::EntryPoint::GPT3_5_TURBO_ID) }
 | |
| 
 | |
|   describe "#process" do
 | |
|     it "can read a topic" do
 | |
|       post1 = Fabricate(:post, raw: "hello there")
 | |
|       Fabricate(:post, raw: "mister sam", topic: post1.topic)
 | |
| 
 | |
|       read = described_class.new(bot_user: bot_user, args: nil, post: post1)
 | |
| 
 | |
|       results = read.process(topic_id: post1.topic_id)
 | |
| 
 | |
|       expect(results[:topic_id]).to eq(post1.topic_id)
 | |
|       expect(results[:content]).to include("hello")
 | |
|       expect(results[:content]).to include("sam")
 | |
|       expect(read.description_args).to eq(title: post1.topic.title, url: post1.topic.relative_url)
 | |
|     end
 | |
|   end
 | |
| end
 |