Skip to content

Commit

Permalink
update llama_index
Browse files Browse the repository at this point in the history
  • Loading branch information
qingzhong1 committed Jan 24, 2024
1 parent eec2578 commit 69ed7cd
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import pytest
from llama_index import Document
from llama_index.schema import NodeWithScore, TextNode

from erniebot_agent.tools.llama_index_retrieval_tool import LlamaIndexRetrievalTool


class FakeRetrieval:
def retrieve(self, query: str):
doc = NodeWithScore(node=TextNode(text="电动汽车的品牌有哪些?各有什么特点?"), score=0.5)
retrieval_results = [doc]
return retrieval_results


class FakeSearch:
def as_retriever(self, similarity_top_k: int = 10, **kwargs):
def retrieve(query: str):
doc = (Document(text="电动汽车的品牌有哪些?各有什么特点?"), 0.5)
retrieval_results = [doc]
return retrieval_results

return retrieve
return FakeRetrieval()


@pytest.fixture(scope="module")
Expand Down

0 comments on commit 69ed7cd

Please sign in to comment.