code: def _convert_text_completion_to_chat(
      completion: llama_types.Completion,
  ) -> llama_types.ChatCompletion:
      return {
          "id": "chat" + completion["id"],
          "object": "chat.completion",
          "created": completion["created"],
          "model": completion["model"],
          "choices": [
              {
                  "index": 0,
                  "message": {
                      "role": "assistant",
                      "content": completion["choices"][0]["text"],
                  },
                  "finish_reason": completion["choices"][0][
                      "finish_reason"
                  ],
              }
          ],
          "usage": completion["usage"],
      }
  
imports: from __future__ import annotations
  import os
  import json
  import ctypes
  import dataclasses
  from typing import Any, Dict, Iterator, List, Optional, Tuple, Union, Protocol
  import llama_cpp.llama
  import llama_cpp.llama_types
  import llama_cpp.llama_grammar
  from ._utils import suppress_stdout_stderr
label_desc: Use image node_id 12 for calling a global function with example usage: _convert_text_completion_to_chat(completion) and returns: dict