Skip to content

Commit 41f4c54

Browse files
authored
Merge pull request #21 from ewdlop/ewdlop-patch-17
Create chromadb_example.py
2 parents 753d5ae + 915b9e8 commit 41f4c54

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from chromadb import ChromaClient
2+
3+
# Initialize the client
4+
client = ChromaClient()
5+
6+
# Create a collection
7+
collection = client.create_collection(name="example_collection", dimension=128)
8+
9+
# Insert vectors
10+
collection.insert([
11+
{"id": "vector_id_1", "vector": [0.1, 0.2, 0.3, ..., 0.128]},
12+
{"id": "vector_id_2", "vector": [0.2, 0.3, 0.4, ..., 0.129]},
13+
# More vectors
14+
])
15+
16+
# Query the collection
17+
results = collection.query(
18+
query_vector=[0.1, 0.2, 0.3, ..., 0.128],
19+
top_k=5
20+
)
21+
22+
# Print the results
23+
print(results)

0 commit comments

Comments
 (0)