Updated error message for invalid or missing embedding model (#257)

* Updated error message for missing embedding model

---------

Co-authored-by: Simon Willison <swillison@gmail.com>
This commit is contained in:
Alexis Métaireau 2023-09-10 20:56:29 +02:00 committed by GitHub
parent ab05023b30
commit df32d7685d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -1082,7 +1082,7 @@ def embed(collection, id, input, model, store, database, content, metadata, form
model = get_default_embedding_model()
if model is None:
raise click.ClickException(
"You need to specify a model (no default model is set)"
"You need to specify an embedding model (no default model is set)"
)
collection_obj = Collection(collection, db=db, model_id=model)
model_obj = collection_obj.model()
@ -1092,7 +1092,7 @@ def embed(collection, id, input, model, store, database, content, metadata, form
model_obj = get_embedding_model(model)
except UnknownModelError:
raise click.ClickException(
"You need to specify a model (no default model is set)"
"You need to specify an embedding model (no default model is set)"
)
show_output = True
@ -1216,7 +1216,7 @@ def embed_multi(
)
except ValueError:
raise click.ClickException(
"You need to specify a model (no default model is set)"
"You need to specify an embedding model (no default model is set)"
)
expected_length = None

View file

@ -474,7 +474,10 @@ def test_default_embed_model_errors(user_path, default_is_set, command):
assert result.exit_code == 0
else:
assert result.exit_code == 1
assert "You need to specify a model (no default model is set)" in result.output
assert (
"You need to specify an embedding model (no default model is set)"
in result.output
)
# Now set the default model and try again
result2 = runner.invoke(cli, ["embed-models", "default", "embed-demo"])
assert result2.exit_code == 0