Ir al contenido

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:

LegacyActual
new MLForm(url)mountForm(container, { transport: createJsonTransport({ endpoint: url }), schema })
toHTMLElement(...)mountForm(...)
coleccion inputscoleccion fields
coleccion outputscoleccion reports
type de campokind de campo
title de campolabel de campo
callback onSubmithooks.afterSubmit, hooks.beforeSubmit o mounted.form.submit()
estrategias mlform/extensionsdefiniciones 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" }],
};