mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

[BUG] ValueError: Expected metadatas to be a list, got ({'url': 'local'},)

Open cachho opened this issue 2 years ago • 1 comments


File "/usr/local/lib/python3.8/site-packages/embedchain/embedchain.py", line 94, in add

        :param url: The URL where the data is located.

        """

        loader = self._get_loader(data_type)

        chunker = self._get_chunker(data_type)

        self.user_asks.append([data_type, url])

        self.load_and_embed(loader, chunker, url)

 

    def add_local(self, data_type, content):

        """

        Adds the data you supply to the vector db.

        Loads the data, chunks it, create embedding for each chunk

File "/usr/local/lib/python3.8/site-packages/embedchain/embedchain.py", line 140, in load_and_embed

                return

 

            ids = list(data_dict.keys())

            documents, metadatas = zip(*data_dict.values())

 

        self.collection.add(

            documents=documents,

            metadatas=metadatas,

            ids=ids

        )

        print(f"Successfully saved {url}. Total chunks count: {self.collection.count()}")

File "/usr/local/lib/python3.8/site-packages/chromadb/api/models/Collection.py", line 96, in add

            ValueError: If you provide both embeddings and documents

            ValueError: If you provide an id that already exists

 

        """

 

        ids, embeddings, metadatas, documents = self._validate_embedding_set(

            ids, embeddings, metadatas, documents

        )

 

        self._client._add(

            ids, self.id, embeddings, metadatas, documents, increment_index

File "/usr/local/lib/python3.8/site-packages/chromadb/api/models/Collection.py", line 354, in _validate_embedding_set

            validate_embeddings(maybe_cast_one_to_many(embeddings))

            if embeddings is not None

            else None

        )

        metadatas = (

            validate_metadatas(maybe_cast_one_to_many(metadatas))

            if metadatas is not None

            else None

        )

        documents = maybe_cast_one_to_many(documents) if documents is not None else None

 

File "/usr/local/lib/python3.8/site-packages/chromadb/api/types.py", line 140, in validate_metadatas

 

 

def validate_metadatas(metadatas: Metadatas) -> Metadatas:

    """Validates metadatas to ensure it is a list of dictionaries of strings to strings, ints, or floats"""

    if not isinstance(metadatas, list):

        raise ValueError(f"Expected metadatas to be a list, got {metadatas}")

    for metadata in metadatas:

        validate_metadata(metadata)

    return metadatas

cachho avatar Jul 01 '23 09:07 cachho

The PR fixes this issue

cachho avatar Jul 01 '23 12:07 cachho