diff --git a/extension/llm/apple/ExecuTorchLLM/Exported/ExecuTorchLLMMultimodalRunner.mm b/extension/llm/apple/ExecuTorchLLM/Exported/ExecuTorchLLMMultimodalRunner.mm index 964805053e2..2de2d902205 100644 --- a/extension/llm/apple/ExecuTorchLLM/Exported/ExecuTorchLLMMultimodalRunner.mm +++ b/extension/llm/apple/ExecuTorchLLM/Exported/ExecuTorchLLMMultimodalRunner.mm @@ -170,8 +170,8 @@ - (BOOL)isLoaded { - (BOOL)loadWithError:(NSError**)error { if (![self isLoaded]) { _runner = llm::create_multimodal_runner( - _modelPath.UTF8String, - llm::load_tokenizer(_tokenizerPath.UTF8String) + _modelPath.UTF8String ?: "", + llm::load_tokenizer(_tokenizerPath.UTF8String ?: "") ); if (!_runner) { if (error) { @@ -206,7 +206,7 @@ - (BOOL)generateWithInputs:(NSArray *)inputs for (ExecuTorchLLMMultimodalInput *input in inputs) { switch (input.type) { case ExecuTorchLLMMultimodalInputTypeText: - nativeInputs.emplace_back(llm::MultimodalInput(input.text.UTF8String)); + nativeInputs.emplace_back(llm::MultimodalInput(input.text.UTF8String ?: "")); break; case ExecuTorchLLMMultimodalInputTypeImage: { ExecuTorchLLMImage *image = input.image; diff --git a/extension/llm/apple/ExecuTorchLLM/Exported/ExecuTorchLLMTextRunner.mm b/extension/llm/apple/ExecuTorchLLM/Exported/ExecuTorchLLMTextRunner.mm index 1a6c3f40045..ea858f1df9e 100644 --- a/extension/llm/apple/ExecuTorchLLM/Exported/ExecuTorchLLMTextRunner.mm +++ b/extension/llm/apple/ExecuTorchLLM/Exported/ExecuTorchLLMTextRunner.mm @@ -44,7 +44,7 @@ - (instancetype)initWithModelPath:(NSString*)modelPath _tokenizerPath = [tokenizerPath copy]; _specialTokens = std::make_unique>(); for (NSString *token in specialTokens) { - _specialTokens->emplace_back(token.UTF8String); + _specialTokens->emplace_back(token.UTF8String ?: ""); } } return self; @@ -57,8 +57,8 @@ - (BOOL)isLoaded { - (BOOL)loadWithError:(NSError**)error { if (![self isLoaded]) { _runner = llm::create_text_llm_runner( - _modelPath.UTF8String, - llm::load_tokenizer(_tokenizerPath.UTF8String, std::move(_specialTokens)) + _modelPath.UTF8String ?: "", + llm::load_tokenizer(_tokenizerPath.UTF8String ?: "", std::move(_specialTokens)) ); if (!_runner) { if (error) { @@ -89,7 +89,7 @@ - (BOOL)generateWithPrompt:(NSString*)prompt return NO; } auto status = _runner->generate( - prompt.UTF8String, + prompt.UTF8String ?: "", config.nativeConfig, [callback](const std::string& token) { if (callback) {