gusye1234 / nano-graphrag

A simple, easy-to-hack GraphRAG implementation
MIT License
1.66k stars 160 forks source link

ollama connection issues #32

Closed summer3shadow closed 1 month ago

summer3shadow commented 2 months ago

Does anyone know how to resolve the Ollama connection issues? need to set anything?

IINFO:sentence_transformers.SentenceTransformer:Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2 /home/smartrx/.local/lib/python3.10/site-packages/transformers/tokenization_utils_base.py:1601: FutureWarning: clean_up_tokenization_spaces was not set. It will be set to True by default. This behavior will be depracted in transformers v4.45, and will be then set to False by default. For more details check this issue: https://github.com/huggingface/transformers/issues/31884 warnings.warn( INFO:nano-graphrag:Load KV full_docs with 0 data INFO:nano-graphrag:Load KV text_chunks with 0 data INFO:nano-graphrag:Load KV llm_response_cache with 0 data INFO:nano-graphrag:Load KV community_reports with 0 data INFO:nano-vectordb:Init {'embedding_dim': 384, 'metric': 'cosine', 'storage_file': './nano_graphrag_cache_ollama_TEST/vdb_entities.json'} 0 data INFO:nano-graphrag:[New Docs] inserting 1 docs INFO:nano-graphrag:[New Chunks] inserting 5 chunks INFO:nano-graphrag:[Entity Extraction]... ERROR:root:Failed to send request: All connection attempts failed ERROR:root:Failed to send request: All connection attempts failed ERROR:root:Failed to send request: All connection attempts failed ERROR:root:Failed to send request: All connection attempts failed ERROR:root:Failed to send request: All connection attempts failed INFO:nano-graphrag:Writing graph with 0 nodes, 0 edges Traceback (most recent call last): File "/home/smartrx/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 72, in map_httpcore_exceptions yield File "/home/smartrx/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 377, in handle_async_request resp = await self._pool.handle_async_request(req) File "/home/smartrx/.local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 216, in handle_async_request raise exc from None File "/home/smartrx/.local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 196, in handle_async_request response = await connection.handle_async_request( File "/home/smartrx/.local/lib/python3.10/site-packages/httpcore/_async/connection.py", line 99, in handle_async_request raise exc File "/home/smartrx/.local/lib/python3.10/site-packages/httpcore/_async/connection.py", line 76, in handle_async_request stream = await self._connect(request) File "/home/smartrx/.local/lib/python3.10/site-packages/httpcore/_async/connection.py", line 122, in _connect stream = await self._network_backend.connect_tcp(**kwargs) File "/home/smartrx/.local/lib/python3.10/site-packages/httpcore/_backends/auto.py", line 30, in connect_tcp return await self._backend.connect_tcp( File "/home/smartrx/.local/lib/python3.10/site-packages/httpcore/_backends/anyio.py", line 114, in connect_tcp with map_exceptions(exc_map): File "/usr/lib/python3.10/contextlib.py", line 153, in exit self.gen.throw(typ, value, traceback) File "/home/smartrx/.local/lib/python3.10/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions raise to_exc(exc) from exc httpcore.ConnectError: All connection attempts failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/smartrx/yingzhi/nano_graghrag.py", line 113, in insert() File "/home/smartrx/yingzhi/nano_graghrag.py", line 106, in insert rag.insert(FAKE_TEXT) File "/home/smartrx/.local/lib/python3.10/site-packages/nano_graphrag/graphrag.py", line 181, in insert return loop.run_until_complete(self.ainsert(string_or_strings)) File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/home/smartrx/.local/lib/python3.10/site-packages/nano_graphrag/graphrag.py", line 276, in ainsert maybe_new_kg = await extract_entities( File "/home/smartrx/.local/lib/python3.10/site-packages/nano_graphrag/_op.py", line 311, in extract_entities results = await asyncio.gather( File "/home/smartrx/.local/lib/python3.10/site-packages/nano_graphrag/_op.py", line 250, in _process_single_content final_result = await use_llm_func(hint_prompt) File "/home/smartrx/.local/lib/python3.10/site-packages/nano_graphrag/_utils.py", line 165, in wait_func result = await func(args, kwargs) File "/home/smartrx/yingzhi/nano_graghrag.py", line 51, in ollama_model_if_cache response = await ollama_client.chat(model=MODEL, messages=messages, kwargs) File "/home/smartrx/.local/lib/python3.10/site-packages/ollama/_client.py", line 654, in chat return await self._request_stream( File "/home/smartrx/.local/lib/python3.10/site-packages/ollama/_client.py", line 518, in _request_stream response = await self._request(args, kwargs) File "/home/smartrx/.local/lib/python3.10/site-packages/ollama/_client.py", line 483, in _request response = await self._client.request(method, url, kwargs) File "/home/smartrx/.local/lib/python3.10/site-packages/httpx/_client.py", line 1585, in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) File "/home/smartrx/.local/lib/python3.10/site-packages/httpx/_client.py", line 1674, in send response = await self._send_handling_auth( File "/home/smartrx/.local/lib/python3.10/site-packages/httpx/_client.py", line 1702, in _send_handling_auth response = await self._send_handling_redirects( File "/home/smartrx/.local/lib/python3.10/site-packages/httpx/_client.py", line 1739, in _send_handling_redirects response = await self._send_single_request(request) File "/home/smartrx/.local/lib/python3.10/site-packages/httpx/_client.py", line 1776, in _send_single_request response = await transport.handle_async_request(request) File "/home/smartrx/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 376, in handle_async_request with map_httpcore_exceptions(): File "/usr/lib/python3.10/contextlib.py", line 153, in exit self.gen.throw(typ, value, traceback) File "/home/smartrx/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 89, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ConnectError: All connection attempts failed

xxxibgdrgn123 commented 2 months ago

I also encountered the same mistake, have you solved it

gusye1234 commented 2 months ago

Hi, doest anyone solve this problem? It seems like a user-caused error and not nano-graphrag error

eunjilee commented 2 months ago

You have to run ollama server in other terminal.

In my case, I tested in centos7 and it worked.

If it worked well, the example uses "qwen2" model, so you need to pull the model. (ollama._types.ResponseError: model "qwen2" not found, try pulling it first)