code: def completion(
      model: str,
      messages: list,
      model_response: ModelResponse,
      print_verbose: Callable,
      encoding,
      logging_obj,
      custom_prompt_dict={},
      optional_params=None,
      litellm_params=None,
      logger_fn=None,
  ):
      global llm
      try:
          llm, SamplingParams = validate_environment(model=model)
      except Exception as e:
          raise VLLMError(status_code=0, message=str(e))
      sampling_params = SamplingParams(**optional_params)
      if model in custom_prompt_dict:
          # check if the model has a registered custom prompt
          model_prompt_details = custom_prompt_dict[model]
          prompt = custom_prompt(
              role_dict=model_prompt_details["roles"],
              initial_prompt_value=model_prompt_details[
                  "initial_prompt_value"
              ],
              final_prompt_value=model_prompt_details[
                  "final_prompt_value"
              ],
              messages=messages,
          )
      else:
          prompt = prompt_factory(model=model, messages=messages)
  
      ## LOGGING
      logging_obj.pre_call(
          input=prompt,
          api_key="",
          additional_args={"complete_input_dict": sampling_params},
      )
  
      if llm:
          outputs = llm.generate(prompt, sampling_params)
      else:
          raise VLLMError(
              status_code=0,
              message="Need to pass in a model name to initialize vllm",
          )
  
      ## COMPLETION CALL
      if (
          "stream" in optional_params
          and optional_params["stream"] == True
      ):
          return iter(outputs)
      else:
          ## LOGGING
          logging_obj.post_call(
              input=prompt,
              api_key="",
              original_response=outputs,
              additional_args={"complete_input_dict": sampling_params},
          )
          print_verbose(f"raw model_response: {outputs}")
          ## RESPONSE OBJECT
          model_response["choices"][0]["message"]["content"] = (
              outputs[0].outputs[0].text
          )
  
          ## CALCULATING USAGE
          prompt_tokens = len(outputs[0].prompt_token_ids)
          completion_tokens = len(outputs[0].outputs[0].token_ids)
  
          model_response["created"] = int(time.time())
          model_response["model"] = model
          usage = Usage(
              prompt_tokens=prompt_tokens,
              completion_tokens=completion_tokens,
              total_tokens=prompt_tokens + completion_tokens,
          )
          model_response.usage = usage
          return model_response
  
file_path: litellm/litellm/llms/vllm.py
imports: import os
  import json
  from enum import Enum
  import requests
  import time, httpx
  from typing import Callable, Any
  from litellm.utils import ModelResponse, Usage
  from .prompt_templates.factory import prompt_factory, custom_prompt
label_desc: Use image node_id 2 for calling a global function with example usage: completion(model, messages, model_response, print_verbose, encoding, logging_obj, custom_prompt_dict, optional_params, litellm_params, logger_fn) and returns: iter, model_response