Skip to content

Commit

Permalink
Add OpenAI org ID prompt to config setup
Browse files Browse the repository at this point in the history
  • Loading branch information
beyimjan committed Apr 1, 2024
1 parent 28db1df commit 3372a3b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions shell_whiz/cli/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,32 @@ def config() -> None:
rich.print(
"Visit https://platform.openai.com/api-keys to get your API key."
)
openai_api_key = questionary.text(
"OpenAI API key",
default=os.environ.get("OPENAI_API_KEY", ""),
validate=lambda text: len(text) > 0,
).unsafe_ask()

rich.print(
"\n[bold italic](Optional)[/] Leave blank if you are not a member of multiple organizations."
)
openai_org_id = questionary.text(
"Organization ID", default=os.environ.get("OPENAI_ORG_ID", "")
).unsafe_ask()

try:
config = ConfigModel(
openai_api_key=questionary.text(
"OpenAI API key",
default=os.environ.get("OPENAI_API_KEY", ""),
validate=lambda text: len(text) > 0,
).unsafe_ask()
openai_api_key=openai_api_key, openai_org_id=openai_org_id or None
)
except pydantic.ValidationError:
rich.print(
"[bold yellow]Error[/]: Something went wrong.", file=sys.stderr
)
raise typer.Exit(1)

print(config)
return

try:
Config.write(config)
except ConfigError as e:
Expand Down

0 comments on commit 3372a3b

Please sign in to comment.