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

Prioritize api_key given in kwargs over the OPENAI_API_KEY env variable #22

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion simpleaichat/simpleaichat.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def new_session(
kwargs["model"] = "gpt-3.5-turbo"
# TODO: Add support for more models (PaLM, Claude)
if "gpt-" in kwargs["model"]:
gpt_api_key = os.getenv("OPENAI_API_KEY") or kwargs.get("api_key")
gpt_api_key = kwargs.get("api_key") or os.getenv("OPENAI_API_KEY")
assert gpt_api_key, f"An API key for {kwargs['model'] } was not defined."
sess = ChatGPTSession(
auth={
Expand Down