{"record":{"id":"5c7f005a5695b870","repo":"xtekky/gpt4free","slug":"model-model-file-not-found","errorCode":null,"errorMessage":"Model \"{model_file}\" not found.","messagePattern":"Model \"(.+?)\" not found\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"g4f/locals/provider.py","lineNumber":54,"sourceCode":"    def create_completion(\n        model: str, messages: Messages, stream: bool = False, **kwargs\n    ):\n        global MODEL_LIST\n        if MODEL_LIST is None:\n            MODEL_LIST = get_models()\n        if model not in MODEL_LIST:\n            raise ValueError(f'Model \"{model}\" not found / not yet implemented')\n\n        model = MODEL_LIST[model]\n        model_file = model[\"path\"]\n        model_dir = find_model_dir(model_file)\n        if not os.path.isfile(os.path.join(model_dir, model_file)):\n            print(f'Model file \"models/{model_file}\" not found.')\n            download = input(f\"Do you want to download {model_file}? [y/n]: \")\n            if download in [\"y\", \"Y\"]:\n                GPT4All.download_model(model_file, model_dir)\n            else:\n                raise ValueError(f'Model \"{model_file}\" not found.')\n\n        model = GPT4All(\n            model_name=model_file,\n            # n_threads=8,\n            verbose=False,\n            allow_download=False,\n            model_path=model_dir,\n        )\n\n        system_message = \"\\n\".join(\n            message[\"content\"] for message in messages if message[\"role\"] == \"system\"\n        )\n        if system_message:\n            system_message = \"A chat between a curious user and an artificial intelligence assistant.\"\n\n        prompt_template = \"USER: {0}\\nASSISTANT: \"\n        conversation = (\n            \"\\n\".join(","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/locals/provider.py#L36-L72","documentation":"Thrown by LocalProvider.create_completion() when the cataloged model file is not present under the models directory and the interactive download prompt was declined (or received anything other than y/Y). Note it calls input(): in a non-TTY context (server, cron, subprocess) input() raises EOFError first, so this exact ValueError mostly appears in interactive sessions.","triggerScenarios":"First use of a local model whose GGUF file was never downloaded; answering 'n' at the 'Do you want to download ...? [y/n]' prompt; a models dir where the file was deleted or the filename in models.yaml doesn't match what's on disk.","commonSituations":"Fresh installs expecting local models to be bundled (they are not); deployments where the prompt hangs or EOFs because stdin is closed; partial downloads leaving a wrong-sized/absent file.","solutions":["Run once interactively and answer 'y' to let GPT4All.download_model fetch the file.","Or pre-download manually: place the GGUF from the catalog entry into the models dir with the exact 'path' filename from models.yaml.","For headless servers, pre-populate the models directory in the image/deploy step so the prompt never triggers (it also avoids the EOFError from input())."],"exampleFix":"// before\n# headless call with no model file on disk -> input() EOFError / decline -> ValueError\nLocalProvider.create_completion(model=name, messages=msgs)\n\n// after\n# pre-provision the file (deploy step):\n# curl -L -o models/<model_file_from_models_yaml> <gguf_url>\nLocalProvider.create_completion(model=name, messages=msgs)","handlingStrategy":"validation","validationCode":"from g4f.locals.provider import get_models, find_model_dir\nimport os\n\ndef model_file_present(model: str) -> bool:\n    entry = get_models().get(model)\n    if entry is None:\n        return False\n    d = find_model_dir(entry[\"path\"])\n    return os.path.isfile(os.path.join(d, entry[\"path\"]))","typeGuard":null,"tryCatchPattern":"try:\n    LocalProvider.create_completion(model=model, messages=msgs)\nexcept (EOFError, ValueError) as e:\n    # EOFError: input() in non-TTY; ValueError: download declined\n    raise RuntimeError(f\"model file missing for {model}; pre-provision it\") from e","preventionTips":["Pre-download model files in your deploy step; never rely on the interactive prompt in servers.","Verify file names match models.yaml 'path' entries exactly."],"tags":["local-provider","model-download","gpt4all","interactive"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}