neuroidss / create_function_chat

GNU Affero General Public License v3.0
6 stars 0 forks source link

httpx.ConnectError #3

Closed D-314 closed 2 months ago

D-314 commented 3 months ago
python create_function_chat.py "call Create function described as Search for articles on arxiv" "call Create function described as Send a message using the Telegram Bot API." 'call Create function with description "Via telegram web api read last message id, using token and chat_id, do not use telegram library"' 'call Create function with description "Via telegram web api read messages every second until message id will be different that provided as parameter, using token and chat_id, do not use telegram library, return json string"' 'send telegram bot message "which science articles to search?" via web api, token=0123456789:ABCDEF0123456789_abcdef0123456789FF, chat_id=0123456789' 'read last message id' 'then use that last message id to get new message' 'search 2 articles on arxiv about what user sent in last message' 'send telegram bot message Summary about these 2 last articles via web api'

argument list: ['create_function_chat.py', 'call Create function described as Search for articles on arxiv', 'call Create function described as Send a message using the Telegram Bot API.', 'call Create function with description Via', 'telegram', 'web', 'api', 'read', 'last', 'message', 'id,', 'using', 'token', 'and', 'chat_id,', 'do', 'not', 'use', 'telegram', 'library', 'call Create function with description Via', 'telegram', 'web', 'api', 'read', 'messages', 'every', 'second', 'until', 'message', 'id', 'will', 'be', 'different', 'that', 'provided', 'as', 'parameter,', 'using', 'token', 'and', 'chat_id,', 'do', 'not', 'use', 'telegram', 'library,', 'return', 'json', 'string', 'send telegram bot message which', 'science', 'articles', 'to', 'search? via web api, token=0123456789:ABCDEF0123456789_abcdef0123456789FF, chat_id=0123456789', 'read last message id', 'then use that last message id to get new message', 'search 2 articles on arxiv about what user sent in last message', 'send telegram bot message Summary about these 2 last articles via web api']
>>> call Create function described as Search for articles on arxiv
Traceback (most recent call last):
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx\_transports\default.py", line 69, in map_httpcore_exceptions
    yield
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx\_transports\default.py", line 233, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpcore\_sync\connection_pool.py", line 216, in handle_request
    raise exc from None
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpcore\_sync\connection_pool.py", line 196, in handle_request
    response = connection.handle_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpcore\_sync\connection.py", line 99, in handle_request
    raise exc
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpcore\_sync\connection.py", line 76, in handle_request
    stream = self._connect(request)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpcore\_sync\connection.py", line 122, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpcore\_backends\sync.py", line 205, in connect_tcp
    with map_exceptions(exc_map):
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 158, in __exit__
    self.gen.throw(value)
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpcore\_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpx.ConnectError: [WinError 10061] No connection could be made because the target machine actively refused it

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

Traceback (most recent call last):
  File "C:\Users\sereg\OneDrive\Desktop\chat_bot\create_function_chat-main\create_function_chat.py", line 289, in <module>
    run('mistral-nemo:12b-instruct-2407-q6_K', message)
  File "C:\Users\sereg\OneDrive\Desktop\chat_bot\create_function_chat-main\create_function_chat.py", line 206, in run
    response = client.chat(
               ^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\ollama\_client.py", line 235, in chat
    return self._request_stream(
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\ollama\_client.py", line 98, in _request_stream
    return self._stream(*args, **kwargs) if stream else self._request(*args, **kwargs).json()
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\ollama\_client.py", line 69, in _request
    response = self._client.request(method, url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx\_client.py", line 827, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx\_client.py", line 914, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx\_client.py", line 942, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx\_client.py", line 979, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx\_client.py", line 1015, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx\_transports\default.py", line 232, in handle_request
    with map_httpcore_exceptions():
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 158, in __exit__
    self.gen.throw(value)
  File "C:\Users\sereg\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx\_transports\default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [WinError 10061] No connection could be made because the target machine actively refused it

OS: Win11 The same error on Linux, but with a different error code:

httpx.ConnectError: [Errno 111] Connection refused
D-314 commented 2 months ago

In addition to the python library, ollama itself and the corresponding model must be installed:

pip install ollama
sudo curl -fsSL https://ollama.com/install.sh | sh
ollama pull mistral-nemo:12b-instruct-2407-q6_K
ollama run mistral-nemo:12b-instruct-2407-q6_K

This model requires an Nvidia GPU with >12GB of video memory. For example, RTX3060.