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

move RuntimeError if no provider is given #1053

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
20 changes: 10 additions & 10 deletions lumen/command/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ def add_lumen_arguments(self, parser: argparse.ArgumentParser) -> None:
def invoke(self, args: argparse.Namespace) -> bool:
"""Override invoke to handle both sets of arguments"""
provider = args.provider
if provider is None:
raise RuntimeError(
"It looks like a Language Model provider isn't set up yet.\n"
"You have a few options to resolve this:\n\n"
"- Set environment variables with an API key: For example, OPENAI_API_KEY or ANTHROPIC_API_KEY.\n"
"- Specify a provider and API key directly: For example, set `--provider openai` with your API key via --api-key.\n"
"- Custom endpoint: If using an OpenAI-compatible API, set --provider openai and define the --provider-endpoint.\n\n"
"If you still need assistance visit the docs: https://lumen.holoviz.org/lumen_ai/how_to/llm/index.html"
)

api_key = args.api_key
endpoint = args.provider_endpoint
mode = args.validation_mode
Expand All @@ -121,16 +131,6 @@ def invoke(self, args: argparse.Namespace) -> bool:
f"Could not find LLM Provider {provider!r}, valid providers include: {list(LLM_PROVIDERS)}."
)

if provider is None:
raise RuntimeError(
"It looks like a Language Model provider isn't set up yet.\n"
"You have a few options to resolve this:\n\n"
"- Set environment variables with an API key: For example, OPENAI_API_KEY or ANTHROPIC_API_KEY.\n"
"- Specify a provider and API key directly: For example, set `--provider openai` with your API key via --api-key.\n"
"- Custom endpoint: If using an OpenAI-compatible API, set --provider openai and define the --provider-endpoint.\n\n"
"If you still need assistance visit the docs: https://lumen.holoviz.org/lumen_ai/how_to/llm/index.html"
)

model_kwargs = None
if args.model_kwargs or llm_model_url:
model_kwargs = {}
Expand Down
Loading