pyodide-kernel icon indicating copy to clipboard operation
pyodide-kernel copied to clipboard

JavaScript Examples wanted

Open MRYingLEE opened this issue 1 year ago • 2 comments

One great feature of Pyodide is supporting JavaScript by a robust Javascript ⟺ Python foreign function interface.

But I only found few useful documents and examples on this topic, and they are all too simple.

Can you provide related examples? At least one on how to call Python functions in JavaScript.

Thank you in advance,

MRYingLEE avatar Jun 20 '24 00:06 MRYingLEE

@MRYingLEE what would you like to achieve with the Python <-> JavaScript bindings that Pyodide provides?

It's also worth noting that the JupyterLite Pyodide kernel runs in a Web Worker, and does not direct have access to the main execution context of the page.

jtpio avatar Jun 20 '24 07:06 jtpio

I am looking for a way to call AI APIs, such as OpenAI API, from Pyodide. I understand there is a limit on networking in Pyodide. So instead of calling OpenAI PYTHON API directly, maybe an OpenAI JAVASCRIPT API based JavaScript function can be called in Pyodide.

MRYingLEE avatar Jun 20 '24 07:06 MRYingLEE