| 
									
										
										
										
											2024-02-22 23:31:57 +08:00
										 |  |  | from abc import ABC, abstractmethod | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Embeddings(ABC): | 
					
						
							|  |  |  |     """Interface for embedding models.""" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @abstractmethod | 
					
						
							|  |  |  |     def embed_documents(self, texts: list[str]) -> list[list[float]]: | 
					
						
							|  |  |  |         """Embed search docs.""" | 
					
						
							| 
									
										
										
										
											2024-10-17 19:12:42 +08:00
										 |  |  |         raise NotImplementedError | 
					
						
							| 
									
										
										
										
											2024-02-22 23:31:57 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     @abstractmethod | 
					
						
							|  |  |  |     def embed_query(self, text: str) -> list[float]: | 
					
						
							|  |  |  |         """Embed query text.""" | 
					
						
							| 
									
										
										
										
											2024-10-17 19:12:42 +08:00
										 |  |  |         raise NotImplementedError | 
					
						
							| 
									
										
										
										
											2024-02-22 23:31:57 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     async def aembed_documents(self, texts: list[str]) -> list[list[float]]: | 
					
						
							|  |  |  |         """Asynchronous Embed search docs.""" | 
					
						
							|  |  |  |         raise NotImplementedError | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async def aembed_query(self, text: str) -> list[float]: | 
					
						
							|  |  |  |         """Asynchronous Embed query text.""" | 
					
						
							|  |  |  |         raise NotImplementedError |