Skip to content

Fuzzy citation

FuzzyCitationEnginePack #

Bases: BaseLlamaPack

Source code in llama_index/packs/fuzzy_citation/base.py
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
class FuzzyCitationEnginePack(BaseLlamaPack):
    def __init__(
        self, query_engine: BaseQueryEngine, threshold: int = DEFAULT_THRESHOLD
    ) -> None:
        """初始化参数。"""
        try:
            from thefuzz import fuzz  # noqa: F401
        except ImportError:
            raise ImportError(
                "Please run `pip install thefuzz` to use the fuzzy citation engine."
            )

        self.query_engine = FuzzyCitationQueryEngine(
            query_engine=query_engine, threshold=threshold
        )

    def get_modules(self) -> Dict[str, Any]:
        """获取模块。"""
        return {
            "query_engine": self.query_engine,
            "query_engine_cls": FuzzyCitationQueryEngine,
        }

    def run(self, query_str: str, **kwargs: Any) -> RESPONSE_TYPE:
        """运行流水线。"""
        return self.query_engine.query(query_str)

get_modules #

get_modules() -> Dict[str, Any]

获取模块。

Source code in llama_index/packs/fuzzy_citation/base.py
124
125
126
127
128
129
def get_modules(self) -> Dict[str, Any]:
    """获取模块。"""
    return {
        "query_engine": self.query_engine,
        "query_engine_cls": FuzzyCitationQueryEngine,
    }

run #

run(query_str: str, **kwargs: Any) -> RESPONSE_TYPE

运行流水线。

Source code in llama_index/packs/fuzzy_citation/base.py
131
132
133
def run(self, query_str: str, **kwargs: Any) -> RESPONSE_TYPE:
    """运行流水线。"""
    return self.query_engine.query(query_str)