Skip to content

Add ids to the document in the base #20

@ginimod

Description

@ginimod

documents = []
ids = []
for filename in os.listdir(source_directory):
[...]
ids.append(filename)
[...]
documents.extend(loader.load())

vector_store = Chroma.from_documents(
documents = texts,
ids=slugify(filename),
embedding = embeddings,
persist_directory = db_path,
collection_name = collection_name
)

File "/home/gini/Téléchargements/rag_md/vector.py", line 51, in md_rag
vector_store = Chroma.from_documents(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/gini/anaconda3/envs/wrbui/lib/python3.11/site-packages/langchain_chroma/vectorstores.py", line 1388, in from_documents
return cls.from_texts(
^^^^^^^^^^^^^^^
File "/home/gini/anaconda3/envs/wrbui/lib/python3.11/site-packages/langchain_chroma/vectorstores.py", line 1321, in from_texts
chroma_collection.add_texts(
File "/home/gini/anaconda3/envs/wrbui/lib/python3.11/site-packages/langchain_chroma/vectorstores.py", line 645, in add_texts
ids_with_metadata = [ids[idx] for idx in non_empty_ids]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gini/anaconda3/envs/wrbui/lib/python3.11/site-packages/langchain_chroma/vectorstores.py", line 645, in
ids_with_metadata = [ids[idx] for idx in non_empty_ids]
~~~^^^^^
IndexError: list index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions