jupyterlite / pyodide-kernel

Python kernel for JupyterLite powered by Pyodide
https://jupyterlite-pyodide-kernel.readthedocs.io/en/latest/_static/
BSD 3-Clause "New" or "Revised" License
46 stars 25 forks source link

JavaScript Examples wanted #122

Open MRYingLEE opened 4 months ago

MRYingLEE commented 4 months ago

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,

jtpio commented 4 months ago

@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.

MRYingLEE commented 4 months ago

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.