Simatwa / python-tgpt

AI Chat in Terminal + Package + REST-API
https://python-tgpt.onrender.com
MIT License
102 stars 15 forks source link

pytgpt gpt4free update breaking functioning in termux #41

Closed schonda closed 4 months ago

schonda commented 5 months ago

after running "pytgpt gpt4free update" in termux on Android, it is no longer possible to use pytgpt. error message (related to webview package):

~ $ pytgpt Traceback (most recent call last): File "/data/data/com.termux/files/usr/bin/pytgpt", line 5, in from pytgpt.console import main File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/pytgpt/init.py", line 2, in import g4f File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/g4f/init.py", line 6, in from .models import Model File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/g4f/models.py", line 5, in from .Provider import RetryProvider, ProviderType File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/g4f/Provider/init.py", line 8, in from .deprecated import * File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/g4f/Provider/deprecated/init.py", line 1, in from .AiService import AiService File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/g4f/Provider/deprecated/AiService.py", line 6, in from ..base_provider import AbstractProvider File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/g4f/Provider/base_provider.py", line 3, in from .helper import get_cookies, format_prompt File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/g4f/Provider/helper.py", line 3, in from ..requests.aiohttp import get_connector File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/g4f/requests/init.py", line 12, in import webview File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/webview/init.py", line 34, in from webview.window import Window File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/webview/window.py", line 72, in class Window: File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/webview/window.py", line 259, in Window def load_html(self, content: str, base_uri: str = base_uri()) -> None: ^^^^^^^^^^ File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/webview/util.py", line 96, in base_uri if not os.path.exists(base_path): ^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 19, in exists TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

Simatwa commented 5 months ago

Thank you for raising this. Running pytgpt gpt4free update -e none might be helpful and if not then try to directly install with pip : pip install -U g4f

schonda commented 5 months ago

thanks for the quick response! unfortunately, nothing helps. I uninstalled and reinstalled python-tgpt and g4f, even python and pip, still not working. Do you have any idea what to do besides reinstalling the whole termux app?

Simatwa commented 4 months ago

g4f has undergone major updates. Try to install v0.2.6.1.

pip install g4f==0.2.6.1

https://github.com/Simatwa/python-tgpt/blob/a4ba0255add231a0dfb576ed2dab62a36824a504/setup.py#L26