Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent commit broke the gpt usage (for me) #29

Closed
schnika opened this issue May 10, 2023 · 5 comments
Closed

Recent commit broke the gpt usage (for me) #29

schnika opened this issue May 10, 2023 · 5 comments

Comments

@schnika
Copy link

schnika commented May 10, 2023

Current behaviour (46247d3)

~/p/g/gpt-cli ❯❯❯ ./gpt.py dev                                                 main
Traceback (most recent call last):
  File "./gpt.py", line 10, in <module>
    from gptcli.assistant import (
  File "/Users/patricknueser/projects/gpt-cli/gpt-cli/gptcli/assistant.py", line 8, in <module>
    from gptcli.llama import LLaMACompletionProvider
  File "/Users/patricknueser/projects/gpt-cli/gpt-cli/gptcli/llama.py", line 12, in <module>
    LLAMA_MODELS: Optional[dict[str, Path]] = None
TypeError: 'type' object is not subscriptable

Expected behaviour (7752b05)
~/p/g/gpt-cli ❯❯❯ ./gpt.py dev ✘ 1 main
Hi! I'm here to help. Type q or Ctrl-D to exit, c or Ctrl-C to clear the
conversation, r or Ctrl-R to re-generate the last response. To enter multi-line
mode, enter a backslash \ followed by a new line. Exit the multi-line mode by
pressing ESC and then Enter (Meta+Enter).

@kharvd
Copy link
Owner

kharvd commented May 10, 2023

Hmm, I can't reproduce on a clean installation. What is your python version? GPT-4 thinks you're using an outdated version. Could you try the suggested fix below as well?

The error is caused by using dict[str, Path] with an older Python version that doesn't support it. Upgrade
to Python 3.9 or later, or use typing.Dict:

 from typing import Dict, Optional
 LLAMA_MODELS: Optional[Dict[str, Path]] = None

@sthiffea
Copy link

sthiffea commented May 17, 2023

I'm having same issue. Python 3.8.10 on Ubuntu 20.04 under WSL2.
Tried clean install. Same issue.

Traceback (most recent call last):
  File "./gpt.py", line 8, in <module>
    import google.generativeai as genai
  File "/home/sthiffea/gpt-cli/venv/lib/python3.8/site-packages/google/generativeai/__init__.py", line 59, in <module>
    from google.generativeai import types
  File "/home/sthiffea/gpt-cli/venv/lib/python3.8/site-packages/google/generativeai/types/__init__.py", line 19, in <module>
    from google.generativeai.types.text_types import *
  File "/home/sthiffea/gpt-cli/venv/lib/python3.8/site-packages/google/generativeai/types/text_types.py", line 34, in <module>
    class Completion(abc.ABC):
  File "/home/sthiffea/gpt-cli/venv/lib/python3.8/site-packages/google/generativeai/types/text_types.py", line 49, in Completion
    filters: Optional[list[safety_types.ContentFilterDict]]
TypeError: 'type' object is not subscriptable```

```(venv) sthiffea@win11desktop:~/gpt-cli$ pip freeze
aiohttp==3.8.4
aiosignal==1.3.1
anthropic==0.2.8
anyio==3.6.2
async-timeout==4.0.2
attrs==23.1.0
black==23.1.0
cachetools==5.3.0
certifi==2023.5.7
charset-normalizer==3.1.0
click==8.1.3
exceptiongroup==1.1.1
frozenlist==1.3.3
google-ai-generativelanguage==0.2.0
google-api-core==2.11.0
google-auth==2.18.0
google-generativeai==0.1.0rc2
googleapis-common-protos==1.59.0
grpcio==1.54.2
grpcio-status==1.54.2
h11==0.14.0
httpcore==0.17.0
httpx==0.24.0
idna==3.4
iniconfig==2.0.0
markdown-it-py==2.2.0
mdurl==0.1.2
multidict==6.0.4
mypy-extensions==1.0.0
openai==0.27.2
packaging==23.1
pathspec==0.11.1
pkg_resources==0.0.0
platformdirs==3.5.1
pluggy==1.0.0
prompt-toolkit==3.0.38
proto-plus==1.22.2
protobuf==4.23.0
pyasn1==0.5.0
pyasn1-modules==0.3.0
Pygments==2.15.1
pytest==7.3.1
PyYAML==6.0
regex==2023.5.5
requests==2.30.0
rich==13.3.2
rsa==4.9
six==1.16.0
sniffio==1.3.0
tiktoken==0.3.3
tokenizers==0.13.3
tomli==2.0.1
tqdm==4.65.0
typing_extensions==4.5.0
urllib3==1.26.15
wcwidth==0.2.6
yarl==1.9.2```

@dltn
Copy link
Contributor

dltn commented Jun 26, 2023

I've also hit this on a clean install on Mac. The issue occurs for any Python <3.9 due to the typing error in upstream google-generativeai 0.1.0rc2, discussed in google-gemini/generative-ai-python#13 and fixed in google-gemini/generative-ai-python#16.

In addition to fixing the type issue, google-generativeai has also dropped support for any Python <3.9 in 0.1.0rc3/0.1.0, which means it isn't as simple as bumping the package:

% diff --git a/requirements.txt b/requirements.txt
-google-generativeai==0.1.0rc2
+google-generativeai==0.1.0

% python3 -m pip install -r requirements.txt
ERROR: Ignored the following versions that require a different python version: 0.1.0 Requires-Python >=3.9; 0.1.0rc3 Requires-Python >=3.9

@kharvd: do you want to make gpt-cli Python 3.9+ only?

@dltn
Copy link
Contributor

dltn commented Jun 26, 2023

@kharvd: do you want to make gpt-cli Python 3.9+ only?

If yes: #39

kharvd pushed a commit that referenced this issue Jun 27, 2023
…ge (#39)

Upstream `google-generativeai@0.1.0` requires Python 3.9+. The older
version we currently use (`0.1.0rc2` ) implicitly requires it anyway
(see #29).

macOS Ventura's default `python3` version is `3.8.9` so this might
introduce friction to many future adopters. I propose we unbreak this
for now, and consider alternatives (ex. conditional loading) if we're
worried about it.
@kharvd
Copy link
Owner

kharvd commented Jun 27, 2023

Merged #39, Python >= 3.9 is now required, thanks @dltn

@kharvd kharvd closed this as completed Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants