replicate-javascript icon indicating copy to clipboard operation
replicate-javascript copied to clipboard

API not working on Expo SDK 51 project

Open Ahelsamahy opened this issue 5 months ago • 2 comments

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

Ahelsamahy avatar Sep 04 '24 07:09 Ahelsamahy