mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-02 14:45:17 +02:00
lazy import colbert
This commit is contained in:
parent
676d5ff55b
commit
b355f715bd
1 changed files with 7 additions and 4 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import contextlib
|
||||
|
||||
import pytest
|
||||
from llama_index.core.llms import MockLLM
|
||||
from llama_index.core.postprocessor import LLMRerank
|
||||
|
|
@ -41,12 +43,13 @@ class TestRankerFactory:
|
|||
assert isinstance(ranker, LLMRerank)
|
||||
|
||||
def test_create_colbert_ranker(self, mocker, mock_llm):
|
||||
mocker.patch("metagpt.rag.factories.ranker.ColbertRerank", return_value="colbert")
|
||||
with contextlib.suppress(ImportError):
|
||||
mocker.patch("llama_index.postprocessor.colbert_rerank.ColbertRerank", return_value="colbert")
|
||||
|
||||
mock_config = ColbertRerankConfig(llm=mock_llm)
|
||||
ranker = self.ranker_factory._create_colbert_ranker(mock_config)
|
||||
mock_config = ColbertRerankConfig(llm=mock_llm)
|
||||
ranker = self.ranker_factory._create_colbert_ranker(mock_config)
|
||||
|
||||
assert ranker == "colbert"
|
||||
assert ranker == "colbert"
|
||||
|
||||
def test_create_object_ranker(self, mocker, mock_llm):
|
||||
mocker.patch("metagpt.rag.factories.ranker.ObjectSortPostprocessor", return_value="object")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue