nhamid289's picture
Deploy autodiff ff35e9c
b9499ab verified
Raw History Blame Contribute Delete
644 Bytes
import { createPython } from "@elvis/pyodide";
import type { Graph, Mode, State } from "./types";
// The methods of backend/src/manager.py's Manager
export type AutodiffApi = {
handle_set_function: { args: { expression: string }; result: Graph };
// seed is needed in forward mode
handle_set_run: { args: { mode: Mode; inputs: Record<string, number>; seed?: string }; result: { steps: number } };
// null past the last step
handle_state: { args: { iteration: number }; result: State | null };
};
export const python = createPython<AutodiffApi>(
new Worker(new URL("./pyodide.worker.ts", import.meta.url), { type: "module" }),
);