developer
developer copied to clipboard
Traceback errors and KeyError
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
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
I'm getting the same error. Did you find out what was wrong?
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
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.