{"record":{"id":"c92111212c830cee","repo":"huggingface/transformers","slug":"you-need-to-install-rich-to-use-the-chat-interface","errorCode":null,"errorMessage":"You need to install rich to use the chat interface. (`pip install rich`)","messagePattern":"You need to install rich to use the chat interface\\. \\(`pip install rich`\\)","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"src/transformers/cli/chat.py","lineNumber":379,"sourceCode":"        config.update(do_sample=True, max_new_tokens=256)  # some default values\n        config.update(**parse_generate_flags(generate_flags))\n        self.config = config\n\n        self.settings = {\"base_url\": base_url, \"model_id\": model_id, \"config\": self.config.to_dict()}\n\n        # User settings\n        self.user = user if user is not None else get_username()\n\n        # Load examples\n        if examples_path:\n            with open(examples_path) as f:\n                self.examples = yaml.safe_load(f)\n        else:\n            self.examples = DEFAULT_EXAMPLES\n\n        # Check requirements\n        if not is_rich_available():\n            raise ImportError(\"You need to install rich to use the chat interface. (`pip install rich`)\")\n\n        # Run chat session\n        asyncio.run(self._inner_run())\n\n    @staticmethod\n    def check_health(url):\n        health_url = urljoin(get_service_root_url(url) + \"/\", \"health\")\n        try:\n            output = httpx.get(health_url)\n            if output.status_code != 200:\n                raise ValueError(\n                    f\"The server running on {url} returned status code {output.status_code} on health check (/health).\"\n                )\n        except httpx.ConnectError:\n            raise ValueError(\n                f\"No server currently running on {url}. To run a local server, please run `transformers serve` in a\"\n                f\"separate shell. Find more information here: https://huggingface.co/docs/transformers/serving\"\n            )","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/cli/chat.py#L361-L397","documentation":"The `transformers chat` command renders its interface with the rich library, which is an optional dependency. ChatInterface.__init__ (via its run path) checks is_rich_available() and raises ImportError telling you to `pip install rich` when it is missing. Without rich there is no usable terminal UI, so the command aborts before connecting.","triggerScenarios":"Running `transformers chat` in an environment where transformers was installed without optional UI extras and rich is absent; slim Docker images; poetry/uv lock files that dropped rich.","commonSituations":"Minimal production containers; a fresh venv with only `pip install transformers`; rich removed during dependency pruning or a conflict-resolution downgrade.","solutions":["pip install rich","Or install the serving extras which include UI deps: pip install \"transformers[serving]\"","Re-run transformers chat"],"exampleFix":"# before\ntransformers chat  # ImportError: need rich\n\n# after\npip install rich\ntransformers chat","handlingStrategy":"validation","validationCode":"try:\n    import rich  # noqa\nexcept ImportError:\n    raise SystemExit(\"pip install rich (or transformers[serving]) before using transformers chat\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install transformers[serving] in environments used for chat/serve","Pin rich in lockfiles for images that run the CLI","Smoke-test `transformers chat --help` in new environments"],"tags":["cli","missing-dependency","rich","importerror","chat"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}