Download api/core/rag/rerank/rerank_base.py from ZHZ1024/dify: direct link, hf CLI and curl.
- Browser
- Download file 698 Bytes
-
https://huggingface.co/spaces/ZHZ1024/dify/resolve/main/api/core/rag/rerank/rerank_base.py
- Command line
-
hf download hf://spaces/ZHZ1024/dify/api/core/rag/rerank/rerank_base.py
-
curl -L -o rerank_base.py https://huggingface.co/spaces/ZHZ1024/dify/resolve/main/api/core/rag/rerank/rerank_base.py
698 Bytes
| from abc import ABC, abstractmethod | |
| from typing import Optional | |
| from core.rag.models.document import Document | |
| class BaseRerankRunner(ABC): | |
| 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 | |