Skip to content

Commit 5f21dba

Browse files
committed
Apply feedback
1 parent d9d1a84 commit 5f21dba

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

mobile/examples/phi-3/ios/LocalLLM/LocalLLM.xcodeproj/project.pbxproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,7 @@
422422
"$(PROJECT_DIR)/LocalLLM/lib",
423423
);
424424
MARKETING_VERSION = 1.0;
425-
"MTL_ENABLE_DEBUG_INFO[sdk=iphoneos*]" = "";
426-
PRODUCT_BUNDLE_IDENTIFIER = ai.onnxruntime.genai.demo.LocalLL;
425+
PRODUCT_BUNDLE_IDENTIFIER = ai.onnxruntime.genai.demo.LocalLLM;
427426
PRODUCT_NAME = "$(TARGET_NAME)";
428427
PROVISIONING_PROFILE_SPECIFIER = "";
429428
SWIFT_EMIT_LOC_STRINGS = YES;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct ContentView: View {
124124
promptProcRate)
125125
}
126126
}
127-
.onReceive(NotificationCenter.default.publisher(for: NSNotification.Name("TokenGenerationError"))) { notification in
127+
.onReceive(NotificationCenter.default.publisher(for: NSNotification.Name("GenAIError"))) { notification in
128128
if let userInfo = notification.userInfo, let error = userInfo["error"] as? String {
129129
errorMessage = error
130130
isGenerating = false

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "ort_genai.h"
88
#include "ort_genai_c.h"
99

10-
const size_t kMaxTokens = 64;
10+
const size_t kMaxTokens = 200;
1111

1212
@interface GenAIGenerator () {
1313
std::unique_ptr<OgaModel> model;
@@ -34,7 +34,19 @@ - (void)setModelFolderPath:(NSString*)modelPath {
3434
@synchronized(self) {
3535
self->modelPath = [modelPath copy];
3636
NSLog(@"Model folder path set to: %@", modelPath);
37-
[self loadModelFromPath];
37+
38+
try {
39+
[self loadModelFromPath];
40+
} catch (const std::exception& e) {
41+
NSString* errorMessage = [NSString stringWithUTF8String:e.what()];
42+
NSLog(@"Error loading model: %@", errorMessage);
43+
44+
// Notify the UI about the error
45+
NSDictionary* errorInfo = @{@"error" : errorMessage};
46+
dispatch_async(dispatch_get_main_queue(), ^{
47+
[[NSNotificationCenter defaultCenter] postNotificationName:@"GenAIError" object:nil userInfo:errorInfo];
48+
});
49+
}
3850
}
3951
}
4052

@@ -82,7 +94,6 @@ - (void)generate:(nonnull NSString*)input_user_question {
8294
NSLog(@"Starting token generation loop...");
8395

8496
startTime = Clock::now();
85-
firstTokenTime = Clock::now();
8697
generator->AppendTokenSequences(*sequences);
8798
while (!generator->IsDone()) {
8899
tokenStartTime = Clock::now();
@@ -142,7 +153,7 @@ - (void)generate:(nonnull NSString*)input_user_question {
142153
// Send error to the UI
143154
NSDictionary* errorInfo = @{@"error" : errorMessage};
144155
dispatch_async(dispatch_get_main_queue(), ^{
145-
[[NSNotificationCenter defaultCenter] postNotificationName:@"TokenGenerationError" object:nil userInfo:errorInfo];
156+
[[NSNotificationCenter defaultCenter] postNotificationName:@"GenAIError" object:nil userInfo:errorInfo];
146157
});
147158
}
148159
}

0 commit comments

Comments
 (0)