Spaces:
Build error
Build error
| import chromadb | |
| from sentence_transformers import SentenceTransformer | |
| # Initialize Chroma client | |
| client = chromadb.Client() | |
| # Initialize SentenceTransformer model | |
| model = SentenceTransformer('all-MiniLM-L6-v2') | |
| # Create or load Chroma collection | |
| collection = client.create_collection(name="documents") | |
| # Add documents and their embeddings to Chroma | |
| documents = ['document 1 text', 'document 2 text', 'document 3 text'] | |
| embeddings = model.encode(documents) | |
| # Insert documents into Chroma | |
| collection.add(documents=documents, embeddings=embeddings) |