pip install chromadb

 Downloading chromadb-0.4.24-py3-none-any.whl (525 kB)

可以看到我装的是0.4.24版本的


 https://python.langchain.com/docs/integrations/vectorstores/chroma 

参考的是LangChain的文档

 https://docs.trychroma.com/getting-started 

看了一下还是从官方的chroma的文档开始把

import chromadb
# 拿一个client出来
chroma_client = chromadb.Client()
# 等于是新建了一个数据库
collection = chroma_client.create_collection(name="my_collection")
#新增
collection.add(
    documents=["This is a document", "This is another document"],
    metadatas=[{"source": "my_source"}, {"source": "my_source"}],
    ids=["id1", "id2"]
)

然后马上就报错了


 https://docs.trychroma.com/troubleshooting#sqlite 

 https://zhuanlan.zhihu.com/p/636675047 

 https://zhuanlan.zhihu.com/p/637791135 


我自己引用自己

原来如此

升级到了Debian12之后,python也到了11版本

先在几乎是可以说python在强迫你用虚拟环境了

也好

这个库等于说会自动下载一个嵌入模型下来

挺好的

=========================================


import chromadb
# 拿一个client出来
chroma_client = chromadb.Client()
# 等于是新建了一个数据库
collection = chroma_client.create_collection(name="my_collection")
#新增
collection.add(
    documents=["This is a document", "This is another document"],
    metadatas=[{"source": "my_source"}, {"source": "my_source"}],
    ids=["id1", "id2"]
)
# 查询
results = collection.query(
    query_texts=["This is a document"],
    n_results=1
)
print(results)


然后这就是完整的输出了

0.0的距离哈