Spaces:
Running on Zero
Running on Zero
| from config import Settings | |
| from rag_engine import DocumentChunk, RAGEngine | |
| def test_chunking_preserves_text(): | |
| settings = Settings(chunk_size=80, chunk_overlap=10) | |
| engine = RAGEngine(settings) | |
| text = "Alpha sentence. " * 20 | |
| chunks = engine._chunk_text(text) | |
| assert len(chunks) > 1 | |
| assert all(chunk.strip() for chunk in chunks) | |
| def test_minmax_constant_vector(): | |
| values = RAGEngine._minmax([3.0, 3.0, 3.0]) | |
| assert values.tolist() == [0.0, 0.0, 0.0] | |
| def test_retrieval_text_includes_title(): | |
| chunk = DocumentChunk(chunk_id=0, source_id="x", title="Ada Lovelace", text="Mathematics") | |
| assert RAGEngine._retrieval_text(chunk).startswith("Ada Lovelace") | |