fixie-ai / ai-jsx

The AI Application Framework for Javascript
https://docs.ai-jsx.com
MIT License
1.05k stars 78 forks source link

Error: TextEncoder is required for this module to work in the browser #177

Open juberti opened 1 year ago

juberti commented 1 year ago

Mobile Client Error

Error: TextEncoder is required for this module to work in the browser ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter. A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

abranhe commented 8 months ago

Any updates here?

I have the same issue with the most basic example, so this comment here is out of date https://github.com/fixie-ai/ai-jsx/issues/451#issuecomment-1787894683 because there is a reason why it is not working. (@petersalas)

This is an issue with an ai-jsx's dependency (tiktoken).

See the code here: https://github.com/dqbd/tiktoken/blob/4a91a815a3db04536bd4848c9307c60553194b45/js/src/core.ts#L67

petersalas commented 8 months ago

Thanks for the additional details! It looks like React Native doesn't have built-in support for TextEncoder. Can you try the workaround suggested in this thread (namely, using a polyfill)?

abranhe commented 8 months ago

@petersalas I tried it yesterday, and ran into other issues. I will report my findings or issues.