mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-15 19:18:30 +00:00
First take on a rag tool
This commit is contained in:
21
tests/rag_tool_test.py
Normal file
21
tests/rag_tool_test.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from crewai_tools.rag_tool import Adapter, RagTool
|
||||
|
||||
|
||||
class MockAdapter(Adapter):
|
||||
answer: str
|
||||
|
||||
def query(self, question: str) -> str:
|
||||
return self.answer
|
||||
|
||||
|
||||
def test_rag_tool():
|
||||
adapter = MockAdapter(answer="42")
|
||||
rag_tool = RagTool(adapter=adapter)
|
||||
|
||||
assert rag_tool.name == "Knowledge base"
|
||||
assert (
|
||||
rag_tool.description == "A knowledge base that can be used to answer questions."
|
||||
)
|
||||
assert (
|
||||
rag_tool.run("What is the answer to life, the universe and everything?") == "42"
|
||||
)
|
||||
Reference in New Issue
Block a user