class_docstr: A prompter that generates prompts for the ShareGPT
class_docstr_tok: ["A","prompter","that","generates","prompts","for","the","ShareGPT"]
code: def _build_result(self, source):
      if len(source) < 2:
          # If there isn't a back and forth conversation, ignore it
          # also happens on the data splitting leaving empty conversations
          raise IndexError(
              f"A conversation entry has less than 2 messages :\n{source}"
          )
  
      conv = self._conversation.copy()
  
      # Add the conversation system prompt if provided, otherwise use the default one
      if source[0]["from"] == "system":
          conv.set_system_message(source[0]["value"])
          source.pop(0)
  
      roles = {
          self.role_key_human: conv.roles[0],
          self.role_key_model: conv.roles[1],
      }
  
      try:
          # Apply prompt templates
          if source[0]["from"] not in roles:
              # Skip the first one if it is not from human
              source = source[1:]
      except IndexError as err:
          # sometimes there is a bing or system chat
          raise err
  
      conv.messages = []
      for _, sentence in enumerate(source):
          role = roles[sentence["from"]]
          if len(conv.messages) > 0 and (
              (role == conv.messages[-1][0]) or (role not in conv.roles)
          ):
              LOG.warning(
                  f"{SHAREGPT_ASSERTION_FAILED_ROLE}: {sentence}"
              )
          conv.append_message(role, sentence["value"])
  
      return conv.get_turns()
  
imports: import logging
  from enum import Enum
  from typing import Generator, Optional, Union
  from colorama import Fore
  from fastchat.conversation import Conversation, get_conv_template
label_desc: Use image node_id 2 for calling the ShareGPTPrompter obj's underlying member method code with example usage: obj._build_result(source) and returns: conv