change variable name to is_done (variable name suggested by ggerganov)

This commit is contained in:
o 2024-07-19 23:50:33 -04:00
parent b25654dde1
commit e8c7a25c9e
2 changed files with 4 additions and 4 deletions

View file

@ -26,12 +26,12 @@ actor LlamaContext {
private var context: OpaquePointer private var context: OpaquePointer
private var batch: llama_batch private var batch: llama_batch
private var tokens_list: [llama_token] private var tokens_list: [llama_token]
var latest_llama_token_is_eog_or_reach_len: Bool = false var is_done: Bool = false
/// This variable is used to store temporarily invalid cchars /// This variable is used to store temporarily invalid cchars
private var temporary_invalid_cchars: [CChar] private var temporary_invalid_cchars: [CChar]
var n_len: Int32 = 64 var n_len: Int32 = 1024
var n_cur: Int32 = 0 var n_cur: Int32 = 0
var n_decode: Int32 = 0 var n_decode: Int32 = 0
@ -161,7 +161,7 @@ actor LlamaContext {
if llama_token_is_eog(model, new_token_id) || n_cur == n_len { if llama_token_is_eog(model, new_token_id) || n_cur == n_len {
print("\n") print("\n")
latest_llama_token_is_eog_or_reach_len = true is_done = true
let new_token_str = String(cString: temporary_invalid_cchars + [0]) let new_token_str = String(cString: temporary_invalid_cchars + [0])
temporary_invalid_cchars.removeAll() temporary_invalid_cchars.removeAll()
return new_token_str return new_token_str

View file

@ -132,7 +132,7 @@ class LlamaState: ObservableObject {
messageLog += "\(text)" messageLog += "\(text)"
Task.detached { Task.detached {
while await !llamaContext.latest_llama_token_is_eog_or_reach_len{ while await !llamaContext.is_done{
let result = await llamaContext.completion_loop() let result = await llamaContext.completion_loop()
await MainActor.run { await MainActor.run {
self.messageLog += "\(result)" self.messageLog += "\(result)"