-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in pinecone utils and add test for docubot build knowledge ba…
…se method.
- Loading branch information
Showing
3 changed files
with
30 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import unittest | ||
from docubot import build_kb | ||
from text_utils.text_utils import tiktoken_len | ||
from langchain.docstore.document import Document | ||
|
||
|
||
class TestDocuBot(unittest.TestCase): | ||
""" | ||
A class for testing the functionality of the DocuBot application. | ||
""" | ||
|
||
def test_build_kb(self): | ||
chunks = build_kb("test_files") | ||
# Test if the function returns a list | ||
self.assertIsInstance(chunks, list) | ||
|
||
# Test if a chunk is a document | ||
self.assertIsInstance(chunks[0], Document) | ||
|
||
# Test if the function returns a list of chunks with at most 512 tokens per chunk | ||
for c in chunks: | ||
self.assertLessEqual(tiktoken_len(c.page_content), 512) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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