🐛 fix(loading.py): ensure metadata values are not None for Chroma class

The docstring for the CombineDocsChain class has been updated to reflect the correct function name. In the loading.py file, the instantiate_vectorstore function has been updated to ensure that metadata values are not None for the Chroma class. This is because Chroma requires all metadata values to not be None, and this fix ensures that the application will not encounter errors when using Chroma.
🐛 fix(custom.py): update docstring to reflect the correct function name
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-13 14:07:27 -03:00
commit 09d4c89136
2 changed files with 10 additions and 1 deletions

View file

@ -97,7 +97,7 @@ class TimeTravelGuideChain(BaseCustomConversationChain):
class CombineDocsChain(CustomChain):
"""Implementation of AgentInitializer function"""
"""Implementation of load_qa_chain function"""
@staticmethod
def function_name():

View file

@ -151,6 +151,15 @@ def instantiate_vectorstore(class_object, params):
"The source you provided did not load correctly or was empty."
"This may cause an error in the vectorstore."
)
# Chroma requires all metadata values to not be None
if class_object.__name__ == "Chroma":
for doc in params["documents"]:
if doc.metadata is None:
doc.metadata = {}
for key, value in doc.metadata.items():
if value is None:
doc.metadata[key] = ""
return class_object.from_documents(**params)