While running examples from
https://gpt-index.readthedocs.io/en/stable/examples/evaluation/TestNYC-Evaluation.html on def evaluate_query_engine(query_engine, questions):
correct, total = evaluate_query_engine(vector_query_engine, eval_questions[:5])
Got error:
---------------
RuntimeError Traceback (most recent call last)
Cell In[71], line 2
1 vector_query_engine = vector_index.as_query_engine()
----> 2 correct, total = evaluate_query_engine(vector_query_engine, questions)
4 print(f"score: {correct}/{total}")
Cell In[69], line 6, in evaluate_query_engine(query_engine, questions)
4 def evaluate_query_engine(query_engine, questions):
5 c = [query_engine.aquery(q) for q in questions]
----> 6 results = asyncio.run(asyncio.gather(*c))
7 print("finished query")
9 total_correct = 0
File /usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py:186, in run(main, debug)
161 """Execute the coroutine and return the result.
162
163 This function runs the passed coroutine, taking care of
(...)
182 asyncio.run(main())
183 """
184 if events._get_running_loop() is not None:
185 # fail fast with short traceback
--> 186 raise RuntimeError(
187 "asyncio.run() cannot be called from a running event loop")
189 with Runner(debug=debug) as runner:
190 return runner.run(main)
RuntimeError: asyncio.run() cannot be called from a running event loop