| 
									
										
										
										
											2023-05-23 23:08:17 +10:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | RSpec.describe DiscourseAi::AiBot::AnthropicBot do | 
					
						
							|  |  |  |   describe "#update_with_delta" do | 
					
						
							|  |  |  |     def bot_user | 
					
						
							|  |  |  |       User.find(DiscourseAi::AiBot::EntryPoint::GPT4_ID) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     subject { described_class.new(bot_user) } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     describe "get_delta" do | 
					
						
							|  |  |  |       it "can properly remove Assistant prefix" do | 
					
						
							|  |  |  |         context = {} | 
					
						
							|  |  |  |         reply = +"" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-20 08:45:31 +10:00
										 |  |  |         reply << subject.get_delta({ completion: "Hello " }, context) | 
					
						
							|  |  |  |         expect(reply).to eq("Hello ") | 
					
						
							| 
									
										
										
										
											2023-05-23 23:08:17 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-20 08:45:31 +10:00
										 |  |  |         reply << subject.get_delta({ completion: "Hello world" }, context) | 
					
						
							|  |  |  |         expect(reply).to eq("Hello world") | 
					
						
							| 
									
										
										
										
											2023-05-23 23:08:17 +10:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |