Skip to content

feat: React Native support #287

Open
@raymon-io

Description

@raymon-io

Feature Description

Is it possible for node-llama-cpp to support React Native projects?
I know that this project depends on many node standard libraries, but is it possible to make changes and run in RN runtime? Especially now that it supports arm64 Mac and Windows machines, is it possible to run in arm64 non-node environments?
Even just importing node-llama-cpp necessary functions produces error.

On Android it gives error: The package at "node_modules/node-llama-cpp/dist/evaluator/LlamaModel/LlamaModel.js" attempted to import the Node standard library module "process". It failed because the native React runtime does not include the Node standard library.

On React Native web (using expo) it gives the following error
The resource from “http://localhost:8081/node_modules/expo/AppEntry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.routerRoot=app” was blocked due to MIME type (“application/json”) mismatch
which comes from a <script> tag in html
<script src="/node_modules/expo/AppEntry.bundle?platform=web&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.routerRoot=app" defer></script>>

The Solution

Not asking to make huge changes but this is more like a theoretical question if experimental supporting of RN runtime is possible after removing or replacing node standard libraries.

Considered Alternatives

llama.rn https://github.com/mybigday/llama.rn
web-llm https://github.com/mlc-ai/web-llm
onnxruntime-react-native https://github.com/microsoft/onnxruntime/tree/main/js/react_native

Metadata

Metadata

Assignees

No one assigned

    Labels

    new featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions