Add new files and update existing files
This commit is contained in:
@@ -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 文件中。")
|
||||
Reference in New Issue
Block a user