-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_test.py
More file actions
59 lines (49 loc) · 1.95 KB
/
Copy pathsimple_test.py
File metadata and controls
59 lines (49 loc) · 1.95 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
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
"""
Simple test to create vector store with HuggingFace embeddings only
"""
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_chroma import Chroma
from langchain.schema import Document
def simple_test():
print("Testing simple vector store creation...")
# Test with sample transcript
sample_transcript = """
This is a sample transcript for testing purposes.
It contains multiple sentences to test the chunking functionality.
We want to make sure that the vector store creation works properly.
This should be enough text to create meaningful chunks for testing.
"""
try:
print("Creating chunks...")
text_splitters = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
docs = text_splitters.create_documents([sample_transcript])
print(f"Created {len(docs)} chunks")
print("Creating HuggingFace embeddings...")
from langchain_community.embeddings import HuggingFaceEmbeddings
embedding = HuggingFaceEmbeddings(
model_name="sentence-transformers/all-MiniLM-L6-v2"
)
print("HuggingFace embeddings created successfully")
print("Creating vector store...")
vector_store = Chroma.from_documents(
docs,
embedding
)
print("Vector store created successfully!")
# Test similarity search
print("Testing similarity search...")
results = vector_store.similarity_search("testing", k=2)
print(f"Found {len(results)} similar documents")
return True
except Exception as e:
print(f"ERROR: {e}")
import traceback
traceback.print_exc()
return False
if __name__ == "__main__":
success = simple_test()
if success:
print("✅ Simple vector store test passed!")
else:
print("❌ Simple vector store test failed!")