microsoft / graphrag

A modular graph-based Retrieval-Augmented Generation (RAG) system
https://microsoft.github.io/graphrag/
MIT License
19.43k stars 1.92k forks source link

RuntimeError: asyncio.run() cannot be called from a running event loop #1377

Open bhupender101 opened 2 weeks ago

bhupender101 commented 2 weeks ago

Do you need to file an issue?

Describe the bug

Cell In[11], line 1 ----> 1 search_engine.search(query="whatr is thre summary of the Document") File ~/miniconda3/envs/graphrag/lib/python3.10/site-packages/graphrag/query/structured_search/global_search/search.py:195, in GlobalSearch.search(self, query, conversation_history, kwargs) 188 def search( 189 self, 190 query: str, 191 conversation_history: ConversationHistory | None = None, 192 kwargs: Any, 193 ) -> GlobalSearchResult: 194 """Perform a global search synchronously.""" --> 195 return asyncio.run(self.asearch(query, conversation_history)) File ~/miniconda3/envs/graphrag/lib/python3.10/asyncio/runners.py:33, in run(main, debug) 9 """Execute the coroutine and return the result. 10 11 This function runs the passed coroutine, taking care of (...) 30 asyncio.run(main()) 31 """ 32 if events._get_running_loop() is not None: ---> 33 raise RuntimeError( 34 "asyncio.run() cannot be called from a running event loop") 36 if not coroutines.iscoroutine(main): 37 raise ValueError("a coroutine was expected, got {!r}".format(main)) RuntimeError: asyncio.run() cannot be called from a running event loop

Steps to reproduce

i am getting error in the Starter Code OF the Graph Rag

Expected Behavior

No response

GraphRAG Config Used

# Paste your config here

Logs and screenshots

No response

Additional Information

JordiPG05 commented 2 weeks ago

I give more information on where the problem lies: /home/.local/lib/python3.11/site-packages/graphrag/cli/main.py:117 in
│ _index_cli

│ 114 │ ] = None,
│ 115 ):
│ 116 │ """Build a knowledge graph index."""
│ ❱ 117 │ index_cli(
│ 118 │ │ root_dir=root,
│ 119 │ │ verbose=verbose,
│ 120 │ │ resume=resume,

/home/.local/lib/python3.11/site-packages/graphrag/cli/index.py:120 in
│ index_cli

│ 117 │
│ 118 │ _register_signal_handlers(progress_reporter)
│ 119 │
│ ❱ 120 │ outputs = asyncio.run(
│ 121 │ │ api.build_index(
│ 122 │ │ │ config=config,
│ 123 │ │ │ run_id=run_id,

/usr/local/lib/python3.11/asyncio/runners.py:190 in run

│ 187 │ │ │ "asyncio.run() cannot be called from a running event loop" │ 188 │
│ 189 │ with Runner(debug=debug) as runner:
│ ❱ 190 │ │ return runner.run(main)
│ 191
│ 192
│ 193 def _cancel_all_tasks(loop):

│ /usr/local/lib/python3.11/asyncio/runners.py:118 in run

│ 115 │ │
│ 116 │ │ self._interrupt_count = 0
│ 117 │ │ try:
│ ❱ 118 │ │ │ return self._loop.run_until_complete(task)
│ 119 │ │ except exceptions.CancelledError:
│ 120 │ │ │ if self._interrupt_count > 0: