Sumanth077 / chat_with_pdf

Chat with PDF using Llama 3.2
32 stars 6 forks source link

Connection Refused 111 #1

Closed ashish-atidiv closed 1 week ago

ashish-atidiv commented 1 week ago

Hey @Sumanth077 I am facing issues running the project and getting this error.

Environment:

  1. I am using WSL on Windows machine.
  2. Ports 3000 and 8000 are auto-forwarded to Windows as I am using VS Code.
App running at: http://localhost:3000
Backend running at: http://0.0.0.0:8000
[Reflex Backend Exception]
 Traceback (most recent call last):
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_transports/default.py", line 72, in map_httpcore_exceptions
    yield
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_transports/default.py", line 236, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
    raise exc from None
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 196, in handle_request
    response = connection.handle_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 99, in handle_request
    raise exc
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 76, in handle_request
    stream = self._connect(request)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 122, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_backends/sync.py", line 205, in connect_tcp
    with map_exceptions(exc_map):
  File "/home/stallians/.pyenv/versions/3.11.1/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [Errno 111] Connection refused

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

Traceback (most recent call last):
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/reflex/state.py", line 1624, in _process_event
    events = await fn(**payload)
             ^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/chat_with_pdf/chat_with_pdf.py", line 44, in handle_upload
    app = self.get_app()
          ^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/chat_with_pdf/chat_with_pdf.py", line 17, in get_app
    return App.from_config(
           ^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/embedchain/app.py", line 393, in from_config
    llm = LlmFactory.create(llm_provider, llm_config_data.get("config", {}))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/embedchain/factory.py", line 46, in create
    return llm_class(config=llm_config_class(**config_data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/embedchain/llm/ollama.py", line 30, in __init__
    local_models = client.list()["models"]
                   ^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/ollama/_client.py", line 465, in list
    return self._request('GET', '/api/tags').json()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/ollama/_client.py", line 70, in _request
    response = self._client.request(method, url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_client.py", line 837, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_client.py", line 926, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_client.py", line 954, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_client.py", line 991, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_client.py", line 1027, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_transports/default.py", line 235, in handle_request
    with map_httpcore_exceptions():
  File "/home/stallians/.pyenv/versions/3.11.1/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_transports/default.py", line 89, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno 111] Connection refused

^C[16:54:32] Reflex app stopped.                                                                                                                                                                            console.py:104
(.venv) stallians@ITFY22EUDWIN400:~/projects/poc/chat_with_pdf$ reflex run
────────────────────────────────────────────────────────────────────────────────────────────── Initializing chat_with_pdf ──────────────────────────────────────────────────────────────────────────────────────────────
[16:55:07] Initializing the web directory.                                                                                                                                                                console.py:104
Success: Initialized chat_with_pdf
───────────────────────────────────────────────────────────────────────────────────────────────── Starting Reflex App ──────────────────────────────────────────────────────────────────────────────────────────────────
[16:55:15] Compiling: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 13/13 0:00:00
───────────────────────────────────────────────────────────────────────────────────────────────────── App Running ──────────────────────────────────────────────────────────────────────────────────────────────────────
App running at: http://localhost:3000
Backend running at: http://0.0.0.0:8000
[Reflex Backend Exception]
 Traceback (most recent call last):
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_transports/default.py", line 72, in map_httpcore_exceptions
    yield
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_transports/default.py", line 236, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
    raise exc from None
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 196, in handle_request
    response = connection.handle_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 99, in handle_request
    raise exc
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 76, in handle_request
    stream = self._connect(request)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 122, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_backends/sync.py", line 205, in connect_tcp
    with map_exceptions(exc_map):
  File "/home/stallians/.pyenv/versions/3.11.1/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [Errno 111] Connection refused

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

Traceback (most recent call last):
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/reflex/state.py", line 1624, in _process_event
    events = await fn(**payload)
             ^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/chat_with_pdf/chat_with_pdf.py", line 44, in handle_upload
    app = self.get_app()
          ^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/chat_with_pdf/chat_with_pdf.py", line 17, in get_app
    return App.from_config(
           ^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/embedchain/app.py", line 393, in from_config
    llm = LlmFactory.create(llm_provider, llm_config_data.get("config", {}))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/embedchain/factory.py", line 46, in create
    return llm_class(config=llm_config_class(**config_data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/embedchain/llm/ollama.py", line 30, in __init__
    local_models = client.list()["models"]
                   ^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/ollama/_client.py", line 465, in list
    return self._request('GET', '/api/tags').json()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/ollama/_client.py", line 70, in _request
    response = self._client.request(method, url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_client.py", line 837, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_client.py", line 926, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_client.py", line 954, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_client.py", line 991, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_client.py", line 1027, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_transports/default.py", line 235, in handle_request
    with map_httpcore_exceptions():
  File "/home/stallians/.pyenv/versions/3.11.1/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/home/stallians/projects/poc/chat_with_pdf/.venv/lib/python3.11/site-packages/httpx/_transports/default.py", line 89, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno 111] Connection refused
wramarques commented 1 week ago

Hi @ashish-atidiv

You first need to install Ollama and pull the Llama 3.2 model. It will run on defaut port indicated in project config (11434)

Sumanth077 commented 1 week ago

Hi @wramarques, thanks for jumping in. Hi @ashish-atidiv sorry for the delayed response. As we are trying to make a request to the Llama 3.2 model running locally on Ollama, please ensure that Ollama is running locally you can do that using ollama run llama3.2. Also verify this by making a curl request to the port curl http://localhost:11434

ashish-atidiv commented 1 week ago

Thanks. This worked!