using System;
using System.Runtime.InteropServices;
namespace LLama.Native;
using llama_token = Int32;
///
/// Information about a single beam in a beam search
///
[StructLayout(LayoutKind.Sequential)]
public struct LLamaBeamView
{
private unsafe llama_token* tokens;
private nint n_tokens;
///
/// Cumulative beam probability (renormalized relative to all beams)
///
public float CumulativeProbability;
///
/// Callback should set this to true when a beam is at end-of-beam.
///
public bool EndOfBeam;
///
/// Tokens in this beam
///
public readonly Span Tokens
{
get
{
unsafe
{
if (n_tokens > int.MaxValue)
throw new InvalidOperationException("More than 2147483647 tokens is not supported");
return new Span(tokens, (int)n_tokens);
}
}
}
}