| 
					
					
						
							
						
					
					
				 | 
				@ -31,27 +31,31 @@ input: | 
			
		
		
	
		
			
				 | 
				 | 
				{context} | 
				 | 
				 | 
				{context} | 
			
		
		
	
		
			
				 | 
				 | 
				""" | 
				 | 
				 | 
				""" | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				sys_message = """Your name is TowheeChat.""" | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				p = ( | 
				 | 
				 | 
				p = ( | 
			
		
		
	
		
			
				 | 
				 | 
				    pipe.input('question', 'doc', 'history') | 
				 | 
				 | 
				    pipe.input('question', 'doc', 'history') | 
			
		
		
	
		
			
				 | 
				 | 
				    .map('doc', 'doc', lambda x: x[:2000]) | 
				 | 
				 | 
				    .map('doc', 'doc', lambda x: x[:2000]) | 
			
		
		
	
		
			
				 | 
				 | 
				    .map(('question', 'doc', 'history'), 'prompt', ops.prompt.template(temp, ['question', 'context'])) | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    .map(('question', 'doc', 'history'), 'prompt', ops.prompt.template(temp, ['question', 'context'], sys_message)) | 
			
		
		
	
		
			
				 | 
				 | 
				    .map('prompt', 'answer', ops.LLM.OpenAI()) | 
				 | 
				 | 
				    .map('prompt', 'answer', ops.LLM.OpenAI()) | 
			
		
		
	
		
			
				 | 
				 | 
				    .output('answer') | 
				 | 
				 | 
				    .output('answer') | 
			
		
		
	
		
			
				 | 
				 | 
				) | 
				 | 
				 | 
				) | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				an1 = p('Tell me something about Towhee', towhee_docs, []).get()[0] | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				an1 = p('Who are you?', [], []).get()[0] | 
			
		
		
	
		
			
				 | 
				 | 
				print(an1) | 
				 | 
				 | 
				print(an1) | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				an2 = p('How to use it', towhee_docs, [('Tell me something about Towhee', an1)]).get()[0] | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				an2 = p('Tell me something about Towhee', towhee_docs, []).get()[0] | 
			
		
		
	
		
			
				 | 
				 | 
				print(an2) | 
				 | 
				 | 
				print(an2) | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				an3 = p('How to use it', towhee_docs, [('Tell me something about Towhee', an2)]).get()[0] | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				print(an3) | 
			
		
		
	
		
			
				 | 
				 | 
				``` | 
				 | 
				 | 
				``` | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				## Factory Constructor | 
				 | 
				 | 
				## Factory Constructor | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				Create the operator via the following factory method: | 
				 | 
				 | 
				Create the operator via the following factory method: | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				***ops.prompt.template(temp, keys)*** | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				***ops.prompt.template(temp, keys, sys_msg)*** | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				<br /> | 
				 | 
				 | 
				<br /> | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
					
				 | 
				
  |