feat: rag

This commit is contained in:
heyong.fu
2026-05-06 11:35:10 +08:00
commit a17c65c4bc
75 changed files with 5196 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
# 获取已经存在的集合
# 如果集合已经存在,可以使用get_collection() 或者 get_or_create_collection() 方法
import chromadb
# 创建持久化客户端
client = chromadb.PersistentClient(path="./chromadb_store")
# 方法1:获取已存在的集合
try:
existring_collection = client.get_collection(name="notes")
print("集合已经存在", existring_collection.name)
except Exception as e:
print("集合不存在", e)
# 方法2:获取或者创建集合(推荐使用)
collection = client.get_or_create_collection(
name="notes", metadata={"description": "笔记集合"}
)
print(collection.name)