@hotg-ai/react-native-runevm

0.1.3 • Public • Published

react-native-runevm

Run Rune container in React Native (iOS & Android)

Getting started

$ npm install @hotg-ai/react-native-runevm --save

Mostly automatic installation

$ react-native link @hotg-ai/react-native-runevm

Usage

Since RN does not support transferring TypedArrays to native, data is transferred in base64 over the RN-bridge. We recommend using 'react-native-base64' package for this:

$ npm install react-native-base64 --save

import Runevm, { TensorType } from '@hotg-ai/react-native-runevm';
import base64 from 'react-native-base64';

//init the Rune 

const b64encoded = base64.encodeFromByteArray(runeBytes); //bytes is a Uint8Array containing the rune
let message = await Runevm.loadWasm(b64encoded, (message) => {
  //json formatted manifest file
  console.log(message);
});

//add input before running inference (eg image data)

const b64encoded = base64.encodeFromByteArray(inputBytes);
await Runevm.addInput(1, b64encoded, [width, width, 3], TensorType.U8, (response) => {
  console.log(response);
});

//Run model

await Runevm.runRune((message) => {
  this.setState(() => {
    return { message: message };
  });
});

//Retrieve logs of inference

await Runevm.getRuneLogs((logs) => {
  console.log(logs);
});
      

A working example can be found here: example/App.js

Readme

Keywords

Package Sidebar

Install

npm i @hotg-ai/react-native-runevm

Homepage

hotg.dev/

Weekly Downloads

0

Version

0.1.3

License

MIT OR Apache-2.0

Unpacked Size

99.4 MB

Total Files

132

Last publish

Collaborators

  • ge_te80
  • kthakorehotg
  • dinesh8076
  • michael-hotg-ai