Pyodide
These runtime helpers provide a friendly wrapper around the pyodide ecosystem to execute Python code in the browser.
Installation
Section titled “Installation”npm i -D @genaiscript/plugin-pyodide
pnpm add -D @genaiscript/plugin-pyodide
yarn add -D @genaiscript/plugin-pyodide
If you are using the plugin in a Node.JS environment, without a .genai...
entry file, you will need
to initialize the runtime before using the plugin:
import { initialize } from "@genaiscript/runtime";
await initialize();
Python code execution
Section titled “Python code execution”import { python } from "@genaiscript/plugin-pyodide";
const py = await python();
const result = await py(`def greet(name): return f"Hello, {name}!"
greet("World")`);
console.log(result); // "Hello, World!"