This page describes Typescript functions that are the building blocks for logic used in Vertex. In order to call Live-deployed models from within Functions on objects, refer to Functions on models.
Functions can be used to write a Model Function, which is logic within a model that estimates a set of outputs based on some inputs. This ModelFunction
may be used throughout Vertex, Objectives, Scenarios, and the rest of the Foundry platform.
Model Functions are used to estimate some set of values based on an input set. These functions are pure functions, where evaluating the Model Function multiple times with the same inputs will always result in the same output values. Model Functions do not load data and the computation can be done entirely based on the set of inputs provided.
The following are some terms that have specific meanings when using a Model Function:
Model Functions have the following uses in Foundry:
Model Functions differ from standard Functions in two key ways:
@ModelFunction()
imported from @foundry/functions-api
(rather than @Function()
)Any actions that can be performed on a standard Function can be performed on a Model Function, for example, testing in Live Preview
, tagging and publishing. The Model Function can also be used in any contexts that a standard Function can be used.
Model Functions only support a subset of the available Functions types. The allowed types are primitive types, such as all Scalars, Optionals, and Collections. For Collection types, all objects within the collection must also be one of the allowed types. Notably, Model Functions do not support Aggregations, Ontology Types, or Notifications. In order to use values from an Object within a Model Function, you should have an input parameter for each property which you would like to use. When using this Model Function within another Foundry app, you will be able to specify which properties from an Object correspond to each parameter. This will be covered further in the tutorials below.
Model Functions must output an anonymous custom type where each of the fields is one of the supported primitive types described above.
If a Model Function is written using a disallowed type, you will receive an error and the function will not be published:
This tutorial outlines how to submit a Model to Modeling Objectives.
This tutorial outlines how to configure a Model to be used in Vertex.