brainy/test-tensorflow-import.cjs

25 lines
747 B
JavaScript
Raw Normal View History

const { applyTensorFlowPatch } = require('./dist/unified.js')
console.log('Before patch:')
console.log('global.TextEncoder:', typeof global.TextEncoder)
console.log('global.__TextEncoder__:', typeof global.__TextEncoder__)
applyTensorFlowPatch()
console.log('After patch:')
console.log('global.TextEncoder:', typeof global.TextEncoder)
console.log('global.__TextEncoder__:', typeof global.__TextEncoder__)
// Try to import tensorflow
async function testTensorFlow() {
try {
console.log('Importing TensorFlow...')
const tf = await import('@tensorflow/tfjs-core')
console.log('TensorFlow imported successfully:', tf.version)
} catch (error) {
console.error('TensorFlow import failed:', error.message)
}
}
testTensorFlow()