File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
packages/react-native-executorch/src Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,17 @@ export class LLMController {
186186 this . isGeneratingCallback ( false ) ;
187187 }
188188
189+ private getImageToken ( ) : string {
190+ const token = this . tokenizerConfig . image_token ;
191+ if ( ! token ) {
192+ throw new RnExecutorchError (
193+ RnExecutorchErrorCode . InvalidConfig ,
194+ "Tokenizer config is missing 'image_token'. Vision models require tokenizerConfigSource with an 'image_token' field."
195+ ) ;
196+ }
197+ return token ;
198+ }
199+
189200 private filterSpecialTokens ( text : string ) : string {
190201 let filtered = text ;
191202 if (
@@ -240,7 +251,7 @@ export class LLMController {
240251 ? await this . nativeModule . generateMultimodal (
241252 input ,
242253 imagePaths ,
243- this . tokenizerConfig ?. image_token ?? '<image>' ,
254+ this . getImageToken ( ) ,
244255 this . onToken
245256 )
246257 : await this . nativeModule . generate ( input , this . onToken ) ;
Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ export interface LLMTypeMultimodal<
157157}
158158
159159/**
160- * Return type for `useLLM` when `model.isMultimodal ` is absent or `false `.
160+ * Return type for `useLLM` when `model.capabilities ` is absent or does not include `'vision' `.
161161 * `sendMessage` accepts only text.
162162 *
163163 * @category Types
You can’t perform that action at this time.
0 commit comments