{"record":{"id":"464305a7000ba569","repo":"oobabooga/textgen","slug":"unexpected-response-format-completion-probabilit","errorCode":null,"errorMessage":"Unexpected response format: 'completion_probabilities' not found in {result}","messagePattern":"Unexpected response format: 'completion_probabilities' not found in (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"modules/llama_cpp_server.py","lineNumber":321,"sourceCode":"            logger.info(\"GENERATE_PARAMS=\")\n            printable_payload = {k: v for k, v in payload.items() if k != \"prompt\"}\n            pprint.PrettyPrinter(indent=4, sort_dicts=False).pprint(printable_payload)\n            print()\n\n        def _try_fetch_logits():\n            for retry in range(5):\n                response = self.session.post(url, json=payload)\n                result = response.json()\n\n                if \"completion_probabilities\" in result:\n                    if use_samplers:\n                        return result[\"completion_probabilities\"][0][\"top_probs\"]\n                    else:\n                        return result[\"completion_probabilities\"][0][\"top_logprobs\"]\n\n                time.sleep(0.05)\n            else:\n                raise Exception(f\"Unexpected response format: 'completion_probabilities' not found in {result}\")\n\n        result = _try_fetch_logits()\n        for entry in result:\n            if not entry.get('token'):\n                entry['token'] = self.decode([entry['id']])\n        return result\n\n    def get_prompt_logprob_entries(self, token_ids, n_probs=5, prompt=\"\"):\n        \"\"\"Get logprob entries for prompt tokens via a single n_predict=0 request.\n\n        Requires llama.cpp server with prompt_logprobs support.\n        Returns entries in the standard format for format_completion_logprobs().\n        \"\"\"\n        token_ids_list = token_ids.tolist() if hasattr(token_ids, 'tolist') else list(token_ids)\n\n        url = f\"http://127.0.0.1:{self.port}/completion\"\n        payload = {\n            \"prompt\": token_ids_list,","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/oobabooga/textgen/blob/ed888c71f221df552750e1834b3654abab8ae345/modules/llama_cpp_server.py#L303-L339","documentation":"Error \"Unexpected response format: 'completion_probabilities' not found in {result}\" thrown in oobabooga/textgen.","triggerScenarios":"Raised when the llama.cpp server response to a logprobs/completion-probabilities request does not contain the 'completion_probabilities' field. Triggers when the loaded model or llama.cpp server build does not support probabilities for the request, or when the server returned an error-shaped response instead.","commonSituations":"See trigger scenarios.","solutions":["Enable logprobs/completion probabilities on the llama.cpp server request so 'completion_probabilities' is returned.","Check that the server response is not an error payload before reading 'completion_probabilities'."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ed888c71f221df552750e1834b3654abab8ae345","analyzedAt":"2026-08-15T05:24:21.000Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}