[9d3784]: / aiagents4pharma / talk2knowledgegraphs / tests / test_utils_enrichments_enrichments.py

Download this file

40 lines (33 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Test cases for utils/enrichments/enrichments.py
"""
from ..utils.enrichments.enrichments import Enrichments
class TestEnrichments(Enrichments):
"""Test implementation of the Enrichments interface for testing purposes."""
def enrich_documents(self, texts: list[str]) -> list[list[float]]:
return [
f"Additional text description of {text} as the input." for text in texts
]
def enrich_documents_with_rag(self, texts, docs):
# Currently we don't have a RAG model to test this method.
# Thus, we will just call the enrich_documents method instead.
return self.enrich_documents(texts)
def test_enrich_documents():
"""Test enriching documents using the Enrichments interface."""
enrichments = TestEnrichments()
texts = ["text1", "text2"]
result = enrichments.enrich_documents(texts)
assert result == [
"Additional text description of text1 as the input.",
"Additional text description of text2 as the input.",
]
def test_enrich_documents_with_rag():
"""Test enriching documents with RAG using the Enrichments interface."""
enrichments = TestEnrichments()
texts = ["text1", "text2"]
docs = ["doc1", "doc2"]
result = enrichments.enrich_documents_with_rag(texts, docs)
assert result == [
"Additional text description of text1 as the input.",
"Additional text description of text2 as the input.",
]