{"record":{"id":"935d9113b020c176","repo":"2noise/ChatTTS","slug":"either-prompts-or-prompt-token-ids-must-be-provide","errorCode":null,"errorMessage":"Either prompts or prompt_token_ids must be provided.","messagePattern":"Either prompts or prompt_token_ids must be provided\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ChatTTS/model/velocity/llm.py","lineNumber":148,"sourceCode":"\n        NOTE: This class automatically batches the given prompts, considering\n        the memory constraint. For the best performance, put all of your prompts\n        into a single list and pass it to this method.\n\n        Args:\n            prompts: A list of prompts to generate completions for.\n            sampling_params: The sampling parameters for text generation. If\n                None, we use the default sampling parameters.\n            prompt_token_ids: A list of token IDs for the prompts. If None, we\n                use the tokenizer to convert the prompts to token IDs.\n            use_tqdm: Whether to use tqdm to display the progress bar.\n\n        Returns:\n            A list of `RequestOutput` objects containing the generated\n            completions in the same order as the input prompts.\n        \"\"\"\n        if prompts is None and prompt_token_ids is None:\n            raise ValueError(\"Either prompts or prompt_token_ids must be \" \"provided.\")\n        if isinstance(prompts, str):\n            # Convert a single prompt to a list.\n            prompts = [prompts]\n        if (\n            prompts is not None\n            and prompt_token_ids is not None\n            and len(prompts) != len(prompt_token_ids)\n        ):\n            raise ValueError(\n                \"The lengths of prompts and prompt_token_ids \" \"must be the same.\"\n            )\n        if sampling_params is None:\n            # Use default sampling params.\n            sampling_params = SamplingParams()\n\n        # Add requests to the engine.\n        num_requests = len(prompts) if prompts is not None else len(prompt_token_ids)\n        for i in range(num_requests):","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/2noise/ChatTTS/blob/77b89ee281cd479f5b1a787ada330dc975ca1f2a/ChatTTS/model/velocity/llm.py#L130-L166","documentation":"LLM.generate() requires input: either prompts (string or list of strings) or prompt_token_ids (list of token-id lists). Passing both as None (e.g. generate() with no arguments, or a variable that evaluated to None) raises immediately. The two arguments exist so you can skip tokenization by supplying pre-tokenized ids.","triggerScenarios":"llm.generate() with no arguments; llm.generate(prompts=None, prompt_token_ids=None); passing a variable that is None because an upstream tokenizer/extraction step failed silently.","commonSituations":"Default-argument misuse after refactoring; prompt list built from an empty filter that produced None; confusion with APIs where the prompt is optional.","solutions":["Pass prompts: llm.generate(['Hello']) or prompt_token_ids: llm.generate(prompt_token_ids=[[1,2,3]]).","If your prompt comes from a pipeline, assert it is non-None before calling generate to fail with a clearer message."],"exampleFix":"# before\nout = llm.generate(prompts, sampling_params)  # prompts is None\n\n# after\nassert prompts, 'prompt extraction failed'\nout = llm.generate(prompts, sampling_params)","handlingStrategy":"validation","validationCode":"def validated_generate(llm, prompts=None, prompt_token_ids=None, sampling_params=None):\n    if prompts is None and prompt_token_ids is None:\n        raise ValueError('no prompt: upstream extraction produced nothing')\n    if isinstance(prompts, str):\n        prompts = [prompts]\n    return llm.generate(prompts, prompt_token_ids, sampling_params)","typeGuard":null,"tryCatchPattern":"try:\n    out = llm.generate(prompts, sampling_params=sampling_params)\nexcept ValueError as e:\n    if 'must be provided' in str(e):\n        raise RuntimeError('prompt pipeline produced no input') from e\n    raise","preventionTips":["Assert prompts is non-empty right after building it.","Wrap generate() in a thin helper that validates inputs once."],"tags":["api-misuse","input-validation","generate"],"backgroundTag":"missing-required-argument","analyzedSha":"77b89ee281cd479f5b1a787ada330dc975ca1f2a","analyzedAt":"2026-08-26T17:48:24.233Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}