call method

Map<String, dynamic> call()

Converts the message to a format suitable for the API call. @return A Map<String, dynamic(text or image base64encoded)> representing the message.

Implementation

Map<String, dynamic> call() {
  Map<String, dynamic> message = {"role": EnumToString.convertToString(role)};
  message["content"] = [
    {"type": "text", "text": content},
  ];
  if (images != null) {
    if (images is Map<String, dynamic>) {
      images = [images];
    }
    message["content"].addAll(images);
  }
  return message;
}