2023-05-05 20:13:05 +00:00
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
from langchain.document_loaders import WhatsAppChatLoader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_whatsapp_chat_loader() -> None:
|
|
|
|
|
"""Test WhatsAppChatLoader."""
|
|
|
|
|
file_path = Path(__file__).parent.parent / "examples" / "whatsapp_chat.txt"
|
|
|
|
|
loader = WhatsAppChatLoader(str(file_path))
|
|
|
|
|
docs = loader.load()
|
|
|
|
|
|
|
|
|
|
assert len(docs) == 1
|
|
|
|
|
assert docs[0].metadata["source"] == str(file_path)
|
|
|
|
|
assert docs[0].page_content == (
|
|
|
|
|
"James on 05.05.23, 15:48:11: Hi here\n\n"
|
|
|
|
|
"User name on 11/8/21, 9:41:32 AM: Message 123\n\n"
|
|
|
|
|
"User 2 on 1/23/23, 3:19 AM: Bye!\n\n"
|
|
|
|
|
"User 1 on 1/23/23, 3:22_AM: And let me know if anything changes\n\n"
|
2023-05-09 22:00:04 +00:00
|
|
|
|
"~ User name 2 on 1/24/21, 12:41:03 PM: Of course!\n\n"
|
2023-06-22 02:11:49 +00:00
|
|
|
|
"~ User 2 on 2023/5/4, 16:13:23: See you!\n\n"
|
2023-06-25 19:08:43 +00:00
|
|
|
|
"User 1 on 7/19/22, 11:32 PM: Hello\n\n"
|
|
|
|
|
"User 2 on 7/20/22, 11:32 am: Goodbye\n\n"
|
2023-05-05 20:13:05 +00:00
|
|
|
|
)
|