-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_processing.py
More file actions
46 lines (36 loc) · 1.3 KB
/
test_processing.py
File metadata and controls
46 lines (36 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import sys
from ingest import load_and_chunk
from langchain_core.documents import Document
def test_ingest():
print("--- Testing Document Processing ---")
file_path = "test_doc_a.pdf"
if not os.path.exists(file_path):
print(f"❌ Test file not found: {file_path}")
# Create a dummy PDF if needed or just fail
return False
try:
print(f"Processing {file_path}...")
chunks = load_and_chunk(file_path, "doc_a")
if not chunks:
print("❌ No chunks generated")
return False
print(f"✅ Generated {len(chunks)} chunks")
print(f" First chunk content preview: {chunks[0].page_content[:100]}...")
# Verify metadata
if chunks[0].metadata.get("doc_source") == "doc_a":
print("✅ Metadata verified")
else:
print("❌ Metadata incorrect")
return False
return True
except Exception as e:
print(f"❌ Processing failed: {e}")
return False
if __name__ == "__main__":
if test_ingest():
print("\n✅ Document Processing Verification Successful")
sys.exit(0)
else:
print("\n❌ Document Processing Verification Failed")
sys.exit(1)