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

Getting error ValueError: OPENAI_API_KEY is not set or passed as an argument #1

Open
pst2154 opened this issue May 27, 2023 · 1 comment

Comments

@pst2154
Copy link

pst2154 commented May 27, 2023

tried with version .5 and .4 on pypi

import openlm as openai
import json

completion = openai.Completion.create(
    model="ada", 
    prompt="Hello world",
)
print(json.dumps(completion, indent=4))

if I use openai instead it runs perfectly fine

import openai as openai

@Nantero1
Copy link

Nantero1 commented May 27, 2024

Yes, it seems cls.register_default() is called without arguments here, it should be called with arguments, in case the API key is passed as parameter. Interestingly it is designed to be able to receive an api key as input parameter, but is not called in this way.

Here a workaround to silence this issue:

import openlm

# FIXME: Cannot instantiate the api_key using a parameter (and do not want to reuse OPENAI_API_KEY)
openlm.api_key = os.environ.get("OPEN_LLM_API_KEY")

llm = OpenLM(base_url=...

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