Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Nov 26, 2024
1 parent 14539a8 commit 29ab06a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions shiny/ui/_chat_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ def get_default_tokenizer() -> TokenizersTokenizer:
return Tokenizer.from_pretrained("bert-base-cased") # type: ignore
except ImportError:
raise ValueError(
"A tokenizer is required to impose `token_limits` on messages. "
"Failed to download a default tokenizer. "
"A tokenizer is required to impose `token_limits` on `chat.messages()`. "
"To get a generic default tokenizer, install the `tokenizers` "
"package (`pip install tokenizers`). "
"To get a more precise token count, provide a specific tokenizer "
"to the `Chat` constructor."
)
except Exception as e:
raise ValueError(
"Failed to load the default tokenizer. "
"Ensure that the `tokenizers` package is installed and "
"that the `bert-base-cased` model is available. "
"Failed to download a default tokenizer. "
"A tokenizer is required to impose `token_limits` on `chat.messages()`. "
"Try downloading a different tokenizer using "
"`tokenizers.Tokenizer.from_pretrained()`. "
f"Error: {e}"
) from e

0 comments on commit 29ab06a

Please sign in to comment.