diff --git a/src/llama_stack_client/lib/cli/configure.py b/src/llama_stack_client/lib/cli/configure.py index 9ad4bae5..0319acbe 100644 --- a/src/llama_stack_client/lib/cli/configure.py +++ b/src/llama_stack_client/lib/cli/configure.py @@ -10,6 +10,7 @@ import yaml from prompt_toolkit import prompt from prompt_toolkit.validation import Validator +from urllib.parse import urlparse from llama_stack_client.lib.cli.constants import LLAMA_STACK_CLIENT_CONFIG_DIR, get_config_file_path @@ -36,8 +37,8 @@ def configure(endpoint: str | None, api_key: str | None): final_endpoint = prompt( "> Enter the endpoint of the Llama Stack distribution server: ", validator=Validator.from_callable( - lambda x: len(x) > 0, - error_message="Endpoint cannot be empty, please enter a valid endpoint", + lambda x: len(x) > 0 and (parsed := urlparse(x)).scheme and parsed.netloc, + error_message="Endpoint cannot be empty and must be a valid URL, please enter a valid endpoint", ), )