Desde MLForm Legacy
Los ejemplos antiguos usaban una API con forma de clase:
const mlForm = new MLForm("/api/predict");await mlForm.toHTMLElement(schema, container);Usa mountForm:
const mounted = mountForm(container, { transport: createJsonTransport({ endpoint: "/api/predict" }), schema,});Mapa de migracion:
| Legacy | Actual |
|---|---|
new MLForm(url) | mountForm(container, { transport: createJsonTransport({ endpoint: url }), schema }) |
toHTMLElement(...) | mountForm(...) |
coleccion inputs | coleccion fields |
coleccion outputs | coleccion reports |
type de campo | kind de campo |
title de campo | label de campo |
callback onSubmit | hooks.afterSubmit, hooks.beforeSubmit o mounted.form.submit() |
estrategias mlform/extensions | definiciones de engine y primitive registries |
Schema legacy:
const oldSchema = { inputs: [{ type: "text", title: "Prompt" }], outputs: [{ type: "classifier", title: "Prediction" }],};Schema actual:
const schema = { fields: [{ kind: "text", label: "Prompt" }], reports: [{ kind: "classifier", label: "Prediction" }],};