{"record":{"id":"37a0a7420f7fc96d","repo":"zylon-ai/private-gpt","slug":"mistral-tokenizer-dependencies-are-not-installed","errorCode":null,"errorMessage":"Mistral tokenizer dependencies are not installed. Install with `uv sync --inexact --extra llm-mistral`.","messagePattern":"Mistral tokenizer dependencies are not installed\\. Install with `uv sync --inexact --extra llm-mistral`\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/llm/tokenizers/mistral.py","lineNumber":34,"sourceCode":"    AudioLike,\n    ImageLike,\n    TextLike,\n    TokenizedInput,\n    TokenizerBase,\n)\nfrom private_gpt.utils.dependencies import format_missing_dependency_message\n\nChatMessageType: TypeAlias = Any\nTokenized: TypeAlias = Any\nPublicMistralTokenizer: TypeAlias = Any\n\n\n@lru_cache\ndef _load_mistral_module(module_name: str) -> Any:\n    try:\n        return importlib.import_module(module_name)\n    except ImportError as e:\n        raise ImportError(\n            format_missing_dependency_message(\n                \"Mistral tokenizer\",\n                extras=\"llm-mistral\",\n            )\n        ) from e\n\n\n_messages_module = _load_mistral_module(\"mistral_common.protocol.instruct.messages\")\nAssistantMessage = _messages_module.AssistantMessage\nSystemMessage = _messages_module.SystemMessage\nToolMessage = _messages_module.ToolMessage\nUserMessage = _messages_module.UserMessage\n\nlogger = logging.getLogger(__name__)\n\n\ndef is_list_of(\n    value: object,","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/llm/tokenizers/mistral.py#L16-L52","documentation":"MistralTokenizer lazily imports modules from mistral_common via _load_mistral_module; module-level imports like mistral_common.protocol.instruct.messages run at import time. If mistral-common is missing, ImportError is raised with the hint to install the llm-mistral extra.","triggerScenarios":"Importing private_gpt.components.llm.tokenizers.mistral (or using tokenizer_mode='mistral') in an environment where mistral-common is not installed. Because several imports happen at module level, the error fires as soon as the module is imported.","commonSituations":"Minimal installs without the llm-mistral extra; deploying for a different backend (openai/local) but config or DI still selects the mistral tokenizer; fresh venvs created from a trimmed lockfile.","solutions":["Install the extra: uv sync --inexact --extra llm-mistral.","Verify: python -c \"import mistral_common\".","If Mistral is not intended, change tokenizer_mode away from 'mistral'."],"exampleFix":"# before: tokenizer_mode='mistral' without mistral-common\n# after\nuv sync --inexact --extra llm-mistral","handlingStrategy":"validation","validationCode":"def mistral_deps_available() -> bool:\n    try:\n        import mistral_common  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\nassert mistral_deps_available(), 'install: uv sync --inexact --extra llm-mistral'","typeGuard":null,"tryCatchPattern":"try:\n    from private_gpt.components.llm.tokenizers.mistral import MistralTokenizer\nexcept ImportError as e:\n    raise RuntimeError('tokenizer_mode=mistral requires the llm-mistral extra') from e","preventionTips":["Install the llm-mistral extra whenever tokenizer_mode='mistral' is configured.","Probe optional deps at startup for the selected mode.","Keep mistral-common pinned via the project lockfile to avoid version drift."],"tags":["dependencies","import","mistral","tokenizer"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}