{"record":{"id":"4a5e9ba18bfcea41","repo":"VectifyAI/PageIndex","slug":"chat-is-an-empty-dict-chat-takes-model-and-ba","errorCode":null,"errorMessage":"chat is an empty dict — chat takes \"model\" and \"backend\" (your own model), or {\"mode\": \"cloud\"} / \"cloud\" for the managed chat.","messagePattern":"chat is an empty dict — chat takes \"model\" and \"backend\" \\(your own model\\), or (.+?) / \"cloud\" for the managed chat\\.","errorType":"validation","errorClass":"PageIndexAPIError","httpStatus":null,"severity":"error","filePath":"pageindex/client.py","lineNumber":205,"sourceCode":"        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 '\n                    f\"({', '.join(sorted(conf))}) — the managed chat \"\n                    \"selects its own model. Drop the mode, or the keys.\")\n            return \"managed\", {}\n        mapped = {\"chat_model\": conf.get(\"model\"),\n                  \"chat_backend\": conf.get(\"backend\")}\n        return \"own\", {name: value for name, value in mapped.items()\n                       if value is not None}\n    raise PageIndexAPIError(\"chat must be a string or a dict.\")\n\n","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/VectifyAI/PageIndex/blob/afb5e119766630af6014b04fe8b53357527bc05e/pageindex/client.py#L187-L223","documentation":"chat was given as a dict but, after dropping None-valued keys and any mode key, nothing remained to configure. The dict form exists to carry \"model\"/\"backend\" (or {\"mode\": \"cloud\"}); an effectively empty dict declares no chat at all, which the SDK treats as a mistake rather than silently ignoring it.","triggerScenarios":"PageIndexClient(chat={}), chat={\"model\": None}, chat={\"mode\": None}, or chat built from a config dict whose keys are all None.","commonSituations":"Forwarding a YAML/JSON config block where chat: is present but empty or only has null fields; merging dicts that filtered out all real values.","solutions":["Populate the dict with \"model\" and/or \"backend\": chat={\"model\": \"gpt-4o-mini\", \"backend\": {...}}","Use {\"mode\": \"cloud\"} for the managed chat","Remove the chat= argument entirely if no chat config is intended","Filter None values before passing so an all-None dict becomes chat=None"],"exampleFix":"# before\nPageIndexClient(chat={\"model\": cfg.get(\"model\")})  # cfg has no model → {\"model\": None}\n# after\nPageIndexClient(chat={k: v for k, v in cfg.items() if v is not None} or None)","handlingStrategy":"validation","validationCode":"chat_conf = {k: v for k, v in raw_chat.items() if v is not None} if isinstance(raw_chat, dict) else raw_chat\nif chat_conf == {}:\n    chat_conf = None\nclient = PageIndexClient(chat=chat_conf)","typeGuard":"def chat_dict_ok(d: dict) -> bool:\n    return bool({k: v for k, v in d.items() if v is not None and k != \"mode\"}) or d.get(\"mode\") is not None","tryCatchPattern":null,"preventionTips":["Filter None-valued keys from config dicts and collapse empty results to None","Validate loaded YAML blocks before passing them as slot dicts"],"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"}