Find answers from the community

Updated 8 months ago

Hello

Hello
Seeing the following exception when I execute the line index.as_query_engine(llm=None). What could be causing this issue?

File "/....../.venv/lib/python3.9/site-packages/llama_index/core/indices/base.py", line 391, in as_query_engine
from llama_index.core.query_engine.retriever_query_engine import (
File "/....../.venv/lib/python3.9/site-packages/llama_index/core/query_engine/init.py", line 14, in <module>
from llama_index.core.query_engine.flare.base import FLAREInstructQueryEngine
File "/....../.venv/lib/python3.9/site-packages/llama_index/core/query_engine/flare/base.py", line 24, in <module>
from llama_index.core.query_engine.retriever_query_engine import RetrieverQueryEngine
File "/....../.venv/lib/python3.9/site-packages/llama_index/core/query_engine/retriever_query_engine.py", line 27, in <module>
dispatcher = instrument.get_dispatcher(name)
File "/....../.venv/lib/python3.9/site-packages/llama_index/core/instrumentation/init.py", line 26, in get_dispatcher
new_dispatcher = Dispatcher(
File "/....../.venv/lib/python3.9/site-packages/llama_index/core/instrumentation/dispatcher.py", line 65, in init
self._asyncio_lock = asyncio.Lock()
File "/.../.pyenv/versions/3.9.6/lib/python3.9/asyncio/locks.py", line 81, in init
self._loop = events.get_event_loop()
File "/.../.pyenv/versions/3.9.6/lib/python3.9/asyncio/events.py", line 642, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Thread-79'.
L
G
14 comments
probably that lock should have lazy initialization in the framework. Its a bug for now
Oh... Thank you @Logan M What do you suggest that I do? Roll back to an older version of llama-index? Or anything else?
You could roll back, or ensure your code/thread is running with an async loop initialized
How do I run the code in an async loop? Any pointers?
Or if I have to rollback, any other version in the 0.10.x series that you suggest?
The last version we had was 0.9.x where we were using Service Contaxt and this piece was working fine.
We would like to update to 0.10.x..
probably v0.10.15 or so? And not sure, seems like you are threading your code? Unfamiliar with that. This bug should also be fixed in future versions
Thank you @Logan M That is a good starter for me. Let me put my hands on this and see...
One question @Logan M Any rough idea around when this bug is exptected to be fixed?
its actually already merged into main, will be in the next release (probably tomorrow, if I have time)
That will be super helpful @Logan M, to see it in 0.10.28! Many thanks!
I already mentioned this. But just incase you have missed it. I am seeing similar errors when I simply import BaseEmbedding
from llama_index.core.embeddings import BaseEmbedding2024-04-08T07:41:51.523398341Z File "/app/.venv/lib/python3.9/site-packages/llama_index/core/init.py", line 15, in <module>2024-04-08T07:41:51.523400447Z from llama_index.core.embeddings.mock_embed_model import MockEmbedding2024-04-08T07:41:51.523402662Z File "/app/.venv/lib/python3.9/site-packages/llama_index/core/embeddings/init.py", line 1, in <module>2024-04-08T07:41:51.523405175Z from llama_index.core.base.embeddings.base import BaseEmbedding2024-04-08T07:41:51.523407203Z File "/app/.venv/lib/python3.9/site-packages/llama_index/core/base/embeddings/base.py", line 26, in <module>2024-04-08T07:41:51.523409468Z import llama_index.core.instrumentation as instrument2024-04-08T07:41:51.523411699Z File "/app/.venv/lib/python3.9/site-packages/llama_index/core/instrumentation/init.py", line 5, in <module>2024-04-08T07:41:51.523414054Z root_dispatcher: Dispatcher = Dispatcher(2024-04-08T07:41:51.523415985Z File "/app/.venv/lib/python3.9/site-packages/llama_index/core/instrumentation/dispatcher.py", line 65, in init2024-04-08T07:41:51.523418048Z self._asyncio_lock = asyncio.Lock()2024-04-08T07:41:51.523420017Z File "/usr/local/lib/python3.9/asyncio/locks.py", line 81, in init2024-04-08T07:41:51.523422179Z self._loop = events.get_event_loop()2024-04-08T07:41:51.523425208Z File "/usr/local/lib/python3.9/asyncio/events.py", line 642, in get_event_loop2024-04-08T07:41:51.523427198Z raise RuntimeError('There is no current event loop in thread %r.'2024-04-08T07:41:51.523429237Z RuntimeError: There is no current event loop in thread 'ThreadPoolExecutor-0_0'
Guess this PR - https://github.com/run-llama/llama_index/pull/12638 is the one that will fix the problem?
Thank you @Logan M for 0.10.28!! Helped us progress further!
Add a reply
Sign up and join the conversation on Discord