内容纲要
官网主页:https://www.trychroma.com/
官网文档:https://docs.trychroma.com/
https://docs.trychroma.com/getting-started
github主页:https://github.com/chroma-core/
github项目:https://github.com/chroma-core/chroma
引入
使用
创建Chroma对象和数据集
import chromadb
# 读取Chroma Client对象
chroma_client = chromadb.Client()
# 创建Chroma数据集
collection = chroma_client.create_collection(name="my_collection")
collection
Collection(name=my_collection)
添加数据
# 添加数据
collection.add(
documents=["This is an apple", "This is a banana"]
metadatas=[{"source":"my_source"}, {"source": "my_source"}]
ids=["id1", "id2"]
)
collection
查询数据
# 查询数据
results = collection.query(
query_texts=["This is a query document"],
n_results=2
)
results