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

AssertionError: openai package is not installed or the API key is not set #122

Open
mhaugestad opened this issue Feb 13, 2024 · 1 comment

Comments

@mhaugestad
Copy link

I am running into an error: AssertionError: openai package is not installed or the API key is not set.

I am certain that both the openai package is installed and I have the API set as environment variable OPENAI_API_KEY.

openai version 1.11.1
chatarena version 0.1.18

When I run the following code in the same environment 'is_openai_available' resolves to True.

try:
import openai
except ImportError:
is_openai_available = False
# logging.warning("openai package is not installed")
else:
try:
client = openai.OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
is_openai_available = True
except openai.OpenAIError:
# logging.warning("OpenAI API key is not set. Please set the environment variable OPENAI_API_KEY")
is_openai_available = False

Any ideas what could be causing this?

@elliottower
Copy link
Collaborator

Not sure what would cause this exactly but sounds like a bug. I don’t have much time to check on this but if you figure out the specific part in the codebase the problem is I can take a look, and maybe some more details to reproduce the problem

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

2 participants