VolkovLabs / business-text

The Business Text panel plugin allows you to construct a text visualization template from the values of a dataset returned by a data source query.
https://volkovlabs.io
Apache License 2.0
83 stars 13 forks source link

Issues loading and using TensorFlow.js in Grafana plugin #374

Closed jduran0322 closed 4 days ago

jduran0322 commented 4 days ago

Problem Description: I am trying to use TensorFlow.js with the Business Text plugin in Grafana. Despite following the examples and suggestions provided in the plugin's documentation, I have not been able to get the library to load correctly and be available in my code.

Plugin documentation: https://volkovlabs.io/plugins/business-text/external/

The console shows the following error: Uncaught (in promise) TypeError: tf.ready is not a function

Expected Behavior: I expect TensorFlow.js to load correctly and for the tf object to be available for use in my JavaScript code.

Current Behavior: The tf object is not defined after loading the tf.min.js file. I have tried loading the library both from a local file in the public folder and from a CDN, but I continue to encounter errors related to the definition of the tf object.

Additional Details

Grafana version: 11.2.4 OSS

Grafana environment: Docker, image grafana/grafana:11.2.4-ubuntu

I would appreciate any help or suggestions to resolve this issue, especially if someone has done something similar or knows the correct way to do it.

mikhail-vl commented 4 days ago

@jduran0322 You need to use ESM library like https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@4.22.0/dist/tf.fesm.js to import it in the Business Text panel.

Generic JS version won't work.

jduran0322 commented 2 days ago

Thank you very much for your help, it does indeed work correctly with the ESM version of TensorFlow

image
mikhail-vl commented 2 days ago

@jduran0322 Thank you for confirming.

Documentation updated: https://volkovlabs.io/plugins/business-text/external/#tensorflow