From b55b97ba5ef6478caad4cb107b9518607ca21bee Mon Sep 17 00:00:00 2001 From: jhen Date: Fri, 19 Jan 2024 10:20:39 +0800 Subject: [PATCH] fix: use -1 instead of LLAMA_DEFAULT_SEED for default seed --- android/src/main/java/com/rnllama/LlamaContext.java | 3 +-- ios/RNLlamaContext.mm | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/rnllama/LlamaContext.java b/android/src/main/java/com/rnllama/LlamaContext.java index 0f2497d..0fc8500 100644 --- a/android/src/main/java/com/rnllama/LlamaContext.java +++ b/android/src/main/java/com/rnllama/LlamaContext.java @@ -20,7 +20,6 @@ public class LlamaContext { public static final String NAME = "RNLlamaContext"; - private static final int LLAMA_DEFAULT_SEED = 0xFFFFFFFF; private int id; private ReactApplicationContext reactContext; @@ -175,7 +174,7 @@ public WritableMap completion(ReadableMap params) { // float typical_p, params.hasKey("typical_p") ? (float) params.getDouble("typical_p") : 1.00f, // int seed, - params.hasKey("seed") ? params.getInt("seed") : LLAMA_DEFAULT_SEED, + params.hasKey("seed") ? params.getInt("seed") : -1, // String[] stop, params.hasKey("stop") ? params.getArray("stop").toArrayList().toArray(new String[0]) : new String[0], // boolean ignore_eos, diff --git a/ios/RNLlamaContext.mm b/ios/RNLlamaContext.mm index 6012997..8a1bbe7 100644 --- a/ios/RNLlamaContext.mm +++ b/ios/RNLlamaContext.mm @@ -164,7 +164,7 @@ - (NSDictionary *)completion:(NSDictionary *)params if (params[@"typical_p"]) sparams.typical_p = [params[@"typical_p"] doubleValue]; - llama_set_rng_seed(llama->ctx, params[@"seed"] ? [params[@"seed"] intValue] : LLAMA_DEFAULT_SEED); + llama_set_rng_seed(llama->ctx, params[@"seed"] ? [params[@"seed"] intValue] : -1); if (params[@"grammar"]) { sparams.grammar = [params[@"grammar"] UTF8String];