-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(document-search): Implement document search public interface (#58)
- Loading branch information
1 parent
704eef2
commit abbcdb0
Showing
9 changed files
with
566 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/ragbits-document-search/tests/integration/test_file.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Ragbits | ||
|
||
Repository for internal experiment with our upcoming LLM framework. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 22 additions & 8 deletions
30
packages/ragbits-document-search/tests/unit/test_document_processor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
import pytest | ||
|
||
from ragbits.document_search.documents.document import DocumentMeta, DocumentType | ||
from ragbits.document_search.ingestion.document_processor import DocumentProcessor | ||
from ragbits.document_search.ingestion.document_processor import DocumentProcessorRouter | ||
from ragbits.document_search.ingestion.providers.dummy import DummyProvider | ||
|
||
|
||
async def test_document_processor_processes_text_document_with_dummy_provider(): | ||
providers_config = {DocumentType.TXT: DummyProvider()} | ||
document_processor = DocumentProcessor.from_config(providers_config) | ||
async def test_document_processor_router(): | ||
document_processor_router = DocumentProcessorRouter.from_config({DocumentType.TXT: DummyProvider()}) | ||
|
||
document_meta = DocumentMeta.create_text_document_from_literal("Name of Peppa's brother is George") | ||
|
||
elements = await document_processor.process(document_meta) | ||
document_processor = document_processor_router.get_provider(document_meta) | ||
|
||
assert isinstance(document_processor, DummyProvider) | ||
|
||
|
||
async def test_document_processor_router_raises_when_no_provider_found(): | ||
document_processor_router = DocumentProcessorRouter.from_config() | ||
document_processor_router._providers = {DocumentType.TXT: DummyProvider()} | ||
|
||
document_meta = DocumentMeta.create_text_document_from_literal("Name of Peppa's brother is George") | ||
|
||
document_meta.document_type = DocumentType.PDF | ||
|
||
with pytest.raises(ValueError) as err: | ||
_ = document_processor_router.get_provider(document_meta) | ||
|
||
assert isinstance(document_processor._providers[DocumentType.TXT], DummyProvider) | ||
assert len(elements) == 1 | ||
assert elements[0].content == "Name of Peppa's brother is George" | ||
assert str(err.value) == f"No provider found for the document type {DocumentType.PDF}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.