Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { LanguageModelV3 } from '@ai-sdk/provider'
import { mlc } from '@react-native-ai/mlc'
import { File, Paths } from 'expo-file-system'
import { Platform } from 'react-native'

import type { Availability, SetupAdapter } from '../../config/providers.common'

Expand All @@ -19,7 +20,14 @@ export const createMLCLanguageSetupAdapter = (
},
builtIn: false,
isAvailable(): Availability {
return new File(Paths.document, model.modelId, 'tensor-cache.json').exists
return new File(
Paths.document,
...(Platform.select({
ios: ['bundle'],
}) ?? []),
model.modelId,
'tensor-cache.json'
).exists
? 'yes'
: 'availableForDownload'
},
Expand Down
10 changes: 4 additions & 6 deletions packages/mlc/ATTRIBUTIONS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Third-Party Notices
===================
# Third-Party Notices

## MLC-LLM (mlc-ai/mlc-llm)

MLC-LLM (mlc-ai/mlc-llm)
-----------------------
Portions of the iOS engine implementation are derived from the MLC-LLM project,
and the prebuilt runtime binaries shipped in this package are based on MLC-LLM.

Expand All @@ -14,7 +13,6 @@ License: Apache License, Version 2.0
License URL: https://www.apache.org/licenses/LICENSE-2.0

Derived source files in this package:

- packages/mlc/ios/engine/LLMEngine.h
- packages/mlc/ios/engine/LLMEngine.mm
- packages/mlc/ios/engine/JSONFFIEngine.h
- packages/mlc/ios/engine/JSONFFIEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class NativeMLCEngineModule(reactContext: ReactApplicationContext) : NativeMLCEn

private fun getModelConfig(modelId: String): Pair<ModelRecord, File>? {
val modelRecord = appConfig.model_list.find { it.model_id == modelId } ?: return null
val modelDir = File(reactApplicationContext.getExternalFilesDir(""), modelRecord.model_id)
val modelDir = File(reactApplicationContext.getFilesDir(), modelRecord.model_id)
return Pair(modelRecord, modelDir)
}
}
Expand Down
Loading