code: def convert_messages_to_prompt(
      model, messages, provider, custom_prompt_dict
  ):
      # handle anthropic prompts using anthropic constants
      if provider == "anthropic":
          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,
                  custom_llm_provider="anthropic",
              )
      else:
          prompt = ""
          for message in messages:
              if "role" in message:
                  if message["role"] == "user":
                      prompt += f"{message['content']}"
                  else:
                      prompt += f"{message['content']}"
              else:
                  prompt += f"{message['content']}"
      return prompt
  
imports: import json, copy, types
  import os
  from enum import Enum
  import time
  from typing import Callable, Optional, Any, Union
  import litellm
  from litellm.utils import ModelResponse, get_secret, Usage
  from .prompt_templates.factory import prompt_factory, custom_prompt
  import httpx
label_desc: Use image node_id 2 for calling a global function with example usage: convert_messages_to_prompt(model, messages, provider, custom_prompt_dict) and returns: prompt