@dr33m/react-native-litert-lm 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -431,15 +431,16 @@ public class HybridLiteRTLM: HybridLiteRTLMSpec_base, HybridLiteRTLMSpec_protoco
431
431
 
432
432
  litert_lm_session_config_set_max_output_tokens(sessionConfig, Int32(self.maxOutputTokens))
433
433
 
434
- var sampler = LiteRtLmSamplerParams()
435
- sampler.type = kLiteRtLmSamplerTypeTopP
436
- sampler.top_k = Int32(self.topK)
437
- sampler.top_p = Float(self.topP)
438
- sampler.temperature = Float(self.temperature)
439
- sampler.seed = 0
440
- withUnsafePointer(to: &sampler) { samplerPtr in
441
- litert_lm_session_config_set_sampler_params(sessionConfig, samplerPtr)
442
- }
434
+ // v0.15: sampler params are opaque — built through create/setters
435
+ // instead of a stack struct. set_sampler_params copies the values into
436
+ // the session config, so the params can be freed when this scope ends.
437
+ guard let sampler = litert_lm_sampler_params_create(kLiteRtLmSamplerTypeTopP) else { return }
438
+ defer { litert_lm_sampler_params_delete(sampler) }
439
+ litert_lm_sampler_params_set_top_k(sampler, Int32(self.topK))
440
+ litert_lm_sampler_params_set_top_p(sampler, Float(self.topP))
441
+ litert_lm_sampler_params_set_temperature(sampler, Float(self.temperature))
442
+ litert_lm_sampler_params_set_seed(sampler, 0)
443
+ litert_lm_session_config_set_sampler_params(sessionConfig, sampler)
443
444
 
444
445
  litert_lm_conversation_config_set_session_config(convConfig, sessionConfig)
445
446
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dr33m/react-native-litert-lm",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "litertLm": {
5
5
  "version": "0.15.0",
6
6
  "androidMavenVersion": "0.15.0",