copyWith method

CreateMessageResult copyWith({
  1. Map<String, Object?>? meta,
  2. List<SamplingMessageContentBlock>? content,
  3. String? model,
  4. Role? role,
  5. String? stopReason,
})

A copy with the given properties replaced; everything else, unknown keys included, is kept.

Implementation

CreateMessageResult copyWith({
  Map<String, Object?>? meta,
  List<SamplingMessageContentBlock>? content,
  String? model,
  Role? role,
  String? stopReason,
}) =>
    CreateMessageResult.fromJson({
      ...toJson(),
      if (meta != null) '_meta': $encode(meta),
      if (content != null) 'content': (content.length == 1 ? $encode(content.single) : $encode(content)),
      if (model != null) 'model': $encode(model),
      if (role != null) 'role': $encode(role),
      if (stopReason != null) 'stopReason': $encode(stopReason),
    });