Nicer error message for unknown models with -c mode, closes #92

This commit is contained in:
Simon Willison 2023-07-11 19:29:54 -07:00
parent 9a226a8b43
commit 7bef414de7
2 changed files with 6 additions and 2 deletions

View file

@ -79,7 +79,7 @@ def get_model(name):
try:
return aliases[name]
except KeyError:
raise UnknownModelError(name)
raise UnknownModelError("Unknown model: " + name)
def get_key(key_arg, default_key, env_var=None):

View file

@ -5,6 +5,7 @@ from llm import (
Conversation,
Response,
Template,
UnknownModelError,
get_key,
get_plugins,
get_model,
@ -184,7 +185,10 @@ def prompt(
conversation = None
if conversation_id or _continue:
# Load the conversation - loads most recent if no ID provided
conversation = load_conversation(conversation_id)
try:
conversation = load_conversation(conversation_id)
except UnknownModelError as ex:
raise click.ClickException(str(ex))
# Figure out which model we are using
if model_id is None: