{"record":{"id":"03708655f1de1c45","repo":"VectifyAI/PageIndex","slug":"chat-is-an-empty-string-pass-a-model-name-or-c","errorCode":null,"errorMessage":"chat is an empty string — pass a model name, or \"cloud\" for the managed chat.","messagePattern":"chat is an empty string — pass a model name, or \"cloud\" for the managed chat\\.","errorType":"validation","errorClass":"PageIndexAPIError","httpStatus":null,"severity":"error","filePath":"pageindex/client.py","lineNumber":195,"sourceCode":"\n\ndef _resolve_chat_slot(chat) -> \"tuple[Optional[str], dict[str, Any]]\":\n    \"\"\"The ``chat=`` slot as (mode, own-model overrides) — mode is\n    \"managed\", \"own\", or None (nothing declared beyond the overrides).\"\"\"\n    from .types import PAGEINDEX_CLOUD\n    if isinstance(chat, str):\n        word = chat.strip().lower()\n        if word in (PAGEINDEX_CLOUD, \"cloud\"):\n            return \"managed\", {}\n        if word == \"local\":\n            return \"own\", {}\n        if word in _RESERVED_MODE_WORDS:\n            raise PageIndexAPIError(\n                f'chat=\"{chat}\" is not a mode word — the managed chat is '\n                'chat=\"cloud\".')\n        if chat.strip():\n            return \"own\", {\"chat_model\": chat}\n        raise PageIndexAPIError(\n            \"chat is an empty string — pass a model name, or \"\n            '\"cloud\" for the managed chat.')\n    if isinstance(chat, Mapping):\n        # None-valued keys mean \"absent\", exactly like the flat arguments.\n        conf = {name: value for name, value in chat.items()\n                if value is not None}\n        declared = _declared_mode(conf.pop(\"mode\", None), \"chat\")\n        unknown = set(conf) - {\"model\", \"backend\"}\n        if (not conf and declared is None) or unknown:\n            raise PageIndexAPIError(\n                (\"chat is an empty dict\" if not conf else\n                 f\"Unknown chat keys ({', '.join(sorted(unknown))})\")\n                + ' — chat takes \"model\" and \"backend\" (your own model), '\n                'or {\"mode\": \"cloud\"} / \"cloud\" for the managed chat.')\n        if declared == \"cloud\":\n            if conf:\n                raise PageIndexAPIError(\n                    'chat declares mode \"cloud\" but carries '","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/VectifyAI/PageIndex/blob/afb5e119766630af6014b04fe8b53357527bc05e/pageindex/client.py#L177-L213","documentation":"The chat argument was a string, but blank (empty or whitespace-only) after checking it isn't a reserved mode word. The library rejects it because an empty model name would configure nothing and the intended mode (own model vs managed cloud chat) becomes ambiguous. Pass a real model name or the string \"cloud\".","triggerScenarios":"Calling PageIndexClient(chat=\"\"), chat=\"   \", or passing chat=os.getenv(\"CHAT_MODEL\") when the env var is unset (yields \"\").","commonSituations":"Reading the chat model from an environment variable that is not set; copy-pasting a config template with a placeholder left empty; programmatically building kwargs where the model field defaults to \"\".","solutions":["Pass a real model name, e.g. chat=\"gpt-4o-mini\" (or \"cloud\" for the managed chat)","If the value comes from an env var, guard it: chat=os.environ.get(\"CHAT_MODEL\") or \"cloud\"","Drop the chat argument entirely if you don't want to configure the chat side"],"exampleFix":"# before\nPageIndexClient(chat=os.getenv(\"CHAT_MODEL\", \"\"))\n# after\nPageIndexClient(chat=os.getenv(\"CHAT_MODEL\") or \"cloud\")","handlingStrategy":"validation","validationCode":"chat = os.getenv(\"CHAT_MODEL\")\nif chat is not None and not chat.strip():\n    chat = \"cloud\"  # or raise\nclient = PageIndexClient(chat=chat)","typeGuard":"def valid_chat_str(chat: str) -> bool:\n    return isinstance(chat, str) and bool(chat.strip())","tryCatchPattern":null,"preventionTips":["Never default env lookups to \"\" — use os.getenv(...) which returns None","Normalize empty/whitespace strings to None before passing them to the client"],"tags":["config","chat","empty-argument"],"backgroundTag":"empty-config-value","analyzedSha":"afb5e119766630af6014b04fe8b53357527bc05e","analyzedAt":"2026-08-27T11:20:48.519Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}