developer icon indicating copy to clipboard operation
developer copied to clipboard

Traceback errors and KeyError

Open TheEvulKing opened this issue 1 year ago • 2 comments

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

TheEvulKing avatar Jun 07 '23 20:06 TheEvulKing

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

therealron avatar Jun 08 '23 03:06 therealron

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.

boylucky avatar Jun 08 '23 10:06 boylucky