concat method

Merges this result with another by concatenating the outputs.

Implementation

@override
ChatResult concat(
  final LanguageModelResult<AIChatMessage> other,
) {
  return ChatResult(
    id: other.id.isNotEmpty ? other.id : id,
    output: output.concat(other.output),
    finishReason: finishReason != FinishReason.unspecified &&
            other.finishReason == FinishReason.unspecified
        ? finishReason
        : other.finishReason,
    metadata: {
      ...metadata,
      ...other.metadata,
    },
    usage: usage.concat(other.usage),
    streaming: other.streaming,
  );
}