Skip to content

Commit

Permalink
refactor(configure): move OpenAI client initialization into function
Browse files Browse the repository at this point in the history
This commit moves the initialization of the OpenAI client into the `default_model` function.
This change improves the code organization and ensures the client is only initialized when needed.
It should also eliminate OpenAI API key errors.
  • Loading branch information
ericmjl committed Nov 11, 2023
1 parent a09e69b commit bd50b90
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llamabot/cli/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from .utils import configure_environment_variable


client = OpenAI()

app = typer.Typer()


Expand Down Expand Up @@ -46,6 +44,8 @@ def default_model(model_name=None):

load_dotenv(llamabotrc_path)

client = OpenAI()

model_list = client.models.list()
available_models = [x.id for x in model_list if "gpt" in x.id]
available_models.sort()
Expand Down

0 comments on commit bd50b90

Please sign in to comment.