Simatwa / python-tgpt

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

Bard Session ID #23

Closed sinuso closed 7 months ago

sinuso commented 7 months ago

How do add the session_id or .json file to the command?

:~$ pytgpt generate --provider bard "1+1?"
15:49:17 - ERROR : Bard's session-id or path to bard.google.com.cookies.json file is required
Quitting
Simatwa commented 7 months ago

Use the flag --key followed by session_id or path to the .json file exported by export-cookie-for-puppeter extension.

Note : The library providing Bard's interaction seems to be deprecated. Shall be fixed in time.

sinuso commented 7 months ago

@Simatwa I can't get it to work. I have tried with the content of __Secure-1PSID and with .json in the same directory from where I run the command and it always returns the same error

:~$ pytgpt generate --provider bard --key g.XXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXX "1+1?"
01:13:32 - ERROR : __Secure-1PSID value must end with a single dot. Enter correct __Secure-1PSID value.
Quitting
:~$ pytgpt generate --provider bard --key bard.google.com.cookies.json "1+1?"
01:16:59 - ERROR : __Secure-1PSID value must end with a single dot. Enter correct __Secure-1PSID value.
Quitting
Simatwa commented 7 months ago

I'll fix this in the course of the day.

sinuso commented 7 months ago

I'll fix this in the course of the day.

I think I'm doing something wrong, it still doesn't work.

:~$ pytgpt generate --provider bard --key g.XXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXX "1+1?"
14:59:23 - ERROR : g.XXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXX is not a valid file path
Quitting
:~$ pytgpt generate --provider bard --key bard.google.com.cookies.json "1+1?"
14:51:40 - ERROR : SNlM0e value not found in response. Check __Secure_1PSID value.
Quitting
Simatwa commented 7 months ago

It's working pretty fine on my side. Export the cookies again and try out. Share the update. Screenshot_20240203-184619

sinuso commented 7 months ago

@Simatwa I have updated both python-tgpt and the cookie and now they are all errors on Linux, on windows it works fine.

Result in Windows

C:\Users\Test\Downloads> pytgpt interactive -p bard -k bard.google.com.cookies.json  
Welcome to AI Chat in terminal. Type 'help' or 'h' for usage info.
Submit any bug at https://github.com/Simatwa/python-tgpt/issues/new
╭─[Test@pyTGPT](bard)~[🕒17:39:51-💻00:00:00-⚡0.0s]
╰─>

Result in Linux

test@localhost:~$ pytgpt interactive -p bard -k bard.google.com.cookies.json
Traceback (most recent call last):
  File "/home/test/.local/bin/pytgpt", line 5, in <module>
    from pytgpt.console import main
  File "/home/test/.local/lib/python3.11/site-packages/pytgpt/__init__.py", line 2, in <module>
    import g4f
  File "/home/test/.local/lib/python3.11/site-packages/g4f/__init__.py", line 6, in <module>
    from .models   import Model, ModelUtils
  File "/home/test/.local/lib/python3.11/site-packages/g4f/models.py", line 3, in <module>
    from .Provider   import RetryProvider, ProviderType
  File "/home/test/.local/lib/python3.11/site-packages/g4f/Provider/__init__.py", line 7, in <module>
    from .deprecated      import *
  File "/home/test/.local/lib/python3.11/site-packages/g4f/Provider/deprecated/__init__.py", line 18, in <module>
    from .Aibn          import Aibn
  File "/home/test/.local/lib/python3.11/site-packages/g4f/Provider/deprecated/Aibn.py", line 7, in <module>
    from ...requests import StreamSession
  File "/home/test/.local/lib/python3.11/site-packages/g4f/requests.py", line 6, in <module>
    from curl_cffi.requests import Session
  File "/home/test/.local/lib/python3.11/site-packages/curl_cffi/requests/__init__.py", line 29, in <module>
    from .session import AsyncSession, BrowserType, Session
  File "/home/test/.local/lib/python3.11/site-packages/curl_cffi/requests/session.py", line 30, in <module>
    import eventlet.tpool
  File "/home/test/.local/lib/python3.11/site-packages/eventlet/__init__.py", line 6, in <module>
    from eventlet import convenience
  File "/home/test/.local/lib/python3.11/site-packages/eventlet/convenience.py", line 7, in <module>
    from eventlet.green import socket
  File "/home/test/.local/lib/python3.11/site-packages/eventlet/green/socket.py", line 21, in <module>
    from eventlet.support import greendns
  File "/home/test/.local/lib/python3.11/site-packages/eventlet/support/greendns.py", line 78, in <module>
    setattr(dns, pkg, import_patched('dns.' + pkg))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/test/.local/lib/python3.11/site-packages/eventlet/support/greendns.py", line 60, in import_patched
    return patcher.import_patched(module_name, **modules)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/test/.local/lib/python3.11/site-packages/eventlet/patcher.py", line 132, in import_patched
    return inject(
           ^^^^^^^
  File "/home/test/.local/lib/python3.11/site-packages/eventlet/patcher.py", line 109, in inject
    module = __import__(module_name, {}, {}, module_name.split('.')[:-1])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/test/.local/lib/python3.11/site-packages/dns/asyncquery.py", line 38, in <module>
    from dns.query import (
  File "/home/test/.local/lib/python3.11/site-packages/dns/query.py", line 64, in <module>
    import httpcore
  File "/home/test/.local/lib/python3.11/site-packages/httpcore/__init__.py", line 1, in <module>
    from ._api import request, stream
  File "/home/test/.local/lib/python3.11/site-packages/httpcore/_api.py", line 5, in <module>
    from ._sync.connection_pool import ConnectionPool
  File "/home/test/.local/lib/python3.11/site-packages/httpcore/_sync/__init__.py", line 1, in <module>
    from .connection import HTTPConnection
  File "/home/test/.local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 12, in <module>
    from .._synchronization import Lock
  File "/home/test/.local/lib/python3.11/site-packages/httpcore/_synchronization.py", line 11, in <module>
    import trio
  File "/home/test/.local/lib/python3.11/site-packages/trio/__init__.py", line 20, in <module>
    from ._core import TASK_STATUS_IGNORED as TASK_STATUS_IGNORED  # isort: split
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/test/.local/lib/python3.11/site-packages/trio/_core/__init__.py", line 21, in <module>
    from ._local import RunVar, RunVarToken
  File "/home/test/.local/lib/python3.11/site-packages/trio/_core/_local.py", line 9, in <module>
    from . import _run
  File "/home/test/.local/lib/python3.11/site-packages/trio/_core/_run.py", line 2762, in <module>
    from ._io_epoll import (
  File "/home/test/.local/lib/python3.11/site-packages/trio/_core/_io_epoll.py", line 202, in <module>
    class EpollIOManager:
  File "/home/test/.local/lib/python3.11/site-packages/trio/_core/_io_epoll.py", line 203, in EpollIOManager
    _epoll: select.epoll = attr.ib(factory=select.epoll)
                                           ^^^^^^^^^^^^
AttributeError: module 'eventlet.green.select' has no attribute 'epoll'
Simatwa commented 7 months ago

Seems there's an issue with the http request dependencies of which I have no idea on addressing them. However, you can try out the binaries or the installable .deb package (recommended) available on the assets section. Echo the update kindly.

sinuso commented 7 months ago

Seems there's an issue with the http request dependencies of which I have no idea on addressing them. However, you can try out the binaries or the installable .deb package (recommended) available on the assets section. Echo the update kindly.

With the deb package I get this error:

test@localhost:~$ pytgpt -v
[222515] Error loading Python lib '/usr/lib/pytgpt/libpython3.11.so.1.0': dlopen: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.35' not found (required by /usr/lib/pytgpt/libpython3.11.so.1.0)