llamaBatchAdd method

llama_batch llamaBatchAdd({
  1. required llama_batch batch,
  2. required int token,
  3. required int pos,
  4. required List<int> seqIds,
  5. required bool logits,
})

Add a token to the batch.

Implementation

llama_batch llamaBatchAdd({
  required llama_batch batch,
  required int token,
  required int pos,
  required List<int> seqIds,
  required bool logits,
}) {
  batch.token[batch.n_tokens] = token;
  batch.pos[batch.n_tokens] = pos;
  batch.n_seq_id[batch.n_tokens] = seqIds.length;

  for (var i = 0; i < seqIds.length; ++i) {
    batch.seq_id[batch.n_tokens][i] = seqIds[i];
  }

  batch.logits[batch.n_tokens] = logits ? 1 : 0;
  batch.n_tokens += 1;

  return batch;
}