module RubyLLM::Provider::InstanceMethods

def to_json_stream(&block)

def to_json_stream(&block)
  parser = EventStreamParser::Parser.new
  proc do |chunk, _bytes, _|
    parser.feed(chunk) do |_type, data|
      unless data == '[DONE]'
        parsed_data = JSON.parse(data)
        RubyLLM.logger.debug "chunk: #{parsed_data}"
        block.call(parsed_data)
      end
    end
  end
end