Skip to content

Commit

Permalink
Apply clang and swift format
Browse files Browse the repository at this point in the history
  • Loading branch information
vraspar committed Dec 19, 2024
1 parent 6102533 commit b3785a7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 46 deletions.
12 changes: 6 additions & 6 deletions mobile/examples/phi-3/ios/LocalLLM/LocalLLM/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ struct Message: Identifiable {
}

struct ContentView: View {
@State private var userInput: String = ""
@State private var messages: [Message] = [] // Store chat messages locally
@State private var isGenerating: Bool = false // Track token generation state
@State private var stats: String = "" // token generation stats
@State private var showAlert: Bool = false
@State private var errorMessage: String = ""
@State private var userInput: String = ""
@State private var messages: [Message] = [] // Store chat messages locally
@State private var isGenerating: Bool = false // Track token generation state
@State private var stats: String = "" // token generation stats
@State private var showAlert: Bool = false
@State private var errorMessage: String = ""

private let generator = GenAIGenerator()

Expand Down
44 changes: 22 additions & 22 deletions mobile/examples/phi-3/ios/LocalLLM/LocalLLM/FolderPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@ import SwiftUI
import UIKit

struct FolderPicker: UIViewControllerRepresentable {
var onPick: (URL?) -> Void
var onPick: (URL?) -> Void

func makeUIViewController(context: Context) -> UIDocumentPickerViewController {
let picker = UIDocumentPickerViewController(forOpeningContentTypes: [.folder])
picker.allowsMultipleSelection = false
picker.delegate = context.coordinator
return picker
}
func makeUIViewController(context: Context) -> UIDocumentPickerViewController {
let picker = UIDocumentPickerViewController(forOpeningContentTypes: [.folder])
picker.allowsMultipleSelection = false
picker.delegate = context.coordinator
return picker
}

func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {}
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {}

func makeCoordinator() -> Coordinator {
Coordinator(onPick: onPick)
}
func makeCoordinator() -> Coordinator {
Coordinator(onPick: onPick)
}

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

init(onPick: @escaping (URL?) -> Void) {
self.onPick = onPick
}
init(onPick: @escaping (URL?) -> Void) {
self.onPick = onPick
}

func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
onPick(urls.first)
}
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
onPick(urls.first)
}

func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
onPick(nil)
}
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
onPick(nil)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface GenAIGenerator : NSObject

- (void)setModelFolderPath:(nonnull NSString*)modelPath;
- (void)setModelFolderPath:(nonnull NSString *)modelPath;
- (void)generate:(NSString *)input_user_question;

@end
Expand Down
5 changes: 0 additions & 5 deletions mobile/examples/phi-3/ios/LocalLLM/LocalLLM/GenAIGenerator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ @interface GenAIGenerator () {

@implementation GenAIGenerator

typedef std::chrono::steady_clock Clock;
typedef std::chrono::time_point<Clock> TimePoint;
static std::unique_ptr<OgaModel> model = nullptr;
static std::unique_ptr<OgaTokenizer> tokenizer = nullptr;

typedef std::chrono::steady_clock Clock;
typedef std::chrono::time_point<Clock> TimePoint;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import Combine
import Foundation

@objc class SharedTokenUpdater: NSObject, ObservableObject {
@Published var decodedTokens: [String] = []

@objc static let shared = SharedTokenUpdater()

@objc func addDecodedToken(_ token: String) {
DispatchQueue.main.async {
self.decodedTokens.append(token)
}
@Published var decodedTokens: [String] = []

@objc static let shared = SharedTokenUpdater()

@objc func addDecodedToken(_ token: String) {
DispatchQueue.main.async {
self.decodedTokens.append(token)
}
}

@objc func clearTokens() {
DispatchQueue.main.async {
self.decodedTokens.removeAll()
}
@objc func clearTokens() {
DispatchQueue.main.async {
self.decodedTokens.removeAll()
}
}
}

0 comments on commit b3785a7

Please sign in to comment.