mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
27 lines
698 B
Python
27 lines
698 B
Python
|
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
|