-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
...onal_mnemonic_medium/v2/domain/prompt_source/document_ingesters/fake_document_ingester.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from collections.abc import Sequence | ||
|
||
from ..document_ingesters.document import Document | ||
from .base_document_ingester import BaseDocumentIngester | ||
|
||
|
||
class FakeDocumentIngester(BaseDocumentIngester): | ||
def __init__(self, documents: Sequence[Document]): | ||
self.documents = documents | ||
|
||
def get_documents(self) -> Sequence[Document]: | ||
return self.documents |
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
File renamed without changes.
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
29 changes: 29 additions & 0 deletions
29
personal_mnemonic_medium/v2/domain/prompt_source/test_document_prompt_source.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from pathlib import Path | ||
|
||
from .document_ingesters.document import Document | ||
from .document_ingesters.fake_document_ingester import ( | ||
FakeDocumentIngester, | ||
) | ||
from .document_prompt_source import DocumentPromptSource | ||
from .prompt_extractors.qa_prompt_extractor import QAPromptExtractor | ||
|
||
|
||
def test_document_prompt_source(): | ||
source = DocumentPromptSource( | ||
document_ingester=FakeDocumentIngester( | ||
[ | ||
Document( | ||
"""Q. What is a test even? | ||
A. Nothing""", | ||
Path("test.md"), | ||
) | ||
] | ||
), | ||
prompt_extractors=[ | ||
QAPromptExtractor( | ||
question_prefix="Q.", answer_prefix="A." | ||
) | ||
], | ||
) | ||
prompts = source.get_prompts() | ||
assert len(prompts) == 1 |