expo-ai-kit 0.1.21 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/build/ExpoAiKitModule.d.ts +10 -1
- package/build/ExpoAiKitModule.d.ts.map +1 -1
- package/build/ExpoAiKitModule.js.map +1 -1
- package/build/hooks.d.ts +60 -1
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +134 -1
- package/build/hooks.js.map +1 -1
- package/build/index.d.ts +82 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +140 -0
- package/build/index.js.map +1 -1
- package/build/memory.d.ts +21 -4
- package/build/memory.d.ts.map +1 -1
- package/build/memory.js +54 -11
- package/build/memory.js.map +1 -1
- package/build/models.d.ts +43 -0
- package/build/models.d.ts.map +1 -0
- package/build/models.js +45 -0
- package/build/models.js.map +1 -0
- package/build/types.d.ts +82 -0
- package/build/types.d.ts.map +1 -1
- package/build/types.js +13 -1
- package/build/types.js.map +1 -1
- package/ios/ExpoAiKit.podspec +1 -1
- package/package.json +4 -4
- package/src/ExpoAiKitModule.ts +35 -1
- package/src/hooks.ts +172 -1
- package/src/index.ts +171 -0
- package/src/memory.ts +63 -11
- package/src/models.ts +78 -0
- package/src/types.ts +112 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build/.transforms/550f2d3d50c89e495845cc30f2214044/results.bin +0 -1
- package/android/build/.transforms/550f2d3d50c89e495845cc30f2214044/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/a588f18db136c18b668ecd9727a7dc6b/results.bin +0 -1
- package/android/build/.transforms/a588f18db136c18b668ecd9727a7dc6b/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/results.bin +0 -1
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/BuildConfig.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$1$5$1.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$6$$inlined$AsyncFunction$1.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$6$$inlined$AsyncFunction$2.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$6$$inlined$AsyncFunction$3.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$6$$inlined$AsyncFunctionWithoutArgs$1.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$6$$inlined$Constant$1.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$6$$inlined$FunctionWithoutArgs$1.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$6$$inlined$View$1.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$6$lambda$5$$inlined$Prop$1.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitView$webView$1$1.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitView.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/PromptApiClient$isAvailable$1.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/PromptApiClient$isAvailableBlocking$1.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/PromptApiClient.dex +0 -0
- package/android/build/.transforms/c485bab123d2a96b9ef2e8051e8dcd8c/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/results.bin +0 -1
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/BuildConfig.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$1$2$conversationPrompt$2.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$1$3$conversationPrompt$2.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$1$3$job$1$1.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$1$3$job$1.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$1.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$2.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$3.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$4.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$5.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$6.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$7.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$Coroutine$1.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$Coroutine$2.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$Coroutine$3.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$FunctionWithoutArgs$1.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/ExpoAiKitModule.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/PromptApiClient$generateText$2.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/PromptApiClient$generateTextStream$2$1.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/PromptApiClient$generateTextStream$2.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/PromptApiClient$isAvailable$1.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/PromptApiClient$isAvailableBlocking$1.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/aikit/PromptApiClient.dex +0 -0
- package/android/build/.transforms/e7552020676c2f8a620fec964bf11729/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/generated/source/buildConfig/debug/expo/modules/aikit/BuildConfig.java +0 -10
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +0 -7
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +0 -18
- package/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +0 -6
- package/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +0 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
- package/android/build/intermediates/java_res/debug/processDebugJavaRes/out/META-INF/expo-ai-kit_debug.kotlin_module +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/expo/modules/aikit/BuildConfig.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +0 -2
- package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +0 -7
- package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +0 -7
- package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +0 -1
- package/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +0 -1
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/META-INF/expo-ai-kit_debug.kotlin_module +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/BuildConfig.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$1$2$conversationPrompt$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$1$3$conversationPrompt$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$1$3$job$1$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$1$3$job$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$3.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$4.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$5.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$6.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$7.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$Coroutine$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$Coroutine$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$Coroutine$3.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$FunctionWithoutArgs$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/ExpoAiKitModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/PromptApiClient$generateText$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/PromptApiClient$generateTextStream$2$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/PromptApiClient$generateTextStream$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/PromptApiClient$isAvailable$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/PromptApiClient$isAvailableBlocking$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/aikit/PromptApiClient.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +0 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -14
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/META-INF/expo-ai-kit_debug.kotlin_module +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$1$2$conversationPrompt$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$1$3$conversationPrompt$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$1$3$job$1$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$1$3$job$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$3.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$4.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$5.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$6.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$AsyncFunction$7.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$Coroutine$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$Coroutine$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$Coroutine$3.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule$definition$lambda$11$$inlined$FunctionWithoutArgs$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/ExpoAiKitModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/PromptApiClient$generateText$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/PromptApiClient$generateTextStream$2$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/PromptApiClient$generateTextStream$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/PromptApiClient$isAvailable$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/PromptApiClient$isAvailableBlocking$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/aikit/PromptApiClient.class +0 -0
package/build/models.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Registry
|
|
3
|
+
*
|
|
4
|
+
* Defines all downloadable models known to expo-ai-kit.
|
|
5
|
+
* getDownloadableModels() reads from this registry and enriches
|
|
6
|
+
* each entry with on-device status from the native layer.
|
|
7
|
+
*/
|
|
8
|
+
export const MODEL_REGISTRY = [
|
|
9
|
+
{
|
|
10
|
+
id: 'gemma-e2b',
|
|
11
|
+
name: 'Gemma 4 E2B',
|
|
12
|
+
parameterCount: '2.3B',
|
|
13
|
+
quantization: 'Q4_K_M',
|
|
14
|
+
downloadUrl: 'https://huggingface.co/google/gemma-4-e2b-it-GGUF/resolve/main/gemma-4-e2b-it-Q4_K_M.gguf',
|
|
15
|
+
sha256: '', // TODO: Fill with actual hash once model file is verified
|
|
16
|
+
sizeBytes: 1_400_000_000, // ~1.4GB
|
|
17
|
+
// Conservative limit for 4GB RAM devices. Base model supports 128k but
|
|
18
|
+
// KV cache won't fit. TODO: Benchmark during Phase 2 testing.
|
|
19
|
+
contextWindow: 8_000,
|
|
20
|
+
minRamBytes: 4_000_000_000, // 4GB
|
|
21
|
+
supportedPlatforms: ['ios', 'android'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'gemma-e4b',
|
|
25
|
+
name: 'Gemma 4 E4B',
|
|
26
|
+
parameterCount: '4.5B',
|
|
27
|
+
quantization: 'Q4_K_M',
|
|
28
|
+
downloadUrl: 'https://huggingface.co/google/gemma-4-e4b-it-GGUF/resolve/main/gemma-4-e4b-it-Q4_K_M.gguf',
|
|
29
|
+
sha256: '', // TODO: Fill with actual hash once model file is verified
|
|
30
|
+
sizeBytes: 2_800_000_000, // ~2.8GB
|
|
31
|
+
// Conservative limit for 6GB RAM devices. Base model supports 128k but
|
|
32
|
+
// KV cache won't fit. TODO: Benchmark during Phase 2 testing.
|
|
33
|
+
contextWindow: 16_000,
|
|
34
|
+
minRamBytes: 6_000_000_000, // 6GB
|
|
35
|
+
supportedPlatforms: ['ios', 'android'],
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
/**
|
|
39
|
+
* Look up a model registry entry by ID.
|
|
40
|
+
* Returns undefined if not found.
|
|
41
|
+
*/
|
|
42
|
+
export function getRegistryEntry(modelId) {
|
|
43
|
+
return MODEL_REGISTRY.find((m) => m.id === modelId);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgCH,MAAM,CAAC,MAAM,cAAc,GAAyB;IAClD;QACE,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,aAAa;QACnB,cAAc,EAAE,MAAM;QACtB,YAAY,EAAE,QAAQ;QACtB,WAAW,EACT,2FAA2F;QAC7F,MAAM,EAAE,EAAE,EAAE,0DAA0D;QACtE,SAAS,EAAE,aAAa,EAAE,SAAS;QACnC,uEAAuE;QACvE,8DAA8D;QAC9D,aAAa,EAAE,KAAK;QACpB,WAAW,EAAE,aAAa,EAAE,MAAM;QAClC,kBAAkB,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC;KACvC;IACD;QACE,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,aAAa;QACnB,cAAc,EAAE,MAAM;QACtB,YAAY,EAAE,QAAQ;QACtB,WAAW,EACT,2FAA2F;QAC7F,MAAM,EAAE,EAAE,EAAE,0DAA0D;QACtE,SAAS,EAAE,aAAa,EAAE,SAAS;QACnC,uEAAuE;QACvE,8DAA8D;QAC9D,aAAa,EAAE,MAAM;QACrB,WAAW,EAAE,aAAa,EAAE,MAAM;QAClC,kBAAkB,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC;KACvC;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC;AACtD,CAAC","sourcesContent":["/**\n * Model Registry\n *\n * Defines all downloadable models known to expo-ai-kit.\n * getDownloadableModels() reads from this registry and enriches\n * each entry with on-device status from the native layer.\n */\n\nexport type ModelRegistryEntry = {\n /** Unique model identifier used in setModel/downloadModel */\n id: string;\n /** Human-readable model name */\n name: string;\n /** Parameter count label */\n parameterCount: string;\n /** Quantization variant */\n quantization: string;\n /** URL to download the GGUF model file */\n downloadUrl: string;\n /** SHA256 hash for integrity verification after download */\n sha256: string;\n /** Download file size in bytes */\n sizeBytes: number;\n /**\n * Practical context window (max tokens) for this model on constrained devices.\n *\n * These are conservative defaults, NOT the base model's theoretical max (128k).\n * On a memory-constrained mobile device running quantized inference, KV cache\n * cannot fit the full 128k context. These values should be benchmarked and\n * adjusted during Phase 2 testing with real devices.\n */\n contextWindow: number;\n /** Minimum device RAM in bytes required to run this model */\n minRamBytes: number;\n /** Platforms this model can run on */\n supportedPlatforms: ('ios' | 'android')[];\n};\n\nexport const MODEL_REGISTRY: ModelRegistryEntry[] = [\n {\n id: 'gemma-e2b',\n name: 'Gemma 4 E2B',\n parameterCount: '2.3B',\n quantization: 'Q4_K_M',\n downloadUrl:\n 'https://huggingface.co/google/gemma-4-e2b-it-GGUF/resolve/main/gemma-4-e2b-it-Q4_K_M.gguf',\n sha256: '', // TODO: Fill with actual hash once model file is verified\n sizeBytes: 1_400_000_000, // ~1.4GB\n // Conservative limit for 4GB RAM devices. Base model supports 128k but\n // KV cache won't fit. TODO: Benchmark during Phase 2 testing.\n contextWindow: 8_000,\n minRamBytes: 4_000_000_000, // 4GB\n supportedPlatforms: ['ios', 'android'],\n },\n {\n id: 'gemma-e4b',\n name: 'Gemma 4 E4B',\n parameterCount: '4.5B',\n quantization: 'Q4_K_M',\n downloadUrl:\n 'https://huggingface.co/google/gemma-4-e4b-it-GGUF/resolve/main/gemma-4-e4b-it-Q4_K_M.gguf',\n sha256: '', // TODO: Fill with actual hash once model file is verified\n sizeBytes: 2_800_000_000, // ~2.8GB\n // Conservative limit for 6GB RAM devices. Base model supports 128k but\n // KV cache won't fit. TODO: Benchmark during Phase 2 testing.\n contextWindow: 16_000,\n minRamBytes: 6_000_000_000, // 6GB\n supportedPlatforms: ['ios', 'android'],\n },\n];\n\n/**\n * Look up a model registry entry by ID.\n * Returns undefined if not found.\n */\nexport function getRegistryEntry(modelId: string): ModelRegistryEntry | undefined {\n return MODEL_REGISTRY.find((m) => m.id === modelId);\n}\n"]}
|
package/build/types.d.ts
CHANGED
|
@@ -259,6 +259,81 @@ export type UseOnDeviceAIReturn = {
|
|
|
259
259
|
/** Whether the availability check is still in progress */
|
|
260
260
|
isChecking: boolean;
|
|
261
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* A built-in model provided by the OS (e.g. Apple Foundation Models, ML Kit).
|
|
264
|
+
* These are always available on supported devices -- no download needed.
|
|
265
|
+
*/
|
|
266
|
+
export type BuiltInModel = {
|
|
267
|
+
/** Unique model identifier (e.g. 'apple-fm', 'mlkit') */
|
|
268
|
+
id: string;
|
|
269
|
+
/** Human-readable model name */
|
|
270
|
+
name: string;
|
|
271
|
+
/** Whether this model is available on the current device/OS */
|
|
272
|
+
available: boolean;
|
|
273
|
+
/** Platform this model is associated with */
|
|
274
|
+
platform: 'ios' | 'android';
|
|
275
|
+
/** Maximum context window in tokens */
|
|
276
|
+
contextWindow: number;
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* A downloadable model that the user manages (download, load, delete).
|
|
280
|
+
* These require explicit download before use.
|
|
281
|
+
*/
|
|
282
|
+
export type DownloadableModel = {
|
|
283
|
+
/** Unique model identifier (e.g. 'gemma-e2b', 'gemma-e4b') */
|
|
284
|
+
id: string;
|
|
285
|
+
/** Human-readable model name */
|
|
286
|
+
name: string;
|
|
287
|
+
/** Parameter count label (e.g. '2.3B') */
|
|
288
|
+
parameterCount: string;
|
|
289
|
+
/** Download file size in bytes */
|
|
290
|
+
sizeBytes: number;
|
|
291
|
+
/** Maximum context window in tokens */
|
|
292
|
+
contextWindow: number;
|
|
293
|
+
/** Minimum device RAM in bytes required to run */
|
|
294
|
+
minRamBytes: number;
|
|
295
|
+
/** Current lifecycle status */
|
|
296
|
+
status: DownloadableModelStatus;
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* Lifecycle status of a downloadable model.
|
|
300
|
+
*
|
|
301
|
+
* - 'not-downloaded': Model file is not on disk
|
|
302
|
+
* - 'downloading': Model file is being downloaded
|
|
303
|
+
* - 'loading': File is on disk, model is being loaded into memory for inference
|
|
304
|
+
* - 'ready': Model is loaded in memory and ready for inference
|
|
305
|
+
*/
|
|
306
|
+
export type DownloadableModelStatus = 'not-downloaded' | 'downloading' | 'loading' | 'ready';
|
|
307
|
+
/**
|
|
308
|
+
* Error codes for model-related operations.
|
|
309
|
+
*/
|
|
310
|
+
export type ModelErrorCode = 'MODEL_NOT_FOUND' | 'MODEL_NOT_DOWNLOADED' | 'DOWNLOAD_FAILED' | 'DOWNLOAD_CORRUPT' | 'DOWNLOAD_STORAGE_FULL' | 'INFERENCE_OOM' | 'INFERENCE_FAILED' | 'MODEL_LOAD_FAILED' | 'DEVICE_NOT_SUPPORTED';
|
|
311
|
+
/**
|
|
312
|
+
* Structured error for model operations.
|
|
313
|
+
*/
|
|
314
|
+
export declare class ModelError extends Error {
|
|
315
|
+
code: ModelErrorCode;
|
|
316
|
+
modelId: string;
|
|
317
|
+
constructor(code: ModelErrorCode, modelId: string, message?: string);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Event payload for model download progress.
|
|
321
|
+
*/
|
|
322
|
+
export type ModelDownloadProgressEvent = {
|
|
323
|
+
/** Model being downloaded */
|
|
324
|
+
modelId: string;
|
|
325
|
+
/** Download progress from 0 to 1 */
|
|
326
|
+
progress: number;
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Event payload for model state changes.
|
|
330
|
+
*/
|
|
331
|
+
export type ModelStateChangeEvent = {
|
|
332
|
+
/** Model whose state changed */
|
|
333
|
+
modelId: string;
|
|
334
|
+
/** New status */
|
|
335
|
+
status: DownloadableModelStatus;
|
|
336
|
+
};
|
|
262
337
|
/**
|
|
263
338
|
* Options for creating a ChatMemoryManager.
|
|
264
339
|
*/
|
|
@@ -273,6 +348,13 @@ export type ChatMemoryOptions = {
|
|
|
273
348
|
* Optional system prompt to prepend to every generated prompt.
|
|
274
349
|
*/
|
|
275
350
|
systemPrompt?: string;
|
|
351
|
+
/**
|
|
352
|
+
* Maximum context window in tokens. When set, trimHistory will also
|
|
353
|
+
* trim messages that exceed this token budget (in addition to maxTurns).
|
|
354
|
+
* Whichever limit is hit first triggers trimming.
|
|
355
|
+
* @default Infinity (no token-based trimming)
|
|
356
|
+
*/
|
|
357
|
+
contextWindow?: number;
|
|
276
358
|
};
|
|
277
359
|
/**
|
|
278
360
|
* A snapshot of the current chat memory state.
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GA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AE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,uCAAuC;IACvC,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,iCAAiC;IACjC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
package/build/types.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Structured error for model operations.
|
|
3
|
+
*/
|
|
4
|
+
export class ModelError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
modelId;
|
|
7
|
+
constructor(code, modelId, message) {
|
|
8
|
+
super(message ?? `${code}: ${modelId}`);
|
|
9
|
+
this.name = 'ModelError';
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.modelId = modelId;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
2
14
|
//# sourceMappingURL=types.js.map
|
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Role in a conversation message.\n */\nexport type LLMRole = 'system' | 'user' | 'assistant';\n\n/**\n * A single message in a conversation.\n */\nexport type LLMMessage = {\n role: LLMRole;\n content: string;\n};\n\n/**\n * Options for sendMessage.\n */\nexport type LLMSendOptions = {\n /**\n * Default system prompt to use if no system message is provided in the messages array.\n * If a system message exists in the array, this is ignored.\n */\n systemPrompt?: string;\n};\n\n/**\n * Response from sendMessage.\n */\nexport type LLMResponse = {\n /** The generated response text */\n text: string;\n};\n\n/**\n * Options for streamMessage.\n */\nexport type LLMStreamOptions = {\n /**\n * Default system prompt to use if no system message is provided in the messages array.\n * If a system message exists in the array, this is ignored.\n */\n systemPrompt?: string;\n};\n\n/**\n * Event payload for streaming tokens.\n */\nexport type LLMStreamEvent = {\n /** Unique identifier for this streaming session */\n sessionId: string;\n /** The token/chunk of text received */\n token: string;\n /** Accumulated text so far */\n accumulatedText: string;\n /** Whether this is the final chunk */\n isDone: boolean;\n};\n\n/**\n * Callback function for streaming events.\n */\nexport type LLMStreamCallback = (event: LLMStreamEvent) => void;\n\n// ============================================================================\n// Prompt Helper Types\n// ============================================================================\n\n/**\n * Options for the summarize helper.\n */\nexport type LLMSummarizeOptions = {\n /**\n * Target length for the summary.\n * @default 'medium'\n */\n length?: 'short' | 'medium' | 'long';\n /**\n * Style of summary to generate.\n * @default 'paragraph'\n */\n style?: 'paragraph' | 'bullets' | 'tldr';\n};\n\n/**\n * Options for the translate helper.\n */\nexport type LLMTranslateOptions = {\n /**\n * Target language to translate to.\n */\n to: string;\n /**\n * Source language (auto-detected if not provided).\n */\n from?: string;\n /**\n * Tone/formality of the translation.\n * @default 'neutral'\n */\n tone?: 'formal' | 'informal' | 'neutral';\n};\n\n/**\n * Options for the rewrite helper.\n */\nexport type LLMRewriteOptions = {\n /**\n * Style to rewrite in.\n */\n style:\n | 'formal'\n | 'casual'\n | 'professional'\n | 'friendly'\n | 'concise'\n | 'detailed'\n | 'simple'\n | 'academic';\n};\n\n/**\n * Options for the extractKeyPoints helper.\n */\nexport type LLMExtractKeyPointsOptions = {\n /**\n * Maximum number of key points to extract.\n * @default 5\n */\n maxPoints?: number;\n};\n\n/**\n * Options for the answerQuestion helper.\n */\nexport type LLMAnswerQuestionOptions = {\n /**\n * How detailed the answer should be.\n * @default 'medium'\n */\n detail?: 'brief' | 'medium' | 'detailed';\n};\n\n// ============================================================================\n// Smart Suggestions Types\n// ============================================================================\n\n/**\n * Options for the suggest helper.\n */\nexport type LLMSuggestOptions = {\n /**\n * Number of suggestions to generate.\n * @default 3\n */\n count?: number;\n /**\n * Optional context to inform the suggestions (e.g., surrounding text, app context).\n */\n context?: string;\n /**\n * Tone of the suggestions.\n * @default 'neutral'\n */\n tone?: 'formal' | 'casual' | 'professional' | 'friendly' | 'neutral';\n};\n\n/**\n * A single suggestion item.\n */\nexport type LLMSuggestion = {\n /** The suggested text */\n text: string;\n};\n\n/**\n * Response from suggest/smartReply containing multiple suggestions.\n */\nexport type LLMSuggestResponse = {\n /** Array of generated suggestions */\n suggestions: LLMSuggestion[];\n /** Raw response text from the model */\n raw: string;\n};\n\n/**\n * Options for the smartReply helper.\n */\nexport type LLMSmartReplyOptions = {\n /**\n * Number of reply suggestions to generate.\n * @default 3\n */\n count?: number;\n /**\n * Tone of the reply suggestions.\n * @default 'neutral'\n */\n tone?: 'formal' | 'casual' | 'professional' | 'friendly' | 'neutral';\n /**\n * Optional persona/context for the replier (e.g., \"customer support agent\", \"friendly colleague\").\n */\n persona?: string;\n};\n\n/**\n * Options for the autocomplete helper.\n */\nexport type LLMAutocompleteOptions = {\n /**\n * Number of completions to generate.\n * @default 3\n */\n count?: number;\n /**\n * Maximum length of each completion in words.\n * @default 10\n */\n maxWords?: number;\n /**\n * Optional context to inform the completions (e.g., what the user is writing about).\n */\n context?: string;\n};\n\n// ============================================================================\n// Hook Types\n// ============================================================================\n\n/**\n * Options for the useChat hook.\n */\nexport type UseChatOptions = {\n /** System prompt for the AI assistant */\n systemPrompt?: string;\n /** Maximum conversation turns to keep in memory (default: 10) */\n maxTurns?: number;\n /** Initial messages to populate the chat */\n initialMessages?: LLMMessage[];\n /** Callback when a response is complete */\n onFinish?: (response: LLMResponse) => void;\n /** Callback when an error occurs */\n onError?: (error: Error) => void;\n};\n\n/**\n * Return type for the useChat hook.\n */\nexport type UseChatReturn = {\n /** All messages in the conversation */\n messages: LLMMessage[];\n /** Current input text value */\n input: string;\n /** Set the input text value */\n setInput: (input: string) => void;\n /** Send the current input (or provided text) as a message */\n sendMessage: (text?: string) => Promise<void>;\n /** Whether the AI is currently streaming a response */\n isStreaming: boolean;\n /** Stop the current streaming response */\n stop: () => void;\n /** Clear all messages and reset the conversation */\n clear: () => void;\n /** The most recent error, if any */\n error: Error | null;\n};\n\n/**\n * Options for the useCompletion hook.\n */\nexport type UseCompletionOptions = {\n /** System prompt for the AI */\n systemPrompt?: string;\n /** Callback when completion is done */\n onFinish?: (response: LLMResponse) => void;\n /** Callback when an error occurs */\n onError?: (error: Error) => void;\n};\n\n/**\n * Return type for the useCompletion hook.\n */\nexport type UseCompletionReturn = {\n /** The current completion text */\n completion: string;\n /** Whether a completion is in progress */\n isLoading: boolean;\n /** Request a completion for the given prompt */\n complete: (prompt: string) => Promise<string>;\n /** Stop the current completion */\n stop: () => void;\n /** The most recent error, if any */\n error: Error | null;\n};\n\n/**\n * Return type for the useOnDeviceAI hook.\n */\nexport type UseOnDeviceAIReturn = {\n /** Whether on-device AI is available */\n isAvailable: boolean;\n /** Whether the availability check is still in progress */\n isChecking: boolean;\n};\n\n// ============================================================================\n// Chat Memory Types\n// ============================================================================\n\n/**\n * Options for creating a ChatMemoryManager.\n */\nexport type ChatMemoryOptions = {\n /**\n * Maximum number of conversation turns to keep in memory.\n * A turn is one user message + one assistant response.\n * @default 10\n */\n maxTurns?: number;\n /**\n * Optional system prompt to prepend to every generated prompt.\n */\n systemPrompt?: string;\n};\n\n/**\n * A snapshot of the current chat memory state.\n */\nexport type ChatMemorySnapshot = {\n /** All messages currently in memory */\n messages: LLMMessage[];\n /** The system prompt (if any) */\n systemPrompt: string | undefined;\n /** Current number of turns stored */\n turnCount: number;\n /** Maximum turns allowed */\n maxTurns: number;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAqXA;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,IAAI,CAAiB;IACrB,OAAO,CAAS;IAEhB,YAAY,IAAoB,EAAE,OAAe,EAAE,OAAgB;QACjE,KAAK,CAAC,OAAO,IAAI,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF","sourcesContent":["/**\n * Role in a conversation message.\n */\nexport type LLMRole = 'system' | 'user' | 'assistant';\n\n/**\n * A single message in a conversation.\n */\nexport type LLMMessage = {\n role: LLMRole;\n content: string;\n};\n\n/**\n * Options for sendMessage.\n */\nexport type LLMSendOptions = {\n /**\n * Default system prompt to use if no system message is provided in the messages array.\n * If a system message exists in the array, this is ignored.\n */\n systemPrompt?: string;\n};\n\n/**\n * Response from sendMessage.\n */\nexport type LLMResponse = {\n /** The generated response text */\n text: string;\n};\n\n/**\n * Options for streamMessage.\n */\nexport type LLMStreamOptions = {\n /**\n * Default system prompt to use if no system message is provided in the messages array.\n * If a system message exists in the array, this is ignored.\n */\n systemPrompt?: string;\n};\n\n/**\n * Event payload for streaming tokens.\n */\nexport type LLMStreamEvent = {\n /** Unique identifier for this streaming session */\n sessionId: string;\n /** The token/chunk of text received */\n token: string;\n /** Accumulated text so far */\n accumulatedText: string;\n /** Whether this is the final chunk */\n isDone: boolean;\n};\n\n/**\n * Callback function for streaming events.\n */\nexport type LLMStreamCallback = (event: LLMStreamEvent) => void;\n\n// ============================================================================\n// Prompt Helper Types\n// ============================================================================\n\n/**\n * Options for the summarize helper.\n */\nexport type LLMSummarizeOptions = {\n /**\n * Target length for the summary.\n * @default 'medium'\n */\n length?: 'short' | 'medium' | 'long';\n /**\n * Style of summary to generate.\n * @default 'paragraph'\n */\n style?: 'paragraph' | 'bullets' | 'tldr';\n};\n\n/**\n * Options for the translate helper.\n */\nexport type LLMTranslateOptions = {\n /**\n * Target language to translate to.\n */\n to: string;\n /**\n * Source language (auto-detected if not provided).\n */\n from?: string;\n /**\n * Tone/formality of the translation.\n * @default 'neutral'\n */\n tone?: 'formal' | 'informal' | 'neutral';\n};\n\n/**\n * Options for the rewrite helper.\n */\nexport type LLMRewriteOptions = {\n /**\n * Style to rewrite in.\n */\n style:\n | 'formal'\n | 'casual'\n | 'professional'\n | 'friendly'\n | 'concise'\n | 'detailed'\n | 'simple'\n | 'academic';\n};\n\n/**\n * Options for the extractKeyPoints helper.\n */\nexport type LLMExtractKeyPointsOptions = {\n /**\n * Maximum number of key points to extract.\n * @default 5\n */\n maxPoints?: number;\n};\n\n/**\n * Options for the answerQuestion helper.\n */\nexport type LLMAnswerQuestionOptions = {\n /**\n * How detailed the answer should be.\n * @default 'medium'\n */\n detail?: 'brief' | 'medium' | 'detailed';\n};\n\n// ============================================================================\n// Smart Suggestions Types\n// ============================================================================\n\n/**\n * Options for the suggest helper.\n */\nexport type LLMSuggestOptions = {\n /**\n * Number of suggestions to generate.\n * @default 3\n */\n count?: number;\n /**\n * Optional context to inform the suggestions (e.g., surrounding text, app context).\n */\n context?: string;\n /**\n * Tone of the suggestions.\n * @default 'neutral'\n */\n tone?: 'formal' | 'casual' | 'professional' | 'friendly' | 'neutral';\n};\n\n/**\n * A single suggestion item.\n */\nexport type LLMSuggestion = {\n /** The suggested text */\n text: string;\n};\n\n/**\n * Response from suggest/smartReply containing multiple suggestions.\n */\nexport type LLMSuggestResponse = {\n /** Array of generated suggestions */\n suggestions: LLMSuggestion[];\n /** Raw response text from the model */\n raw: string;\n};\n\n/**\n * Options for the smartReply helper.\n */\nexport type LLMSmartReplyOptions = {\n /**\n * Number of reply suggestions to generate.\n * @default 3\n */\n count?: number;\n /**\n * Tone of the reply suggestions.\n * @default 'neutral'\n */\n tone?: 'formal' | 'casual' | 'professional' | 'friendly' | 'neutral';\n /**\n * Optional persona/context for the replier (e.g., \"customer support agent\", \"friendly colleague\").\n */\n persona?: string;\n};\n\n/**\n * Options for the autocomplete helper.\n */\nexport type LLMAutocompleteOptions = {\n /**\n * Number of completions to generate.\n * @default 3\n */\n count?: number;\n /**\n * Maximum length of each completion in words.\n * @default 10\n */\n maxWords?: number;\n /**\n * Optional context to inform the completions (e.g., what the user is writing about).\n */\n context?: string;\n};\n\n// ============================================================================\n// Hook Types\n// ============================================================================\n\n/**\n * Options for the useChat hook.\n */\nexport type UseChatOptions = {\n /** System prompt for the AI assistant */\n systemPrompt?: string;\n /** Maximum conversation turns to keep in memory (default: 10) */\n maxTurns?: number;\n /** Initial messages to populate the chat */\n initialMessages?: LLMMessage[];\n /** Callback when a response is complete */\n onFinish?: (response: LLMResponse) => void;\n /** Callback when an error occurs */\n onError?: (error: Error) => void;\n};\n\n/**\n * Return type for the useChat hook.\n */\nexport type UseChatReturn = {\n /** All messages in the conversation */\n messages: LLMMessage[];\n /** Current input text value */\n input: string;\n /** Set the input text value */\n setInput: (input: string) => void;\n /** Send the current input (or provided text) as a message */\n sendMessage: (text?: string) => Promise<void>;\n /** Whether the AI is currently streaming a response */\n isStreaming: boolean;\n /** Stop the current streaming response */\n stop: () => void;\n /** Clear all messages and reset the conversation */\n clear: () => void;\n /** The most recent error, if any */\n error: Error | null;\n};\n\n/**\n * Options for the useCompletion hook.\n */\nexport type UseCompletionOptions = {\n /** System prompt for the AI */\n systemPrompt?: string;\n /** Callback when completion is done */\n onFinish?: (response: LLMResponse) => void;\n /** Callback when an error occurs */\n onError?: (error: Error) => void;\n};\n\n/**\n * Return type for the useCompletion hook.\n */\nexport type UseCompletionReturn = {\n /** The current completion text */\n completion: string;\n /** Whether a completion is in progress */\n isLoading: boolean;\n /** Request a completion for the given prompt */\n complete: (prompt: string) => Promise<string>;\n /** Stop the current completion */\n stop: () => void;\n /** The most recent error, if any */\n error: Error | null;\n};\n\n/**\n * Return type for the useOnDeviceAI hook.\n */\nexport type UseOnDeviceAIReturn = {\n /** Whether on-device AI is available */\n isAvailable: boolean;\n /** Whether the availability check is still in progress */\n isChecking: boolean;\n};\n\n// ============================================================================\n// Model Types\n// ============================================================================\n\n/**\n * A built-in model provided by the OS (e.g. Apple Foundation Models, ML Kit).\n * These are always available on supported devices -- no download needed.\n */\nexport type BuiltInModel = {\n /** Unique model identifier (e.g. 'apple-fm', 'mlkit') */\n id: string;\n /** Human-readable model name */\n name: string;\n /** Whether this model is available on the current device/OS */\n available: boolean;\n /** Platform this model is associated with */\n platform: 'ios' | 'android';\n /** Maximum context window in tokens */\n contextWindow: number;\n};\n\n/**\n * A downloadable model that the user manages (download, load, delete).\n * These require explicit download before use.\n */\nexport type DownloadableModel = {\n /** Unique model identifier (e.g. 'gemma-e2b', 'gemma-e4b') */\n id: string;\n /** Human-readable model name */\n name: string;\n /** Parameter count label (e.g. '2.3B') */\n parameterCount: string;\n /** Download file size in bytes */\n sizeBytes: number;\n /** Maximum context window in tokens */\n contextWindow: number;\n /** Minimum device RAM in bytes required to run */\n minRamBytes: number;\n /** Current lifecycle status */\n status: DownloadableModelStatus;\n};\n\n/**\n * Lifecycle status of a downloadable model.\n *\n * - 'not-downloaded': Model file is not on disk\n * - 'downloading': Model file is being downloaded\n * - 'loading': File is on disk, model is being loaded into memory for inference\n * - 'ready': Model is loaded in memory and ready for inference\n */\nexport type DownloadableModelStatus =\n | 'not-downloaded'\n | 'downloading'\n | 'loading'\n | 'ready';\n\n/**\n * Error codes for model-related operations.\n */\nexport type ModelErrorCode =\n | 'MODEL_NOT_FOUND'\n | 'MODEL_NOT_DOWNLOADED'\n | 'DOWNLOAD_FAILED'\n | 'DOWNLOAD_CORRUPT'\n | 'DOWNLOAD_STORAGE_FULL'\n | 'INFERENCE_OOM'\n | 'INFERENCE_FAILED'\n | 'MODEL_LOAD_FAILED'\n | 'DEVICE_NOT_SUPPORTED';\n\n/**\n * Structured error for model operations.\n */\nexport class ModelError extends Error {\n code: ModelErrorCode;\n modelId: string;\n\n constructor(code: ModelErrorCode, modelId: string, message?: string) {\n super(message ?? `${code}: ${modelId}`);\n this.name = 'ModelError';\n this.code = code;\n this.modelId = modelId;\n }\n}\n\n/**\n * Event payload for model download progress.\n */\nexport type ModelDownloadProgressEvent = {\n /** Model being downloaded */\n modelId: string;\n /** Download progress from 0 to 1 */\n progress: number;\n};\n\n/**\n * Event payload for model state changes.\n */\nexport type ModelStateChangeEvent = {\n /** Model whose state changed */\n modelId: string;\n /** New status */\n status: DownloadableModelStatus;\n};\n\n// ============================================================================\n// Chat Memory Types\n// ============================================================================\n\n/**\n * Options for creating a ChatMemoryManager.\n */\nexport type ChatMemoryOptions = {\n /**\n * Maximum number of conversation turns to keep in memory.\n * A turn is one user message + one assistant response.\n * @default 10\n */\n maxTurns?: number;\n /**\n * Optional system prompt to prepend to every generated prompt.\n */\n systemPrompt?: string;\n /**\n * Maximum context window in tokens. When set, trimHistory will also\n * trim messages that exceed this token budget (in addition to maxTurns).\n * Whichever limit is hit first triggers trimming.\n * @default Infinity (no token-based trimming)\n */\n contextWindow?: number;\n};\n\n/**\n * A snapshot of the current chat memory state.\n */\nexport type ChatMemorySnapshot = {\n /** All messages currently in memory */\n messages: LLMMessage[];\n /** The system prompt (if any) */\n systemPrompt: string | undefined;\n /** Current number of turns stored */\n turnCount: number;\n /** Maximum turns allowed */\n maxTurns: number;\n};\n"]}
|
package/ios/ExpoAiKit.podspec
CHANGED
|
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
:tvos => '15.1'
|
|
16
16
|
}
|
|
17
17
|
s.swift_version = '5.9'
|
|
18
|
-
s.source = { git: 'https://github.com/
|
|
18
|
+
s.source = { git: 'https://github.com/saidkaban/expo-ai-kit' }
|
|
19
19
|
s.static_framework = true
|
|
20
20
|
|
|
21
21
|
s.dependency 'ExpoModulesCore'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-ai-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Expo AI Kit module",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"expo-ai-kit",
|
|
35
35
|
"ExpoAiKit"
|
|
36
36
|
],
|
|
37
|
-
"repository": "https://github.com/
|
|
37
|
+
"repository": "https://github.com/saidkaban/expo-ai-kit",
|
|
38
38
|
"bugs": {
|
|
39
|
-
"url": "https://github.com/
|
|
39
|
+
"url": "https://github.com/saidkaban/expo-ai-kit/issues"
|
|
40
40
|
},
|
|
41
|
-
"author": "
|
|
41
|
+
"author": "Said Kaban (https://github.com/saidkaban)",
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"homepage": "https://expo-ai-kit.dev",
|
|
44
44
|
"dependencies": {},
|
package/src/ExpoAiKitModule.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { requireNativeModule } from 'expo-modules-core';
|
|
2
2
|
import type { EventSubscription } from 'expo-modules-core';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
LLMMessage,
|
|
5
|
+
LLMResponse,
|
|
6
|
+
LLMStreamEvent,
|
|
7
|
+
BuiltInModel,
|
|
8
|
+
DownloadableModelStatus,
|
|
9
|
+
ModelDownloadProgressEvent,
|
|
10
|
+
ModelStateChangeEvent,
|
|
11
|
+
} from './types';
|
|
4
12
|
|
|
5
13
|
export type ExpoAiKitModuleEvents = {
|
|
6
14
|
onStreamToken: (event: LLMStreamEvent) => void;
|
|
15
|
+
onDownloadProgress: (event: ModelDownloadProgressEvent) => void;
|
|
16
|
+
onModelStateChange: (event: ModelStateChangeEvent) => void;
|
|
7
17
|
};
|
|
8
18
|
|
|
9
19
|
export interface ExpoAiKitNativeModule {
|
|
20
|
+
// Existing inference API
|
|
10
21
|
isAvailable(): boolean;
|
|
11
22
|
sendMessage(
|
|
12
23
|
messages: LLMMessage[],
|
|
@@ -18,6 +29,29 @@ export interface ExpoAiKitNativeModule {
|
|
|
18
29
|
sessionId: string
|
|
19
30
|
): Promise<void>;
|
|
20
31
|
stopStreaming(sessionId: string): Promise<void>;
|
|
32
|
+
|
|
33
|
+
// Model discovery
|
|
34
|
+
getBuiltInModels(): BuiltInModel[];
|
|
35
|
+
getDownloadableModelStatus(modelId: string): DownloadableModelStatus;
|
|
36
|
+
|
|
37
|
+
// Model selection & memory management
|
|
38
|
+
// setModel is async: switching to a downloadable model loads it into memory.
|
|
39
|
+
// Auto-unloads the previous downloadable model (only one loaded at a time).
|
|
40
|
+
setModel(modelId: string): Promise<void>;
|
|
41
|
+
getActiveModel(): string;
|
|
42
|
+
// Explicitly free memory from the loaded downloadable model.
|
|
43
|
+
// Reverts to the platform built-in model.
|
|
44
|
+
unloadModel(): Promise<void>;
|
|
45
|
+
|
|
46
|
+
// Model lifecycle (downloadable models only)
|
|
47
|
+
downloadModel(
|
|
48
|
+
modelId: string,
|
|
49
|
+
url: string,
|
|
50
|
+
sha256: string
|
|
51
|
+
): Promise<void>;
|
|
52
|
+
deleteModel(modelId: string): Promise<void>;
|
|
53
|
+
|
|
54
|
+
// Event subscription
|
|
21
55
|
addListener<K extends keyof ExpoAiKitModuleEvents>(
|
|
22
56
|
eventName: K,
|
|
23
57
|
listener: ExpoAiKitModuleEvents[K]
|
package/src/hooks.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isAvailable,
|
|
4
|
+
streamMessage,
|
|
5
|
+
getBuiltInModels as getBuiltInModelsApi,
|
|
6
|
+
getDownloadableModels as getDownloadableModelsApi,
|
|
7
|
+
downloadModel as downloadModelApi,
|
|
8
|
+
deleteModel as deleteModelApi,
|
|
9
|
+
} from './index';
|
|
3
10
|
import { ChatMemoryManager } from './memory';
|
|
11
|
+
import ExpoAiKitModule from './ExpoAiKitModule';
|
|
4
12
|
import type {
|
|
5
13
|
LLMMessage,
|
|
6
14
|
UseChatOptions,
|
|
@@ -8,6 +16,10 @@ import type {
|
|
|
8
16
|
UseCompletionOptions,
|
|
9
17
|
UseCompletionReturn,
|
|
10
18
|
UseOnDeviceAIReturn,
|
|
19
|
+
BuiltInModel,
|
|
20
|
+
DownloadableModel,
|
|
21
|
+
DownloadableModelStatus,
|
|
22
|
+
ModelError,
|
|
11
23
|
} from './types';
|
|
12
24
|
|
|
13
25
|
// Cache availability result across all hook instances
|
|
@@ -329,3 +341,162 @@ export function useCompletion(options: UseCompletionOptions = {}): UseCompletion
|
|
|
329
341
|
error,
|
|
330
342
|
};
|
|
331
343
|
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* React hook for managing a downloadable model's lifecycle.
|
|
347
|
+
*
|
|
348
|
+
* Tracks download status, progress, and provides download/delete controls.
|
|
349
|
+
*
|
|
350
|
+
* @param modelId - The downloadable model ID (e.g. 'gemma-e2b')
|
|
351
|
+
* @returns Model status, progress, and control functions
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```tsx
|
|
355
|
+
* function ModelManager() {
|
|
356
|
+
* const { status, progress, download, delete: remove, error } = useModel('gemma-e2b');
|
|
357
|
+
*
|
|
358
|
+
* if (status === 'not-downloaded') {
|
|
359
|
+
* return <Button title="Download" onPress={download} />;
|
|
360
|
+
* }
|
|
361
|
+
* if (status === 'downloading') {
|
|
362
|
+
* return <Text>Downloading: {Math.round(progress * 100)}%</Text>;
|
|
363
|
+
* }
|
|
364
|
+
* if (status === 'loading') {
|
|
365
|
+
* return <Text>Loading model...</Text>;
|
|
366
|
+
* }
|
|
367
|
+
* return <Text>Model ready!</Text>;
|
|
368
|
+
* }
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
export function useModel(modelId: string): {
|
|
372
|
+
status: DownloadableModelStatus;
|
|
373
|
+
progress: number;
|
|
374
|
+
download: () => Promise<void>;
|
|
375
|
+
delete: () => Promise<void>;
|
|
376
|
+
error: ModelError | null;
|
|
377
|
+
} {
|
|
378
|
+
const [status, setStatus] = useState<DownloadableModelStatus>('not-downloaded');
|
|
379
|
+
const [progress, setProgress] = useState(0);
|
|
380
|
+
const [error, setError] = useState<ModelError | null>(null);
|
|
381
|
+
const mountedRef = useRef(true);
|
|
382
|
+
|
|
383
|
+
useEffect(() => {
|
|
384
|
+
// Query initial status
|
|
385
|
+
try {
|
|
386
|
+
const initialStatus = ExpoAiKitModule.getDownloadableModelStatus(modelId);
|
|
387
|
+
setStatus(initialStatus);
|
|
388
|
+
} catch {
|
|
389
|
+
// Model not found or native module not ready
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// Listen for state changes
|
|
393
|
+
const stateSubscription = ExpoAiKitModule.addListener(
|
|
394
|
+
'onModelStateChange',
|
|
395
|
+
(event) => {
|
|
396
|
+
if (event.modelId === modelId && mountedRef.current) {
|
|
397
|
+
setStatus(event.status);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
// Listen for download progress
|
|
403
|
+
const progressSubscription = ExpoAiKitModule.addListener(
|
|
404
|
+
'onDownloadProgress',
|
|
405
|
+
(event) => {
|
|
406
|
+
if (event.modelId === modelId && mountedRef.current) {
|
|
407
|
+
setProgress(event.progress);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
|
|
412
|
+
return () => {
|
|
413
|
+
mountedRef.current = false;
|
|
414
|
+
stateSubscription.remove();
|
|
415
|
+
progressSubscription.remove();
|
|
416
|
+
};
|
|
417
|
+
}, [modelId]);
|
|
418
|
+
|
|
419
|
+
const download = useCallback(async () => {
|
|
420
|
+
setError(null);
|
|
421
|
+
setProgress(0);
|
|
422
|
+
try {
|
|
423
|
+
await downloadModelApi(modelId, {
|
|
424
|
+
onProgress: (p) => {
|
|
425
|
+
if (mountedRef.current) setProgress(p);
|
|
426
|
+
},
|
|
427
|
+
});
|
|
428
|
+
} catch (err) {
|
|
429
|
+
if (mountedRef.current) {
|
|
430
|
+
setError(err as ModelError);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}, [modelId]);
|
|
434
|
+
|
|
435
|
+
const del = useCallback(async () => {
|
|
436
|
+
setError(null);
|
|
437
|
+
try {
|
|
438
|
+
await deleteModelApi(modelId);
|
|
439
|
+
if (mountedRef.current) {
|
|
440
|
+
setStatus('not-downloaded');
|
|
441
|
+
setProgress(0);
|
|
442
|
+
}
|
|
443
|
+
} catch (err) {
|
|
444
|
+
if (mountedRef.current) {
|
|
445
|
+
setError(err as ModelError);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}, [modelId]);
|
|
449
|
+
|
|
450
|
+
return { status, progress, download, delete: del, error };
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* React hook to discover all available models (built-in and downloadable).
|
|
455
|
+
*
|
|
456
|
+
* @returns Built-in models, downloadable models, and loading state
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```tsx
|
|
460
|
+
* function ModelPicker() {
|
|
461
|
+
* const { builtIn, downloadable, isLoading } = useAvailableModels();
|
|
462
|
+
*
|
|
463
|
+
* if (isLoading) return <Text>Loading models...</Text>;
|
|
464
|
+
*
|
|
465
|
+
* return (
|
|
466
|
+
* <View>
|
|
467
|
+
* <Text>Built-in: {builtIn.map(m => m.name).join(', ')}</Text>
|
|
468
|
+
* <Text>Downloadable: {downloadable.map(m => m.name).join(', ')}</Text>
|
|
469
|
+
* </View>
|
|
470
|
+
* );
|
|
471
|
+
* }
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
export function useAvailableModels(): {
|
|
475
|
+
builtIn: BuiltInModel[];
|
|
476
|
+
downloadable: DownloadableModel[];
|
|
477
|
+
isLoading: boolean;
|
|
478
|
+
} {
|
|
479
|
+
const [builtIn, setBuiltIn] = useState<BuiltInModel[]>([]);
|
|
480
|
+
const [downloadable, setDownloadable] = useState<DownloadableModel[]>([]);
|
|
481
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
482
|
+
|
|
483
|
+
useEffect(() => {
|
|
484
|
+
let mounted = true;
|
|
485
|
+
|
|
486
|
+
Promise.all([getBuiltInModelsApi(), getDownloadableModelsApi()]).then(
|
|
487
|
+
([bi, dl]) => {
|
|
488
|
+
if (mounted) {
|
|
489
|
+
setBuiltIn(bi);
|
|
490
|
+
setDownloadable(dl);
|
|
491
|
+
setIsLoading(false);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
return () => {
|
|
497
|
+
mounted = false;
|
|
498
|
+
};
|
|
499
|
+
}, []);
|
|
500
|
+
|
|
501
|
+
return { builtIn, downloadable, isLoading };
|
|
502
|
+
}
|