Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API not working on Expo SDK 51 project #303

Open
Ahelsamahy opened this issue Sep 4, 2024 · 3 comments
Open

API not working on Expo SDK 51 project #303

Ahelsamahy opened this issue Sep 4, 2024 · 3 comments

Comments

@Ahelsamahy
Copy link

Hi all,

I have an Expo application that I created from scratch npx create-expo-app@latest ./ --template and added a function to touch LLama model with this.

import Replicate from 'replicate';

export async function getStreamOutput() {
	const replicate = new Replicate({
		auth: process.env.EXPO_PUBLIC_REPLICATE_API,
	});

	const input = {
		prompt: "Tina has one brother and one sister. How many sisters do Tina's siblings have?",
		max_tokens: 1024,
	};

	try {
		// Run the model and return the result without streaming
		const output = await replicate.run('meta/meta-llama-3.1-405b-instruct', { input });
		return output.join("");  // Combine the output into a single string
	} catch (error) {
		console.error('Error getting prediction:', error);
		throw error;
	}
}

I get error

ERROR  Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes

in the terminal and my ios emulator shows property error from 'TransformStream' doesn't exist
image
and the same goes when i try with android emulator.

My Expo SDK is 51

@mattt
Copy link
Contributor

mattt commented Sep 16, 2024

Hi @Ahelsamahy. Sorry for the late response. Can you try adding the web-streams-polyfill package dependency and let me know if that resolves your error?

@Ahelsamahy
Copy link
Author

Hi @mattt. I did try to install the package npm i web-streams-polyfill and I got the same error.

This is my package.json

{
  "name": "test",
  "version": "1.0.0",
  "main": "expo/AppEntry.js",
  "module": "expo/main.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@expo/env": "^0.3.0",
    "esm": "^3.2.25",
    "expo": "~51.0.28",
    "expo-status-bar": "~1.12.1",
    "react": "18.2.0",
    "react-native": "0.74.5",
    "react-native-dotenv": "^3.4.11",
    "replicate": "^0.32.1",
    "web-streams-polyfill": "^4.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true,
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": ""
}

@aron
Copy link
Contributor

aron commented Oct 21, 2024

@Ahelsamahy did you import it? From the docs I think you need:

import "web-streams-polyfill/polyfill";

https://www.npmjs.com/package/web-streams-polyfill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants