refactor: move the embedding to the rag module and abstract the rerank runner for extension (#9423)
This commit is contained in:
parent
e7aecb89dd
commit
b90ad587c2
61 changed files with 135 additions and 78 deletions
23
api/core/rag/embedding/embedding_base.py
Normal file
23
api/core/rag/embedding/embedding_base.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def embed_query(self, text: str) -> list[float]:
|
||||
"""Embed query text."""
|
||||
raise NotImplementedError
|
||||
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue