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

Traceback errors and KeyError #85

Open
TheEvulKing opened this issue Jun 7, 2023 · 2 comments
Open

Traceback errors and KeyError #85

TheEvulKing opened this issue Jun 7, 2023 · 2 comments

Comments

@TheEvulKing
Copy link

Hi guys! I'm still very new to coding, so please be patient with me. I followed all of the instructions to run Smol-ai and put my api key from openai into the area: OPENAI_API_KEY=

After prompting Smol-ai It tells me:

hi its me, 🐣the smol developer🐣! you said you wanted: "My_Prompt" in text

But then I get the following errors

Traceback (most recent call last):
File "C:\A.I\Smol Ai Developer\developer\main_no_modal.py", line 230, in
main(prompt, directory, file)
File "C:\A.I\Smol Ai Developer\developer\main_no_modal.py", line 121, in main
filepaths_string = generate_response(
File "C:\A.I\Smol Ai Developer\developer\main_no_modal.py", line 26, in generate_response
openai.api_key = os.environ["OPENAI_API_KEY"]
File "C:\Users\Zove\AppData\Local\Programs\Python\Python310\lib\os.py", line 680, in getitem
raise KeyError(key) from None
KeyError: 'OPENAI_API_KEY'

I signed up for Modal but am still on the waitlist. So I'm using the: python main_no_modal.py " " --model=gpt-4

I also have access to gpt-4 through the paid subscription as well

Any help would be appreciated and thanks!! :D

@therealron
Copy link

I'm getting the same error. Did you find out what was wrong?

@boylucky
Copy link

boylucky commented Jun 8, 2023

I solved the problem with KeyError: 'OPENAI_API_KEY' mentioned above by adding the API key directly to main_no_modal.py on line 26: openai.api_key = "paste here your api key"

next solution of the same problem could be also to install python-dotenv:

pip install python-dotenv

Anyway then I am getting another error in the main_no_modal.py:

Note: The user may choose to name the files differently or store them in a different directory.
Traceback (most recent call last):
File "C:\Github\developer\main_no_modal.py", line 230, in
main(prompt, directory, file)
File "C:\Github\developer\main_no_modal.py", line 135, in main
list_actual = ast.literal_eval(filepaths_string)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\boylucky\AppData\Local\Programs\Python\Python311\Lib\ast.py", line 64, in literal_eval
node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\boylucky\AppData\Local\Programs\Python\Python311\Lib\ast.py", line 50, in parse
return compile(source, filename, mode, flags,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1
I assume you want me to generate the filepaths for creating a python script that counts from 100 to 1. Here are the filepaths:
^^^^^^
SyntaxError: invalid syntax

Any help will be appreciated. By the way I am using the python virtual environments instead of modal. All the modules from requirements.txt were installed.

In the end I assigned to modal and then looks the smol-ai works ok. But with modal I get many errors when trying to run with GPT-4 API. Command used:
modal run main.py --prompt "Write a python script which will count from 100 to 1" --model=gpt-4

Traceback (most recent call last):
File "/pkg/modal/_container_entrypoint.py", line 330, in handle_input_exception
yield
File "/pkg/modal/_container_entrypoint.py", line 403, in call_function_sync
res = fun(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/root/main.py", line 55, in generate_response
response = openai.ChatCompletion.create(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/api_resources/chat_completion.py", line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 230, in request
resp, got_stream = self._interpret_response(result, stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 624, in _interpret_response
self._interpret_response_line(
File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 687, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: The model: gpt-4 does not exist

When running without gpt-4 parameter then the smol-ai succeed.

Thanks in advance for help.

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

3 participants