From 55a08ed06a89c9d498418f38e6b5e7bc9ba288b4 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Thu, 5 Sep 2024 18:29:53 +0300 Subject: [PATCH] swift : fix example --- examples/llama.swiftui/llama.cpp.swift/LibLlama.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/llama.swiftui/llama.cpp.swift/LibLlama.swift b/examples/llama.swiftui/llama.cpp.swift/LibLlama.swift index 24cef348ce734..92f61fe83081d 100644 --- a/examples/llama.swiftui/llama.cpp.swift/LibLlama.swift +++ b/examples/llama.swiftui/llama.cpp.swift/LibLlama.swift @@ -24,7 +24,7 @@ func llama_batch_add(_ batch: inout llama_batch, _ id: llama_token, _ pos: llama actor LlamaContext { private var model: OpaquePointer private var context: OpaquePointer - private var sampling: llama_sampler + private var sampling: UnsafeMutablePointer private var batch: llama_batch private var tokens_list: [llama_token] var is_done: Bool = false @@ -43,8 +43,11 @@ actor LlamaContext { self.tokens_list = [] self.batch = llama_batch_init(512, 0, 1) self.temporary_invalid_cchars = [] - var sparams = llama_sampler_chain_default_params() + let sparams = llama_sampler_chain_default_params() self.sampling = llama_sampler_chain_init(sparams) + llama_sampler_chain_add(self.sampling, llama_sampler_init_temp(0.4)) + llama_sampler_chain_add(self.sampling, llama_sampler_init_softmax()) + llama_sampler_chain_add(self.sampling, llama_sampler_init_dist(1234)) } deinit {