Find answers from the community

Updated 9 months ago

Hi, I'm using LlamaIndex 0.10.18 with

Hi, I'm using LlamaIndex 0.10.18 with FastAPI. Every module that I use with use_async=True return errors. Am I doing anything wrong? Here is the example error when I use SubQuestionQueryEngine:

Plain Text
File "/opt/anaconda3/envs/talking-resume/lib/python3.11/site-packages/llama_index/core/async_utils.py", line 49, in run_async_tasks
    outputs: List[Any] = asyncio.run(_gather())
                         ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/talking-resume/lib/python3.11/asyncio/runners.py", line 186, in run
    raise RuntimeError(
RuntimeError: asyncio.run() cannot be called from a running event loop
/opt/anaconda3/envs/talking-resume/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py:-1: RuntimeWarning: coroutine 'run_async_tasks.<locals>._gather' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/opt/anaconda3/envs/talking-resume/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py:-1: RuntimeWarning: coroutine 'SubQuestionQueryEngine._aquery_subq' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
L
s
6 comments
You need to enable nested async (this happens when a sync method is running async tasks with asyncio.run() ``` import nest_asyncio nest_asyncio.apply() ``` But in fast-api, that will error out unless you set the loop type to be asyncio uvicorn.run(..., loop="asyncio")`
I tried but it didn't work.
Where to put that async io code? In main.py where the FastAPI starts or just include when running async task?
At the top of your main.py file
It works now. Thanks a lot!
Hi @Logan M I'm using SummaryIndex and VectorIndex for the same document and trying to delete the indices from /storage (docstore.json, index_store.json), like this:

Plain Text
index.delete_ref_doc(ref_doc_id=ref_doc_id, delete_from_docstore=True)


The vector indices in db is deleted but
1) The nodes in index_store.json index_store/data object is empty but the record of the indices still exists. Like this:

Plain Text
{
  "index_store/data": {
    "vector_store.5aca6f9d-5e21-40db-bc8d-c64d0cb7cb49": {
      "__type__": "vector_store",
      "__data__": "{\"index_id\": \"vector_store.5aca6f9d-5e21-40db-bc8d-c64d0cb7cb49\", \"summary\": null, \"nodes_dict\": {}, \"doc_id_dict\": {}, \"embeddings_dict\": {}}"
    },
  "list.5aca6f9d-5e21-40db-bc8d-c64d0cb7cb49": {
      "__type__": "list",
      "__data__": "{\"index_id\": \"list.5aca6f9d-5e21-40db-bc8d-c64d0cb7cb49\", \"summary\": null, \"nodes\": []}"
    },
}


2) The docstore/data is still there just the embedding is null now but docstore/metadata and docstore/ref_doc_info are also null.

How can I delete them both? Thank you in advance.
Add a reply
Sign up and join the conversation on Discord