-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
metagpt.config.NotConfiguredException: Set OPENAI_API_KEY first #33
Comments
@gnoejuan
By the way, you can debug your container by the following step: docker run --name test -d docker.io/library/metagpt:latest tail -f /dev/null
docker exec -it test /bin/sh
cat config/key.yaml
python startup.py "do something"
export OPENAI_API_KEY="xxx"
python startup.py "do something"
... Then you can find where the problem is. |
Awesome! Thank you! So, looks like with the command line I was running earlier, the mount was in the wrong place! Good catch! But, before I figured out the mount issue, when I was testing the
step, I ran into the NotConfiguredException. So, I'm happy and taken care of ( I can modify the Job to use the config ), the documentation in the Readme does suggest that an environment variable should also be a viable approach. |
I know the problem, because config.yaml has higher priority, so the stub in config.yaml blocks the env variable. I will fix this in the next update |
da11d38 |
Yup! That worked! The Job was able to complete using the environment variables! |
Greetings!
I've tried several ways of passing the OPENAI_API_KEY
First, here is the Dockerfile:
Dockerfile
I tried with the equivalent of the
docker run
command in the instructions.Oh, here is the config.yaml / key.yaml with the api key redacted
key.yaml
And when I check for the file, its there.
Running without the volume mounts returns this:
but that's cause I cloned from source.
I also tried with passing the api key as an environment argument to the
run
command.nerdctl run --rm -e OPENAI_API_KEY="sk-----" -v /home/charlesrod/Documents/Projects/MetaGPT/workspace:/app/metagpt/workspace docker.io/library/metagpt:latest python startup.py
I created a Kubernetes resource to run it. One where the config is mounted and another where the environment variables are part of the job spec ( latest attempt before raising this issue )
Job.yaml
And the pod Errors with "metagpt.config.NotConfiguredException: Set OPENAI_API_KEY first".
Image
Updating the job to
command: ["printenv"]
again proves that teh env is thereFrom the code in config.py https://github.com/geekan/MetaGPT/blob/317f0955ab81919e2ff32f0a81ad112131965123/metagpt/config.py#L64C73-L64C73
It looks like it should grab the environment variable as well. I rebuilt the image, since the git clone stage was cached from 2 days ago at this point.
I'm stumped at the moment.
The text was updated successfully, but these errors were encountered: