mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-29 01:31:41 +00:00
Add helpful ImportError messages for optional dependencies
When optional dependencies are missing, raise ImportError with installation instructions pointing to the relevant extras group (e.g. `[messaging]`, `[cli]`, `[mcp]`, etc.) instead of letting the import fail silently.
This commit is contained in:
parent
847ffca715
commit
850973295e
9 changed files with 81 additions and 14 deletions
|
|
@ -754,7 +754,13 @@ def _estimate_tool_tokens() -> Dict[str, int]:
|
|||
if _tool_token_cache is not None:
|
||||
return _tool_token_cache
|
||||
|
||||
import tiktoken
|
||||
try:
|
||||
import tiktoken
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"tiktoken is required for tool token estimation. "
|
||||
"Install with: pip install hermes-agent[cli]"
|
||||
) from None
|
||||
enc = tiktoken.get_encoding("cl100k_base")
|
||||
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue