| 
					
					
						
							
						
					
					
				 | 
				@ -3,10 +3,7 @@ from typing import List, Tuple, Dict, Optional | 
			
		
		
	
		
			
				 | 
				 | 
				from towhee.operator import PyOperator | 
				 | 
				 | 
				from towhee.operator import PyOperator | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				class QAPrompt(PyOperator): | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				    def __init__(self): | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				        super().__init__() | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				        self._template = """Use the following pieces of context to answer the question at the end. | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				gpt_prompt =  """Use the following pieces of context to answer the question at the end. | 
			
		
		
	
		
			
				 | 
				 | 
				If you don't know the answer, just say that you don't know, don't try to make up an answer. | 
				 | 
				 | 
				If you don't know the answer, just say that you don't know, don't try to make up an answer. | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				{context} | 
				 | 
				 | 
				{context} | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -16,6 +13,24 @@ Question: {question} | 
			
		
		
	
		
			
				 | 
				 | 
				Helpful Answer: | 
				 | 
				 | 
				Helpful Answer: | 
			
		
		
	
		
			
				 | 
				 | 
				""" | 
				 | 
				 | 
				""" | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				dolly_prompt = """{question} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				Input: | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				{context} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				""" | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				class QAPrompt(PyOperator): | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    def __init__(self, temp: str = None, llm_name: str = None): | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        super().__init__() | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        if temp: | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				            self._template = temp | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        else: | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				            if llm_name.lower() == 'dolly': | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				                self._template = dolly_prompt | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				            else: | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				                self._template = gpt_prompt | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				    def __call__(self, question: str, docs: List[str], history=Optional[List[Tuple]]) -> List[Dict[str, str]]: | 
				 | 
				 | 
				    def __call__(self, question: str, docs: List[str], history=Optional[List[Tuple]]) -> List[Dict[str, str]]: | 
			
		
		
	
		
			
				 | 
				 | 
				        """ | 
				 | 
				 | 
				        """ | 
			
		
		
	
		
			
				 | 
				 | 
				        history: | 
				 | 
				 | 
				        history: | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
					
				 | 
				
  |