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
43 stars 22 forks source link

JavaScript Examples wanted #122

Open MRYingLEE opened 1 week ago

MRYingLEE commented 1 week 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 1 week 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 1 week 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.