class Anthropic::Helpers::Streaming::MessageStream

def accumulated_text

Returns:
  • (String) -

Other tags:
    Api: - public
def accumulated_text
  message = accumulated_message
  text_blocks = []
  message.content.each do |block|
    if block.type == :text
      text_blocks << block.text
    end
  end
  if text_blocks.empty?
    raise RuntimeError.new("Expected to have received at least 1 text block")
  end
  text_blocks.join
end