File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed
examples/demo-apps/apple_ios/LLaMA/LLaMA/Application Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -204,15 +204,21 @@ struct ContentView: View {
204
204
return
205
205
}
206
206
do {
207
+ var tokens : [ String ] = [ ]
207
208
try runnerHolder. runner? . generate ( text, sequenceLength: seq_len) { token in
208
-
209
- DispatchQueue . main. async {
210
- withAnimation {
211
- var message = messages. removeLast ( )
212
- message. text += token
213
- message. tokenCount += 1
214
- message. dateUpdated = Date ( )
215
- messages. append ( message)
209
+ tokens. append ( token)
210
+ if tokens. count > 2 {
211
+ let text = tokens. joined ( )
212
+ let count = text. count
213
+ tokens = [ ]
214
+ DispatchQueue . main. async {
215
+ withAnimation {
216
+ var message = messages. removeLast ( )
217
+ message. text += text
218
+ message. tokenCount += count
219
+ message. dateUpdated = Date ( )
220
+ messages. append ( message)
221
+ }
216
222
}
217
223
}
218
224
if shouldStopGenerating {
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ final class ResourceMonitor: ObservableObject {
12
12
}
13
13
14
14
public func start( ) {
15
- memoryUpdateTimer = Timer . scheduledTimer ( withTimeInterval: 0.5 , repeats: true ) { [ weak self] _ in
15
+ memoryUpdateTimer = Timer . scheduledTimer ( withTimeInterval: 1 , repeats: true ) { [ weak self] _ in
16
16
self ? . updateMemoryUsage ( )
17
17
}
18
18
}
You can’t perform that action at this time.
0 commit comments