Coder Social home page Coder Social logo

Comments (1)

dosubot avatar dosubot commented on June 7, 2024 2

The issue you're experiencing with FirestoreKVStore's aget_all method is due to not awaiting the doc.get() coroutine before attempting to call to_dict() on its result. This leads to the AttributeError: 'coroutine' object has no attribute 'to_dict' because doc.get() returns a coroutine that needs to be awaited to obtain the document snapshot, which then allows you to call .to_dict() on the snapshot.

Here's how you can fix the method:

async def aget_all(self, collection: str = DEFAULT_COLLECTION) -> Dict[str, dict]:
    collection_id = self.firestore_collection(collection)
    docs = self._adb.collection(collection_id).list_documents()
    output = {}
    async for doc in docs:
        key = doc.id
        doc_ref = await doc.get()  # Await the coroutine to get the document snapshot
        if doc_ref.exists:
            data = doc_ref.to_dict()  # Now you can safely call to_dict on the document snapshot
            if data is None:
                continue
            val = self.replace_field_name_get(data)
            output[key] = val
    return output

By awaiting doc.get(), you ensure that you're working with a document snapshot from which you can safely call .to_dict(), thus resolving the AttributeError.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

from llama_index.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.