from dotenv import load_dotenv
from trusttest.catalog import RagFunctionalScenario
from trusttest.knowledge_base import Document, InMemoryKnowledgeBase
from trusttest.targets.testing import DummyTarget
from trusttest.probes.rag import BenignQuestion
load_dotenv(override=True)
documents = [
Document(
id="1",
content="""
Vic is of ancient origin. In past times it was called Ausa by the Romans.
Iberian coins bearing this name have been found there.
The Visigoths called it Ausona.
Sewage caps on sidewalks around the city will also read "Vich", an old spelling of the name.
""",
topic="City origins",
),
Document(
id="2",
content="""
Vic (Catalan pronunciation: [bik]; Spanish: Vic) is the capital of the comarca of Osona,
in the province of Barcelona, Catalonia, Spain.
Vic is located 69 km (43 mi) from Barcelona and 60 km (37 mi) from Girona.
""",
topic="City location",
),
]
knowledge_base = InMemoryKnowledgeBase(documents=documents)
rag_test = RagFunctionalScenario(
target=DummyTarget(),
knowledge_base=knowledge_base,
num_questions=2,
question_types=[BenignQuestion.SIMPLE]
)
test_set = rag_test.probe.get_test_set()
results = rag_test.eval.evaluate(test_set)
results.display()