Predictors

The core of Function.

"""
Prediction function.
"""
type Predictor {
...
}

Prediction functions, or predictors, are arbitrary Python functions that make AI predictions.

The Predictor Type

The predictor type forms the core of Function.

Identifying the Predictor

"""
Predictor tag.
"""
tag: Tag!
"""
Predictor name.
"""
name: String!

The predictor tag uniquely identifies a predictor across the Function platform. The predictor tag is always of the form:

@[owner username]/[predictor name]

Inspecting the Owner

"""
Predictor owner.
"""
owner: Profile!

The predictor owner provides information about the owner of the predictor. See Profile for more info.

Inspecting the Predictor Type

"""
Predictor type.
"""
type: PredictorType!

The predictor type specifies where predictions are run. Current options include:

"""
Predictor type.
"""
enum PredictorType {
"""
Predictions are run in the cloud.
"""
CLOUD
}

Inspecting the Predictor Status

"""
Predictor status.
"""
status: PredictorStatus!

The predictor status specifies the current status of the predictor. Current options include:

"""
Predictor status.
"""
enum PredictorStatus {
"""
Predictor is being provisioned.
"""
PROVISIONING
"""
Predictor is active.
"""
ACTIVE
"""
Predictor is invalid.
"""
INVALID
"""
Predictor is archived.
"""
ARCHIVED
}

Accessing the Predictor

"""
Predictor access.
"""
access: AccessMode!

The predictor access determines who has access to the predictor. Current options include:

"""
Access mode.
"""
enum AccessMode {
"""
Resource can be accessed by any user.
"""
PUBLIC
"""
Resource can only be accessed by the owner.
"""
PRIVATE
}

For predictors owned by organizations, PRIVATE access means that only members of the organization have access to the predictor.

Inspecting the Predictor Usage

"""
Number of predictions.
"""
predictions: Int!

The predictor specifies the number of predictions that have been made.

Inspecting the Creation Date

"""
Date created.
"""
created: DateTime!

The predictor provides the date that it was created.

Describing the Predictor

"""
Predictor description.
"""
description: String

When a predictor is created, a description can be specified. This assists users in discovering the predictor, and understanding what it does.

The description must be 200 characters or less.

Predictor Card

"""
Predictor card.
This is extracted from the first cell of the predictor notebook.
"""
card: String

The predictor card is extracted from the first cell of the predictor notebook, if and only if the first cell is a Markdown cell. This card is displayed prominently on fxn.ai and should contain useful information about the predictor.

The card is always Markdown.

Viewing the Predictor Media

"""
Predictor media.
"""
media: URL

When a predictor is created, media can be specified. This is usually an image or animated GIF that illustrates how the predictor works.

Inspecting the Predictor Acceleration

"""
Predictor acceleration.
"""
acceleration: Acceleration

The acceleration specifies what hardware tier that the predictor runs on. Function currently supports the following predictor accelerations:

"""
Predictor acceleration.
"""
enum Acceleration {
"""
Predictions are run on the CPU.
"""
CPU
"""
Predictions are run on an Nvidia A40 GPU.
"""
A40
"""
Predictions are run on an Nvidia A100 GPU.
"""
A100
}

The predictor acceleration directly determines how much you will be billed for predictions. See our pricing

The predictor acceleration is only specified for CLOUD predictors.

Inspecting the Predictor Signature

"""
Predictor signature.
"""
signature: Signature

The signature provides information about the predictor's input and output parameters:

"""
Predictor signature.
"""
type Signature {
"""
Prediction inputs.
"""
inputs: [Parameter!]!
"""
Prediction outputs.
"""
outputs: [Parameter!]!
}

For CLOUD predictors, the signature outputs may be empty.

The Parameter type provides rich information about each parameter within the predictor signature:

"""
Predictor parameter.
This describes a feature that is consumed or produced by a predictor.
"""
type Parameter {
"""
Parameter name.
"""
name: String!
"""
Parameter type.
This is `null` if the type is unknown or unsupported by Function.
"""
type: Dtype
"""
Parameter description.
"""
description: String
"""
Whether parameter is optional.
"""
optional: Boolean
"""
Parameter value range for numeric parameters.
"""
range: [Float!]
"""
Parameter value choices for enumeration parameters.
"""
enumeration: [EnumerationMember!]
"""
Parameter default value.
"""
defaultValue: Feature
}

See Feature for more information about the Dtype enumeration and Feature type.

For enumeration parameters, Function provides the EnumerationMember type:

"""
Prediction parameter enumeration member.
"""
type EnumerationMember {
"""
Enumeration member name.
"""
name: String!
"""
Enumeration member value.
This is usually a `String` or a `Int`.
"""
value: JSON!
}

Creating a Predictor

Create a predictor by specifying the predictor tag and the URL (or path, for clients that support it) to the predictor notebook.

The predictor notebook MUST contain a function called predict.

The request accepts the following input parameters:

input CreatePredictorInput {
"""
Predictor tag.
"""
tag: Tag!
"""
Predictor notebook.
This MUST be a `NOTEBOOK` upload URL.
"""
notebook: URL!
"""
Predictor type.
This defaults to `CLOUD`.
"""
type: PredictorType
"""
Predictor access mode.
This defaults to `PRIVATE`.
"""
access: AccessMode
"""
Predictor description.
This must be under 200 characters long.
"""
description: String
"""
Predictor media.
"""
media: URL
"""
Predictor acceleration.
This only applies for `CLOUD` predictors.
This defaults to `CPU`.
"""
acceleration: Acceleration
"""
Predictor environment variables.
"""
environment: [EnvironmentVariableInput!]
"""
Predictor license.
"""
license: URL
"""
Overwrite any existing predictor with the same tag.
Existing predictor will be deleted.
"""
overwrite: Boolean
}

Deleting the Predictor

Predictors can be deleted when they are not needed. The request accepts the following input parameters:

input DeletePredictorInput {
"""
Predictor tag.
"""
tag: Tag!
}

Public predictors that have been used to make predictions cannot be deleted. You must archive them instead.

Archiving the Predictor

Predictors can be archived, preventing them from being discovered and preventing new users from making predictions with them.

Users who have made predictions with this predictor will be unaffected, ensuring that their apps do not break.

The request accepts the following input parameters:

input ArchivePredictorInput {
"""
Predictor tag.
"""
tag: Tag!
}
Previous
Introduction