Add new files and update existing files

This commit is contained in:
chentianrui
2024-08-15 19:08:58 +08:00
parent d3df62f454
commit 3082ac5f3d
9 changed files with 330 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import chromadb
# 创建 ChromaDB 客户端
chroma_client = chromadb.PersistentClient(path="/home/bw/ctr/zjdataai-app/backend/storage_vector-1/")
# 获取已存在的 "default" 集合
collection = chroma_client.get_collection(name="default")
# 获取集合中的所有数据
results = collection.get(
include=['documents', 'metadatas', 'embeddings'] # 只包含允许的选项
)
# 将结果转换为字符串并保存到txt文件中
with open('/home/bw/ctr/zjdataai-app/backend/test1/query_results-1.txt', 'w', encoding='utf-8') as file:
file.write(str(results))
# 打印结果
print("查询结果已保存到 query_results.txt 文件中。")