Skip to content

Commit b3785a7

Browse files
committed
Apply clang and swift format
1 parent 6102533 commit b3785a7

File tree

5 files changed

+41
-46
lines changed

5 files changed

+41
-46
lines changed

mobile/examples/phi-3/ios/LocalLLM/LocalLLM/ContentView.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ struct Message: Identifiable {
1010
}
1111

1212
struct ContentView: View {
13-
@State private var userInput: String = ""
14-
@State private var messages: [Message] = [] // Store chat messages locally
15-
@State private var isGenerating: Bool = false // Track token generation state
16-
@State private var stats: String = "" // token generation stats
17-
@State private var showAlert: Bool = false
18-
@State private var errorMessage: String = ""
13+
@State private var userInput: String = ""
14+
@State private var messages: [Message] = [] // Store chat messages locally
15+
@State private var isGenerating: Bool = false // Track token generation state
16+
@State private var stats: String = "" // token generation stats
17+
@State private var showAlert: Bool = false
18+
@State private var errorMessage: String = ""
1919

2020
private let generator = GenAIGenerator()
2121

mobile/examples/phi-3/ios/LocalLLM/LocalLLM/FolderPicker.swift

+22-22
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,34 @@ import SwiftUI
55
import UIKit
66

77
struct FolderPicker: UIViewControllerRepresentable {
8-
var onPick: (URL?) -> Void
8+
var onPick: (URL?) -> Void
99

10-
func makeUIViewController(context: Context) -> UIDocumentPickerViewController {
11-
let picker = UIDocumentPickerViewController(forOpeningContentTypes: [.folder])
12-
picker.allowsMultipleSelection = false
13-
picker.delegate = context.coordinator
14-
return picker
15-
}
10+
func makeUIViewController(context: Context) -> UIDocumentPickerViewController {
11+
let picker = UIDocumentPickerViewController(forOpeningContentTypes: [.folder])
12+
picker.allowsMultipleSelection = false
13+
picker.delegate = context.coordinator
14+
return picker
15+
}
1616

17-
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {}
17+
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {}
1818

19-
func makeCoordinator() -> Coordinator {
20-
Coordinator(onPick: onPick)
21-
}
19+
func makeCoordinator() -> Coordinator {
20+
Coordinator(onPick: onPick)
21+
}
2222

23-
class Coordinator: NSObject, UIDocumentPickerDelegate {
24-
let onPick: (URL?) -> Void
23+
class Coordinator: NSObject, UIDocumentPickerDelegate {
24+
let onPick: (URL?) -> Void
2525

26-
init(onPick: @escaping (URL?) -> Void) {
27-
self.onPick = onPick
28-
}
26+
init(onPick: @escaping (URL?) -> Void) {
27+
self.onPick = onPick
28+
}
2929

30-
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
31-
onPick(urls.first)
32-
}
30+
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
31+
onPick(urls.first)
32+
}
3333

34-
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
35-
onPick(nil)
36-
}
34+
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
35+
onPick(nil)
3736
}
37+
}
3838
}

mobile/examples/phi-3/ios/LocalLLM/LocalLLM/GenAIGenerator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
1111

1212
@interface GenAIGenerator : NSObject
1313

14-
- (void)setModelFolderPath:(nonnull NSString*)modelPath;
14+
- (void)setModelFolderPath:(nonnull NSString *)modelPath;
1515
- (void)generate:(NSString *)input_user_question;
1616

1717
@end

mobile/examples/phi-3/ios/LocalLLM/LocalLLM/GenAIGenerator.mm

-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ @interface GenAIGenerator () {
1818

1919
@implementation GenAIGenerator
2020

21-
typedef std::chrono::steady_clock Clock;
22-
typedef std::chrono::time_point<Clock> TimePoint;
23-
static std::unique_ptr<OgaModel> model = nullptr;
24-
static std::unique_ptr<OgaTokenizer> tokenizer = nullptr;
25-
2621
typedef std::chrono::steady_clock Clock;
2722
typedef std::chrono::time_point<Clock> TimePoint;
2823

mobile/examples/phi-3/ios/LocalLLM/LocalLLM/SharedTokenUpdater.swift

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import Combine
55
import Foundation
66

77
@objc class SharedTokenUpdater: NSObject, ObservableObject {
8-
@Published var decodedTokens: [String] = []
9-
10-
@objc static let shared = SharedTokenUpdater()
11-
12-
@objc func addDecodedToken(_ token: String) {
13-
DispatchQueue.main.async {
14-
self.decodedTokens.append(token)
15-
}
8+
@Published var decodedTokens: [String] = []
9+
10+
@objc static let shared = SharedTokenUpdater()
11+
12+
@objc func addDecodedToken(_ token: String) {
13+
DispatchQueue.main.async {
14+
self.decodedTokens.append(token)
1615
}
16+
}
1717

18-
@objc func clearTokens() {
19-
DispatchQueue.main.async {
20-
self.decodedTokens.removeAll()
21-
}
18+
@objc func clearTokens() {
19+
DispatchQueue.main.async {
20+
self.decodedTokens.removeAll()
2221
}
22+
}
2323
}

0 commit comments

Comments
 (0)