mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-11 11:56:53 +08:00
refactor: move the embedding to the rag module and abstract the rerank runner for extension (#9423)
This commit is contained in:
26
api/core/rag/rerank/rerank_base.py
Normal file
26
api/core/rag/rerank/rerank_base.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Optional
|
||||
|
||||
from core.rag.models.document import Document
|
||||
|
||||
|
||||
class BaseRerankRunner(ABC):
|
||||
@abstractmethod
|
||||
def run(
|
||||
self,
|
||||
query: str,
|
||||
documents: list[Document],
|
||||
score_threshold: Optional[float] = None,
|
||||
top_n: Optional[int] = None,
|
||||
user: Optional[str] = None,
|
||||
) -> list[Document]:
|
||||
"""
|
||||
Run rerank model
|
||||
:param query: search query
|
||||
:param documents: documents for reranking
|
||||
:param score_threshold: score threshold
|
||||
:param top_n: top n
|
||||
:param user: unique user id if needed
|
||||
:return:
|
||||
"""
|
||||
raise NotImplementedError
|
||||
Reference in New Issue
Block a user