feat: adiciona formatos e metadados ao RAG
This commit is contained in:
parent
e7850f0416
commit
c2c2fc716c
10 changed files with 400 additions and 21 deletions
43
tests/test_rag_source_metadata.py
Normal file
43
tests/test_rag_source_metadata.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(REPO_ROOT / "rag-api"))
|
||||
|
||||
from source_metadata import source_reference
|
||||
|
||||
|
||||
class SourceMetadataTests(unittest.TestCase):
|
||||
def test_reference_preserves_available_location_metadata(self):
|
||||
reference = source_reference(
|
||||
{
|
||||
"source": "manual.pdf",
|
||||
"file_type": "pdf",
|
||||
"page": 3,
|
||||
"section": "Cadastro",
|
||||
"document_id": "doc-1",
|
||||
"chunk_index": 2,
|
||||
},
|
||||
0.87654321,
|
||||
)
|
||||
|
||||
self.assertEqual(reference, {
|
||||
"source": "manual.pdf",
|
||||
"score": 0.876543,
|
||||
"file_type": "pdf",
|
||||
"section": "Cadastro",
|
||||
"page": 3,
|
||||
"document_id": "doc-1",
|
||||
"chunk_index": 2,
|
||||
})
|
||||
|
||||
def test_missing_metadata_is_not_fabricated(self):
|
||||
self.assertEqual(
|
||||
source_reference({"path": "readme.md"}, None),
|
||||
{"source": "readme.md", "score": 0.0},
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue