Skip to content

Conversation

@Josephasafg
Copy link
Contributor

There was a bug where if you were to set an env var after AI21Client was imported, to not receive the updated value of the variable

@Josephasafg Josephasafg requested a review from a team May 22, 2024 15:23
@Josephasafg Josephasafg changed the title fix: updated env var live fix: updated env var in real time May 22, 2024
@Josephasafg
Copy link
Contributor Author

That was the use case -

import os
from ai21 import AI21Client

os.enviorn["AI21_API_KEY] = "my-key"

client = AI21Client()

This implies that not setting api_key to anything is okay, and under the hood the code will check os.environ["AI21_API_KEY"]. But that doesn't seem to be true. Simply instantiating the client as client=AI21Client() fails to run with a missing API key, even though in the previous line I wrote:
os.environ["AI21_API_KEY"] = "...my key here..."

This was caused due to not fetching the env var in real time but only on first import of the client

@Josephasafg Josephasafg merged commit d19332d into main May 22, 2024
@Josephasafg Josephasafg deleted the env_var_not_being_set_all_the_time branch May 22, 2024 18:04
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

Successfully merging this pull request may close these issues.

4 participants