问题验证
- 我已经在文档和Discord上搜索了答案。
问题
你好,我正在使用更多的数据在我的系统中,因此我尝试设置一个ChromaDB服务器来检索我的向量化信息,而不是使用磁盘存储检索。以下是我正在使用的代码:
def citation_indexing():
chroma_client = chromadb.Client()
try:
print("Loading Vector Content")
storage_context = StorageContext.from_chroma(client=chroma_client, collection_name='azure')
azure_index = load_index_from_storage(storage_context, show_progress=True)
storage_context = StorageContext.from_chroma(client=chroma_client, collection_name='assessment')
assessment_index = load_index_from_storage(storage_context, show_progress=True)
storage_context = StorageContext.from_chroma(client=chroma_client, collection_name='control')
control_index = load_index_from_storage(storage_context, show_progress=True)
storage_context = StorageContext.from_chroma(client=chroma_client, collection_name='questionaire')
questionaire_index = load_index_from_storage(storage_context, show_progress=True)
storage_context = StorageContext.from_chroma(client=chroma_client, collection_name='aws_docs')
aws_index = load_index_from_storage(storage_context, show_progress=True)
index_loaded = True
except Exception as e:
print(f"Error Loading Vector Content: {e}")
index_loaded = False
if not index_loaded:
print('Vectorizing Content')
# load data
azure_docs = SimpleDirectoryReader(
input_files=["/home/ubuntu/environment/revised-Project/All Docs/azure_services.pdf"]
).load_data()
assessment_docs = SimpleDirectoryReader(
input_files=["/home/ubuntu/environment/revised-Project/assessment-procedures.pdf"]).load_data()
control_docs = SimpleDirectoryReader("/home/ubuntu/environment/revised-Project/controls").load_data()
ques_docs = SimpleDirectoryReader("/home/ubuntu/environment/revised-Project/ques").load_data()
aws_documents = SimpleDirectoryReader("/home/ubuntu/environment/revised-Project/AWSDOCS").load_data()
# build index
azure_index = VectorStoreIndex.from_documents(azure_docs, storage_context=StorageContext.from_chroma(client=chroma_client, collection_name='azure'), show_progress=True)
assessment_index = VectorStoreIndex.from_documents(assessment_docs, storage_context=StorageContext.from_chroma(client=chroma_client, collection_name='assessment'), show_progress=True)
control_index = VectorStoreIndex.from_documents(control_docs, storage_context=StorageContext.from_chroma(client=chroma_client, collection_name='control'), show_progress=True)
ques_index = VectorStoreIndex.from_documents(ques_docs, storage_context=StorageContext.from_chroma(client=chroma_client, collection_name='questionaire'), show_progress=True)
aws_index = VectorStoreIndex.from_documents(aws_documents, storage_context=StorageContext.from_chroma(client=chroma_client, collection_name='aws_docs'), show_progress=True)
print("Vector Content Loaded")
return azure_index, assessment_index, control_index, ques_index, aws_index
我遇到了一个错误,提示 -> ValueError: 无法连接到租户default_tenant。你确定它存在吗?
我还尝试使用 -> chroma_server --host {EC2 IP} --port {EC2 端口号} 启动ChromaDB服务器。
我该如何修复我的错误,以便在我的Cloud9环境中创建一个ChromaDB服务器。
4条答案
按热度按时间2admgd591#
storage_context = StorageContext.from_chroma(client=chroma_client, collection_name='azure')
这不是正确的语法。请参阅文档
https://docs.llamaindex.ai/en/stable/examples/vector_stores/ChromaIndexDemo/?h=chroma
例如
也可以查看chromas文档以设置客户端
https://docs.trychroma.com/guides#using-the-python-http-only-client
jqjz2hbq2#
storage_context = StorageContext.from_chroma(client=chroma_client, collection_name='azure')
这不是正确的语法。请参阅文档 https://docs.llamaindex.ai/en/stable/examples/vector_stores/ChromaIndexDemo/?h=chroma
例如
请查看chromas文档,了解如何设置客户端 https://docs.trychroma.com/guides#using-the-python-http-only-client
我遵循了文档,我现在遵循的特定部分是这个:
现在我的代码看起来像这样:
我面临的问题是内容不再被识别,这就是为什么观察结果为空的原因。我正在使用Chain of Thought来查看RAG LLM的思想过程,但它给我的所有只是:
c0vxltue3#
try/except永远不会捕获到异常。
例如,这两行代码总是可以正常运行:
无论db_path是否存在,也无论集合是否已经存在。
可能你应该检查一下
db_path
是否存在,而不是使用try/except。(在重新运行之前删除db_path,以便正确重建)6qfn3psc4#
try/except永远不会捕获到异常。
例如,这两行代码总是可以正常工作:
无论db_path是否存在,也无论集合是否已经存在。
可能你应该检查一下
db_path
是否存在,而不是使用try/except。(在重新运行之前删除db_path,这样它就可以正确地重建)我已经让RAG系统正常工作了。我添加了一些不在文档中的功能:
is the ServiceContext:
service_context = ServiceContext.from_defaults(embed_model = embed_model, chunk_size = 1000, chunk_overlap = 20)
至少在我提供的内容中,它需要在运行向量索引之前进行分块。在我对数据进行分块之后,它就可以正常工作了。
至于try/except,我主要是出于调试目的才加上的,但现在它可以正常工作了,我会按照你们的建议进行修改。感谢你们的帮助。