From 2df3e7617e03a5872e7995cfc7b302c50f652bf4 Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Fri, 15 Dec 2023 22:55:04 +0000 Subject: [PATCH] Added a method to set the RNG seed on the context --- LLama/LLamaContext.cs | 9 +++++++++ LLama/Native/SafeLLamaContextHandle.cs | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/LLama/LLamaContext.cs b/LLama/LLamaContext.cs index 2902dc8f..3496e967 100644 --- a/LLama/LLamaContext.cs +++ b/LLama/LLamaContext.cs @@ -86,6 +86,15 @@ namespace LLama NativeHandle = SafeLLamaContextHandle.Create(model.NativeHandle, lparams); } + /// + /// Set the seed for the RNG + /// + /// + public void SetSeed(uint seed) + { + NativeApi.llama_set_rng_seed(NativeHandle, seed); + } + /// /// Tokenize a string. /// diff --git a/LLama/Native/SafeLLamaContextHandle.cs b/LLama/Native/SafeLLamaContextHandle.cs index bb49cc0f..df33076f 100644 --- a/LLama/Native/SafeLLamaContextHandle.cs +++ b/LLama/Native/SafeLLamaContextHandle.cs @@ -283,5 +283,14 @@ namespace LLama.Native } } #endregion + + /// + /// Set the RNG seed + /// + /// + public void SetSeed(uint seed) + { + NativeApi.llama_set_rng_seed(this, seed); + } } }