File tree Expand file tree Collapse file tree 12 files changed +99
-21
lines changed
examples/demo-apps/apple_ios/LLaMA Expand file tree Collapse file tree 12 files changed +99
-21
lines changed Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
import SwiftUI
4
10
Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
import SwiftUI
4
10
import UniformTypeIdentifiers
@@ -204,15 +210,21 @@ struct ContentView: View {
204
210
return
205
211
}
206
212
do {
213
+ var tokens : [ String ] = [ ]
207
214
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)
215
+ tokens. append ( token)
216
+ if tokens. count > 2 {
217
+ let text = tokens. joined ( )
218
+ let count = text. count
219
+ tokens = [ ]
220
+ DispatchQueue . main. async {
221
+ withAnimation {
222
+ var message = messages. removeLast ( )
223
+ message. text += text
224
+ message. tokenCount += count
225
+ message. dateUpdated = Date ( )
226
+ messages. append ( message)
227
+ }
216
228
}
217
229
}
218
230
if shouldStopGenerating {
Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
import SwiftUI
4
10
Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
import SwiftUI
4
10
Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
import Foundation
4
10
Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
import SwiftUI
4
10
Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
import SwiftUI
4
10
Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
import SwiftUI
4
10
Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
import Foundation
4
10
@@ -12,7 +18,7 @@ final class ResourceMonitor: ObservableObject {
12
18
}
13
19
14
20
public func start( ) {
15
- memoryUpdateTimer = Timer . scheduledTimer ( withTimeInterval: 0.5 , repeats: true ) { [ weak self] _ in
21
+ memoryUpdateTimer = Timer . scheduledTimer ( withTimeInterval: 1 , repeats: true ) { [ weak self] _ in
16
22
self ? . updateMemoryUsage ( )
17
23
}
18
24
}
Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
#import < Foundation/Foundation.h>
4
10
Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
#import " LLaMARunner.h"
4
10
Original file line number Diff line number Diff line change 1
- // (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
2
8
3
9
@testable import LLaMARunner
4
10
You can’t perform that action at this time.
0 commit comments