using System; using System.Runtime.InteropServices; namespace LLama.Native; public static partial class NativeApi { /// /// Type of pointer to the beam_search_callback function. /// /// callback_data is any custom data passed to llama_beam_search, that is subsequently passed back to beam_search_callbac /// public delegate void LLamaBeamSearchCallback(IntPtr callback_data, LLamaBeamsState state); /// Deterministically returns entire sentence constructed by a beam search. /// Pointer to the llama_context. /// Invoked for each iteration of the beam_search loop, passing in beams_state. /// A pointer that is simply passed back to callback. /// Number of beams to use. /// Number of tokens already evaluated. /// Maximum number of tokens to predict. EOS may occur earlier. /// Number of threads. [DllImport(libraryName, EntryPoint = "llama_beam_search", CallingConvention = CallingConvention.Cdecl)] public static extern void llama_beam_search(SafeLLamaContextHandle ctx, LLamaBeamSearchCallback callback, IntPtr callback_data, ulong n_beams, int n_past, int n_predict, int n_threads); }